From bae7680e59db7bd5b0a82bddd210bb92648ffd31 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 21 Feb 2019 00:23:25 +0100 Subject: [PATCH] Ref T401, server info also when not connected --- src/blackcore/context/contextsimulatorimpl.cpp | 2 +- src/blackgui/components/logincomponent.cpp | 2 +- src/blackmisc/network/server.cpp | 9 +++++---- src/blackmisc/network/server.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index d6d501a2a..9fcb50188 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -703,7 +703,7 @@ namespace BlackCore BLACK_VERIFY_X(this->getIContextNetwork(), Q_FUNC_INFO, "Missing network context"); if (to == INetwork::Connected && this->getIContextNetwork()) { - m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(); + m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(false); if (m_simulatorPlugin.second) // check in case the plugin has been unloaded { m_simulatorPlugin.second->setFlightNetworkConnected(true); diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index cf6fc0443..4f306f919 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -314,7 +314,7 @@ namespace BlackGui sGui->setExtraWindowTitle(QStringLiteral("[%1]").arg(ownAircraft.getCallsignAsString())); sGui->crashAndLogInfoUserName(currentServer.getUser().getRealNameAndId()); sGui->crashAndLogInfoFlightNetwork(currentServer.getEcosystem().toQString(true)); - sGui->crashAndLogAppendInfo(currentServer.getServerSessionId()); + sGui->crashAndLogAppendInfo(currentServer.getServerSessionId(false)); m_networkSetup.setLastServer(currentServer); m_lastAircraftModel.set(ownAircraft.getModel()); ui->le_LoginCallsign->setText(ownAircraft.getCallsignAsString()); diff --git a/src/blackmisc/network/server.cpp b/src/blackmisc/network/server.cpp index 1ecf59e4f..d39c51e12 100644 --- a/src/blackmisc/network/server.cpp +++ b/src/blackmisc/network/server.cpp @@ -186,11 +186,12 @@ namespace BlackMisc return msgs; } - QString CServer::getServerSessionId() const + QString CServer::getServerSessionId(bool onlyConnected) const { - if (!this->isConnected()) { return {}; } - static const QString session("%1 %2:%3 [%4] %5 %6"); - return session.arg(this->getName(), this->getAddress()).arg(this->getPort()).arg(this->getEcosystem().getSystemString(), this->getUser().getRealName(), this->getFormattedUtcTimestampHms()); + const bool isConnected = this->isConnected(); + if (onlyConnected && !isConnected) { return {}; } + static const QString session("%1 %2 %3:%4 [%5] %6 %7"); + return session.arg(isConnected ? u"connected" : u"disconnected").arg(this->getName(), this->getAddress()).arg(this->getPort()).arg(this->getEcosystem().getSystemString(), this->getUser().getRealName(), this->getFormattedUtcTimestampHms()); } CVariant CServer::propertyByIndex(const CPropertyIndex &index) const diff --git a/src/blackmisc/network/server.h b/src/blackmisc/network/server.h index 5b9d7e7f7..9d8b6949a 100644 --- a/src/blackmisc/network/server.h +++ b/src/blackmisc/network/server.h @@ -203,7 +203,7 @@ namespace BlackMisc CStatusMessageList validate() const; //! Identifying a session, if not connected empty - QString getServerSessionId() const; + QString getServerSessionId(bool onlyConnected) const; //! \copydoc BlackMisc::Mixin::Index::propertyByIndex CVariant propertyByIndex(const CPropertyIndex &index) const;