Ref T301, make login mode via contexts available

This commit is contained in:
Klaus Basan
2018-08-12 03:08:29 +02:00
parent 7805e2315c
commit 7b360e03cc
6 changed files with 27 additions and 1 deletions

View File

@@ -235,6 +235,9 @@ namespace BlackCore
//! 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;
//! Disconnect from network
//! \return messages generated during disconnecting
virtual BlackMisc::CStatusMessage disconnectFromNetwork() = 0;

View File

@@ -125,6 +125,13 @@ namespace BlackCore
return BlackMisc::Network::CServer();
}
//! \copydoc IContextNetwork::getLoginMode
virtual INetwork::LoginMode getLoginMode() const override
{
logEmptyContextWarning(Q_FUNC_INFO);
return BlackCore::INetwork::LoginNormal;
}
//! \copydoc IContextNetwork::sendTextMessages()
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override
{

View File

@@ -216,6 +216,7 @@ namespace BlackCore
mode = INetwork::LoginAsObserver;
}
m_currentMode = mode;
m_network->presetLoginMode(mode);
m_network->presetCallsign(ownAircraft.getCallsign());
m_network->presetIcaoCodes(ownAircraft);
@@ -231,12 +232,19 @@ namespace BlackCore
return this->isConnected() ? m_network->getPresetServer() : CServer();
}
INetwork::LoginMode CContextNetwork::getLoginMode() const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return m_currentMode;
}
CStatusMessage CContextNetwork::disconnectFromNetwork()
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
if (m_network->isConnected() || m_network->isPendingConnection())
{
m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect
m_currentMode = INetwork::LoginNormal;
m_network->terminateConnection();
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection terminating");
}

View File

@@ -87,7 +87,7 @@ namespace BlackCore
public:
//! Destructor
virtual ~CContextNetwork();
virtual ~CContextNetwork() override;
//! \ingroup remoteaircraftprovider
//! @{
@@ -226,6 +226,7 @@ namespace BlackCore
virtual BlackMisc::Aviation::CAtcStation getOnlineStationForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, BlackCore::INetwork::LoginMode mode) override;
virtual BlackMisc::Network::CServer getConnectedServer() const override;
virtual INetwork::LoginMode getLoginMode() const override;
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
virtual bool isConnected() const override;
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
@@ -265,6 +266,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
QTimer *m_networkDataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
// Digest signals, only sending after some time

View File

@@ -333,6 +333,11 @@ namespace BlackCore
return m_dBusInterface->callDBusRet<BlackMisc::Network::CServer>(QLatin1String("getConnectedServer"));
}
INetwork::LoginMode CContextNetworkProxy::getLoginMode() const
{
return m_dBusInterface->callDBusRet<BlackCore::INetwork::LoginMode>(QLatin1String("getLoginMode"));
}
bool CContextNetworkProxy::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
{
return m_dBusInterface->callDBusRet<bool>(QLatin1String("parseCommandLine"), commandLine, originator);

View File

@@ -88,6 +88,7 @@ namespace BlackCore
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
virtual bool isConnected() const override;
virtual BlackMisc::Network::CServer getConnectedServer() const override;
virtual INetwork::LoginMode 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;