diff --git a/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/declarativeplugin/kdeconnectdeclarativeplugin.cpp index d42425cff..adacf1b5d 100644 --- a/declarativeplugin/kdeconnectdeclarativeplugin.cpp +++ b/declarativeplugin/kdeconnectdeclarativeplugin.cpp @@ -90,6 +90,11 @@ QObject* createRemoteCommandsInterface(const QVariant& deviceId) return new RemoteCommandsDbusInterface(deviceId.toString()); } +QObject* createShareInterface(const QVariant& deviceId) +{ + return new ShareDbusInterface(deviceId.toString()); +} + void KdeConnectDeclarativePlugin::registerTypes(const char* uri) { qmlRegisterType(uri, 1, 0, "DevicesModel"); @@ -103,6 +108,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri) qmlRegisterUncreatableType(uri, 1, 0, "RemoteKeyboardDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); + qmlRegisterUncreatableType(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterSingletonType(uri, 1, 0, "DaemonDbusInterface", [](QQmlEngine*, QJSEngine*) -> QObject* { return new DaemonDbusInterface; @@ -149,4 +155,7 @@ void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const cha engine->rootContext()->setContextProperty(QStringLiteral("RemoteCommandsDbusInterfaceFactory") , new ObjectFactory(engine, createRemoteCommandsInterface)); + + engine->rootContext()->setContextProperty(QStringLiteral("ShareDbusInterfaceFactory") + , new ObjectFactory(engine, createShareInterface)); } diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt index 7f7e00fd2..f15625029 100644 --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -50,6 +50,7 @@ geninterface(${CMAKE_SOURCE_DIR}/plugins/remotecommands/remotecommandsplugin.h r geninterface(${CMAKE_SOURCE_DIR}/plugins/remotekeyboard/remotekeyboardplugin.h remotekeyboardinterface) geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/smsplugin.h smsinterface) geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/conversationsdbusinterface.h conversationsinterface) +geninterface(${CMAKE_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface) add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC}) diff --git a/interfaces/dbusinterfaces.cpp b/interfaces/dbusinterfaces.cpp index c36861eff..c7cbf5688 100644 --- a/interfaces/dbusinterfaces.cpp +++ b/interfaces/dbusinterfaces.cpp @@ -182,3 +182,10 @@ SmsDbusInterface::SmsDbusInterface(const QString& deviceId, QObject* parent): } SmsDbusInterface::~SmsDbusInterface() = default; + +ShareDbusInterface::ShareDbusInterface(const QString& deviceId, QObject* parent): + OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/" + deviceId + "/share", QDBusConnection::sessionBus(), parent) +{ +} + +ShareDbusInterface::~ShareDbusInterface() = default; diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index f75ef7454..ebcff16f1 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -37,6 +37,7 @@ #include "interfaces/remotekeyboardinterface.h" #include "interfaces/smsinterface.h" #include "interfaces/conversationsinterface.h" +#include "interfaces/shareinterface.h" /** * Using these "proxy" classes just in case we need to rename the @@ -219,6 +220,15 @@ public: ~SmsDbusInterface() override; }; +class KDECONNECTINTERFACES_EXPORT ShareDbusInterface + : public OrgKdeKdeconnectDeviceShareInterface +{ + Q_OBJECT +public: + explicit ShareDbusInterface(const QString& deviceId, QObject* parent = nullptr); + ~ShareDbusInterface() override; +}; + template static void setWhenAvailable(const QDBusPendingReply& pending, W func, QObject* parent) {