diff --git a/interfaces/dbusinterfaces.cpp b/interfaces/dbusinterfaces.cpp index 141ef6495..6ee93bdb0 100644 --- a/interfaces/dbusinterfaces.cpp +++ b/interfaces/dbusinterfaces.cpp @@ -40,7 +40,7 @@ DaemonDbusInterface::~DaemonDbusInterface() DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent) : OrgKdeKdeconnectDeviceInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent) { - + connect(this, &OrgKdeKdeconnectDeviceInterface::pairingChanged, this, &DeviceDbusInterface::pairingChangedProxy); } DeviceDbusInterface::~DeviceDbusInterface() @@ -48,6 +48,12 @@ DeviceDbusInterface::~DeviceDbusInterface() } +void DeviceDbusInterface::pluginCall(const QString &plugin, const QString &method) +{ + QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id()+'/'+plugin, "org.kde.kdeconnect.device."+plugin, method); + QDBusConnection::sessionBus().asyncCall(msg); +} + DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent) : OrgKdeKdeconnectDeviceBatteryInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent) { diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index 8f49fe378..142da398e 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -47,9 +47,17 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface : public OrgKdeKdeconnectDeviceInterface { Q_OBJECT +// Workaround because OrgKdeKdeconnectDeviceInterface is not generating +// the signals for the properties + Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChangedProxy) public: DeviceDbusInterface(const QString& deviceId, QObject* parent = 0); virtual ~DeviceDbusInterface(); + + Q_SCRIPTABLE void pluginCall(const QString &plugin, const QString &method); + +Q_SIGNALS: + void pairingChangedProxy(bool paired); }; class KDECONNECTINTERFACES_EXPORT DeviceBatteryDbusInterface diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index dc61e1d0b..e3f26e1c9 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -276,8 +276,7 @@ void KdeConnectKcm::save() void KdeConnectKcm::sendPing() { if (!currentDevice) return; - QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+currentDevice->id()+"/ping", "org.kde.kdeconnect.device.ping", "sendPing"); - QDBusConnection::sessionBus().call(msg); + currentDevice->pluginCall("ping", "sendPing"); } QSize KdeConnectKcm::sizeHint() const