diff --git a/TelepathyQt/abstract-interface.cpp b/TelepathyQt/abstract-interface.cpp index bdaf677..0728d96 100644 --- a/TelepathyQt/abstract-interface.cpp +++ b/TelepathyQt/abstract-interface.cpp @@ -43,6 +43,7 @@ struct TP_QT_NO_EXPORT AbstractInterface::Private { QString mError; QString mMessage; + bool monitorProperties; }; /** @@ -60,6 +61,7 @@ AbstractInterface::AbstractInterface(const QString &busName, : QDBusAbstractInterface(busName, path, interface.latin1(), dbusConnection, parent), mPriv(new Private) { + mPriv->monitorProperties = false; } AbstractInterface::AbstractInterface(DBusProxy *parent, const QLatin1String &interface) @@ -133,4 +135,28 @@ PendingVariantMap *AbstractInterface::internalRequestAllProperties() const return new PendingVariantMap(pendingCall, DBusProxyPtr(proxy)); } +void AbstractInterface::setMonitorProperties(bool monitorProperties) +{ + if (monitorProperties == mPriv->monitorProperties) { + return; + } + + if (monitorProperties) { + connection().connect(service(), path(), TP_QT_IFACE_PROPERTIES, + QLatin1String("PropertiesChanged"), this, + SLOT(onPropertiesChanged(QString,QVariantMap,QStringList))); + } else { + connection().disconnect(service(), path(), TP_QT_IFACE_PROPERTIES, + QLatin1String("PropertiesChanged"), this, + SLOT(onPropertiesChanged(QString,QVariantMap,QStringList))); + } +} + +void AbstractInterface::onPropertiesChanged(const QString &interface, + const QMap &changedProperties, + const QStringList &invalidatedProperties) +{ + Q_EMIT propertiesChanged(changedProperties, invalidatedProperties); +} + } // Tp diff --git a/TelepathyQt/abstract-interface.h b/TelepathyQt/abstract-interface.h index 53205e0..d9ef9f3 100644 --- a/TelepathyQt/abstract-interface.h +++ b/TelepathyQt/abstract-interface.h @@ -51,6 +51,8 @@ public: QString invalidationReason() const; QString invalidationMessage() const; + void setMonitorProperties(bool monitorProperties); + protected Q_SLOTS: virtual void invalidate(Tp::DBusProxy *proxy, const QString &error, const QString &message); @@ -65,6 +67,15 @@ protected: PendingOperation *internalSetProperty(const QString &name, const QVariant &newValue); PendingVariantMap *internalRequestAllProperties() const; +private Q_SLOTS: + void onPropertiesChanged(const QString &interface, + const QMap &changedProperties, + const QStringList &invalidatedProperties); + +Q_SIGNALS: + void propertiesChanged(const QMap &changedProperties, + const QStringList &invalidatedProperties); + private: struct Private; friend struct Private;