Debian Codegraph @

include/util/ddbusextendedabstractinterface.h

raw
1 // SPDX-FileCopyrightText: 2015 Jolla Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4
5 #ifndef DBUSEXTENDEDABSTRACTINTERFACE_H
6 #define DBUSEXTENDEDABSTRACTINTERFACE_H
7 #include "dtkcore_global.h"
8
9 #include <QDBusAbstractInterface>
10 #include <QDBusError>
11 class QDBusPendingCallWatcher;
12 DCORE_BEGIN_NAMESPACE
13
14 class DDBusExtendedPendingCallWatcher;
15
16 class LIBDTKCORESHARED_EXPORT DDBusExtendedAbstractInterface : public QDBusAbstractInterface
17 {
18 Q_OBJECT
19
20 public:
21 virtual ~DDBusExtendedAbstractInterface();
22
23 Q_PROPERTY(bool sync READ sync WRITE setSync)
24 inline bool sync() const { return m_sync; }
25 void setSync(bool sync);
26 void setSync(bool sync, bool autoStart);
27
28 Q_PROPERTY(bool useCache READ useCache WRITE setUseCache)
29 inline bool useCache() const { return m_useCache; }
30 inline void setUseCache(bool useCache) { m_useCache = useCache; }
31
32 void getAllProperties();
33 inline QDBusError lastExtendedError() const { return m_lastExtendedError; }
34
35 public Q_SLOTS:
36 void startServiceProcess();
37
38 protected:
39 DDBusExtendedAbstractInterface(
40 const QString &service, const QString &path, const char *interface, const QDBusConnection &connection, QObject *parent);
41
42 void connectNotify(const QMetaMethod &signal);
43 void disconnectNotify(const QMetaMethod &signal);
44 QVariant internalPropGet(const char *propname, void *propertyPtr);
45 void internalPropSet(const char *propname, const QVariant &value, void *propertyPtr);
46
47 Q_SIGNALS:
48 void serviceValidChanged(const bool valid) const;
49 void serviceStartFinished(const quint32 ret) const;
50 void propertyChanged(const QString &propertyName, const QVariant &value);
51 void propertyInvalidated(const QString &propertyName);
52 void asyncPropertyFinished(const QString &propertyName);
53 void asyncSetPropertyFinished(const QString &propertyName);
54 void asyncGetAllPropertiesFinished();
55
56 private Q_SLOTS:
57 void onPropertiesChanged(const QString &interfaceName,
58 const QVariantMap &changedProperties,
59 const QStringList &invalidatedProperties);
60 void onDBusNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
61 void onAsyncPropertyFinished(QDBusPendingCallWatcher *w);
62 void onAsyncSetPropertyFinished(QDBusPendingCallWatcher *w);
63 void onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher *watcher);
64 void onStartServiceProcessFinished(QDBusPendingCallWatcher *w);
65
66 private:
67 QVariant asyncProperty(const QString &propertyName);
68 void asyncSetProperty(const QString &propertyName, const QVariant &value);
69 static QVariant
70 demarshall(const QString &interface, const QMetaProperty &metaProperty, const QVariant &value, QDBusError *error);
71
72 bool m_sync;
73 bool m_useCache;
74 QDBusPendingCallWatcher *m_getAllPendingCallWatcher;
75 QDBusError m_lastExtendedError;
76 QString m_dbusOwner;
77 bool m_propertiesChangedConnected;
78 };
79 DCORE_END_NAMESPACE
80
81 #endif /* DBUSEXTENDEDABSTRACTINTERFACE_H */