mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 07:05:38 +08:00
refs #316 Application context relays messages over DBus between the CLogHandler instances of different processes.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "blackcore/context_settings.h"
|
#include "blackcore/context_settings.h"
|
||||||
#include "blackcore/input_manager.h"
|
#include "blackcore/input_manager.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
|
#include "blackmisc/loghandler.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
@@ -34,6 +35,11 @@ namespace BlackCore
|
|||||||
IContextApplication::IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
IContextApplication::IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||||
CContext(mode, runtime)
|
CContext(mode, runtime)
|
||||||
{
|
{
|
||||||
|
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [this](const CStatusMessage &message)
|
||||||
|
{
|
||||||
|
this->logMessage(message, {});
|
||||||
|
});
|
||||||
|
|
||||||
changeSettings(IContextSettings::SettingsHotKeys);
|
changeSettings(IContextSettings::SettingsHotKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "blackcore/context.h"
|
#include "blackcore/context.h"
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include "blackmisc/eveventhotkeyfunction.h"
|
#include "blackmisc/eveventhotkeyfunction.h"
|
||||||
|
#include "blackmisc/evoriginator.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
@@ -86,7 +87,13 @@ namespace BlackCore
|
|||||||
//! A component changes
|
//! A component changes
|
||||||
void componentChanged(uint component, uint action);
|
void componentChanged(uint component, uint action);
|
||||||
|
|
||||||
|
//! A log message was logged
|
||||||
|
void messageLogged(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
//! Log a log message
|
||||||
|
//! \note Not pure because it can be called from the base class constructor.
|
||||||
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin) { Q_UNUSED(message); Q_UNUSED(origin); }
|
||||||
|
|
||||||
//! \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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "input_manager.h"
|
#include "input_manager.h"
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
|
#include "blackmisc/loghandler.h"
|
||||||
#include <QtMsgHandler>
|
#include <QtMsgHandler>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
@@ -22,6 +23,18 @@ namespace BlackCore
|
|||||||
IContextApplication(mode, runtime)
|
IContextApplication(mode, runtime)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Log a message
|
||||||
|
*/
|
||||||
|
void CContextApplication::logMessage(const CStatusMessage &message, const Event::COriginator &origin)
|
||||||
|
{
|
||||||
|
if (!origin.isFromSameProcess())
|
||||||
|
{
|
||||||
|
CLogHandler::instance()->logRemoteMessage(message);
|
||||||
|
}
|
||||||
|
emit this->messageLogged(message, origin);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ping, is DBus alive?
|
* Ping, is DBus alive?
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ namespace BlackCore
|
|||||||
friend class IContextApplication;
|
friend class IContextApplication;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
//! \copydoc IContextApplication::logMessage
|
||||||
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin) override;
|
||||||
|
|
||||||
//! \copydoc IContextApplication::ping()
|
//! \copydoc IContextApplication::ping()
|
||||||
virtual qint64 ping(qint64 token) const override;
|
virtual qint64 ping(qint64 token) const override;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "blackcore/context_application_proxy.h"
|
#include "blackcore/context_application_proxy.h"
|
||||||
#include "blackcore/input_manager.h"
|
#include "blackcore/input_manager.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blackmisc/loghandler.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
@@ -25,6 +26,14 @@ namespace BlackCore
|
|||||||
CInputManager *inputManager = CInputManager::getInstance();
|
CInputManager *inputManager = CInputManager::getInstance();
|
||||||
connect(inputManager, &CInputManager::hotkeyFuncEvent, this, &CContextApplicationProxy::processHotkeyFuncEvent);
|
connect(inputManager, &CInputManager::hotkeyFuncEvent, this, &CContextApplicationProxy::processHotkeyFuncEvent);
|
||||||
inputManager->setEventForwarding(true);
|
inputManager->setEventForwarding(true);
|
||||||
|
|
||||||
|
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage &message, const Event::COriginator &origin)
|
||||||
|
{
|
||||||
|
if (!origin.isFromSameProcess())
|
||||||
|
{
|
||||||
|
CLogHandler::instance()->logRemoteMessage(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -34,11 +43,22 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
// signals originating from impl side
|
// signals originating from impl side
|
||||||
bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
|
"messageLogged", this, SIGNAL(messageLogged(BlackMisc::CStatusMessage,BlackMisc::Event::COriginator)));
|
||||||
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
"componentChanged", this, SIGNAL(componentChanged(uint, uint)));
|
"componentChanged", this, SIGNAL(componentChanged(uint, uint)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Log a message
|
||||||
|
*/
|
||||||
|
void CContextApplicationProxy::logMessage(const CStatusMessage &message, const Event::COriginator &origin)
|
||||||
|
{
|
||||||
|
this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ping, is DBus alive?
|
* Ping, is DBus alive?
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ namespace BlackCore
|
|||||||
virtual ~CContextApplicationProxy() {}
|
virtual ~CContextApplicationProxy() {}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
//! \copydoc IContextApplication::logMessage
|
||||||
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::Event::COriginator &origin) override;
|
||||||
|
|
||||||
//! \copydoc IContextApplication::ping()
|
//! \copydoc IContextApplication::ping()
|
||||||
virtual qint64 ping(qint64 token) const override;
|
virtual qint64 ping(qint64 token) const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user