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() : MessageBase() {}
11 
12  ClientIdentification::ClientIdentification(const QString &sender, quint16 clientId, const QString &clientName,
13  int clientVersionMajor, int clientVersionMinor, const QString &userCid,
14  const QString &sysUid, const QString &initialChallenge)
15  : MessageBase(sender, "SERVER"), m_clientId(clientId), m_clientName(clientName),
16  m_clientVersionMajor(clientVersionMajor), m_clientVersionMinor(clientVersionMinor), m_userCid(userCid),
17  m_sysUid(sysUid), m_initialChallenge(initialChallenge)
18  {}
19 
20  QStringList ClientIdentification::toTokens() const
21  {
22  auto tokens = QStringList {};
23  tokens.push_back(m_sender);
24  tokens.push_back(m_receiver);
25  tokens.push_back(QString::number(m_clientId, 16));
26  tokens.push_back(m_clientName);
27  tokens.push_back(QString::number(m_clientVersionMajor));
28  tokens.push_back(QString::number(m_clientVersionMinor));
29  tokens.push_back(m_userCid);
30  tokens.push_back(m_sysUid);
31  tokens.push_back(m_initialChallenge);
32  return tokens;
33  }
34 
36  {
37  if (tokens.size() < 8)
38  {
39  swift::misc::CLogMessage(static_cast<ClientIdentification *>(nullptr))
40  .warning(u"Wrong number of arguments.");
41  return {};
42  }
43 
44  ClientIdentification packet(tokens[0], tokens[2].toUShort(nullptr, 16), tokens[3], tokens[4].toInt(),
45  tokens[5].toInt(), tokens[6], tokens[7], tokens.size() > 8 ? tokens[8] : QString());
46  return packet;
47  }
48 } // 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.