Merge branch 'master' into pairinghandler

This commit is contained in:
Vineet Garg 2015-07-27 21:00:05 +05:30
commit 06d8b3c54e
25 changed files with 607 additions and 23 deletions

View file

@ -29,6 +29,7 @@ ApplicationWindow
visible: true
width: 400
height: 500
title: i18n("KDE Connect")
toolBar: RowLayout {
Button {
@ -123,8 +124,18 @@ ApplicationWindow
} );
}
Button {
text: i18n("Remote touch and keyboard")
enabled: false
text: i18n("Mouse Pad")
onClicked: stack.push( {
item: "qrc:/qml/mousepad.qml",
properties: { remoteControlInterface: RemoteControlDbusInterfaceFactory.create(deviceView.currentDevice.id()) }
} );
}
Button {
property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id())
text: lockIface.isLocked ? i18n("Unlock") : i18n("Lock")
onClicked: {
lockIface.isLocked = !lockIface.isLocked;
}
}
Item { Layout.fillHeight: true }

64
app/qml/mousepad.qml Normal file
View file

@ -0,0 +1,64 @@
/*
* Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
ColumnLayout
{
id: mousepad
property QtObject remoteControlInterface
MouseArea {
id: area
Layout.fillWidth: true
Layout.fillHeight: true
property var lastPos: Qt.point(-1, -1)
onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true);
onPositionChanged: {
if (lastPos.x > -1) {
// console.log("move", mouse.x, mouse.y, lastPos)
var delta = Qt.point(mouse.x-lastPos.x, mouse.y-lastPos.y);
remoteControlInterface.moveCursor(delta);
}
lastPos = Qt.point(mouse.x, mouse.y);
}
}
RowLayout {
Layout.fillWidth: true
Button {
Layout.fillWidth: true
onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true);
}
Button {
Layout.fillWidth: true
onClicked: mousepad.remoteControlInterface.sendCommand("middleclick", true);
}
Button {
Layout.fillWidth: true
onClicked: mousepad.remoteControlInterface.sendCommand("rightclick", true);
}
}
}

View file

@ -20,7 +20,7 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
import QtQuick.Layouts 1.1
ColumnLayout
{
@ -41,27 +41,27 @@ ColumnLayout
Layout.fillWidth: true
text: root.mprisInterface.nowPlaying
}
Button {
Layout.fillWidth: true
text: root.mprisInterface.isPlaying ? "pause" : "play"
onClicked: root.mprisInterface.sendAction("PlayPause");
}
RowLayout {
Layout.fillWidth: true
Button {
Layout.fillWidth: true
text: "<<"
iconName: "media-skip-backward"
onClicked: root.mprisInterface.sendAction("Previous")
}
Button {
Layout.fillWidth: true
text: ">>"
iconName: root.mprisInterface.isPlaying ? "media-playback-pause" : "media-playback-start"
onClicked: root.mprisInterface.sendAction("PlayPause");
}
Button {
Layout.fillWidth: true
iconName: "media-skip-forward"
onClicked: root.mprisInterface.sendAction("Next")
}
}
RowLayout {
Layout.fillWidth: true
Label { text: "x" }
Label { text: i18n("Volume:") }
Slider {
value: root.mprisInterface.volume
maximumValue: 100

View file

@ -3,5 +3,6 @@
<file>qml/main.qml</file>
<file>qml/DeviceDelegate.qml</file>
<file>qml/mpris.qml</file>
<file>qml/mousepad.qml</file>
</qresource>
</RCC>

View file

@ -56,6 +56,7 @@ int main(int argc, char** argv)
parser.addOption(QCommandLineOption("ping-msg", i18n("Same as ping but you can set the message to display"), i18n("message")));
parser.addOption(QCommandLineOption("share", i18n("Share a file to a said device"), "path"));
parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device")));
parser.addOption(QCommandLineOption("lock", i18n("Lock the specified device")));
parser.addOption(QCommandLineOption(QStringList("device") << "d", i18n("Device ID"), "dev"));
parser.addOption(QCommandLineOption("encryption-info", i18n("Get encryption info about said device")));
about.setupCommandLine(&parser);

View file

@ -10,6 +10,7 @@ function(geninterface source_h output_h)
get_filename_component(basename ${output_h} NAME_WE)
qt5_add_dbus_interface(libkdeconnect_SRC ${xml_file} ${basename})
set(libkdeconnect_SRC ${libkdeconnect_SRC} PARENT_SCOPE)
set(libkdeconnect_HEADERS ${libkdeconnect_HEADERS} PARENT_SCOPE)
endfunction()
set(libkdeconnect_SRC
@ -32,14 +33,15 @@ set(libkdeconnect_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/kdeconnectinterfaces_export.h
)
geninterface(${CMAKE_SOURCE_DIR}/core/daemon.h daemoninterface.h)
geninterface(${CMAKE_SOURCE_DIR}/core/device.h deviceinterface.h)
geninterface(${CMAKE_SOURCE_DIR}/plugins/battery/batterydbusinterface.h devicebatteryinterface.h)
geninterface(${CMAKE_SOURCE_DIR}/plugins/sftp/sftpplugin.h devicesftpinterface.h)
geninterface(${CMAKE_SOURCE_DIR}/plugins/notifications/notificationsdbusinterface.h devicenotificationsinterface.h)
geninterface(${CMAKE_SOURCE_DIR}/plugins/notifications/notification.h notificationinterface.h)
geninterface(${CMAKE_SOURCE_DIR}/core/daemon.h daemoninterface)
geninterface(${CMAKE_SOURCE_DIR}/core/device.h deviceinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/battery/batterydbusinterface.h devicebatteryinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/sftp/sftpplugin.h devicesftpinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/notifications/notificationsdbusinterface.h devicenotificationsinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/notifications/notification.h notificationinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/mprisremote/mprisremoteplugin.h mprisremoteinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/remotecontrol/remotecontrolplugin.h remotecontrolinterface)
geninterface(${CMAKE_SOURCE_DIR}/plugins/lockdevice/lockdeviceplugin.h lockdeviceinterface)
add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC})
set_target_properties(kdeconnectinterfaces PROPERTIES

View file

@ -113,3 +113,25 @@ MprisDbusInterface::MprisDbusInterface(const QString& id, QObject* parent)
MprisDbusInterface::~MprisDbusInterface()
{
}
RemoteControlDbusInterface::RemoteControlDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/" + id + "/remotecontrol", QDBusConnection::sessionBus(), parent)
{
}
RemoteControlDbusInterface::~RemoteControlDbusInterface()
{
}
LockDeviceDbusInterface::LockDeviceDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/" + id + "/lockdevice", QDBusConnection::sessionBus(), parent)
{
connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy);
Q_ASSERT(isValid());
}
LockDeviceDbusInterface::~LockDeviceDbusInterface()
{
}
#include "dbusinterfaces.moc"

View file

@ -30,6 +30,8 @@
#include "interfaces/devicenotificationsinterface.h"
#include "interfaces/notificationinterface.h"
#include "interfaces/mprisremoteinterface.h"
#include "interfaces/remotecontrolinterface.h"
#include "interfaces/lockdeviceinterface.h"
/**
* Using these "proxy" classes just in case we need to rename the
@ -124,4 +126,26 @@ Q_SIGNALS:
void propertiesChangedProxy();
};
class KDECONNECTINTERFACES_EXPORT RemoteControlDbusInterface
: public OrgKdeKdeconnectDeviceRemotecontrolInterface
{
Q_OBJECT
public:
RemoteControlDbusInterface(const QString& deviceId, QObject* parent = 0);
~RemoteControlDbusInterface() override;
};
class KDECONNECTINTERFACES_EXPORT LockDeviceDbusInterface
: public OrgKdeKdeconnectDeviceLockdeviceInterface
{
Q_OBJECT
Q_PROPERTY(bool isLocked READ isLocked WRITE setIsLocked NOTIFY lockedChangedProxy)
public:
LockDeviceDbusInterface(const QString& deviceId, QObject* parent = 0);
virtual ~LockDeviceDbusInterface();
Q_SIGNALS:
void lockedChangedProxy(bool isLocked);
};
#endif

View file

@ -75,7 +75,7 @@ X-KDE-Keywords[nl]=Netwerk,Android,Apparaten
X-KDE-Keywords[pl]=Sieć,Android,Urządzenia
X-KDE-Keywords[pt]=Rede,Android,Dispositivos
X-KDE-Keywords[pt_BR]=Rede,Android,Dispositivos
X-KDE-Keywords[ru]=Network,Android,Devices,сеть,Андроид, устройства
X-KDE-Keywords[ru]=Network,Android,Devices,сеть,Андроид,устройства
X-KDE-Keywords[sk]=Sieť,Android,Zariadenia
X-KDE-Keywords[sv]=Nätverk, Android, apparater
X-KDE-Keywords[tr]=Ağ,Android,Cihazlar,Aygıtlar

View file

@ -49,11 +49,22 @@ QObject* createSftpInterface(QVariant deviceId)
return new SftpDbusInterface(deviceId.toString());
}
QObject* createRemoteControlInterface(QVariant deviceId)
{
return new RemoteControlDbusInterface(deviceId.toString());
}
QObject* createMprisInterface(QVariant deviceId)
{
return new MprisDbusInterface(deviceId.toString());
}
QObject* createDeviceLockInterface(QVariant deviceId)
{
Q_ASSERT(!deviceId.toString().isEmpty());
return new LockDeviceDbusInterface(deviceId.toString());
}
QObject* createDBusResponse()
{
return new DBusAsyncResponse();
@ -67,6 +78,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
qmlRegisterType<ProcessRunner>(uri, 1, 0, "ProcessRunner");
qmlRegisterType<DevicesSortProxyModel>(uri, 1, 0, "DevicesSortProxyModel");
qmlRegisterUncreatableType<MprisDbusInterface>(uri, 1, 0, "MprisDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
qmlRegisterUncreatableType<LockDeviceDbusInterface>(uri, 1, 0, "LockDeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfacess"));
}
@ -85,6 +97,12 @@ void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const cha
engine->rootContext()->setContextProperty("MprisDbusInterfaceFactory"
, new ObjectFactory(engine, createMprisInterface));
engine->rootContext()->setContextProperty("RemoteControlDbusInterfaceFactory"
, new ObjectFactory(engine, createRemoteControlInterface));
engine->rootContext()->setContextProperty("LockDeviceDbusInterfaceFactory"
, new ObjectFactory(engine, createDeviceLockInterface));
engine->rootContext()->setContextProperty("DBusResponseFactory"
, new ObjectFactory(engine, createDBusResponse));

View file

@ -16,6 +16,8 @@ add_subdirectory(screensaver-inhibit)
if(EXPERIMENTALAPP_ENABLED)
add_subdirectory(mprisremote)
add_subdirectory(remotecontrol)
add_subdirectory(lockdevice)
endif()
#FIXME: If we split notifications in several files, they won't appear in the same group in the Notifications KCM

View file

@ -45,6 +45,7 @@
"Name[pl]": "Monitor baterii",
"Name[pt]": "Monitor da bateria",
"Name[pt_BR]": "Monitor de bateria",
"Name[ru]": "Индикатор батареи",
"Name[sk]": "Monitor batérie",
"Name[sv]": "Batteriövervakare",
"Name[tr]": "Pil izleyici",

View file

@ -45,6 +45,7 @@
"Name[pl]": "Schowek",
"Name[pt]": "Área de Transferência",
"Name[pt_BR]": "Área de transferência",
"Name[ru]": "Буфер обмена",
"Name[sk]": "Schránka",
"Name[sv]": "Klippbord",
"Name[tr]": "Geçici taşıma panosu",

View file

@ -0,0 +1,9 @@
qt5_add_dbus_interface(lockdevice_SRCS org.freedesktop.ScreenSaver.xml screensaverdbusinterface)
kdeconnect_add_plugin(kdeconnect_lockdevice JSON kdeconnect_lockdevice.json SOURCES lockdeviceplugin.cpp ${lockdevice_SRCS})
target_link_libraries(kdeconnect_lockdevice
kdeconnectcore
Qt5::DBus
KF5::I18n
)

View file

@ -0,0 +1,48 @@
{
"Encoding": "UTF-8",
"KPlugin": {
"Authors": [
{
"Email": "aleixpol@kde.org",
"Name": "Aleix Pol"
}
],
"Description": "Locks your systems",
"Description[ca]": "Bloqueja els vostres sistemes",
"Description[de]": "Sperrt Ihre Systeme",
"Description[gl]": "Bloquea os seus sistemas.",
"Description[nl]": "Vergrendeld uw systemen",
"Description[pl]": "Zablokuj swoje systemy",
"Description[pt]": "Bloqueia os seus sistemas",
"Description[pt_BR]": "Bloqueia seus sistemas",
"Description[sv]": "Låser dina system",
"Description[uk]": "Блокує вашу систему",
"Description[x-test]": "xxLocks your systemsxx",
"EnabledByDefault": true,
"Icon": "applications-miscelaneaous",
"Id": "kdeconnect_lockdevice",
"License": "GPL",
"Name": "LockDevice",
"Name[ca]": "Bloqueja el dispositiu",
"Name[de]": "Gerätesperrung",
"Name[gl]": "Bloqueo do dispositivo",
"Name[nl]": "Apparaat vergrendelen",
"Name[pl]": "ZablokujUrządzenie",
"Name[pt]": "Bloqueio de Dispositivo",
"Name[pt_BR]": "Bloqueio de dispositivo",
"Name[sv]": "Lås enhet",
"Name[uk]": "LockDevice",
"Name[x-test]": "xxLockDevicexx",
"ServiceTypes": [
"KdeConnect/Plugin"
],
"Version": "0.1",
"Website": "https://kde.org"
},
"X-KdeConnect-OutgoingPackageType": [
"kdeconnect.lock"
],
"X-KdeConnect-SupportedPackageType": [
"kdeconnect.lock"
]
}

View file

@ -0,0 +1,108 @@
/**
* Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "lockdeviceplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
#include <QDebug>
#include <QDBusConnection>
#include <QLoggingCategory>
#include "screensaverdbusinterface.h"
#include <core/device.h>
K_PLUGIN_FACTORY_WITH_JSON( KdeConnectLockPluginFactory, "kdeconnect_lockdevice.json", registerPlugin<LockDevicePlugin>(); )
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_LOCKREMOTE, "kdeconnect.plugin.lock")
LockDevicePlugin::LockDevicePlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
, m_remoteLocked(false)
, m_iface(nullptr)
{
}
LockDevicePlugin::~LockDevicePlugin()
{
delete m_iface;
}
bool LockDevicePlugin::isLocked() const
{
return m_remoteLocked;
}
void LockDevicePlugin::setLocked(bool locked)
{
NetworkPackage np(PACKAGE_TYPE_LOCK);
np.set("setLocked", locked);
sendPackage(np);
}
bool LockDevicePlugin::receivePackage(const NetworkPackage & np)
{
if (np.has("isLocked")) {
bool locked = np.get<bool>("isLocked");
if (m_remoteLocked != locked) {
m_remoteLocked = locked;
Q_EMIT lockedChanged(locked);
}
}
bool sendState = np.has("requestLocked");
if (np.has("setLocked")) {
iface()->SetActive(np.get<bool>("setLocked"));
sendState = true;
}
if (sendState) {
NetworkPackage np(PACKAGE_TYPE_LOCK);
np.set("isLocked", iface()->GetActive());
sendPackage(np);
}
return true;
}
OrgFreedesktopScreenSaverInterface* LockDevicePlugin::iface()
{
if (!m_iface) {
m_iface = new OrgFreedesktopScreenSaverInterface("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", QDBusConnection::sessionBus());
if(!m_iface->isValid())
qCWarning(KDECONNECT_PLUGIN_LOCKREMOTE) << "Couldn't connect to the ScreenSaver interface";
}
return m_iface;
}
void LockDevicePlugin::connected()
{
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
NetworkPackage np(PACKAGE_TYPE_LOCK);
np.set("requestLocked", QVariant());
sendPackage(np);
}
QString LockDevicePlugin::dbusPath() const
{
return "/modules/kdeconnect/devices/" + device()->id() + "/lockdevice";
}
#include "lockdeviceplugin.moc"

View file

@ -0,0 +1,61 @@
/**
* Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LOCKDEVICEPLUGIN_H
#define LOCKDEVICEPLUGIN_H
#include <QObject>
#include <core/kdeconnectplugin.h>
class OrgFreedesktopScreenSaverInterface;
#define PACKAGE_TYPE_LOCK QLatin1String("kdeconnect.lock")
class Q_DECL_EXPORT LockDevicePlugin
: public KdeConnectPlugin
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.lockdevice")
Q_PROPERTY(bool isLocked READ isLocked WRITE setLocked NOTIFY lockedChanged)
public:
explicit LockDevicePlugin(QObject *parent, const QVariantList &args);
virtual ~LockDevicePlugin();
bool isLocked() const;
void setLocked(bool b);
void connected() override;
bool receivePackage(const NetworkPackage & np) override;
Q_SIGNALS:
void lockedChanged(bool locked);
private:
QString dbusPath() const;
bool m_remoteLocked;
OrgFreedesktopScreenSaverInterface* iface();
OrgFreedesktopScreenSaverInterface* m_iface;
};
#endif

View file

@ -0,0 +1,41 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.ScreenSaver">
<signal name="ActiveChanged">
<arg type="b"/>
</signal>
<method name="Lock">
</method>
<method name="SimulateUserActivity">
</method>
<method name="GetActive">
<arg type="b" direction="out"/>
</method>
<method name="GetActiveTime">
<arg name="seconds" type="u" direction="out"/>
</method>
<method name="GetSessionIdleTime">
<arg name="seconds" type="u" direction="out"/>
</method>
<method name="SetActive">
<arg type="b" direction="out"/>
<arg name="e" type="b" direction="in"/>
</method>
<method name="Inhibit">
<arg name="application_name" type="s" direction="in"/>
<arg name="reason_for_inhibit" type="s" direction="in"/>
<arg name="cookie" type="u" direction="out"/>
</method>
<method name="UnInhibit">
<arg name="cookie" type="u" direction="in"/>
</method>
<method name="Throttle">
<arg name="application_name" type="s" direction="in"/>
<arg name="reason_for_inhibit" type="s" direction="in"/>
<arg name="cookie" type="u" direction="out"/>
</method>
<method name="UnThrottle">
<arg name="cookie" type="u" direction="in"/>
</method>
</interface>
</node>

View file

@ -6,7 +6,7 @@ find_package(XTest REQUIRED)
find_package(X11 REQUIRED)
find_package(LibFakeKey REQUIRED)
find_package(Qt5X11Extras REQUIRED)
find_package(KF5Wayland)
find_package(KF5Wayland 5.3.90)
set(HAVE_WAYLAND ${KF5Wayland_FOUND})
configure_file(config-mousepad.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-mousepad.h )

View file

@ -56,9 +56,7 @@
],
"Version": "0.1"
},
"X-KdeConnect-OutgoingPackageType": [
"kdeconnect.mousepad"
],
"X-KdeConnect-OutgoingPackageType": [],
"X-KdeConnect-SupportedPackageType": [
"kdeconnect.mousepad"
]

View file

@ -42,6 +42,7 @@
"Name[pl]": "Powiadomienia synchronizacji",
"Name[pt]": "Sincronização de notificações",
"Name[pt_BR]": "Sincronização de notificações",
"Name[ru]": "Синхронизация уведомлений",
"Name[sk]": "Synchronizácia pripomienok",
"Name[sv]": "Underrättelsesynkronisering",
"Name[tr]": "Bildirim eşitleme",

View file

@ -0,0 +1,7 @@
kdeconnect_add_plugin(kdeconnect_remotecontrol JSON kdeconnect_remotecontrol.json SOURCES remotecontrolplugin.cpp)
target_link_libraries(kdeconnect_remotecontrol
kdeconnectcore
Qt5::DBus
KF5::I18n
)

View file

@ -0,0 +1,44 @@
{
"Encoding": "UTF-8",
"KPlugin": {
"Authors": [
{
"Email": "aleixpol@kde.org",
"Name": "Aleix Pol"
}
],
"Description": "Control Remote systems",
"Description[ca]": "Sistemes de control remot",
"Description[gl]": "Controla sistemas remotos.",
"Description[nl]": "Systemen op afstand bedienen",
"Description[pl]": "Sterowanie zdalnymi systemami",
"Description[pt]": "Comandar sistemas à distância",
"Description[pt_BR]": "Controle remoto de sistemas",
"Description[sv]": "Styr fjärrsystem",
"Description[uk]": "Системи віддаленого керування",
"Description[x-test]": "xxControl Remote systemsxx",
"EnabledByDefault": true,
"Icon": "applications-multimedia",
"Id": "kdeconnect_remotecontrol",
"License": "GPL",
"Name": "RemoteControl",
"Name[ca]": "Control remot",
"Name[gl]": "Mando a distancia",
"Name[nl]": "Afstandsbediening",
"Name[pl]": "ZdalneSterowanie",
"Name[pt]": "Comando à Distância",
"Name[pt_BR]": "Controle remoto",
"Name[sv]": "Fjärrkontroll",
"Name[uk]": "RemoteControl",
"Name[x-test]": "xxRemoteControlxx",
"ServiceTypes": [
"KdeConnect/Plugin"
],
"Version": "0.1",
"Website": "https://kde.org"
},
"X-KdeConnect-OutgoingPackageType": [
"kdeconnect.mousepad"
],
"X-KdeConnect-SupportedPackageType": []
}

View file

@ -0,0 +1,70 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.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 <http://www.gnu.org/licenses/>.
*/
#include "remotecontrolplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
#include <QDebug>
#include <QDBusConnection>
#include <QPoint>
#include <QLoggingCategory>
#include <core/device.h>
K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_remotecontrol.json", registerPlugin< RemoteControlPlugin >(); )
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_REMOTECONTROL, "kdeconnect.plugin.remotecontrol")
RemoteControlPlugin::RemoteControlPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
}
RemoteControlPlugin::~RemoteControlPlugin()
{}
void RemoteControlPlugin::moveCursor(const QPoint &p)
{
NetworkPackage np(PACKAGE_TYPE_MOUSEPAD);
np.set("dx", p.x());
np.set("dy", p.y());
sendPackage(np);
}
void RemoteControlPlugin::sendCommand(const QString &name, bool val)
{
NetworkPackage np(PACKAGE_TYPE_MOUSEPAD);
np.set(name, val);
sendPackage(np);
}
void RemoteControlPlugin::connected()
{
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
}
QString RemoteControlPlugin::dbusPath() const
{
return "/modules/kdeconnect/devices/" + device()->id() + "/remotecontrol";
}
#include "remotecontrolplugin.moc"

View file

@ -0,0 +1,50 @@
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.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 <http://www.gnu.org/licenses/>.
*/
#ifndef MPRISREMOTEPLUGIN_H
#define MPRISREMOTEPLUGIN_H
#include <QObject>
#include <core/kdeconnectplugin.h>
#define PACKAGE_TYPE_MOUSEPAD QLatin1String("kdeconnect.mousepad")
class Q_DECL_EXPORT RemoteControlPlugin
: public KdeConnectPlugin
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.remotecontrol")
public:
explicit RemoteControlPlugin(QObject *parent, const QVariantList &args);
~RemoteControlPlugin() override;
bool receivePackage(const NetworkPackage& /*np*/) override { return false; }
void connected() override;
Q_INVOKABLE void moveCursor(const QPoint &p);
Q_INVOKABLE void sendCommand(const QString &name, bool val);
private:
QString dbusPath() const;
};
#endif