6#include <QDBusConnection>
7#include <QLatin1String>
20namespace swift::core::context
24 : IContextApplication(mode, runtime)
28 this->relaySignals(serviceName, connection);
31 &CContextApplicationProxy::processRemoteHotkeyActionCall);
33 m_pingTimer.setObjectName(serviceName +
"::m_pingTimer");
49 "hotkeyActionsRegistered",
this,
53 "remoteHotkeyAction",
this,
63 m_dBusInterface->callDBus(
QLatin1String(
"changeSettings"), settings, origin);
80 for (
auto it = result.begin(); it != result.end(); ++it)
83 if (it.value().isEmpty())
114 m_dBusInterface->callDBus(
QLatin1String(
"registerHotkeyActions"), actions, origin);
120 m_dBusInterface->callDBus(
QLatin1String(
"callHotkeyActionRemotely"), action, argument, origin);
125 m_proxyPingIdentifiers.insert(application);
126 if (m_pingTimer.isActive())
136 m_proxyPingIdentifiers.remove(application);
137 m_dBusInterface->callDBus(
QLatin1String(
"unregisterApplication"), application);
150 void CContextApplicationProxy::reRegisterApplications()
152 if (!m_dBusInterface)
156 if (m_proxyPingIdentifiers.
isEmpty())
175 static const QString dBusName(
"contexttest");
181 const bool ok = (
id == pingId);
188 msg =
"Mismatch in proxy ping, context not ready.";
194 void CContextApplicationProxy::processRemoteHotkeyActionCall(
const QString &action,
bool argument,
201 sApp->getInputManager()->callFunctionsBy(action, argument);
203 <<
"Calling function" << action <<
"from origin" << origin.
getMachineName();
ContextMode
How to handle a given context.
@ Remote
context runs in a different process.
The class providing facades (the contexts) for all DBus relevant operations.
void changeSettings(const swift::misc::CValueCachePacket &settings, const swift::misc::CIdentifier &origin)
Ratify some settings changed by another process.
CContextApplicationProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Constructor.
QStringList getUnsavedSettingsKeys() const
Get keys of all unsaved settings currently in core settings cache.
swift::misc::CIdentifier getApplicationIdentifier() const
Identifier of application, remote side if distributed.
swift::misc::CStatusMessage loadSettings()
Load core settings from disk.
swift::misc::CStatusMessage saveSettings(const QString &keyPrefix={})
Save core settings to disk.
void unregisterApplication(const swift::misc::CIdentifier &application)
Unregister application.
void synchronizeLocalSettings()
Update local settings with settings from core.
swift::core::context::CSettingsDictionary getUnsavedSettingsKeysDescribed() const
Get keys and descriptions of all unsaved settings currently in core settings cache.
swift::misc::CStatusMessage saveSettingsByKey(const QStringList &keys)
Save core settings to disk.
static bool isContextResponsive(const QString &dbusAddress, QString &msg, int timeoutMs=1500)
Used to test if there is a core running?
swift::misc::CIdentifier registerApplication(const swift::misc::CIdentifier &application)
Register application, can also be used for ping.
swift::misc::CIdentifierList getRegisteredApplications() const
All registered applications.
swift::misc::CValueCachePacket getAllSettings() const
Get all settings currently in core settings cache.
void registerHotkeyActions(const QStringList &actions, const swift::misc::CIdentifier &origin)
Register hotkey action implemented by another process.
void callHotkeyActionRemotely(const QString &action, bool argument, const swift::misc::CIdentifier &origin)
Call a hotkey action on a remote process.
void remoteHotkeyAction(const QString &action, bool argument, const swift::misc::CIdentifier &origin)
Call a hotkey action on a remote process.
static const QString & ObjectPath()
Service path.
void registrationChanged()
A component changes.
void hotkeyActionsRegistered(const QStringList &actions, const swift::misc::CIdentifier &origin)
New action was registered.
static constexpr int PingIdentifiersMs
how often identifiers are pinged
void settingsChanged(const swift::misc::CValueCachePacket &settings, const swift::misc::CIdentifier &origin)
One or more settings were changed.
static const QString & InterfaceName()
Service name.
void relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection, const QString &objectPath, const QString &interfaceName)
Relay signals from this class.
static void disconnectFromDBus(const QDBusConnection &connection, const QString &dBusAddress)
Disconnect from Bus/Peer to peer.
static QDBusConnection connectToDBus(const QString &dbusAddress, const QString &name={})
Connect to DBus.
static bool isDBusAvailable(const QString &host, int port, int timeoutMs=1500)
Is there a DBus server running at the given address?
static const QString & coreServiceName()
Default service name.
Used for hand written interface based on virtual methods.
Value object encapsulating information identifying a component of a modular distributed swift process...
const QString & getMachineName() const
Machine name.
bool isFromLocalMachine() const
Check if originating from the same local machine.
static const CIdentifier & null()
Null (empty) identifier.
Value object encapsulating a list of object identifiers.
static const QString & contextSlot()
Context slots.
Class for emitting a log message.
Derived & debug()
Set the severity to debug.
static CSettingsCache * instance()
Return the singleton instance.
Streamable status message, e.g.
void changeValuesFromRemote(const swift::misc::CValueCachePacket &values, const swift::misc::CIdentifier &originator)
Notify this cache that values have been changed by one of the duplicate caches in the multi-process e...
QString getHumanReadableName(const QString &key) const
Return the human readable name of the given key, or the raw key string if there is none.
Value class used for signalling changed values in the cache.
swift::misc::CDictionary< QString, QString, QMap > CSettingsDictionary
Value type for settings keys with descriptions.
Free functions in swift::misc.
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const