Commit 5c86da54 authored by Billy Laws's avatar Billy Laws Committed by Nicolas Fella

Add QML support for shareplugin

Summary: This will allow it to be used in the plasmoid and QML app via dbus.

Reviewers: nicolasfella

Reviewed By: nicolasfella

Subscribers: kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D16551
parent bf03990b
......@@ -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<DevicesModel>(uri, 1, 0, "DevicesModel");
......@@ -103,6 +108,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
qmlRegisterUncreatableType<RemoteKeyboardDbusInterface>(uri, 1, 0, "RemoteKeyboardDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterSingletonType<DaemonDbusInterface>(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));
}
......@@ -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})
......
......@@ -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;
......@@ -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 <typename T, typename W>
static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment