File indexing completed on 2024-12-22 04:33:56
0001 //SPDX-FileCopyrightText: 2015 Jolla Ltd. <valerio.valerio@jolla.com> 0002 //SPDX-FileContributor: Andres Gomez 0003 // 0004 //SPDX-License-Identifier: LGPL-2.1-or-later 0005 0006 0007 #ifndef DBUSEXTENDEDABSTRACTINTERFACE_H 0008 #define DBUSEXTENDEDABSTRACTINTERFACE_H 0009 0010 #include <dbusextended.h> 0011 0012 #include <QDBusMetaType> 0013 0014 #include <QDBusAbstractInterface> 0015 #include <QDBusError> 0016 0017 class QDBusPendingCallWatcher; 0018 class DBusExtendedPendingCallWatcher; 0019 0020 class DBusExtendedAbstractInterface: public QDBusAbstractInterface 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 virtual ~DBusExtendedAbstractInterface(); 0026 0027 Q_PROPERTY(bool sync READ sync WRITE setSync) 0028 inline bool sync() const { return m_sync; } 0029 inline void setSync(bool sync) { m_sync = sync; } 0030 0031 Q_PROPERTY(bool useCache READ useCache WRITE setUseCache) 0032 inline bool useCache() const { return m_useCache; } 0033 inline void setUseCache(bool useCache) { m_useCache = useCache; } 0034 0035 void getAllProperties(); 0036 inline QDBusError lastExtendedError() const { return m_lastExtendedError; }; 0037 0038 protected: 0039 DBusExtendedAbstractInterface(const QString &service, 0040 const QString &path, 0041 const char *interface, 0042 const QDBusConnection &connection, 0043 QObject *parent); 0044 0045 void connectNotify(const QMetaMethod &signal) override; 0046 void disconnectNotify(const QMetaMethod &signal) override; 0047 QVariant internalPropGet(const char *propname, void *propertyPtr); 0048 void internalPropSet(const char *propname, const QVariant &value, void *propertyPtr); 0049 0050 Q_SIGNALS: 0051 void propertyChanged(const QString &propertyName, const QVariant &value); 0052 void propertyInvalidated(const QString &propertyName); 0053 void asyncPropertyFinished(const QString &propertyName); 0054 void asyncSetPropertyFinished(const QString &propertyName); 0055 void asyncGetAllPropertiesFinished(); 0056 0057 private Q_SLOTS: 0058 void onPropertiesChanged(const QString& interfaceName, 0059 const QVariantMap& changedProperties, 0060 const QStringList& invalidatedProperties); 0061 void onAsyncPropertyFinished(DBusExtendedPendingCallWatcher *watcher); 0062 void onAsyncSetPropertyFinished(DBusExtendedPendingCallWatcher *watcher); 0063 void onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher *watcher); 0064 0065 private: 0066 QVariant asyncProperty(const QString &propertyName); 0067 void asyncSetProperty(const QString &propertyName, const QVariant &value); 0068 static QVariant demarshall(const QString &interface, const QMetaProperty &metaProperty, const QVariant &value, QDBusError *error); 0069 0070 bool m_sync; 0071 bool m_useCache; 0072 QDBusPendingCallWatcher *m_getAllPendingCallWatcher; 0073 QDBusError m_lastExtendedError; 0074 bool m_propertiesChangedConnected; 0075 }; 0076 0077 #endif /* DBUSEXTENDEDABSTRACTINTERFACE_H */