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.
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
/**
|
|
* SPDX-FileCopyrightText: 2021 David Shlemayev <david.shlemayev@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
*/
|
|
|
|
#include "connectivity_reportplugin.h"
|
|
|
|
#include <KLocalizedString>
|
|
#include <KPluginFactory>
|
|
|
|
#include <core/daemon.h>
|
|
|
|
#include "plugin_connectivity_report_debug.h"
|
|
|
|
K_PLUGIN_CLASS_WITH_JSON(ConnectivityReportPlugin, "kdeconnect_connectivity_report.json")
|
|
|
|
ConnectivityReportPlugin::ConnectivityReportPlugin(QObject *parent, const QVariantList &args)
|
|
: KdeConnectPlugin(parent, args)
|
|
{
|
|
}
|
|
|
|
QString ConnectivityReportPlugin::cellularNetworkType() const
|
|
{
|
|
return m_cellularNetworkType;
|
|
}
|
|
|
|
int ConnectivityReportPlugin::cellularNetworkStrength() const
|
|
{
|
|
return m_cellularNetworkStrength;
|
|
}
|
|
|
|
bool ConnectivityReportPlugin::receivePacket(const NetworkPacket &np)
|
|
{
|
|
if (PACKET_TYPE_CONNECTIVITY_REPORT != np.type()) {
|
|
return false;
|
|
}
|
|
|
|
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
|
|
if (!subscriptions.isEmpty()) {
|
|
auto networkInfo = subscriptions.first().toMap();
|
|
|
|
const auto oldCellularNetworkType = m_cellularNetworkType;
|
|
const auto oldNetworkStrength = m_cellularNetworkStrength;
|
|
|
|
m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString();
|
|
m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt();
|
|
|
|
if (oldCellularNetworkType != m_cellularNetworkType || oldNetworkStrength != m_cellularNetworkStrength) {
|
|
Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
QString ConnectivityReportPlugin::dbusPath() const
|
|
{
|
|
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/connectivity_report");
|
|
}
|
|
|
|
#include "connectivity_reportplugin.moc"
|
|
#include "moc_connectivity_reportplugin.cpp"
|