From fa6e7108c7a7be2526197b93464f89496f63d72d Mon Sep 17 00:00:00 2001 From: Roland Rossgotterer Date: Fri, 13 Sep 2019 11:07:38 +0200 Subject: [PATCH] Propagate FacilityType and LoginMode to value objects --- src/blackcore/airspacemonitor.cpp | 2 +- src/blackcore/context/contextnetwork.h | 7 +- src/blackcore/context/contextnetworkempty.h | 6 +- src/blackcore/context/contextnetworkimpl.cpp | 2 +- src/blackcore/context/contextnetworkimpl.h | 6 +- src/blackcore/context/contextnetworkproxy.cpp | 6 +- src/blackcore/context/contextnetworkproxy.h | 4 +- src/blackcore/registermetadata.cpp | 6 +- src/blackgui/components/loginadvcomponent.cpp | 8 +-- src/blackgui/components/logincomponent.cpp | 9 +-- src/blackgui/components/logincomponent.h | 1 - .../components/networkdetailscomponent.cpp | 4 +- .../components/networkdetailscomponent.h | 6 +- src/blackgui/loginmodebuttons.cpp | 24 +++---- src/blackgui/loginmodebuttons.h | 7 +- src/blackmisc/network/facilitytype.cpp | 36 ++++++++++ src/blackmisc/network/facilitytype.h | 66 +++++++++++++++++++ src/blackmisc/network/loginmode.cpp | 30 +++++++++ src/blackmisc/network/loginmode.h | 64 ++++++++++++++++++ src/blackmisc/network/network.h | 2 + .../network/registermetadatanetwork.cpp | 3 + 21 files changed, 243 insertions(+), 56 deletions(-) create mode 100644 src/blackmisc/network/facilitytype.cpp create mode 100644 src/blackmisc/network/facilitytype.h create mode 100644 src/blackmisc/network/loginmode.cpp create mode 100644 src/blackmisc/network/loginmode.h diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 0038e9325..103927bb0 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -1451,7 +1451,7 @@ namespace BlackCore if (!sApp || sApp->isShuttingDown() || !sApp->getIContextNetwork()) { return false; } // It is only relevant if we are logged in as observer - if (sApp->getIContextNetwork()->getLoginMode() != INetwork::LoginAsObserver) { return false; } + if (sApp->getIContextNetwork()->getLoginMode() != BlackMisc::Network::CLoginMode::Observer) { return false; } const CCallsign ownCallsign = this->getOwnAircraft().getCallsign(); return ownCallsign.isMaybeCopilotCallsign(callsign); diff --git a/src/blackcore/context/contextnetwork.h b/src/blackcore/context/contextnetwork.h index a3cc745b3..51d2f2dc9 100644 --- a/src/blackcore/context/contextnetwork.h +++ b/src/blackcore/context/contextnetwork.h @@ -27,6 +27,7 @@ #include "blackmisc/aviation/flightplan.h" #include "blackmisc/network/connectionstatus.h" #include "blackmisc/network/clientlist.h" +#include "blackmisc/network/loginmode.h" #include "blackmisc/network/server.h" #include "blackmisc/network/serverlist.h" #include "blackmisc/network/textmessagelist.h" @@ -248,16 +249,16 @@ namespace BlackCore const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, - BlackCore::INetwork::LoginMode loginMode) = 0; + BlackMisc::Network::CLoginMode loginMode) = 0; //! Server which is connected, if not connected empty default object. virtual BlackMisc::Network::CServer getConnectedServer() const = 0; //! Login mode - virtual INetwork::LoginMode getLoginMode() const = 0; + virtual BlackMisc::Network::CLoginMode getLoginMode() const = 0; //! Mode as string - const QString &getLoginModeAsString() const { return INetwork::modeAsString(this->getLoginMode()); } + QString getLoginModeAsString() const { return this->getLoginMode().toQString(); } //! Disconnect from network //! \return messages generated during disconnecting diff --git a/src/blackcore/context/contextnetworkempty.h b/src/blackcore/context/contextnetworkempty.h index 2edfebefd..e55cdaf73 100644 --- a/src/blackcore/context/contextnetworkempty.h +++ b/src/blackcore/context/contextnetworkempty.h @@ -124,7 +124,7 @@ namespace BlackCore } //! \copydoc IContextNetwork::connectToNetwork - virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackCore::INetwork::LoginMode mode) override + virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackMisc::Network::CLoginMode mode) override { Q_UNUSED(mode); Q_UNUSED(server); @@ -166,10 +166,10 @@ namespace BlackCore } //! \copydoc IContextNetwork::getLoginMode - virtual INetwork::LoginMode getLoginMode() const override + virtual BlackMisc::Network::CLoginMode getLoginMode() const override { logEmptyContextWarning(Q_FUNC_INFO); - return BlackCore::INetwork::LoginNormal; + return BlackMisc::Network::CLoginMode::Pilot; } //! \copydoc IContextNetwork::sendTextMessages() diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index adc0ed360..e5f5c5bdf 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -217,7 +217,7 @@ namespace BlackCore if (m_airspace) { m_airspace->gracefulShutdown(); } } - CStatusMessage CContextNetwork::connectToNetwork(const CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const CCallsign &partnerCallsign, INetwork::LoginMode mode) + CStatusMessage CContextNetwork::connectToNetwork(const CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const CCallsign &partnerCallsign, CLoginMode mode) { if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } QString msg; diff --git a/src/blackcore/context/contextnetworkimpl.h b/src/blackcore/context/contextnetworkimpl.h index 6e8d322b6..94757bb96 100644 --- a/src/blackcore/context/contextnetworkimpl.h +++ b/src/blackcore/context/contextnetworkimpl.h @@ -252,9 +252,9 @@ namespace BlackCore virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Aviation::CAtcStationList getOnlineStationsForFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ChannelSpacing channelSpacing) const override; virtual bool isOnlineStation(const BlackMisc::Aviation::CCallsign &callsign) const override; - virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackCore::INetwork::LoginMode mode) override; + virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackMisc::Network::CLoginMode mode) override; virtual BlackMisc::Network::CServer getConnectedServer() const override; - virtual INetwork::LoginMode getLoginMode() const override; + virtual BlackMisc::Network::CLoginMode getLoginMode() const override; virtual BlackMisc::CStatusMessage disconnectFromNetwork() override; virtual bool isConnected() const override; virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override; @@ -295,7 +295,7 @@ namespace BlackCore CAirspaceMonitor *m_airspace = nullptr; INetwork *m_network = nullptr; INetwork::ConnectionStatus m_currentStatus = INetwork::Disconnected; //!< used to detect pending connections - INetwork::LoginMode m_currentMode = INetwork::LoginNormal; //!< current modeM + BlackMisc::Network::CLoginMode m_currentMode = BlackMisc::Network::CLoginMode::Pilot; //!< current modeM QTimer *m_requestAircraftDataTimer = nullptr; //!< general updates such as frequencies, see requestAircraftDataUpdates() QTimer *m_requestAtisTimer = nullptr; //!< general updates such as ATIS diff --git a/src/blackcore/context/contextnetworkproxy.cpp b/src/blackcore/context/contextnetworkproxy.cpp index e3e5692fb..20118115d 100644 --- a/src/blackcore/context/contextnetworkproxy.cpp +++ b/src/blackcore/context/contextnetworkproxy.cpp @@ -353,7 +353,7 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1String("testAddAltitudeOffset"), callsign, offset); } - CStatusMessage CContextNetworkProxy::connectToNetwork(const CServer &server, const QString &extraLiveryString, bool sendLiveryString, const QString &extraModelString, bool sendModelString, const CCallsign &partnerCallsign, INetwork::LoginMode loginMode) + CStatusMessage CContextNetworkProxy::connectToNetwork(const CServer &server, const QString &extraLiveryString, bool sendLiveryString, const QString &extraModelString, bool sendModelString, const CCallsign &partnerCallsign, CLoginMode loginMode) { return m_dBusInterface->callDBusRet(QLatin1String("connectToNetwork"), server, extraLiveryString, sendLiveryString, extraModelString, sendModelString, partnerCallsign, loginMode); } @@ -373,9 +373,9 @@ namespace BlackCore return m_dBusInterface->callDBusRet(QLatin1String("getConnectedServer")); } - INetwork::LoginMode CContextNetworkProxy::getLoginMode() const + CLoginMode CContextNetworkProxy::getLoginMode() const { - return m_dBusInterface->callDBusRet(QLatin1String("getLoginMode")); + return m_dBusInterface->callDBusRet(QLatin1String("getLoginMode")); } bool CContextNetworkProxy::parseCommandLine(const QString &commandLine, const CIdentifier &originator) diff --git a/src/blackcore/context/contextnetworkproxy.h b/src/blackcore/context/contextnetworkproxy.h index 7662abf8d..4117f7653 100644 --- a/src/blackcore/context/contextnetworkproxy.h +++ b/src/blackcore/context/contextnetworkproxy.h @@ -88,11 +88,11 @@ namespace BlackCore virtual BlackMisc::Aviation::CAtcStationList getOnlineStationsForFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ChannelSpacing channelSpacing) const override; virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual bool isOnlineStation(const BlackMisc::Aviation::CCallsign &callsign) const override; - virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackCore::INetwork::LoginMode mode) override; + virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, const QString &extraLiveryString, bool sendLivery, const QString &extraModelString, bool sendModelString, const BlackMisc::Aviation::CCallsign &partnerCallsign, BlackMisc::Network::CLoginMode mode) override; virtual BlackMisc::CStatusMessage disconnectFromNetwork() override; virtual bool isConnected() const override; virtual BlackMisc::Network::CServer getConnectedServer() const override; - virtual INetwork::LoginMode getLoginMode() const override; + virtual BlackMisc::Network::CLoginMode getLoginMode() const override; virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override; virtual void sendFlightPlan(const BlackMisc::Aviation::CFlightPlan &flightPlan) override; diff --git a/src/blackcore/registermetadata.cpp b/src/blackcore/registermetadata.cpp index 9ff871499..271a11861 100644 --- a/src/blackcore/registermetadata.cpp +++ b/src/blackcore/registermetadata.cpp @@ -30,8 +30,6 @@ namespace BlackCore { // not really clear when a type here has to be registered with qRegisterMetaType // however, does not harm if it is redundant - qRegisterMetaType(); - qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); @@ -40,14 +38,14 @@ namespace BlackCore qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); - qDBusRegisterMetaType(); + qDBusRegisterMetaType(); qDBusRegisterMetaType(); qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); + qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); - qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); Db::CDatabaseReaderConfig::registerMetadata(); diff --git a/src/blackgui/components/loginadvcomponent.cpp b/src/blackgui/components/loginadvcomponent.cpp index 9196b06aa..e6d62075c 100644 --- a/src/blackgui/components/loginadvcomponent.cpp +++ b/src/blackgui/components/loginadvcomponent.cpp @@ -22,7 +22,6 @@ #include "blackcore/context/contextnetwork.h" #include "blackcore/data/globalsetup.h" #include "blackcore/webdataservices.h" -#include "blackcore/network.h" #include "blackcore/simulator.h" #include "blackmisc/simulation/simulatorinternals.h" #include "blackmisc/simulation/aircraftmodel.h" @@ -167,11 +166,10 @@ namespace BlackGui ui->comp_OwnAircraft->updateOwnAircaftIcaoValuesFromGuiValues(); // Login mode - const INetwork::LoginMode mode = ui->comp_NetworkDetails->getLoginMode(); - switch (mode) + const CLoginMode mode = ui->comp_NetworkDetails->getLoginMode(); + switch (mode.getLoginMode()) { - case INetwork::LoginStealth: CLogMessage(this).info(u"login in stealth mode"); break; - case INetwork::LoginAsObserver: CLogMessage(this).info(u"login in observer mode"); break; + case CLoginMode::Observer: CLogMessage(this).info(u"login in observer mode"); break; default: break; // INetwork::LoginNormal } diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index f021042c2..917382cca 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -289,13 +289,8 @@ namespace BlackGui this->updateOwnAircaftIcaoValuesFromGuiValues(); // Login mode - const INetwork::LoginMode mode = ui->frp_LoginMode->getLoginMode(); - switch (mode) - { - case INetwork::LoginStealth: CLogMessage(this).info(u"login in stealth mode"); break; - case INetwork::LoginAsObserver: CLogMessage(this).info(u"login in observer mode"); break; - default: break; // INetwork::LoginNormal - } + const CLoginMode mode = ui->frp_LoginMode->getLoginMode(); + if(mode.isObserver()) { CLogMessage(this).info(u"login in observer mode"); } // Server currentServer = this->getCurrentServer(); diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index 0d83710af..1f3cdf72a 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -13,7 +13,6 @@ #include "blackcore/vatsim/vatsimsettings.h" #include "blackcore/data/networksetup.h" -#include "blackcore/network.h" #include "blackgui/settings/guisettings.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" diff --git a/src/blackgui/components/networkdetailscomponent.cpp b/src/blackgui/components/networkdetailscomponent.cpp index 43fa55c5f..ea9a302cf 100644 --- a/src/blackgui/components/networkdetailscomponent.cpp +++ b/src/blackgui/components/networkdetailscomponent.cpp @@ -75,12 +75,12 @@ namespace BlackGui CNetworkDetailsComponent::~CNetworkDetailsComponent() { } - INetwork::LoginMode CNetworkDetailsComponent::getLoginMode() const + CLoginMode CNetworkDetailsComponent::getLoginMode() const { return ui->frp_LoginMode->getLoginMode(); } - void CNetworkDetailsComponent::setLoginMode(INetwork::LoginMode mode) + void CNetworkDetailsComponent::setLoginMode(CLoginMode mode) { ui->frp_LoginMode->setLoginMode(mode); } diff --git a/src/blackgui/components/networkdetailscomponent.h b/src/blackgui/components/networkdetailscomponent.h index 37c3b1cab..02455b1d3 100644 --- a/src/blackgui/components/networkdetailscomponent.h +++ b/src/blackgui/components/networkdetailscomponent.h @@ -15,7 +15,6 @@ #include #include "blackcore/data/networksetup.h" -#include "blackcore/network.h" #include "blackmisc/network/data/lastserver.h" #include "blackmisc/network/entityflags.h" #include "blackmisc/network/fsdsetup.h" @@ -23,6 +22,7 @@ #include "blackmisc/settingscache.h" #include "blackmisc/datacache.h" #include "blackmisc/network/connectionstatus.h" +#include "blackmisc/network/loginmode.h" namespace Ui { class CNetworkDetailsComponent; } namespace BlackGui @@ -79,10 +79,10 @@ namespace BlackGui bool isVoiceSetupOverrideEnabled() const; //! Login mode - BlackCore::INetwork::LoginMode getLoginMode() const; + BlackMisc::Network::CLoginMode getLoginMode() const; //! Login mode - void setLoginMode(BlackCore::INetwork::LoginMode mode); + void setLoginMode(BlackMisc::Network::CLoginMode mode); //! Reset state void resetState(); diff --git a/src/blackgui/loginmodebuttons.cpp b/src/blackgui/loginmodebuttons.cpp index 5bf441abb..5acd68518 100644 --- a/src/blackgui/loginmodebuttons.cpp +++ b/src/blackgui/loginmodebuttons.cpp @@ -19,6 +19,7 @@ using namespace BlackConfig; using namespace BlackCore; using namespace BlackCore::Context; +using namespace BlackMisc::Network; namespace BlackGui { @@ -35,32 +36,25 @@ namespace BlackGui CLoginModeButtons::~CLoginModeButtons() { } - INetwork::LoginMode BlackGui::CLoginModeButtons::getLoginMode() const + CLoginMode BlackGui::CLoginModeButtons::getLoginMode() const { - INetwork::LoginMode mode = INetwork::LoginNormal; - if (ui->rb_LoginStealth->isChecked()) + CLoginMode mode = CLoginMode::Pilot; + if (ui->rb_LoginObserver->isChecked()) { - mode = INetwork::LoginStealth; - } - else if (ui->rb_LoginObserver->isChecked()) - { - mode = INetwork::LoginAsObserver; + mode.setLoginMode(CLoginMode::Observer); } return mode; } - void CLoginModeButtons::setLoginMode(INetwork::LoginMode mode) + void CLoginModeButtons::setLoginMode(CLoginMode mode) { - switch (mode) + switch (mode.getLoginMode()) { - case INetwork::LoginAsObserver: + case CLoginMode::Observer: ui->rb_LoginObserver->setChecked(true); break; - case INetwork::LoginStealth: - ui->rb_LoginStealth->setChecked(true); - break; default: - case INetwork::LoginNormal: + case CLoginMode::Pilot: ui->rb_LoginNormal->setChecked(true); break; } diff --git a/src/blackgui/loginmodebuttons.h b/src/blackgui/loginmodebuttons.h index 0f827cd97..aaf6706eb 100644 --- a/src/blackgui/loginmodebuttons.h +++ b/src/blackgui/loginmodebuttons.h @@ -11,9 +11,10 @@ #ifndef BLACKGUI_LOGINMODEBUTTONS_H #define BLACKGUI_LOGINMODEBUTTONS_H -#include "blackcore/network.h" #include "blackgui/blackguiexport.h" #include "blackmisc/network/connectionstatus.h" +#include "blackmisc/network/loginmode.h" + #include #include #include @@ -34,10 +35,10 @@ namespace BlackGui virtual ~CLoginModeButtons() override; //! Get login mode, \sa BlackCore::INetwork::LoginMode - BlackCore::INetwork::LoginMode getLoginMode() const; + BlackMisc::Network::CLoginMode getLoginMode() const; //! Set login mode - void setLoginMode(BlackCore::INetwork::LoginMode mode); + void setLoginMode(BlackMisc::Network::CLoginMode mode); //! Set to read only void setReadOnly(bool readonly); diff --git a/src/blackmisc/network/facilitytype.cpp b/src/blackmisc/network/facilitytype.cpp new file mode 100644 index 000000000..f39dee528 --- /dev/null +++ b/src/blackmisc/network/facilitytype.cpp @@ -0,0 +1,36 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "blackmisc/network/facilitytype.h" + +namespace BlackMisc +{ + namespace Network + { + QString CFacilityType::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + + switch (m_facilityType) + { + case OBS: return QStringLiteral("OBS"); + case FSS: return QStringLiteral("FSS"); + case DEL: return QStringLiteral("DEL"); + case GND: return QStringLiteral("GND"); + case TWR: return QStringLiteral("TWR"); + case APP: return QStringLiteral("APP"); + case CTR: return QStringLiteral("CTR"); + case Unknown: return QStringLiteral("Unknown"); + } + + Q_UNREACHABLE(); + return {}; + } + + } // namespace +} // namespace diff --git a/src/blackmisc/network/facilitytype.h b/src/blackmisc/network/facilitytype.h new file mode 100644 index 000000000..8e7e2249e --- /dev/null +++ b/src/blackmisc/network/facilitytype.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_NETWORK_FACILITYTYPE_H +#define BLACKMISC_NETWORK_FACILITYTYPE_H + +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/valueobject.h" + +namespace BlackMisc +{ + namespace Network + { + //! Value object encapsulating the ATC facility type, e.g. TWR, DEP, APP + class BLACKMISC_EXPORT CFacilityType : public CValueObject + { + public: + //! Login modes + enum FacilityType + { + OBS, /*!< OBS */ + FSS, /*!< FSS */ + DEL, /*!< Delivery */ + GND, /*!< Ground */ + TWR, /*!< Tower */ + APP, /*!< Approach */ + CTR, /*!< Center */ + Unknown /*!< Unknown */ + }; + + //! Default constructor. + CFacilityType() = default; + + //! Constructor + CFacilityType(FacilityType mode) : m_facilityType(mode) {} + + //! Get type + FacilityType getFacilityType() const { return m_facilityType; } + + //! Set type + void setFacilityType(FacilityType type) { m_facilityType = type; } + + //! \copydoc BlackMisc::Mixin::String::toQString + QString convertToQString(bool i18n = false) const; + + private: + FacilityType m_facilityType = Unknown; + + BLACK_METACLASS( + CFacilityType, + BLACK_METAMEMBER(facilityType) + ); + }; + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Network::CFacilityType) + +#endif // guard diff --git a/src/blackmisc/network/loginmode.cpp b/src/blackmisc/network/loginmode.cpp new file mode 100644 index 000000000..f4015cd43 --- /dev/null +++ b/src/blackmisc/network/loginmode.cpp @@ -0,0 +1,30 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "blackmisc/network/loginmode.h" + +namespace BlackMisc +{ + namespace Network + { + QString CLoginMode::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + + switch (m_loginMode) + { + case Pilot: return QStringLiteral("Pilot"); + case Observer: return QStringLiteral("Observer"); + } + + Q_UNREACHABLE(); + return {}; + } + + } // namespace +} // namespace diff --git a/src/blackmisc/network/loginmode.h b/src/blackmisc/network/loginmode.h new file mode 100644 index 000000000..69e8fe6f0 --- /dev/null +++ b/src/blackmisc/network/loginmode.h @@ -0,0 +1,64 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_NETWORK_LOGINMODE_H +#define BLACKMISC_NETWORK_LOGINMODE_H + +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/valueobject.h" + +namespace BlackMisc +{ + namespace Network + { + //! Value object encapsulating information about login mode + class BLACKMISC_EXPORT CLoginMode : public CValueObject + { + public: + //! Login modes + enum LoginMode + { + Pilot, //!< Normal login + Observer, //!< Login as observer + }; + + //! Default constructor. + CLoginMode() = default; + + //! Constructor + CLoginMode(LoginMode mode) : m_loginMode(mode) {} + + bool isPilot() const { return m_loginMode == Pilot; } + + bool isObserver() const { return m_loginMode == Observer; } + + //! Get status + LoginMode getLoginMode() const { return m_loginMode; } + + //! Set status + void setLoginMode(LoginMode mode) { m_loginMode = mode; } + + //! \copydoc BlackMisc::Mixin::String::toQString + QString convertToQString(bool i18n = false) const; + + private: + LoginMode m_loginMode = Pilot; + + BLACK_METACLASS( + CLoginMode, + BLACK_METAMEMBER(loginMode) + ); + }; + } // namespace +} // namespace + +Q_DECLARE_METATYPE(BlackMisc::Network::CLoginMode) + +#endif // guard diff --git a/src/blackmisc/network/network.h b/src/blackmisc/network/network.h index 117ce4b1a..1249a95d1 100644 --- a/src/blackmisc/network/network.h +++ b/src/blackmisc/network/network.h @@ -23,7 +23,9 @@ #include "blackmisc/network/ecosystem.h" #include "blackmisc/network/ecosystemlist.h" #include "blackmisc/network/entityflags.h" +#include "blackmisc/network/facilitytype.h" #include "blackmisc/network/fsdsetup.h" +#include "blackmisc/network/loginmode.h" #include "blackmisc/network/rawfsdmessage.h" #include "blackmisc/network/rawfsdmessagelist.h" #include "blackmisc/network/role.h" diff --git a/src/blackmisc/network/registermetadatanetwork.cpp b/src/blackmisc/network/registermetadatanetwork.cpp index b1865d6b5..4be220402 100644 --- a/src/blackmisc/network/registermetadatanetwork.cpp +++ b/src/blackmisc/network/registermetadatanetwork.cpp @@ -24,7 +24,9 @@ namespace BlackMisc CEcosystem::registerMetadata(); CEcosystemList::registerMetadata(); CEntityFlags::registerMetadata(); + CFacilityType::registerMetadata(); CFsdSetup::registerMetadata(); + CLoginMode::registerMetadata(); CRawFsdMessage::registerMetadata(); CRawFsdMessageList::registerMetadata(); CRemoteFile::registerMetadata(); @@ -44,6 +46,7 @@ namespace BlackMisc CUserList::registerMetadata(); CVoiceCapabilities::registerMetadata(); Settings::CNetworkSettings::registerMetadata(); + } } // ns } // ns