mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #217, Project class providing information for compile configuration
* changed .pro / .pri as required * Used info from project class in network_vatlib * Checks / info in GUI/core (e.g. console) * const * versions of systemNameAndVersion / simulators, as mentioned in https://dev.vatsim-germany.org/issues/217#note-4
This commit is contained in:
@@ -3,9 +3,7 @@ include (config.pri)
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
|
|
||||||
contains(BLACK_CONFIG, BlackMisc) {
|
SUBDIRS += src/blackmisc
|
||||||
SUBDIRS += src/blackmisc
|
|
||||||
}
|
|
||||||
|
|
||||||
contains(BLACK_CONFIG, BlackSound) {
|
contains(BLACK_CONFIG, BlackSound) {
|
||||||
SUBDIRS += src/blacksound
|
SUBDIRS += src/blacksound
|
||||||
|
|||||||
15
config.pri
15
config.pri
@@ -8,7 +8,8 @@
|
|||||||
BLACK_VER_MAJ = 0
|
BLACK_VER_MAJ = 0
|
||||||
BLACK_VER_MIN = 4
|
BLACK_VER_MIN = 4
|
||||||
BLACK_VER_PAT = 0
|
BLACK_VER_PAT = 0
|
||||||
BLACK_VERSION = $${BLACK_VER_MAJ}.$${BLACK_VER_MIN}.$${BLACK_VERSION}
|
BLACK_VERSION = $${BLACK_VER_MAJ}.$${BLACK_VER_MIN}.$${BLACK_VER_PAT}
|
||||||
|
DEFINES += BLACK_VERSION=$$BLACK_VERSION
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# Install paths
|
# Install paths
|
||||||
@@ -19,7 +20,6 @@ BLACK_VERSION = $${BLACK_VER_MAJ}.$${BLACK_VER_MIN}.$${BLACK_VERSION}
|
|||||||
# Build configuration
|
# Build configuration
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
BLACK_CONFIG += BlackMisc
|
|
||||||
BLACK_CONFIG += BlackCore
|
BLACK_CONFIG += BlackCore
|
||||||
BLACK_CONFIG += BlackGui
|
BLACK_CONFIG += BlackGui
|
||||||
BLACK_CONFIG += BlackSound
|
BLACK_CONFIG += BlackSound
|
||||||
@@ -29,3 +29,14 @@ BLACK_CONFIG += Unittests
|
|||||||
#BLACK_CONFIG += FSX
|
#BLACK_CONFIG += FSX
|
||||||
#BLACK_CONFIG += XPlane
|
#BLACK_CONFIG += XPlane
|
||||||
#BLACK_CONFIG += Doxygen
|
#BLACK_CONFIG += Doxygen
|
||||||
|
|
||||||
|
################################
|
||||||
|
# Defines, for compile time code
|
||||||
|
################################
|
||||||
|
|
||||||
|
contains(BLACK_CONFIG, BlackSound) { DEFINES += WITH_BLACKSOUND }
|
||||||
|
contains(BLACK_CONFIG, BlackSim) { DEFINES += WITH_BLACKSIM }
|
||||||
|
contains(BLACK_CONFIG, BlackCore) { DEFINES += WITH_BLACKCORE }
|
||||||
|
contains(BLACK_CONFIG, BlackGui) { DEFINES += WITH_BLACKGUI }
|
||||||
|
contains(BLACK_CONFIG, FSX) { DEFINES += WITH_FSX }
|
||||||
|
contains(BLACK_CONFIG, XPlane) { DEFINES += WITH_XPLANE }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "blackcore/context_application_impl.h"
|
#include "blackcore/context_application_impl.h"
|
||||||
#include "blackmisc/networkutils.h"
|
#include "blackmisc/networkutils.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blackmisc/project.h"
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
@@ -29,6 +30,10 @@ int main(int argc, char *argv[])
|
|||||||
QApplication::setWindowIcon(icon);
|
QApplication::setWindowIcon(icon);
|
||||||
QTextStream cin(stdin);
|
QTextStream cin(stdin);
|
||||||
|
|
||||||
|
qDebug() << BlackMisc::CProject::version();
|
||||||
|
qDebug() << BlackMisc::CProject::compiledInfo();
|
||||||
|
qDebug();
|
||||||
|
|
||||||
qDebug() << "1 + la/ra .. session DBus server (default)";
|
qDebug() << "1 + la/ra .. session DBus server (default)";
|
||||||
qDebug() << "2 + la/ra .. system DBus server";
|
qDebug() << "2 + la/ra .. system DBus server";
|
||||||
qDebug() << "3 + la/ra .. P2P DBus server";
|
qDebug() << "3 + la/ra .. P2P DBus server";
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
|
|||||||
|
|
||||||
// with frameless window, we shift menu and statusbar into central widget
|
// with frameless window, we shift menu and statusbar into central widget
|
||||||
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
|
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
|
||||||
|
this->setWindowTitle(CProject::systemNameAndVersion());
|
||||||
if (this->m_windowMode == GuiModes::WindowFrameless)
|
if (this->m_windowMode == GuiModes::WindowFrameless)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -151,6 +152,10 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
|
|||||||
// We don't receive signals from the past. So ask for it simulate an initial signal
|
// We don't receive signals from the past. So ask for it simulate an initial signal
|
||||||
simulatorConnectionChanged(this->getIContextSimulator()->isConnected());
|
simulatorConnectionChanged(this->getIContextSimulator()->isConnected());
|
||||||
|
|
||||||
|
// info
|
||||||
|
this->ui->te_StatusPageConsole->appendPlainText(CProject::systemNameAndVersion());
|
||||||
|
this->ui->te_StatusPageConsole->appendPlainText(CProject::compiledInfo());
|
||||||
|
|
||||||
// do this as last statement, so it can be used as flag
|
// do this as last statement, so it can be used as flag
|
||||||
// whether init has been completed
|
// whether init has been completed
|
||||||
this->m_init = true;
|
this->m_init = true;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace BlackCore
|
|||||||
virtual void unloadSimulatorPlugin () = 0;
|
virtual void unloadSimulatorPlugin () = 0;
|
||||||
|
|
||||||
//! Simulator avialable?
|
//! Simulator avialable?
|
||||||
bool isSimulatorAvailable() const { return !getSimulatorInfo().isUnspecified(); }
|
bool isSimulatorAvailable() const { return BlackMisc::CProject::isCompiledWithFlightSimulatorSupport() && !getSimulatorInfo().isUnspecified(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \brief Constructor
|
//! \brief Constructor
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "network_vatlib.h"
|
#include "network_vatlib.h"
|
||||||
|
#include "blackmisc/project.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -11,10 +12,6 @@
|
|||||||
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");
|
||||||
|
|
||||||
//TODO just placeholders to allow this to compile
|
//TODO just placeholders to allow this to compile
|
||||||
#define CLIENT_NAME_VERSION "BlackBox 0.3"
|
|
||||||
#define CLIENT_VERSION_MAJOR 0
|
|
||||||
#define CLIENT_VERSION_MINOR 3
|
|
||||||
#define CLIENT_SIMULATOR_NAME "None"
|
|
||||||
#define CLIENT_PUBLIC_ID 0
|
#define CLIENT_PUBLIC_ID 0
|
||||||
#define CLIENT_PRIVATE_KEY ""
|
#define CLIENT_PRIVATE_KEY ""
|
||||||
|
|
||||||
@@ -25,6 +22,8 @@ namespace BlackCore
|
|||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
|
||||||
void exceptionDispatcher(const char *caller);
|
void exceptionDispatcher(const char *caller);
|
||||||
|
|
||||||
@@ -66,8 +65,8 @@ namespace BlackCore
|
|||||||
capabilities += "=1";
|
capabilities += "=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_net->CreateNetworkSession(CLIENT_NAME_VERSION, CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR,
|
m_net->CreateNetworkSession(CProject::systemNameAndVersionChar(), CProject::versionMajor(), CProject::versionMinor(),
|
||||||
CLIENT_SIMULATOR_NAME, CLIENT_PUBLIC_ID, CLIENT_PRIVATE_KEY, toFSD(capabilities));
|
CProject::simulatorsChar(), CLIENT_PUBLIC_ID, CLIENT_PRIVATE_KEY, toFSD(capabilities));
|
||||||
|
|
||||||
m_net->InstallOnConnectionStatusChangedEvent(onConnectionStatusChanged, this);
|
m_net->InstallOnConnectionStatusChangedEvent(onConnectionStatusChanged, this);
|
||||||
m_net->InstallOnTextMessageReceivedEvent(onTextMessageReceived, this);
|
m_net->InstallOnTextMessageReceivedEvent(onTextMessageReceived, this);
|
||||||
@@ -264,7 +263,7 @@ namespace BlackCore
|
|||||||
m_bytesVec.push_back(creator->toFSD(*i));
|
m_bytesVec.push_back(creator->toFSD(*i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const char **operator ()()
|
const char **operator()()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_cstrVec.isEmpty());
|
Q_ASSERT(m_cstrVec.isEmpty());
|
||||||
for (auto i = m_bytesVec.begin(); i != m_bytesVec.end(); ++i)
|
for (auto i = m_bytesVec.begin(); i != m_bytesVec.end(); ++i)
|
||||||
@@ -330,7 +329,7 @@ namespace BlackCore
|
|||||||
net = netPtr.data();
|
net = netPtr.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto urlsPtr = QSharedPointer<const char *const>(net->GetVatsimStatusUrls(), [=](const char *const *p){ net->GetVatsimStatusUrls_Free(p); });
|
auto urlsPtr = QSharedPointer<const char *const>(net->GetVatsimStatusUrls(), [ = ](const char *const * p) { net->GetVatsimStatusUrls_Free(p); });
|
||||||
auto urls = urlsPtr.data();
|
auto urls = urlsPtr.data();
|
||||||
while (*urls)
|
while (*urls)
|
||||||
{
|
{
|
||||||
@@ -354,10 +353,10 @@ namespace BlackCore
|
|||||||
net = netPtr.data();
|
net = netPtr.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto namesPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerNames(), [=](const char *const *p){ net->GetVatsimFSDServerNames_Free(p); });
|
auto namesPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerNames(), [ = ](const char *const * p) { net->GetVatsimFSDServerNames_Free(p); });
|
||||||
auto ipsPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerIps(), [=](const char *const *p){ net->GetVatsimFSDServerIps_Free(p); });
|
auto ipsPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerIps(), [ = ](const char *const * p) { net->GetVatsimFSDServerIps_Free(p); });
|
||||||
auto locationsPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerLocations(), [=](const char *const *p){ net->GetVatsimFSDServerLocations_Free(p); });
|
auto locationsPtr = QSharedPointer<const char *const>(net->GetVatsimFSDServerLocations(), [ = ](const char *const * p) { net->GetVatsimFSDServerLocations_Free(p); });
|
||||||
auto acceptsPtr = QSharedPointer<const bool>(net->GetVatsimFSDServerAcceptingConnections(), [=](const bool *p){ net->GetVatsimFSDServerAcceptingConnections_Free(p); });
|
auto acceptsPtr = QSharedPointer<const bool>(net->GetVatsimFSDServerAcceptingConnections(), [ = ](const bool * p) { net->GetVatsimFSDServerAcceptingConnections_Free(p); });
|
||||||
auto names = namesPtr.data();
|
auto names = namesPtr.data();
|
||||||
auto ips = ipsPtr.data();
|
auto ips = ipsPtr.data();
|
||||||
auto locations = locationsPtr.data();
|
auto locations = locationsPtr.data();
|
||||||
@@ -759,8 +758,8 @@ namespace BlackCore
|
|||||||
void CNetworkVatlib::onConnectionStatusChanged(Cvatlib_Network *, Cvatlib_Network::connStatus, Cvatlib_Network::connStatus newStatus, void *cbvar)
|
void CNetworkVatlib::onConnectionStatusChanged(Cvatlib_Network *, Cvatlib_Network::connStatus, Cvatlib_Network::connStatus newStatus, void *cbvar)
|
||||||
{
|
{
|
||||||
if (newStatus == Cvatlib_Network::connStatus_Error ||
|
if (newStatus == Cvatlib_Network::connStatus_Error ||
|
||||||
newStatus == Cvatlib_Network::connStatus_ConnectionFailed ||
|
newStatus == Cvatlib_Network::connStatus_ConnectionFailed ||
|
||||||
newStatus == Cvatlib_Network::connStatus_ConnectionLost)
|
newStatus == Cvatlib_Network::connStatus_ConnectionLost)
|
||||||
{
|
{
|
||||||
cbvar_cast(cbvar)->changeConnectionStatus(newStatus, cbvar_cast(cbvar)->getSocketError());
|
cbvar_cast(cbvar)->changeConnectionStatus(newStatus, cbvar_cast(cbvar)->getSocketError());
|
||||||
}
|
}
|
||||||
|
|||||||
141
src/blackmisc/project.cpp
Normal file
141
src/blackmisc/project.cpp
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
#include "project.h"
|
||||||
|
#include <QStringList>
|
||||||
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
|
||||||
|
#define BLACK_VERSION_STR_X(v) #v
|
||||||
|
#define BLACK_VERSION_STR(v) BLACK_VERSION_STR_X(v)
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithBlackCore()
|
||||||
|
{
|
||||||
|
#ifdef WITH_BLACKCORE
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithBlackSound()
|
||||||
|
{
|
||||||
|
#ifdef WITH_BLACKSOUND
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithFsxSupport()
|
||||||
|
{
|
||||||
|
#ifdef WITH_FSX
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithXPlaneSupport()
|
||||||
|
{
|
||||||
|
#ifdef WITH_XPLANE
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CProject::isCompiledWithFlightSimulatorSupport()
|
||||||
|
{
|
||||||
|
return isCompiledWithFsxSupport() || isCompiledWithXPlaneSupport();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlackMisc::CProject::isCompiledWithGui()
|
||||||
|
{
|
||||||
|
#ifdef WITH_BLACKGUI
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CProject::compiledInfo()
|
||||||
|
{
|
||||||
|
static QString info;
|
||||||
|
if (info.isEmpty())
|
||||||
|
{
|
||||||
|
static QStringList sl;
|
||||||
|
if (isCompiledWithBlackCore()) sl << "BlackCore";
|
||||||
|
if (isCompiledWithBlackSound()) sl << "BlackSound";
|
||||||
|
if (isCompiledWithGui()) sl << "BlackGui";
|
||||||
|
if (isCompiledWithFsxSupport()) sl << "FSX";
|
||||||
|
if (isCompiledWithXPlaneSupport()) sl << "XPlane";
|
||||||
|
info = sl.join(", ");
|
||||||
|
if (info.isEmpty()) info = "<none>";
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CProject::simulators()
|
||||||
|
{
|
||||||
|
static QString sims;
|
||||||
|
if (sims.isEmpty())
|
||||||
|
{
|
||||||
|
static QStringList sl;
|
||||||
|
if (isCompiledWithFsxSupport()) sl << "FSX";
|
||||||
|
if (isCompiledWithXPlaneSupport()) sl << "XPlane";
|
||||||
|
sims = sl.join(", ");
|
||||||
|
if (sims.isEmpty()) sims = "<none>";
|
||||||
|
}
|
||||||
|
return sims;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CProject::simulatorsChar()
|
||||||
|
{
|
||||||
|
static const QByteArray a(simulators().toUtf8());
|
||||||
|
return a.constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CProject::version()
|
||||||
|
{
|
||||||
|
#ifdef BLACK_VERSION
|
||||||
|
const static QString v(BLACK_VERSION_STR(BLACK_VERSION));
|
||||||
|
#else
|
||||||
|
const static QString v("?");
|
||||||
|
#endif
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CProject::systemNameAndVersion()
|
||||||
|
{
|
||||||
|
static QString s = QString("BlackBox %1").arg(version());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CProject::systemNameAndVersionChar()
|
||||||
|
{
|
||||||
|
static const QByteArray a(systemNameAndVersion().toUtf8());
|
||||||
|
return a.constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CProject::versionMajor()
|
||||||
|
{
|
||||||
|
return getMajorMinor(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CProject::versionMinor()
|
||||||
|
{
|
||||||
|
return getMajorMinor(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CProject::getMajorMinor(int index)
|
||||||
|
{
|
||||||
|
QString v = version();
|
||||||
|
if (v.isEmpty() || !v.contains(".")) return -1;
|
||||||
|
bool ok;
|
||||||
|
int vi = v.split(".")[index].toInt(&ok);
|
||||||
|
return ok ? vi : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef BLACK_VERSION_STR
|
||||||
|
#undef BLACK_VERSION_STR_X
|
||||||
66
src/blackmisc/project.h
Normal file
66
src/blackmisc/project.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#ifndef BLACKMISC_CPROJECT_H
|
||||||
|
#define BLACKMISC_CPROJECT_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Metadata about the project
|
||||||
|
*/
|
||||||
|
class CProject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! with BlackCore?
|
||||||
|
static bool isCompiledWithBlackCore();
|
||||||
|
|
||||||
|
//! with BlackSound?
|
||||||
|
static bool isCompiledWithBlackSound();
|
||||||
|
|
||||||
|
//! with FSX support?
|
||||||
|
static bool isCompiledWithFsxSupport();
|
||||||
|
|
||||||
|
//! with XPlane support?
|
||||||
|
static bool isCompiledWithXPlaneSupport();
|
||||||
|
|
||||||
|
//! with any simulator libraries
|
||||||
|
static bool isCompiledWithFlightSimulatorSupport();
|
||||||
|
|
||||||
|
//! with GUI?
|
||||||
|
static bool isCompiledWithGui();
|
||||||
|
|
||||||
|
//! Compiled with as info string
|
||||||
|
static const QString &compiledInfo();
|
||||||
|
|
||||||
|
//! Simulator String info
|
||||||
|
static const QString &simulators();
|
||||||
|
|
||||||
|
//! Simulator String info
|
||||||
|
static const char *simulatorsChar();
|
||||||
|
|
||||||
|
//! Version info
|
||||||
|
static const QString &version();
|
||||||
|
|
||||||
|
//! System's name and version
|
||||||
|
static const QString &systemNameAndVersion();
|
||||||
|
|
||||||
|
//! System's name and version
|
||||||
|
static const char *systemNameAndVersionChar();
|
||||||
|
|
||||||
|
//! Version major
|
||||||
|
static int versionMajor();
|
||||||
|
|
||||||
|
//! Version minor
|
||||||
|
static int versionMinor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Constructor
|
||||||
|
CProject() {}
|
||||||
|
|
||||||
|
//! Split version
|
||||||
|
static int getMajorMinor(int index);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user