2021-03-12 23:27:16 +00:00
|
|
|
/**
|
|
|
|
* 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")
|
|
|
|
|
|
|
|
QString ConnectivityReportPlugin::cellularNetworkType() const
|
|
|
|
{
|
|
|
|
return m_cellularNetworkType;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ConnectivityReportPlugin::cellularNetworkStrength() const
|
|
|
|
{
|
|
|
|
return m_cellularNetworkStrength;
|
|
|
|
}
|
|
|
|
|
2023-07-31 08:25:45 +01:00
|
|
|
void ConnectivityReportPlugin::receivePacket(const NetworkPacket &np)
|
2021-03-12 23:27:16 +00:00
|
|
|
{
|
2023-07-17 13:14:11 +01:00
|
|
|
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
|
|
|
|
if (!subscriptions.isEmpty()) {
|
|
|
|
auto networkInfo = subscriptions.first().toMap();
|
2021-03-12 23:27:16 +00:00
|
|
|
|
2023-07-17 13:14:11 +01:00
|
|
|
const auto oldCellularNetworkType = m_cellularNetworkType;
|
|
|
|
const auto oldNetworkStrength = m_cellularNetworkStrength;
|
2021-11-30 22:33:30 +00:00
|
|
|
|
2023-07-17 13:14:11 +01:00
|
|
|
m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString();
|
|
|
|
m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt();
|
2021-03-12 23:27:16 +00:00
|
|
|
|
2023-07-17 13:14:11 +01:00
|
|
|
if (oldCellularNetworkType != m_cellularNetworkType || oldNetworkStrength != m_cellularNetworkStrength) {
|
|
|
|
Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength);
|
2021-11-30 22:33:30 +00:00
|
|
|
}
|
2021-03-12 23:27:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConnectivityReportPlugin::dbusPath() const
|
|
|
|
{
|
2023-08-12 12:26:05 +01:00
|
|
|
return QLatin1String("/modules/kdeconnect/devices/%1/connectivity_report").arg(device()->id());
|
2021-03-12 23:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "connectivity_reportplugin.moc"
|
2023-07-26 09:15:11 +01:00
|
|
|
#include "moc_connectivity_reportplugin.cpp"
|