Debian Codegraph @

src/dbusextendedabstractinterface.h

raw symbols SCIP
1 // -*- c++ -*-
2
3 /*!
4 *
5 * Copyright (C) 2015 Jolla Ltd.
6 *
7 * Contact: Valerio Valerio <[email protected]>
8 * Author: Andres Gomez <[email protected]>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25
26 #ifndef DBUSEXTENDEDABSTRACTINTERFACE_H
27 #define DBUSEXTENDEDABSTRACTINTERFACE_H
28
29 #include <DBusExtended>
30
31 #include <QDBusAbstractInterface>
32 #include <QDBusError>
33
34 class QDBusPendingCallWatcher;
35 class DBusExtendedPendingCallWatcher;
36
37 class QT_DBUS_EXTENDED_EXPORT DBusExtendedAbstractInterface: public QDBusAbstractInterface
38 {
39 Q_OBJECT
40
41 public:
42 virtual ~DBusExtendedAbstractInterface();
43
44 Q_PROPERTY(bool sync READ sync WRITE setSync)
45 inline bool sync() const { return m_sync; }
46 inline void setSync(bool sync) { m_sync = sync; }
47
48 Q_PROPERTY(bool useCache READ useCache WRITE setUseCache)
49 inline bool useCache() const { return m_useCache; }
50 inline void setUseCache(bool useCache) { m_useCache = useCache; }
51
52 void getAllProperties();
53 inline QDBusError lastExtendedError() const { return m_lastExtendedError; };
54
55 protected:
56 DBusExtendedAbstractInterface(const QString &service,
57 const QString &path,
58 const char *interface,
59 const QDBusConnection &connection,
60 QObject *parent);
61
62 void connectNotify(const QMetaMethod &signal);
63 void disconnectNotify(const QMetaMethod &signal);
64 QVariant internalPropGet(const char *propname, void *propertyPtr);
65 void internalPropSet(const char *propname, const QVariant &value, void *propertyPtr);
66
67 Q_SIGNALS:
68 void propertyChanged(const QString &propertyName, const QVariant &value);
69 void propertyInvalidated(const QString &propertyName);
70 void asyncPropertyFinished(const QString &propertyName);
71 void asyncSetPropertyFinished(const QString &propertyName);
72 void asyncGetAllPropertiesFinished();
73
74 private Q_SLOTS:
75 void onPropertiesChanged(const QString& interfaceName,
76 const QVariantMap& changedProperties,
77 const QStringList& invalidatedProperties);
78 void onAsyncPropertyFinished(DBusExtendedPendingCallWatcher *watcher);
79 void onAsyncSetPropertyFinished(DBusExtendedPendingCallWatcher *watcher);
80 void onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher *watcher);
81
82 private:
83 QVariant asyncProperty(const QString &propertyName);
84 void asyncSetProperty(const QString &propertyName, const QVariant &value);
85 static QVariant demarshall(const QString &interface, const QMetaProperty &metaProperty, const QVariant &value, QDBusError *error);
86
87 bool m_sync;
88 bool m_useCache;
89 QDBusPendingCallWatcher *m_getAllPendingCallWatcher;
90 QDBusError m_lastExtendedError;
91 bool m_propertiesChangedConnected;
92 };
93
94 #endif /* DBUSEXTENDEDABSTRACTINTERFACE_H */