swift
clientidentification.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "misc/logmessage.h"
7 
8 namespace swift::core::fsd
9 {
10  ClientIdentification::ClientIdentification(const QString &sender, quint16 clientId, const QString &clientName,
11  int clientVersionMajor, int clientVersionMinor, const QString &userCid,
12  const QString &sysUid, const QString &initialChallenge)
13  : MessageBase(sender, "SERVER"), m_clientId(clientId), m_clientName(clientName),
14  m_clientVersionMajor(clientVersionMajor), m_clientVersionMinor(clientVersionMinor), m_userCid(userCid),
15  m_sysUid(sysUid), m_initialChallenge(initialChallenge)
16  {}
17 
19  {
20  auto tokens = QStringList {};
21  tokens.push_back(m_sender);
22  tokens.push_back(m_receiver);
23  tokens.push_back(QString::number(m_clientId, 16));
24  tokens.push_back(m_clientName);
25  tokens.push_back(QString::number(m_clientVersionMajor));
26  tokens.push_back(QString::number(m_clientVersionMinor));
27  tokens.push_back(m_userCid);
28  tokens.push_back(m_sysUid);
29  tokens.push_back(m_initialChallenge);
30  return tokens;
31  }
32 
34  {
35  if (tokens.size() < 8)
36  {
37  swift::misc::CLogMessage(static_cast<ClientIdentification *>(nullptr))
38  .warning(u"Wrong number of arguments.");
39  return {};
40  }
41 
42  ClientIdentification packet(tokens[0], tokens[2].toUShort(nullptr, 16), tokens[3], tokens[4].toInt(),
43  tokens[5].toInt(), tokens[6], tokens[7], tokens.size() > 8 ? tokens[8] : QString());
44  return packet;
45  }
46 } // namespace swift::core::fsd
This packet is sent by any client that supports the VATSIM client authentication protocol,...
QStringList toTokens() const
Message converted to tokens.
static ClientIdentification fromTokens(const QStringList &tokens)
Construct from tokens.
FSD message base class.
Definition: messagebase.h:58
QString m_receiver
message receiver
Definition: messagebase.h:89
QString m_sender
message sender
Definition: messagebase.h:88
Class for emitting a log message.
Definition: logmessage.h:27
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
QString number(double n, char format, int precision)