File indexing completed on 2024-04-14 04:51:48

0001 /**
0002  * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "remotecontrolplugin.h"
0008 
0009 #include <KLocalizedString>
0010 #include <KPluginFactory>
0011 
0012 #include <QDBusConnection>
0013 #include <QDebug>
0014 #include <QPoint>
0015 
0016 #include "plugin_remotecontrol_debug.h"
0017 #include <core/device.h>
0018 
0019 K_PLUGIN_CLASS_WITH_JSON(RemoteControlPlugin, "kdeconnect_remotecontrol.json")
0020 
0021 void RemoteControlPlugin::moveCursor(const QPoint &p)
0022 {
0023     NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, {{QStringLiteral("dx"), p.x()}, {QStringLiteral("dy"), p.y()}});
0024     sendPacket(np);
0025 }
0026 
0027 void RemoteControlPlugin::sendCommand(const QVariantMap &body)
0028 {
0029     if (body.isEmpty())
0030         return;
0031     NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, body);
0032     sendPacket(np);
0033 }
0034 
0035 QString RemoteControlPlugin::dbusPath() const
0036 {
0037     return QLatin1String("/modules/kdeconnect/devices/%1/remotecontrol").arg(device()->id());
0038 }
0039 
0040 #include "moc_remotecontrolplugin.cpp"
0041 #include "remotecontrolplugin.moc"