swift
contextapplication.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_CORE_CONTEXT_CONTEXTAPPLICATION_H
7 #define SWIFT_CORE_CONTEXT_CONTEXTAPPLICATION_H
8 
9 #include <QDBusArgument>
10 #include <QList>
11 #include <QMetaType>
12 #include <QString>
13 #include <QStringList>
14 #include <QtGlobal>
15 
16 #include "core/context/context.h"
17 #include "core/corefacadeconfig.h"
18 #include "core/swiftcoreexport.h"
19 #include "misc/dictionary.h"
20 #include "misc/identifier.h"
21 #include "misc/identifierlist.h"
22 #include "misc/statusmessage.h"
23 #include "misc/valuecache.h"
24 
25 // clazy:excludeall=const-signal-or-slot
26 
29 #define SWIFT_CORE_CONTEXTAPPLICATION_INTERFACENAME "org.swift_project.swift_core.contextapplication"
30 
33 #define SWIFT_CORE_CONTEXTAPPLICATION_OBJECTPATH "/application"
34 
35 class QDBusConnection;
36 namespace swift::misc
37 {
38  class CDBusServer;
39 }
40 namespace swift::core
41 {
42  class CCoreFacade;
43  class CInputManager;
44 
45  namespace context
46  {
49 
52  {
53  Q_OBJECT
54  Q_CLASSINFO("D-Bus Interface", SWIFT_CORE_CONTEXTAPPLICATION_INTERFACENAME)
55 
56  public:
58  static const QString &InterfaceName()
59  {
61  return s;
62  }
63 
65  static const QString &ObjectPath()
66  {
68  return s;
69  }
70 
72  QString getPathAndContextId() const override { return this->buildPathAndContextId(ObjectPath()); }
73 
76  swift::misc::CDBusServer *server, QDBusConnection &connection);
77 
79  ~IContextApplication() override = default;
80 
81  signals:
84 
88  const swift::misc::CIdentifier &origin);
89 
92  void hotkeyActionsRegistered(const QStringList &actions, const swift::misc::CIdentifier &origin);
93 
96  void remoteHotkeyAction(const QString &action, bool argument, const swift::misc::CIdentifier &origin);
97 
98  public slots:
102  virtual void changeSettings(const misc::CValueCachePacket &settings, const misc::CIdentifier &origin);
103 
106 
108  virtual QStringList getUnsavedSettingsKeys() const = 0;
109 
112 
114  virtual void synchronizeLocalSettings() = 0;
115 
117  virtual misc::CStatusMessage saveSettings(const QString &keyPrefix = {}) = 0;
118 
120  virtual misc::CStatusMessage saveSettingsByKey(const QStringList &keys) = 0;
121 
124 
128  virtual void registerHotkeyActions(const QStringList &actions, const misc::CIdentifier &origin);
129 
133  virtual void callHotkeyActionRemotely(const QString &action, bool argument,
134  const misc::CIdentifier &origin);
135 
137  virtual misc::CIdentifier registerApplication(const misc::CIdentifier &application) = 0;
138 
140  virtual void unregisterApplication(const misc::CIdentifier &application) = 0;
141 
144 
147 
149  bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator) override;
150 
151  protected:
152  static constexpr int PingIdentifiersMs = 20000;
153 
156  };
157  } // namespace context
158 } // namespace swift::core
159 
161 
162 #endif // SWIFT_CORE_CONTEXT_CONTEXTAPPLICATION_H
ContextMode
How to handle a given context.
The class providing facades (the contexts) for all DBus relevant operations.
Definition: corefacade.h:57
virtual void unregisterApplication(const misc::CIdentifier &application)=0
Unregister application.
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.
virtual CSettingsDictionary getUnsavedSettingsKeysDescribed() const =0
Get keys and descriptions of all unsaved settings currently in core settings cache.
static const QString & InterfaceName()
Service name.
QString getPathAndContextId() const
Id and path name for round trip protection.
virtual void synchronizeLocalSettings()=0
Update local settings with settings from core.
void registrationChanged()
A component changes.
virtual misc::CStatusMessage loadSettings()=0
Load core settings from disk.
virtual misc::CValueCachePacket getAllSettings() const =0
Get all settings currently in core settings cache.
void hotkeyActionsRegistered(const QStringList &actions, const swift::misc::CIdentifier &origin)
New action was registered.
virtual misc::CStatusMessage saveSettingsByKey(const QStringList &keys)=0
Save core settings to disk.
virtual misc::CIdentifier registerApplication(const misc::CIdentifier &application)=0
Register application, can also be used for ping.
void settingsChanged(const swift::misc::CValueCachePacket &settings, const swift::misc::CIdentifier &origin)
One or more settings were changed.
virtual misc::CStatusMessage saveSettings(const QString &keyPrefix={})=0
Save core settings to disk.
virtual misc::CIdentifier getApplicationIdentifier() const =0
Identifier of application, remote side if distributed.
virtual QStringList getUnsavedSettingsKeys() const =0
Get keys of all unsaved settings currently in core settings cache.
virtual misc::CIdentifierList getRegisteredApplications() const =0
All registered applications.
Base for all context classes.
Definition: context.h:34
Custom DBusServer.
Definition: dbusserver.h:34
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Value object encapsulating a list of object identifiers.
Streamable status message, e.g.
Value class used for signalling changed values in the cache.
Definition: valuecache.h:67
#define SWIFT_CORE_CONTEXTAPPLICATION_OBJECTPATH
DBus object path for context.
#define SWIFT_CORE_CONTEXTAPPLICATION_INTERFACENAME
DBus interface for context.
Backend services of the swift project, like dealing with the network or the simulators.
Definition: actionbind.cpp:7
Free functions in swift::misc.
#define SWIFT_CORE_EXPORT
Export a class or function from the library.