Add Bigscreen plugin with support for Bigscreen STT packet type

This commit is contained in:
Aditya Mehra 2020-05-05 17:23:41 +05:30 committed by Philip Cohn-Cort
parent e084ae451a
commit cf2967b9af
9 changed files with 162 additions and 0 deletions

View file

@ -65,6 +65,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
qmlRegisterUncreatableType<RemoteCommandsDbusInterface>(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType<RemoteCommandsDbusInterface>(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<RemoteSystemVolumeDbusInterface>(uri, 1, 0, "RemoteSystemVolumeInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType<RemoteSystemVolumeDbusInterface>(uri, 1, 0, "RemoteSystemVolumeInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<ShareDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces")); qmlRegisterUncreatableType<ShareDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterUncreatableType<BigscreenDbusInterface>(uri, 1, 0, "BigscreenDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface", qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface",
[](QQmlEngine*, QJSEngine*) -> QObject* { [](QQmlEngine*, QJSEngine*) -> QObject* {
return new DaemonDbusInterface; return new DaemonDbusInterface;
@ -89,6 +90,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
registerFactory<RemoteCommandsDbusInterface>(uri, "RemoteCommandsDbusInterfaceFactory"); registerFactory<RemoteCommandsDbusInterface>(uri, "RemoteCommandsDbusInterfaceFactory");
registerFactory<ShareDbusInterface>(uri, "ShareDbusInterfaceFactory"); registerFactory<ShareDbusInterface>(uri, "ShareDbusInterfaceFactory");
registerFactory<RemoteSystemVolumeDbusInterface>(uri, "RemoteSystemVolumeDbusInterfaceFactory"); registerFactory<RemoteSystemVolumeDbusInterface>(uri, "RemoteSystemVolumeDbusInterfaceFactory");
registerFactory<BigscreenDbusInterface>(uri, "BigscreenDbusInterfaceFactory");
} }
void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri) void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const char* uri)

View file

@ -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/sms/conversationsdbusinterface.h conversationsinterface)
geninterface(${PROJECT_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface)
geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface)
geninterface(${PROJECT_SOURCE_DIR}/plugins/bigscreen/bigscreenplugin.h bigscreeninterface)
add_library(kdeconnectinterfaces ${libkdeconnect_SRC}) add_library(kdeconnectinterfaces ${libkdeconnect_SRC})
set_target_properties(kdeconnectinterfaces PROPERTIES set_target_properties(kdeconnectinterfaces PROPERTIES

View file

@ -199,3 +199,12 @@ RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString&
OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), DBusHelper::sessionBus(), parent) 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()
{
}

View file

@ -39,6 +39,7 @@
#include "conversationsinterface.h" #include "conversationsinterface.h"
#include "shareinterface.h" #include "shareinterface.h"
#include "remotesystemvolumeinterface.h" #include "remotesystemvolumeinterface.h"
#include "bigscreeninterface.h"
/** /**
* Using these "proxy" classes just in case we need to rename the * Using these "proxy" classes just in case we need to rename the
@ -240,6 +241,15 @@ public:
~RemoteSystemVolumeDbusInterface() = default; ~RemoteSystemVolumeDbusInterface() = default;
}; };
class KDECONNECTINTERFACES_EXPORT BigscreenDbusInterface
: public OrgKdeKdeconnectDeviceBigscreenInterface
{
Q_OBJECT
public:
explicit BigscreenDbusInterface(const QString& deviceId, QObject* parent = nullptr);
~BigscreenDbusInterface() override;
};
template <typename T, typename W> template <typename T, typename W>
static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent) static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent)
{ {

View file

@ -9,6 +9,7 @@ add_subdirectory(remotecontrol)
add_subdirectory(remotesystemvolume) add_subdirectory(remotesystemvolume)
add_subdirectory(clipboard) add_subdirectory(clipboard)
add_subdirectory(runcommand) add_subdirectory(runcommand)
add_subdirectory(bigscreen)
if(NOT APPLE) if(NOT APPLE)
add_subdirectory(presenter) add_subdirectory(presenter)

View file

@ -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)

View file

@ -0,0 +1,56 @@
/**
* Copyright 2020 Aditya Mehra <aix.m@outlook.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#include "bigscreenplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
#include <QDebug>
#include <QDBusConnection>
#include <QLoggingCategory>
#include <core/device.h>
#include <core/daemon.h>
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<QString>(QStringLiteral("content"));
Q_EMIT messageReceived(message);
return true;
}
QString BigscreenPlugin::dbusPath() const
{
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/bigscreen");
}
#include "bigscreenplugin.moc"

View file

@ -0,0 +1,48 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
* Copyright 2020 Aditya Mehra <aix.m@outlook.com>
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef BIGSCREENPLUGIN_H
#define BIGSCREENPLUGIN_H
#include <core/kdeconnectplugin.h>
#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

View file

@ -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"
]
}