mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
refs #603, cmd args for network vatlib
bundled all defines which should be set on the build server in defines.pri
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f4cbfc2fa9
commit
a43d414a76
@@ -1,4 +1,10 @@
|
|||||||
|
# some global compile options
|
||||||
|
# DEFINES += SWIFT_BETA
|
||||||
|
# DEFINES += SWIFT_SHIPPED
|
||||||
DEFINES += BLACK_VERSION=$$BLACK_VERSION
|
DEFINES += BLACK_VERSION=$$BLACK_VERSION
|
||||||
|
DEFINES += BLACK_CLIENT_PUBLIC_ID=0xb9ba
|
||||||
|
DEFINES += BLACK_CLIENT_PRIVATE_KEY=727d1efd5cb9f8d2c28372469d922bb4
|
||||||
|
DEFINES += BLACK_EOL=20170101
|
||||||
|
|
||||||
contains(BLACK_CONFIG, BlackSound) { DEFINES += WITH_BLACKSOUND }
|
contains(BLACK_CONFIG, BlackSound) { DEFINES += WITH_BLACKSOUND }
|
||||||
contains(BLACK_CONFIG, BlackInput) { DEFINES += WITH_BLACKINPUT }
|
contains(BLACK_CONFIG, BlackInput) { DEFINES += WITH_BLACKINPUT }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
|
|
||||||
#include "networkvatlib.h"
|
#include "networkvatlib.h"
|
||||||
|
#include "application.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@@ -19,11 +20,13 @@
|
|||||||
static_assert(! std::is_abstract<BlackCore::CNetworkVatlib>::value, "Must implement all pure virtuals");
|
static_assert(! std::is_abstract<BlackCore::CNetworkVatlib>::value, "Must implement all pure virtuals");
|
||||||
static_assert(VAT_LIBVATLIB_VERSION == 905, "Wrong vatlib header installed");
|
static_assert(VAT_LIBVATLIB_VERSION == 905, "Wrong vatlib header installed");
|
||||||
|
|
||||||
// TODO just placeholders to allow this to compile
|
#if !defined(BLACK_CLIENT_PUBLIC_ID)
|
||||||
// This is just a test key and is NOT valid on the live network.
|
#error Missing definition of id
|
||||||
// Replace it with the BoG assigned key before shipping the installer
|
#endif
|
||||||
#define CLIENT_PUBLIC_ID 0xb9ba
|
|
||||||
#define CLIENT_PRIVATE_KEY "727d1efd5cb9f8d2c28372469d922bb4"
|
#if !defined(BLACK_CLIENT_PRIVATE_KEY)
|
||||||
|
#error Missing definition of pk
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -35,7 +38,6 @@ using namespace BlackMisc::Simulation;
|
|||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
CNetworkVatlib::CNetworkVatlib(Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent)
|
CNetworkVatlib::CNetworkVatlib(Simulation::IOwnAircraftProvider *ownAircraft, QObject *parent)
|
||||||
: INetwork(parent), COwnAircraftAware(ownAircraft),
|
: INetwork(parent), COwnAircraftAware(ownAircraft),
|
||||||
m_loginMode(LoginNormal),
|
m_loginMode(LoginNormal),
|
||||||
@@ -69,9 +71,11 @@ namespace BlackCore
|
|||||||
clientCapabilities |= vatCapsStealth;
|
clientCapabilities |= vatCapsStealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_net.reset(Vat_CreateNetworkSession(vatServerLegacyFsd, CProject::swiftVersionChar(),
|
static const QString pkDef(BLACK_STRINGIFY(BLACK_CLIENT_PRIVATE_KEY));
|
||||||
|
static const QByteArray pk(this->getCmdLineFsdKey().isEmpty() ? pkDef.toLocal8Bit() : this->getCmdLineFsdKey().toLocal8Bit());
|
||||||
|
m_net.reset(Vat_CreateNetworkSession(vatServerLegacyFsd, sApp->swiftVersionChar(),
|
||||||
CProject::versionMajor(), CProject::versionMinor(),
|
CProject::versionMajor(), CProject::versionMinor(),
|
||||||
"None", CLIENT_PUBLIC_ID, CLIENT_PRIVATE_KEY,
|
"None", BLACK_CLIENT_PUBLIC_ID, pk.constData(),
|
||||||
clientCapabilities));
|
clientCapabilities));
|
||||||
|
|
||||||
Vat_SetStateChangeHandler(m_net.data(), onConnectionStatusChanged, this);
|
Vat_SetStateChangeHandler(m_net.data(), onConnectionStatusChanged, this);
|
||||||
@@ -591,6 +595,25 @@ namespace BlackCore
|
|||||||
Vat_RequestMetar(m_net.data(), toFSD(airportIcao.asString()));
|
Vat_RequestMetar(m_net.data(), toFSD(airportIcao.asString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QList<QCommandLineOption> &CNetworkVatlib::getCmdLineOptions()
|
||||||
|
{
|
||||||
|
static const QList<QCommandLineOption> e;
|
||||||
|
static const QList<QCommandLineOption> opts
|
||||||
|
{
|
||||||
|
QCommandLineOption({ "key", "fsdkey" },
|
||||||
|
QCoreApplication::translate("application", "Key for FSD"),
|
||||||
|
"fsdkey")
|
||||||
|
};
|
||||||
|
|
||||||
|
// only in not officially shipped versions
|
||||||
|
return (CProject::isShippedVersion() && !CProject::isBetaTest()) ? e : opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CNetworkVatlib::getCmdLineFsdKey() const
|
||||||
|
{
|
||||||
|
return sApp->getParserValue("fsdkey").toLower();
|
||||||
|
}
|
||||||
|
|
||||||
void CNetworkVatlib::sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign)
|
void CNetworkVatlib::sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(isConnected(), "CNetworkVatlib", "Can't send to server when disconnected");
|
Q_ASSERT_X(isConnected(), "CNetworkVatlib", "Can't send to server when disconnected");
|
||||||
@@ -643,7 +666,7 @@ namespace BlackCore
|
|||||||
/********************************** shimlib callbacks ************************************/
|
/********************************** shimlib callbacks ************************************/
|
||||||
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
||||||
|
|
||||||
//! Cast void* to a pointer of CNetworkVatlib
|
//! Cast void* to a pointer of CNetworkVatlib
|
||||||
CNetworkVatlib *cbvar_cast(void *cbvar)
|
CNetworkVatlib *cbvar_cast(void *cbvar)
|
||||||
{
|
{
|
||||||
return static_cast<CNetworkVatlib *>(cbvar);
|
return static_cast<CNetworkVatlib *>(cbvar);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QCommandLineOption>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -91,6 +92,12 @@ namespace BlackCore
|
|||||||
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcaoCode &airportIcao) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Cmd.line options this library can handle
|
||||||
|
static const QList<QCommandLineOption> &getCmdLineOptions();
|
||||||
|
|
||||||
|
//! Key if any from cmd.line arguments
|
||||||
|
QString getCmdLineFsdKey() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
void replyToNameQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
void replyToNameQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
@@ -189,6 +196,6 @@ namespace BlackCore
|
|||||||
CTokenBucket m_tokenBucket;
|
CTokenBucket m_tokenBucket;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace BlackCore
|
} //namespace
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user