From a70bc1cb3803ead62be43b891a9960694478c026 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 16 Apr 2014 23:51:19 +0200 Subject: [PATCH] fixes as follow-up of meeting https://dev.vatsim-germany.org/boards/22/topics/1671 * asserts for relaySignals * relay "message" in connection status changed * bug in status message * bug in saving settings refs #198 refs #199 refs #207 refs #209 --- samples/blackgui/mainwindow.cpp | 2 +- samples/blackgui/mainwindow.h | 2 +- src/blackcore/context_application_proxy.cpp | 30 ++++++++++++----- src/blackcore/context_audio_proxy.cpp | 6 ++-- src/blackcore/context_network.h | 3 +- src/blackcore/context_network_impl.cpp | 5 +-- src/blackcore/context_network_impl.h | 2 +- src/blackcore/context_network_proxy.cpp | 36 +++++++++++++-------- src/blackcore/context_settings_impl.cpp | 2 +- src/blackcore/context_settings_proxy.cpp | 6 ++-- src/blackmisc/setnetwork.cpp | 1 + src/blackmisc/statusmessage.cpp | 10 ++++++ 12 files changed, 72 insertions(+), 33 deletions(-) diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index bf2c55a7f..7cfe236d4 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -299,7 +299,7 @@ void MainWindow::connectionTerminated() /* * Connection status changed */ -void MainWindow::connectionStatusChanged(uint /** from **/, uint to) +void MainWindow::connectionStatusChanged(uint /** from **/, uint to, const QString & /* message */) { this->updateGuiStatusInformation(); INetwork::ConnectionStatus newStatus = static_cast(to); diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 7080e50b3..0df7ff4b6 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -294,7 +294,7 @@ private slots: * \param from old status, as uint so it is compliant with DBus * \param to new status, as uint so it is compliant with DBus */ - void connectionStatusChanged(uint from, uint to); + void connectionStatusChanged(uint from, uint to, const QString &message); /*! * \brief Append text messages (received, to be sent) to GUI diff --git a/src/blackcore/context_application_proxy.cpp b/src/blackcore/context_application_proxy.cpp index 7de3aedd9..6a40f54eb 100644 --- a/src/blackcore/context_application_proxy.cpp +++ b/src/blackcore/context_application_proxy.cpp @@ -27,14 +27,19 @@ namespace BlackCore void CContextApplicationProxy::relaySignals(const QString &serviceName, QDBusConnection &connection) { // signals originating from impl side - connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), - "statusMessage", this, SIGNAL(statusMessage(BlackMisc::CStatusMessage))); - connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), - "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); - connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), - "redirectedOutput", this, SIGNAL(redirectedOutput(BlackMisc::CStatusMessage, qint64))); - connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), - "componentChanged", this, SIGNAL(componentChanged(uint, uint))); + bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), + "statusMessage", this, SIGNAL(statusMessage(BlackMisc::CStatusMessage))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), + "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), + "redirectedOutput", this, SIGNAL(redirectedOutput(BlackMisc::CStatusMessage, qint64))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), + "componentChanged", this, SIGNAL(componentChanged(uint, uint))); + Q_ASSERT(s); + } /* @@ -96,4 +101,13 @@ namespace BlackCore if (fileName.isEmpty()) return false; return this->m_dBusInterface->callDBusRet(QLatin1Literal("deleteFile"), fileName); } + + /* + * Check file + */ + bool CContextApplicationProxy::existsFile(const QString &fileName) + { + if (fileName.isEmpty()) return false; + return this->m_dBusInterface->callDBusRet(QLatin1Literal("existsFile"), fileName); + } } // namespace diff --git a/src/blackcore/context_audio_proxy.cpp b/src/blackcore/context_audio_proxy.cpp index 94f365c8c..4e1d6f4e2 100644 --- a/src/blackcore/context_audio_proxy.cpp +++ b/src/blackcore/context_audio_proxy.cpp @@ -29,8 +29,10 @@ namespace BlackCore */ void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection) { - connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), - "audioTestCompleted", this, SIGNAL(audioTestCompleted())); + bool s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), + "audioTestCompleted", this, SIGNAL(audioTestCompleted())); + Q_ASSERT(s); + Q_UNUSED(s); } /* diff --git a/src/blackcore/context_network.h b/src/blackcore/context_network.h index c1b2af6ad..3dbbd4500 100644 --- a/src/blackcore/context_network.h +++ b/src/blackcore/context_network.h @@ -65,10 +65,11 @@ namespace BlackCore * \brief Connection status changed * \param from old status * \param to new status + * \param message further details * \remarks If I use the enum, adaptor / interface are not created correctly * \see INetwork::ConnectionStatus */ - void connectionStatusChanged(uint from, uint to); + void connectionStatusChanged(uint from, uint to, const QString &message); //! Text messages received (also private chat messages, rfaio channel messages) void textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages); diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index 71086663a..42a57d80b 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -270,7 +270,7 @@ namespace BlackCore /* * Connection status changed */ - void CContextNetwork::psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to) + void CContextNetwork::psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message) { if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, QString::number(from), QString::number(to)); CStatusMessageList msgs; @@ -285,12 +285,13 @@ namespace BlackCore // send as message QString m("connection status changed from %1 to %2"); m = m.arg(INetwork::connectionStatusToString(from), INetwork::connectionStatusToString(to)); + if (!message.isEmpty()) m.append(" ").append(message); msgs.push_back(CStatusMessage(CStatusMessage::TypeTrafficNetwork, to == INetwork::DisconnectedError ? CStatusMessage::SeverityError : CStatusMessage::SeverityInfo, m)); if (this->getIContextApplication()) this->getIContextApplication()->sendStatusMessages(msgs); // send as own signal - emit this->connectionStatusChanged(from, to); + emit this->connectionStatusChanged(from, to, message); } /* diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index 57607abfc..6e578ef65 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -174,7 +174,7 @@ namespace BlackCore * \param from old status * \param to new status */ - void psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to); + void psFsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message); //! \brief ATC position update void psFsdAtcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range); diff --git a/src/blackcore/context_network_proxy.cpp b/src/blackcore/context_network_proxy.cpp index f240bf655..ad2306aac 100644 --- a/src/blackcore/context_network_proxy.cpp +++ b/src/blackcore/context_network_proxy.cpp @@ -28,20 +28,28 @@ namespace BlackCore */ void CContextNetworkProxy::relaySignals(const QString &serviceName, QDBusConnection &connection) { - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "connectionStatusChanged", this, SIGNAL(connectionStatusChanged(uint, uint))); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "changedAtcStationsBooked", this, SIGNAL(changedAtcStationsBooked())); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline())); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "connectionTerminated", this, SIGNAL(connectionTerminated())); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "statusMessage", this, SIGNAL(statusMessage(BlackMisc::CStatusMessage))); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); - connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), - "textMessagesReceived", this, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList))); + bool s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "connectionStatusChanged", this, SIGNAL(connectionStatusChanged(uint, uint, const QString &))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "changedAtcStationsBooked", this, SIGNAL(changedAtcStationsBooked())); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "changedAtcStationsOnline", this, SIGNAL(changedAtcStationsOnline())); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "connectionTerminated", this, SIGNAL(connectionTerminated())); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "statusMessage", this, SIGNAL(statusMessage(BlackMisc::CStatusMessage))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); + Q_ASSERT(s); + s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(), + "textMessagesReceived", this, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList))); + Q_ASSERT(s); + Q_UNUSED(s); } /* diff --git a/src/blackcore/context_settings_impl.cpp b/src/blackcore/context_settings_impl.cpp index 8e6e226f6..4b80304db 100644 --- a/src/blackcore/context_settings_impl.cpp +++ b/src/blackcore/context_settings_impl.cpp @@ -110,7 +110,7 @@ namespace BlackCore } /* - * Reset settings file + * Reset settings */ CStatusMessage CContextSettings::reset(bool write) { diff --git a/src/blackcore/context_settings_proxy.cpp b/src/blackcore/context_settings_proxy.cpp index 2666aec2e..e3e4f1103 100644 --- a/src/blackcore/context_settings_proxy.cpp +++ b/src/blackcore/context_settings_proxy.cpp @@ -35,8 +35,10 @@ namespace BlackCore */ void CContextSettingsProxy::relaySignals(const QString &serviceName, QDBusConnection &connection) { - connection.connect(serviceName, IContextSettings::ObjectPath(), IContextSettings::InterfaceName(), - "changedSettings", this, SIGNAL(changedSettings(uint))); + bool s = connection.connect(serviceName, IContextSettings::ObjectPath(), IContextSettings::InterfaceName(), + "changedSettings", this, SIGNAL(changedSettings(uint))); + Q_ASSERT(s); + Q_UNUSED(s); } /* diff --git a/src/blackmisc/setnetwork.cpp b/src/blackmisc/setnetwork.cpp index f551fa0cf..60881fe69 100644 --- a/src/blackmisc/setnetwork.cpp +++ b/src/blackmisc/setnetwork.cpp @@ -133,6 +133,7 @@ namespace BlackMisc */ void CSettingsNetwork::initDefaultValues() { + this->m_trafficNetworkServers.clear(); CServer currentServer(CServer("Testserver", "Client project testserver", "vatsim-germany.org", 6809, CUser("guest", "Guest Client project", "", "guest"))); this->setCurrentNetworkServer(currentServer); this->addTrafficNetworkServer(this->getCurrentTrafficNetworkServer()); diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index 6c5fe2989..585be90f3 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -124,6 +124,16 @@ namespace BlackMisc static QString t("settings"); return t; } + case TypeSimulator: + { + static QString t("simulator"); + return t; + } + case TypeStdoutRedirect: + { + static QString t("redirection"); + return t; + } case TypeTrafficNetwork: { static QString t("traffic network");