refs #199, removed reEmitSignal for time being.

* Discussion: https://dev.vatsim-germany.org/issues/199#note-11
* Turned widgetGuiStarted / Terminated in more generic method
This commit is contained in:
Klaus Basan
2014-04-10 18:07:18 +02:00
parent 429f79f841
commit 4776b1e650
10 changed files with 44 additions and 64 deletions

View File

@@ -67,7 +67,8 @@ void MainWindow::gracefulShutdown()
{ {
if (!this->m_init) return; if (!this->m_init) return;
this->m_init = false; this->m_init = false;
if (this->m_rt->getIContextApplication()) emit this->m_rt->getIContextApplication()->widgetGuiTerminating(); if (this->m_rt->getIContextApplication())
emit this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops);
// close info window // close info window
if (this->m_infoWindow) if (this->m_infoWindow)

View File

@@ -220,7 +220,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
connect = this->connect(this->m_rt->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate); connect = this->connect(this->m_rt->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate);
Q_ASSERT(connect); Q_ASSERT(connect);
Q_UNUSED(connect); // suppress GCC warning in release build Q_UNUSED(connect); // suppress GCC warning in release build
// start timers, update timers will be started when network is connected // start timers, update timers will be started when network is connected
this->m_timerContextWatchdog->start(2 * 1000); this->m_timerContextWatchdog->start(2 * 1000);
@@ -241,7 +241,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
this->initContextMenus(); this->initContextMenus();
// starting // starting
emit this->m_rt->getIContextApplication()->widgetGuiStarting(); emit this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts);
// do this as last statement, so it can be used as flag // do this as last statement, so it can be used as flag
// whether init has been completed // whether init has been completed

View File

@@ -49,26 +49,6 @@ namespace BlackCore
return this->getRuntime()->getIContextSimulator(); return this->getRuntime()->getIContextSimulator();
} }
void CContext::reEmitSignalFromProxy(const QString &signalName)
{
if (signalName.isEmpty()) return;
if (this->usingLocalObjects())
{
// resent in implementation
QString sn = signalName;
if (!sn.endsWith("()")) sn.append("()");
const QMetaObject *metaObject = this->metaObject();
int signalId = metaObject->indexOfSignal(sn.toUtf8().constData());
Q_ASSERT(signalId >= 0);
void *a[] = { 0 };
QMetaObject::activate(this, signalId, a);
}
else
{
Q_ASSERT_X(false, "signalFromProxy", "Proxy needs to override method");
}
}
const IContextSimulator *CContext::getIContextSimulator() const const IContextSimulator *CContext::getIContextSimulator() const
{ {
return this->getRuntime()->getIContextSimulator(); return this->getRuntime()->getIContextSimulator();

View File

@@ -83,10 +83,6 @@ namespace BlackCore
QObject(parent), m_mode(mode), m_contextId(QDateTime::currentMSecsSinceEpoch()) QObject(parent), m_mode(mode), m_contextId(QDateTime::currentMSecsSinceEpoch())
{} {}
//! Re-emit signal locally
//! \details proxy uses slot to send signal, and on implementation side this re-emitted as signal
void reEmitSignalFromProxy(const QString &signalName);
CRuntimeConfig::ContextMode m_mode; //!< How context is used CRuntimeConfig::ContextMode m_mode; //!< How context is used
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
}; };

View File

@@ -30,7 +30,7 @@ namespace BlackCore
public: public:
//! What output to redirect //! What output to redirect
enum RedirectionLevel enum RedirectionLevel : uint
{ {
RedirectNone, RedirectNone,
RedirectAllOutput, RedirectAllOutput,
@@ -38,6 +38,20 @@ namespace BlackCore
RedirectError RedirectError
}; };
//! Components
enum Component : uint
{
ComponentGui,
ComponentCore
};
//! What a component does
enum Actions : uint
{
ActionStarts,
ActionStops
};
//! Service name //! Service name
static const QString &InterfaceName() static const QString &InterfaceName()
{ {
@@ -81,25 +95,22 @@ namespace BlackCore
//! never output redirected stream messages from the same context again //! never output redirected stream messages from the same context again
void redirectedOutput(const BlackMisc::CStatusMessage &message, qint64 contextId); void redirectedOutput(const BlackMisc::CStatusMessage &message, qint64 contextId);
//! Widget GUI is about to start //! A component changes
void widgetGuiStarting(); void componentChanged(uint component, uint action);
//! Widget GUI is about to terminate
void widgetGuiTerminating();
public slots: public slots:
//! \brief Ping a token, used to check if application is alive //! \brief Ping a token, used to check if application is alive
virtual qint64 ping(qint64 token) const = 0; virtual qint64 ping(qint64 token) const = 0;
//! \copydoc CContext::reEmitSignalFromProxy //! Status message
virtual void signalFromProxy(const QString &signalName) = 0;
//! \brief Status message
virtual void sendStatusMessage(const BlackMisc::CStatusMessage &message) = 0; virtual void sendStatusMessage(const BlackMisc::CStatusMessage &message) = 0;
//! Send status messages //! Send status messages
virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) = 0; virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) = 0;
//! A component has changed its state
virtual void notifyAboutComponentChange(uint component, uint action) = 0;
}; };
} }

View File

@@ -44,11 +44,11 @@ namespace BlackCore
} }
/* /*
* Re-emit signal * Component has changed
*/ */
void CContextApplication::signalFromProxy(const QString &signalName) void CContextApplication::notifyAboutComponentChange(uint component, uint action)
{ {
CContext::reEmitSignalFromProxy(signalName); this->componentChanged(component, action);
} }
} // namespace } // namespace

View File

@@ -33,8 +33,8 @@ namespace BlackCore
//! Send status messages //! Send status messages
virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) override; virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) override;
//! \copydoc CContext::reEmitSignalFromProxy //! \copydoc IContextApplication::notifyAboutComponentChange
virtual void signalFromProxy(const QString &signalName) override; virtual void notifyAboutComponentChange(uint component, uint action) override;
protected: protected:
//! Constructor //! Constructor

View File

@@ -33,13 +33,8 @@ namespace BlackCore
"statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList)));
connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"redirectedOutput", this, SIGNAL(redirectedOutput(BlackMisc::CStatusMessage, qint64))); "redirectedOutput", this, SIGNAL(redirectedOutput(BlackMisc::CStatusMessage, qint64)));
connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
// 1. No need to connect widgetGuiTerminating, only orginates from Proxy side / or is local "componentChanged", this, SIGNAL(componentChanged(uint, uint)));
// 2. No need to connect widgetGuiStarting
// signals originating from proxy side
connect(this, &CContextApplicationProxy::widgetGuiStarting, [this] { this->signalFromProxy("widgetGuiStarting");});
connect(this, &CContextApplicationProxy::widgetGuiTerminating, [this] { this->signalFromProxy("widgetGuiTerminating");});
} }
/* /*
@@ -51,14 +46,6 @@ namespace BlackCore
return t; return t;
} }
/*
* Signal from proxy
*/
void CContextApplicationProxy::signalFromProxy(const QString &signalName)
{
this->m_dBusInterface->callDBus(QLatin1Literal("signalFromProxy"), signalName);
}
/* /*
* Status messages * Status messages
*/ */
@@ -75,4 +62,12 @@ namespace BlackCore
this->m_dBusInterface->callDBus(QLatin1Literal("sendStatusMessages"), messages); this->m_dBusInterface->callDBus(QLatin1Literal("sendStatusMessages"), messages);
} }
/*
* Component has changed
*/
void CContextApplicationProxy::notifyAboutComponentChange(uint component, uint action)
{
this->m_dBusInterface->callDBus(QLatin1Literal("notifyAboutComponentChange"), component, action);
}
} // namespace } // namespace

View File

@@ -34,8 +34,8 @@ namespace BlackCore
//! Send status messages //! Send status messages
virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) override; virtual void sendStatusMessages(const BlackMisc::CStatusMessageList &messages) override;
//! \copydoc CContext::reEmitSignalFromProxy //! \copydoc IContextApplication::notifyAboutComponentChange
void signalFromProxy(const QString &signalName) override; virtual void notifyAboutComponentChange(uint component, uint action) override;
protected: protected:
//! Constructor //! Constructor

View File

@@ -72,11 +72,8 @@ namespace BlackCore
if (enabled) if (enabled)
{ {
QMetaObject::Connection con; QMetaObject::Connection con;
con = QObject::connect(this->getIContextApplication(), &IContextApplication::widgetGuiStarting, con = QObject::connect(this->getIContextApplication(), &IContextApplication::componentChanged,
[this]() { QStringList l; l << "widgetGuiStarting"; this->logSignal(this->getIContextApplication(), l);}); [this](uint component, uint action) { QStringList l; l << "componentChanged" << QString::number(component) << QString::number(action); this->logSignal(this->getIContextApplication(), l);});
this->m_logSignalConnections.insert("application", con);
con = QObject::connect(this->getIContextApplication(), &IContextApplication::widgetGuiTerminating,
[this]() { QStringList l; l << "widgetGuiTerminating"; this->logSignal(this->getIContextApplication(), l);});
this->m_logSignalConnections.insert("application", con); this->m_logSignalConnections.insert("application", con);
con = QObject::connect(this->getIContextApplication(), &IContextApplication::statusMessage, con = QObject::connect(this->getIContextApplication(), &IContextApplication::statusMessage,
[this](const BlackMisc::CStatusMessage & msg) { QStringList l; l << "statusMessage" << msg.toQString() ; this->logSignal(this->getIContextApplication(), l);}); [this](const BlackMisc::CStatusMessage & msg) { QStringList l; l << "statusMessage" << msg.toQString() ; this->logSignal(this->getIContextApplication(), l);});