File indexing completed on 2023-09-24 08:52:40

0001 /**
0002  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef DBUSINTERFACES_H
0008 #define DBUSINTERFACES_H
0009 
0010 #include "kdeconnectinterfaces_export.h"
0011 
0012 #include "batteryinterface.h"
0013 #include "bigscreeninterface.h"
0014 #include "connectivityinterface.h"
0015 #include "conversationsinterface.h"
0016 #include "daemoninterface.h"
0017 #include "deviceclipboardinterface.h"
0018 #include "devicefindmyphoneinterface.h"
0019 #include "deviceinterface.h"
0020 #include "devicenotificationsinterface.h"
0021 #include "devicesftpinterface.h"
0022 #include "lockdeviceinterface.h"
0023 #include "mprisremoteinterface.h"
0024 #include "notificationinterface.h"
0025 #include "photointerface.h"
0026 #include "remotecommandsinterface.h"
0027 #include "remotecontrolinterface.h"
0028 #include "remotekeyboardinterface.h"
0029 #include "remotesystemvolumeinterface.h"
0030 #include "shareinterface.h"
0031 #include "smsinterface.h"
0032 #include "virtualmonitorinterface.h"
0033 
0034 /**
0035  * Using these "proxy" classes just in case we need to rename the
0036  * interface, so we can change the class name in a single place.
0037  */
0038 class KDECONNECTINTERFACES_EXPORT DaemonDbusInterface : public OrgKdeKdeconnectDaemonInterface
0039 {
0040     Q_OBJECT
0041     Q_PROPERTY(QStringList customDevices READ customDevices WRITE setCustomDevices NOTIFY customDevicesChangedProxy)
0042 public:
0043     explicit DaemonDbusInterface(QObject *parent = nullptr);
0044     ~DaemonDbusInterface() override;
0045 
0046     static QString activatedService();
0047 
0048 Q_SIGNALS:
0049     void deviceAdded(const QString &id);
0050     void pairingRequestsChangedProxy();
0051     void customDevicesChangedProxy();
0052 };
0053 
0054 class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface : public OrgKdeKdeconnectDeviceInterface
0055 {
0056     Q_OBJECT
0057     //  TODO: Workaround because OrgKdeKdeconnectDeviceInterface is not generating
0058     //  the signals for the properties
0059     Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableChangedProxy)
0060     Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairStateChangedProxy)
0061     Q_PROPERTY(bool isPairRequested READ isPairRequested NOTIFY pairStateChangedProxy)
0062     Q_PROPERTY(bool isPairRequestedByPeer READ isPairRequestedByPeer NOTIFY pairStateChangedProxy)
0063     Q_PROPERTY(int pairState READ pairState NOTIFY pairStateChangedProxy)
0064     Q_PROPERTY(QString name READ name NOTIFY nameChangedProxy)
0065 
0066 public:
0067     explicit DeviceDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0068     ~DeviceDbusInterface() override;
0069 
0070     Q_SCRIPTABLE QString id() const;
0071     Q_SCRIPTABLE void pluginCall(const QString &plugin, const QString &method);
0072 
0073 Q_SIGNALS:
0074     void nameChangedProxy(const QString &name);
0075     void pairStateChangedProxy(int pairState);
0076     void reachableChangedProxy(bool reachable);
0077 
0078 private:
0079     const QString m_id;
0080 };
0081 
0082 class KDECONNECTINTERFACES_EXPORT BatteryDbusInterface : public OrgKdeKdeconnectDeviceBatteryInterface
0083 {
0084     Q_OBJECT
0085     Q_PROPERTY(int charge READ charge NOTIFY refreshedProxy)
0086     Q_PROPERTY(bool isCharging READ isCharging NOTIFY refreshedProxy)
0087 public:
0088     explicit BatteryDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0089     ~BatteryDbusInterface() override;
0090 
0091 Q_SIGNALS:
0092     void refreshedProxy(bool isCharging, int charge);
0093 };
0094 
0095 class KDECONNECTINTERFACES_EXPORT ConnectivityReportDbusInterface : public OrgKdeKdeconnectDeviceConnectivity_reportInterface
0096 {
0097     Q_OBJECT
0098     Q_PROPERTY(QString cellularNetworkType READ cellularNetworkType NOTIFY refreshedProxy)
0099     Q_PROPERTY(int cellularNetworkStrength READ cellularNetworkStrength NOTIFY refreshedProxy)
0100 public:
0101     explicit ConnectivityReportDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0102     ~ConnectivityReportDbusInterface() override;
0103 
0104 Q_SIGNALS:
0105     void refreshedProxy(QString cellularNetworkType, int cellularNetworkStrength);
0106 };
0107 
0108 class KDECONNECTINTERFACES_EXPORT DeviceNotificationsDbusInterface : public OrgKdeKdeconnectDeviceNotificationsInterface
0109 {
0110     Q_OBJECT
0111 public:
0112     explicit DeviceNotificationsDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0113     ~DeviceNotificationsDbusInterface() override;
0114 };
0115 
0116 class KDECONNECTINTERFACES_EXPORT NotificationDbusInterface : public OrgKdeKdeconnectDeviceNotificationsNotificationInterface
0117 {
0118     Q_OBJECT
0119 public:
0120     NotificationDbusInterface(const QString &deviceId, const QString &notificationId, QObject *parent = nullptr);
0121     ~NotificationDbusInterface() override;
0122 
0123     QString notificationId()
0124     {
0125         return id;
0126     }
0127 
0128 private:
0129     const QString id;
0130 };
0131 
0132 class KDECONNECTINTERFACES_EXPORT DeviceConversationsDbusInterface : public OrgKdeKdeconnectDeviceConversationsInterface
0133 {
0134     Q_OBJECT
0135 public:
0136     explicit DeviceConversationsDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0137     ~DeviceConversationsDbusInterface() override;
0138 };
0139 
0140 class KDECONNECTINTERFACES_EXPORT SftpDbusInterface : public OrgKdeKdeconnectDeviceSftpInterface
0141 {
0142     Q_OBJECT
0143 public:
0144     explicit SftpDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0145     ~SftpDbusInterface() override;
0146 };
0147 
0148 class KDECONNECTINTERFACES_EXPORT MprisDbusInterface : public OrgKdeKdeconnectDeviceMprisremoteInterface
0149 {
0150     Q_OBJECT
0151     //  TODO: Workaround because qdbusxml2cpp is not generating
0152     //  the signals for the properties
0153     Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChangedProxy)
0154     Q_PROPERTY(int length READ length NOTIFY propertiesChangedProxy)
0155     Q_PROPERTY(QString title READ title NOTIFY propertiesChangedProxy)
0156     Q_PROPERTY(QString artist READ artist NOTIFY propertiesChangedProxy)
0157     Q_PROPERTY(QString album READ album NOTIFY propertiesChangedProxy)
0158 
0159     Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChangedProxy)
0160     Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChangedProxy)
0161     Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChangedProxy)
0162     Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChangedProxy)
0163 public:
0164     explicit MprisDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0165     ~MprisDbusInterface() override;
0166 
0167 Q_SIGNALS:
0168     void propertiesChangedProxy();
0169 };
0170 
0171 class KDECONNECTINTERFACES_EXPORT RemoteControlDbusInterface : public OrgKdeKdeconnectDeviceRemotecontrolInterface
0172 {
0173     Q_OBJECT
0174 public:
0175     explicit RemoteControlDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0176     ~RemoteControlDbusInterface() override;
0177 };
0178 
0179 class KDECONNECTINTERFACES_EXPORT LockDeviceDbusInterface : public OrgKdeKdeconnectDeviceLockdeviceInterface
0180 {
0181     Q_OBJECT
0182     Q_PROPERTY(bool isLocked READ isLocked WRITE setIsLocked NOTIFY lockedChangedProxy)
0183 public:
0184     explicit LockDeviceDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0185     ~LockDeviceDbusInterface() override;
0186 
0187 Q_SIGNALS:
0188     void lockedChangedProxy(bool isLocked);
0189 };
0190 
0191 class KDECONNECTINTERFACES_EXPORT FindMyPhoneDeviceDbusInterface : public OrgKdeKdeconnectDeviceFindmyphoneInterface
0192 {
0193     Q_OBJECT
0194 public:
0195     explicit FindMyPhoneDeviceDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0196     ~FindMyPhoneDeviceDbusInterface() override;
0197 };
0198 
0199 class KDECONNECTINTERFACES_EXPORT RemoteCommandsDbusInterface : public OrgKdeKdeconnectDeviceRemotecommandsInterface
0200 {
0201     Q_OBJECT
0202 public:
0203     explicit RemoteCommandsDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0204     ~RemoteCommandsDbusInterface() override;
0205 };
0206 
0207 class KDECONNECTINTERFACES_EXPORT RemoteKeyboardDbusInterface : public OrgKdeKdeconnectDeviceRemotekeyboardInterface
0208 {
0209     Q_OBJECT
0210     Q_PROPERTY(bool remoteState READ remoteState NOTIFY remoteStateChanged)
0211 public:
0212     explicit RemoteKeyboardDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0213     ~RemoteKeyboardDbusInterface() override;
0214 Q_SIGNALS:
0215     void remoteStateChanged(bool state);
0216 };
0217 
0218 class KDECONNECTINTERFACES_EXPORT SmsDbusInterface : public OrgKdeKdeconnectDeviceSmsInterface
0219 {
0220     Q_OBJECT
0221 public:
0222     explicit SmsDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0223     ~SmsDbusInterface() override;
0224 };
0225 
0226 class KDECONNECTINTERFACES_EXPORT ShareDbusInterface : public OrgKdeKdeconnectDeviceShareInterface
0227 {
0228     Q_OBJECT
0229 public:
0230     explicit ShareDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0231     ~ShareDbusInterface() override;
0232 };
0233 
0234 class KDECONNECTINTERFACES_EXPORT PhotoDbusInterface : public OrgKdeKdeconnectDevicePhotoInterface
0235 {
0236     Q_OBJECT
0237 public:
0238     explicit PhotoDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0239     ~PhotoDbusInterface() override;
0240 };
0241 
0242 class KDECONNECTINTERFACES_EXPORT RemoteSystemVolumeDbusInterface : public OrgKdeKdeconnectDeviceRemotesystemvolumeInterface
0243 {
0244     Q_OBJECT
0245 public:
0246     explicit RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0247     ~RemoteSystemVolumeDbusInterface() override = default;
0248 };
0249 
0250 class KDECONNECTINTERFACES_EXPORT BigscreenDbusInterface : public OrgKdeKdeconnectDeviceBigscreenInterface
0251 {
0252     Q_OBJECT
0253 public:
0254     explicit BigscreenDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0255     ~BigscreenDbusInterface() override;
0256 };
0257 
0258 class KDECONNECTINTERFACES_EXPORT VirtualmonitorDbusInterface : public OrgKdeKdeconnectDeviceVirtualmonitorInterface
0259 {
0260     Q_OBJECT
0261 public:
0262     explicit VirtualmonitorDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0263     ~VirtualmonitorDbusInterface() override;
0264 };
0265 
0266 template<typename T, typename W>
0267 static void setWhenAvailable(const QDBusPendingReply<T> &pending, W func, QObject *parent)
0268 {
0269     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, parent);
0270     QObject::connect(watcher, &QDBusPendingCallWatcher::finished, parent, [func](QDBusPendingCallWatcher *watcher) {
0271         watcher->deleteLater();
0272         QDBusPendingReply<T> reply = *watcher;
0273         func(reply.value());
0274     });
0275 }
0276 
0277 class KDECONNECTINTERFACES_EXPORT ClipboardDbusInterface : public OrgKdeKdeconnectDeviceClipboardInterface
0278 {
0279     Q_OBJECT
0280     Q_PROPERTY(bool isAutoShareDisabled READ isAutoShareDisabled NOTIFY autoShareDisabledChangedProxy)
0281 public:
0282     explicit ClipboardDbusInterface(const QString &deviceId, QObject *parent = nullptr);
0283     ~ClipboardDbusInterface() override;
0284 Q_SIGNALS:
0285     void autoShareDisabledChangedProxy(bool b);
0286 };
0287 
0288 #endif