From cf2967b9af680a4c40e66510f380ce542cff592d Mon Sep 17 00:00:00 2001 From: Aditya Mehra Date: Tue, 5 May 2020 17:23:41 +0530 Subject: [PATCH] Add Bigscreen plugin with support for Bigscreen STT packet type --- .../kdeconnectdeclarativeplugin.cpp | 2 + interfaces/CMakeLists.txt | 1 + interfaces/dbusinterfaces.cpp | 9 +++ interfaces/dbusinterfaces.h | 10 ++++ plugins/CMakeLists.txt | 1 + plugins/bigscreen/CMakeLists.txt | 7 +++ plugins/bigscreen/bigscreenplugin.cpp | 56 +++++++++++++++++++ plugins/bigscreen/bigscreenplugin.h | 48 ++++++++++++++++ plugins/bigscreen/kdeconnect_bigscreen.json | 28 ++++++++++ 9 files changed, 162 insertions(+) create mode 100644 plugins/bigscreen/CMakeLists.txt create mode 100644 plugins/bigscreen/bigscreenplugin.cpp create mode 100644 plugins/bigscreen/bigscreenplugin.h create mode 100644 plugins/bigscreen/kdeconnect_bigscreen.json diff --git a/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/declarativeplugin/kdeconnectdeclarativeplugin.cpp index 9dcd0fb4f..74f5104c4 100644 --- a/declarativeplugin/kdeconnectdeclarativeplugin.cpp +++ b/declarativeplugin/kdeconnectdeclarativeplugin.cpp @@ -65,6 +65,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri) qmlRegisterUncreatableType(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType(uri, 1, 0, "RemoteSystemVolumeInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); + qmlRegisterUncreatableType(uri, 1, 0, "BigscreenDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterSingletonType(uri, 1, 0, "DaemonDbusInterface", [](QQmlEngine*, QJSEngine*) -> QObject* { return new DaemonDbusInterface; @@ -89,6 +90,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri) registerFactory(uri, "RemoteCommandsDbusInterfaceFactory"); registerFactory(uri, "ShareDbusInterfaceFactory"); registerFactory(uri, "RemoteSystemVolumeDbusInterfaceFactory"); + registerFactory(uri, "BigscreenDbusInterfaceFactory"); } void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri) diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt index 6111deaee..389ca0290 100644 --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -38,6 +38,7 @@ geninterface(${PROJECT_SOURCE_DIR}/plugins/sms/smsplugin.h smsinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/sms/conversationsdbusinterface.h conversationsinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface) +geninterface(${PROJECT_SOURCE_DIR}/plugins/bigscreen/bigscreenplugin.h bigscreeninterface) add_library(kdeconnectinterfaces ${libkdeconnect_SRC}) set_target_properties(kdeconnectinterfaces PROPERTIES diff --git a/interfaces/dbusinterfaces.cpp b/interfaces/dbusinterfaces.cpp index 98f5b3854..3a520fb7d 100644 --- a/interfaces/dbusinterfaces.cpp +++ b/interfaces/dbusinterfaces.cpp @@ -199,3 +199,12 @@ RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString& OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), DBusHelper::sessionBus(), parent) { } + +BigscreenDbusInterface::BigscreenDbusInterface(const QString& deviceId, QObject* parent): + OrgKdeKdeconnectDeviceBigscreenInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/bigscreen"), DBusHelper::sessionBus(), parent) +{ +} + +BigscreenDbusInterface::~BigscreenDbusInterface() +{ +} diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index e7007f71c..dd332857d 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -39,6 +39,7 @@ #include "conversationsinterface.h" #include "shareinterface.h" #include "remotesystemvolumeinterface.h" +#include "bigscreeninterface.h" /** * Using these "proxy" classes just in case we need to rename the @@ -240,6 +241,15 @@ public: ~RemoteSystemVolumeDbusInterface() = default; }; +class KDECONNECTINTERFACES_EXPORT BigscreenDbusInterface + : public OrgKdeKdeconnectDeviceBigscreenInterface +{ + Q_OBJECT +public: + explicit BigscreenDbusInterface(const QString& deviceId, QObject* parent = nullptr); + ~BigscreenDbusInterface() override; +}; + template static void setWhenAvailable(const QDBusPendingReply& pending, W func, QObject* parent) { diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 884064554..175364d61 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(remotecontrol) add_subdirectory(remotesystemvolume) add_subdirectory(clipboard) add_subdirectory(runcommand) +add_subdirectory(bigscreen) if(NOT APPLE) add_subdirectory(presenter) diff --git a/plugins/bigscreen/CMakeLists.txt b/plugins/bigscreen/CMakeLists.txt new file mode 100644 index 000000000..713b68067 --- /dev/null +++ b/plugins/bigscreen/CMakeLists.txt @@ -0,0 +1,7 @@ +set(kdeconnect_bigscreen_SRCS + bigscreenplugin.cpp +) + +kdeconnect_add_plugin(kdeconnect_bigscreen JSON kdeconnect_bigscreen.json SOURCES ${kdeconnect_bigscreen_SRCS}) + +target_link_libraries(kdeconnect_bigscreen kdeconnectcore Qt5::DBus KF5::I18n) diff --git a/plugins/bigscreen/bigscreenplugin.cpp b/plugins/bigscreen/bigscreenplugin.cpp new file mode 100644 index 000000000..adce4cde2 --- /dev/null +++ b/plugins/bigscreen/bigscreenplugin.cpp @@ -0,0 +1,56 @@ +/** + * Copyright 2020 Aditya Mehra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "bigscreenplugin.h" + +#include +#include + +#include +#include +#include + +#include +#include + +K_PLUGIN_CLASS_WITH_JSON(BigscreenPlugin, "kdeconnect_bigscreen.json") + +Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BIGSCREEN, "kdeconnect.plugin.bigscreen") + +BigscreenPlugin::BigscreenPlugin(QObject* parent, const QVariantList& args) + : KdeConnectPlugin(parent, args) +{ +} + +BigscreenPlugin::~BigscreenPlugin() = default; + +bool BigscreenPlugin::receivePacket(const NetworkPacket& np) +{ + QString message = np.get(QStringLiteral("content")); + Q_EMIT messageReceived(message); + return true; +} + +QString BigscreenPlugin::dbusPath() const +{ + return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/bigscreen"); +} + +#include "bigscreenplugin.moc" diff --git a/plugins/bigscreen/bigscreenplugin.h b/plugins/bigscreen/bigscreenplugin.h new file mode 100644 index 000000000..c25c29cf4 --- /dev/null +++ b/plugins/bigscreen/bigscreenplugin.h @@ -0,0 +1,48 @@ +/** + * Copyright 2013 Albert Vaca + * Copyright 2020 Aditya Mehra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BIGSCREENPLUGIN_H +#define BIGSCREENPLUGIN_H + +#include + +#define PACKET_TYPE_BIGSCREEN_STT QStringLiteral("kdeconnect.bigscreen.stt") + +class Q_DECL_EXPORT BigscreenPlugin + : public KdeConnectPlugin +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.bigscreen") + +public: + explicit BigscreenPlugin(QObject* parent, const QVariantList& args); + ~BigscreenPlugin() override; + + bool receivePacket(const NetworkPacket& np) override; + void connected() override {}; + QString dbusPath() const override; + +Q_SIGNALS: + Q_SCRIPTABLE void messageReceived(const QString& message); + +}; + +#endif diff --git a/plugins/bigscreen/kdeconnect_bigscreen.json b/plugins/bigscreen/kdeconnect_bigscreen.json new file mode 100644 index 000000000..ff1d7efc9 --- /dev/null +++ b/plugins/bigscreen/kdeconnect_bigscreen.json @@ -0,0 +1,28 @@ +{ + "KPlugin": { + "Authors": [ + { + "Email": "aix.m@outlook.com", + "Name": "Aditya Mehra" + } + ], + "Description": "Bigscreen Plugin", + "EnabledByDefault": true, + "Icon": "dialog-ok", + "Id": "kdeconnect_bigscreen", + "License": "GPL", + "Name": "Bigscreen", + "ServiceTypes": [ + "KdeConnect/Plugin" + ], + "Version": "0.1", + "Website": "https://aiix.tk" + }, + "X-KdeConnect-OutgoingPacketType": [ + "kdeconnect.mousepad.request", + "kdeconnect.bigscreen.stt" + ], + "X-KdeConnect-SupportedPacketType": [ + "kdeconnect.bigscreen.stt" + ] +}