kdeconnect-kde/plugins/ping/pingplugin.cpp
Alexander Lohnau c5e7fdb5e4 plugins: Prefer using statements with baseclass over empty constructor
Those plugins re really simple and don't need any initialization logic.
With the using statement, we do not need to add a constructor and pass the parent/args to the baseclass
2023-08-07 19:28:37 +02:00

53 lines
1.5 KiB
C++

/**
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "pingplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
#include <QDBusConnection>
#include <QDebug>
#include <core/daemon.h>
#include <core/device.h>
#include "plugin_ping_debug.h"
K_PLUGIN_CLASS_WITH_JSON(PingPlugin, "kdeconnect_ping.json")
void PingPlugin::receivePacket(const NetworkPacket &np)
{
Daemon::instance()->sendSimpleNotification(QStringLiteral("pingReceived"),
device()->name(),
np.get<QString>(QStringLiteral("message"), i18n("Ping!")),
QStringLiteral("dialog-ok"));
}
void PingPlugin::sendPing()
{
NetworkPacket np(PACKET_TYPE_PING);
bool success = sendPacket(np);
qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success;
}
void PingPlugin::sendPing(const QString &customMessage)
{
NetworkPacket np(PACKET_TYPE_PING);
if (!customMessage.isEmpty()) {
np.set(QStringLiteral("message"), customMessage);
}
bool success = sendPacket(np);
qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success;
}
QString PingPlugin::dbusPath() const
{
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/ping");
}
#include "moc_pingplugin.cpp"
#include "pingplugin.moc"