2e67f95017
The rationale is explained in https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/ In case of KDEConnect, it impressively speeds up compilation. Before it took 390 seconds on a clean build and with this change it took 330 seconds. This is due to the mocs_compilation having to include the header files and thus all their headers. Due to the lots of small plugins we have, this means that the same headers must be compiled plenty of times. When we include the moc files directly in the C++ file, they are already available.
66 lines
1.8 KiB
C++
66 lines
1.8 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")
|
|
|
|
PingPlugin::PingPlugin(QObject *parent, const QVariantList &args)
|
|
: KdeConnectPlugin(parent, args)
|
|
{
|
|
// qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin constructor for device" << device()->name();
|
|
}
|
|
|
|
PingPlugin::~PingPlugin()
|
|
{
|
|
// qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name();
|
|
}
|
|
|
|
bool PingPlugin::receivePacket(const NetworkPacket &np)
|
|
{
|
|
Daemon::instance()->sendSimpleNotification(QStringLiteral("pingReceived"),
|
|
device()->name(),
|
|
np.get<QString>(QStringLiteral("message"), i18n("Ping!")),
|
|
QStringLiteral("dialog-ok"));
|
|
|
|
return true;
|
|
}
|
|
|
|
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"
|