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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONNECTIVITY_REPORT_H
|
|
|
|
#define CONNECTIVITY_REPORT_H
|
|
|
|
|
|
|
|
#include <core/kdeconnectplugin.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Packet used to report the current connectivity state
|
|
|
|
* <p>
|
|
|
|
* The body should contain a key "signalStrengths" which has a dict that maps
|
|
|
|
* a SubscriptionID (opaque value) to a dict with the connection info (See below)
|
|
|
|
* <p>
|
|
|
|
* For example:
|
|
|
|
* {
|
|
|
|
* "signalStrengths": {
|
|
|
|
* "6": {
|
|
|
|
* "networkType": "4G",
|
|
|
|
* "signalStrength": 3
|
|
|
|
* },
|
|
|
|
* "17": {
|
|
|
|
* "networkType": "HSPA",
|
|
|
|
* "signalStrength": 2
|
|
|
|
* },
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
#define PACKET_TYPE_CONNECTIVITY_REPORT QStringLiteral("kdeconnect.connectivity_report")
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
class ConnectivityReportPlugin : public KdeConnectPlugin
|
2021-03-12 23:27:16 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.connectivity_report")
|
|
|
|
Q_PROPERTY(QString cellularNetworkType READ cellularNetworkType NOTIFY refreshed)
|
|
|
|
Q_PROPERTY(int cellularNetworkStrength READ cellularNetworkStrength NOTIFY refreshed)
|
|
|
|
|
|
|
|
public:
|
2022-09-10 22:23:52 +01:00
|
|
|
explicit ConnectivityReportPlugin(QObject *parent, const QVariantList &args);
|
2021-03-12 23:27:16 +00:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
bool receivePacket(const NetworkPacket &np) override;
|
2021-03-12 23:27:16 +00:00
|
|
|
void connected() override;
|
|
|
|
QString dbusPath() const override;
|
|
|
|
|
|
|
|
QString cellularNetworkType() const;
|
|
|
|
int cellularNetworkStrength() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
Q_SCRIPTABLE void refreshed(QString cellularNetworkType, int cellularNetworkStrength);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_cellularNetworkType;
|
|
|
|
int m_cellularNetworkStrength = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|