refs #395, refs #411 fixes found in course of DBus testing

* set infobar status correctly when GUI connects after the core has been started
* more detailed information in information statusbar
* allow to obtain currently connected server in network context
* made many network vatlib slots normal member functions
* fixed rendered aircraft flag setting in FSX driver
This commit is contained in:
Klaus Basan
2015-04-28 01:02:24 +02:00
committed by Mathew Sutcliffe
parent 1d89862080
commit 3c15f2ad89
17 changed files with 100 additions and 52 deletions

View File

@@ -194,10 +194,13 @@ namespace BlackCore
virtual BlackMisc::Aviation::CCallsignSet getFastPositionEnabledCallsigns() = 0; virtual BlackMisc::Aviation::CCallsignSet getFastPositionEnabledCallsigns() = 0;
//! Connect to Network //! Connect to Network
//! \return messages gererated during connecting //! \return messages generated during connecting
//! \see INetwork::LoginMode //! \see INetwork::LoginMode
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint loginMode) = 0; virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint loginMode) = 0;
//! Server which is connected, if not connected empty default object.
virtual BlackMisc::Network::CServer getConnectedServer() const = 0;
//! Disconnect from network //! Disconnect from network
//! \return messages generated during disconnecting //! \return messages generated during disconnecting
virtual BlackMisc::CStatusMessage disconnectFromNetwork() = 0; virtual BlackMisc::CStatusMessage disconnectFromNetwork() = 0;

View File

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

View File

@@ -189,6 +189,18 @@ namespace BlackCore
} }
} }
CServer CContextNetwork::getConnectedServer() const
{
if (this->isConnected())
{
return this->m_network->getPresetServer();
}
else
{
return CServer();
}
}
CStatusMessage CContextNetwork::disconnectFromNetwork() CStatusMessage CContextNetwork::disconnectFromNetwork()
{ {
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }

View File

@@ -127,6 +127,9 @@ namespace BlackCore
//! \copydoc IContextNetwork::connectToNetwork() //! \copydoc IContextNetwork::connectToNetwork()
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override; virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override;
//! \copydoc IContextNetwork::getConnectedServer
virtual BlackMisc::Network::CServer getConnectedServer() const override;
//! \copydoc IContextNetwork::disconnectFromNetwork() //! \copydoc IContextNetwork::disconnectFromNetwork()
virtual BlackMisc::CStatusMessage disconnectFromNetwork() override; virtual BlackMisc::CStatusMessage disconnectFromNetwork() override;
@@ -256,13 +259,8 @@ namespace BlackCore
//! Check if a supervisor message was received //! Check if a supervisor message was received
void ps_checkForSupervisiorTextMessage(const BlackMisc::Network::CTextMessageList &messages); void ps_checkForSupervisiorTextMessage(const BlackMisc::Network::CTextMessageList &messages);
/*! //! Connection status changed
* \brief Connection status changed?
* \param from old status
* \param to new status
*/
void ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to); void ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to);
}; };
} }

View File

@@ -243,6 +243,11 @@ namespace BlackCore
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isConnected")); return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isConnected"));
} }
CServer CContextNetworkProxy::getConnectedServer() const
{
return this->m_dBusInterface->callDBusRet<BlackMisc::Network::CServer>(QLatin1Literal("getConnectedServer"));
}
bool CContextNetworkProxy::parseCommandLine(const QString &commandLine, const QString &originator) bool CContextNetworkProxy::parseCommandLine(const QString &commandLine, const QString &originator)
{ {
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("commandLineEntered"), commandLine, originator); return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("commandLineEntered"), commandLine, originator);

View File

@@ -84,6 +84,9 @@ namespace BlackCore
//! \copydoc IContextNetwork::isConnected() //! \copydoc IContextNetwork::isConnected()
virtual bool isConnected() const override; virtual bool isConnected() const override;
//! \copydoc IContextNetwork::getConnectedServer
virtual BlackMisc::Network::CServer getConnectedServer() const override;
//! \copydoc IContextNetwork::parseCommandLine //! \copydoc IContextNetwork::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine, const QString &originator) override; virtual bool parseCommandLine(const QString &commandLine, const QString &originator) override;

View File

@@ -139,23 +139,26 @@ namespace BlackCore
status == DisconnectedFailed || status == DisconnectedLost; status == DisconnectedFailed || status == DisconnectedLost;
} }
////////////////////////////////////////////////////////////////
//! \name Network slots
//! @{
////////////////////////////////////////////////////////////////
/*! /*!
* Returns true if the current ConnectionStatus is a connected state. * Returns true if the current ConnectionStatus is a connected state.
*/ */
virtual bool isConnected() const = 0; virtual bool isConnected() const = 0;
/*!
* Get preset server.
*/
virtual BlackMisc::Network::CServer getPresetServer() const = 0;
/*! /*!
* Returns true if the current ConnectionStatus is in transition, e.g. connecting. * Returns true if the current ConnectionStatus is in transition, e.g. connecting.
*/ */
virtual bool isPendingConnection() const = 0; virtual bool isPendingConnection() const = 0;
public slots:
////////////////////////////////////////////////////////////////
//! \name Network slots
//! @{
////////////////////////////////////////////////////////////////
/*! /*!
* Set the server which will be connected to. * Set the server which will be connected to.
* \pre Network must be disconnected when calling this function. * \pre Network must be disconnected when calling this function.

View File

@@ -277,7 +277,7 @@ namespace BlackCore
} }
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/ /********************************** * * * * * * * * * * * * * * * * * * * ************************************/
/********************************** INetwork slots ************************************/ /********************************** INetwork functions ************************************/
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/ /********************************** * * * * * * * * * * * * * * * * * * * ************************************/
void CNetworkVatlib::presetServer(const CServer &server) void CNetworkVatlib::presetServer(const CServer &server)

View File

@@ -39,9 +39,10 @@ namespace BlackCore
//! Destructor //! Destructor
virtual ~CNetworkVatlib(); virtual ~CNetworkVatlib();
//! \name Network slots //! \name Network functions
//! @{ //! @{
virtual bool isConnected() const override { return m_status == vatStatusConnected; } virtual bool isConnected() const override { return m_status == vatStatusConnected; }
virtual BlackMisc::Network::CServer getPresetServer() const override { return m_server; }
virtual bool isPendingConnection() const override { return m_status == vatStatusConnecting; } virtual bool isPendingConnection() const override { return m_status == vatStatusConnecting; }
virtual void presetLoginMode(LoginMode mode) override; virtual void presetLoginMode(LoginMode mode) override;
virtual void presetServer(const BlackMisc::Network::CServer &server) override; virtual void presetServer(const BlackMisc::Network::CServer &server) override;
@@ -62,12 +63,12 @@ namespace BlackCore
virtual void sendAircraftConfigQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendAircraftConfigQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
//! @} //! @}
//! \name Text message slots //! \name Text message functions
//! @{ //! @{
virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &messages) override; virtual void sendTextMessages(const BlackMisc::Network::CTextMessageList &messages) override;
//! @} //! @}
//! \name ATC slots //! \name ATC functions
//! @{ //! @{
virtual void sendAtcQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendAtcQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void sendAtisQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendAtisQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
@@ -75,7 +76,7 @@ namespace BlackCore
virtual void sendFlightPlanQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendFlightPlanQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
//! @} //! @}
//! \name Aircraft slots //! \name Aircraft functions
//! @{ //! @{
virtual void sendCapabilitiesQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendCapabilitiesQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void sendIcaoCodesQuery(const BlackMisc::Aviation::CCallsign &callsign) override; virtual void sendIcaoCodesQuery(const BlackMisc::Aviation::CCallsign &callsign) override;
@@ -84,7 +85,7 @@ namespace BlackCore
virtual void sendInterimPositions(const BlackMisc::Aviation::CCallsignSet &receiver) override; virtual void sendInterimPositions(const BlackMisc::Aviation::CCallsignSet &receiver) override;
//! @} //! @}
//! \name Weather slots //! \name Weather functions
//! @{ //! @{
virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override; virtual void sendMetarQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override;
virtual void sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override; virtual void sendWeatherDataQuery(const BlackMisc::Aviation::CAirportIcao &airportIcao) override;

View File

@@ -38,6 +38,7 @@ namespace BlackCore
//! ISimulator status //! ISimulator status
enum SimulatorStatus enum SimulatorStatus
{ {
Disconnected = 0,
Connected = 1 << 0, //!< Is the plugin connected to the simulator? Connected = 1 << 0, //!< Is the plugin connected to the simulator?
Running = 1 << 1, //!< Is the simulator actually simulating? Running = 1 << 1, //!< Is the simulator actually simulating?
Paused = 1 << 2, //!< Is the simulator paused? Paused = 1 << 2, //!< Is the simulator paused?

View File

@@ -78,11 +78,15 @@ namespace BlackGui
{ {
connect(this->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::ps_onSimulatorStatusChanged); connect(this->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::ps_onSimulatorStatusChanged);
connect(this->getIContextSimulator(), &IContextSimulator::installedAircraftModelsChanged, this, &CInfoBarStatusComponent::ps_onMapperReady); connect(this->getIContextSimulator(), &IContextSimulator::installedAircraftModelsChanged, this, &CInfoBarStatusComponent::ps_onMapperReady);
// initial values
this->ps_onMapperReady();
bool connected = this->getIContextSimulator()->isConnected();
this->ps_onSimulatorStatusChanged(connected ? ISimulator::Connected : ISimulator::Disconnected);
} }
if (this->getIContextNetwork()) if (this->getIContextNetwork())
{ {
this->ui->led_Simulator->setOn(this->getIContextSimulator()->isConnected());
connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::ps_onNetworkConnectionChanged); connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::ps_onNetworkConnectionChanged);
} }
@@ -98,19 +102,20 @@ namespace BlackGui
} }
} }
void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(quint8 status) void CInfoBarStatusComponent::ps_onSimulatorStatusChanged(int status)
{ {
// if (connected && running) if (status > 0)
if (status & (ISimulator::Connected | ISimulator::Running)) { {
this->ui->led_Simulator->setOn(true); this->ui->led_Simulator->setOn(true);
} else if (status & ISimulator::Connected) { this->ui->led_Simulator->setOnToolTip(getIContextSimulator()->getSimulatorPluginInfo().getDescription());
this->ui->led_Simulator->setTriState(); }
} else { else
{
this->ui->led_Simulator->setOn(false); this->ui->led_Simulator->setOn(false);
} }
} }
void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(uint from, uint to) void CInfoBarStatusComponent::ps_onNetworkConnectionChanged(int from, int to)
{ {
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from); INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to); INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
@@ -126,6 +131,7 @@ namespace BlackGui
break; break;
case INetwork::Connected: case INetwork::Connected:
this->ui->led_Network->setOn(true); this->ui->led_Network->setOn(true);
this->ui->led_Network->setOnToolTip("Connected: " + getIContextNetwork()->getConnectedServer().getName());
break; break;
case INetwork::Connecting: case INetwork::Connecting:
this->ui->led_Network->setTriStateColor(CLedWidget::Yellow); this->ui->led_Network->setTriStateColor(CLedWidget::Yellow);
@@ -179,8 +185,14 @@ namespace BlackGui
return; return;
} }
bool on = this->getIContextSimulator()->getInstalledModelsCount() > 0; int models = this->getIContextSimulator()->getInstalledModelsCount();
bool on = (models > 0);
this->ui->led_MapperReady->setOn(on); this->ui->led_MapperReady->setOn(on);
if (on)
{
QString m = QString("Mapper with %1 models").arg(models);
this->ui->led_MapperReady->setToolTip(m);
}
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -55,10 +55,10 @@ namespace BlackGui
private slots: private slots:
//! Simulator connection has been changed //! Simulator connection has been changed
void ps_onSimulatorStatusChanged(quint8 status); void ps_onSimulatorStatusChanged(int status);
//! Network connection has been changed //! Network connection has been changed
void ps_onNetworkConnectionChanged(uint from, uint to); void ps_onNetworkConnectionChanged(int from, int to);
//! Context menu requested //! Context menu requested
void ps_customAudioContextMenuRequested(const QPoint &position); void ps_customAudioContextMenuRequested(const QPoint &position);

View File

@@ -389,7 +389,7 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>2</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>

View File

@@ -20,6 +20,10 @@ namespace BlackMisc
namespace Aviation namespace Aviation
{ {
CAircraftIcao::CAircraftIcao(const QString &icao, const QString &airline)
: m_aircraftDesignator(icao.trimmed().toUpper()), m_airlineDesignator(airline.trimmed().toUpper())
{}
QString CAircraftIcao::convertToQString(bool i18n) const QString CAircraftIcao::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n);
@@ -41,6 +45,12 @@ namespace BlackMisc
return (this->hasAircraftDesignator() && this->getAircraftDesignator() != "ZZZZ"); return (this->hasAircraftDesignator() && this->getAircraftDesignator() != "ZZZZ");
} }
QString CAircraftIcao::getEngineType() const
{
if (this->m_aircraftCombinedType.length() != 3) return "";
return this->m_aircraftCombinedType.right(1);
}
QString CAircraftIcao::asString() const QString CAircraftIcao::asString() const
{ {
if (this->m_aircraftDesignator.isEmpty()) { return ""; } if (this->m_aircraftDesignator.isEmpty()) { return ""; }

View File

@@ -42,14 +42,10 @@ namespace BlackMisc
//! Constructor. //! Constructor.
explicit CAircraftIcao(const QString &icao) : m_aircraftDesignator(icao.trimmed().toUpper()) {} explicit CAircraftIcao(const QString &icao) : m_aircraftDesignator(icao.trimmed().toUpper()) {}
/*! //! Constructor.
* Constructor. //! \param icao "B737"
* \param icao "B737" //! \param airline "DLH"
* \param airline "DLH" CAircraftIcao(const QString &icao, const QString &airline);
*/
CAircraftIcao(const QString &icao, const QString &airline)
: m_aircraftDesignator(icao.trimmed().toUpper()), m_airlineDesignator(airline.trimmed().toUpper())
{}
/*! /*!
* Constructor. * Constructor.
@@ -115,16 +111,10 @@ namespace BlackMisc
bool hasAircraftCombinedType() const { return this->getAircraftCombinedType().length() == 3; } bool hasAircraftCombinedType() const { return this->getAircraftCombinedType().length() == 3; }
//! Get engine type, e.g. "J" //! Get engine type, e.g. "J"
QString getEngineType() const QString getEngineType() const;
{
if (this->m_aircraftCombinedType.length() != 3) return "";
return this->m_aircraftCombinedType.right(1);
}
/*! //! As string for GUI representation by index
* \brief As string for GUI representation by index //! \remarks Different from toQString()
* \remarks Different from toQString()
*/
QString asString() const; QString asString() const;
//! Set type //! Set type
@@ -175,7 +165,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftIcao, (
o.m_airlineDesignator, o.m_airlineDesignator,
o.m_livery, o.m_livery,
o.m_aircraftColor o.m_aircraftColor
)) ))
#endif // guard #endif // guard

View File

@@ -40,7 +40,7 @@ namespace BlackMisc
CServer() : m_port(-1), m_isAcceptingConnections(true) {} CServer() : m_port(-1), m_isAcceptingConnections(true) {}
//! Constructor. //! Constructor.
CServer(const QString &name, const QString &description, const QString &address, qint32 port, const CUser &user, bool isAcceptingConnections = true) CServer(const QString &name, const QString &description, const QString &address, int port, const CUser &user, bool isAcceptingConnections = true)
: m_name(name), m_description(description), m_address(address), m_port(port), m_user(user), m_isAcceptingConnections(isAcceptingConnections) {} : m_name(name), m_description(description), m_address(address), m_port(port), m_user(user), m_isAcceptingConnections(isAcceptingConnections) {}
//! Get address. //! Get address.

View File

@@ -164,7 +164,8 @@ namespace BlackSimPlugin
// matched models // matched models
CAircraftModel aircraftModel = modelMatching(newRemoteAircraftCopy); CAircraftModel aircraftModel = modelMatching(newRemoteAircraftCopy);
Q_ASSERT_X(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns"); Q_ASSERT_X(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns");
this->updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator()); this->updateAircraftModel(callsign, aircraftModel, simulatorOriginator());
this->updateAircraftRendered(callsign, true, simulatorOriginator());
CSimulatedAircraft aircraftAfterModelApplied(getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign())); CSimulatedAircraft aircraftAfterModelApplied(getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign()));
aircraftAfterModelApplied.setRendered(true); aircraftAfterModelApplied.setRendered(true);
emit modelMatchingCompleted(aircraftAfterModelApplied); emit modelMatchingCompleted(aircraftAfterModelApplied);
@@ -172,7 +173,7 @@ namespace BlackSimPlugin
// create AI // create AI
if (isSimulating()) if (isSimulating())
{ {
//! \todo if exists, recreate (new model?, new ICAO code) //! \todo FSX driver if exists, recreate (new model?, new ICAO code)
QByteArray m = aircraftModel.getModelString().toLocal8Bit(); QByteArray m = aircraftModel.getModelString().toLocal8Bit();
HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, m.constData(), qPrintable(callsign.toQString().left(12)), initialPosition, static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObj.getRequestId())); HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, m.constData(), qPrintable(callsign.toQString().left(12)), initialPosition, static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObj.getRequestId()));
if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); } if (hr != S_OK) { CLogMessage(this).error("SimConnect, can not create AI traffic"); }
@@ -832,6 +833,8 @@ namespace BlackSimPlugin
{ {
Q_CONSTEXPR int QueryInterval = 5 * 1000; // 5 seconds Q_CONSTEXPR int QueryInterval = 5 * 1000; // 5 seconds
m_timer->setInterval(QueryInterval); m_timer->setInterval(QueryInterval);
this->setObjectName("CSimulatorFsxListener");
this->m_timer->setObjectName(this->objectName().append(":m_timer"));
connect(m_timer, &QTimer::timeout, [this]() connect(m_timer, &QTimer::timeout, [this]()
{ {