File indexing completed on 2023-05-30 09:17:24
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 #include "dbusinterfaces.h" 0008 #include <dbushelper.h> 0009 0010 QString DaemonDbusInterface::activatedService() 0011 { 0012 static const QString service = QStringLiteral("org.kde.kdeconnect"); 0013 0014 #ifndef SAILFISHOS 0015 auto reply = QDBusConnection::sessionBus().interface()->startService(service); 0016 if (!reply.isValid()) { 0017 qWarning() << "error activating kdeconnectd:" << reply.error(); 0018 } 0019 #endif 0020 0021 return service; 0022 } 0023 0024 DaemonDbusInterface::DaemonDbusInterface(QObject *parent) 0025 : OrgKdeKdeconnectDaemonInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect"), QDBusConnection::sessionBus(), parent) 0026 { 0027 connect(this, &OrgKdeKdeconnectDaemonInterface::pairingRequestsChanged, this, &DaemonDbusInterface::pairingRequestsChangedProxy); 0028 connect(this, &OrgKdeKdeconnectDaemonInterface::customDevicesChanged, this, &DaemonDbusInterface::customDevicesChangedProxy); 0029 } 0030 0031 DaemonDbusInterface::~DaemonDbusInterface() 0032 { 0033 } 0034 0035 DeviceDbusInterface::DeviceDbusInterface(const QString &id, QObject *parent) 0036 : OrgKdeKdeconnectDeviceInterface(DaemonDbusInterface::activatedService(), 0037 QStringLiteral("/modules/kdeconnect/devices/") + id, 0038 QDBusConnection::sessionBus(), 0039 parent) 0040 , m_id(id) 0041 { 0042 connect(this, &OrgKdeKdeconnectDeviceInterface::trustedChanged, this, &DeviceDbusInterface::trustedChangedProxy); 0043 connect(this, &OrgKdeKdeconnectDeviceInterface::reachableChanged, this, &DeviceDbusInterface::reachableChangedProxy); 0044 connect(this, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DeviceDbusInterface::nameChangedProxy); 0045 connect(this, &OrgKdeKdeconnectDeviceInterface::hasPairingRequestsChanged, this, &DeviceDbusInterface::hasPairingRequestsChangedProxy); 0046 } 0047 0048 DeviceDbusInterface::~DeviceDbusInterface() 0049 { 0050 } 0051 0052 QString DeviceDbusInterface::id() const 0053 { 0054 return m_id; 0055 } 0056 0057 void DeviceDbusInterface::pluginCall(const QString &plugin, const QString &method) 0058 { 0059 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), 0060 QStringLiteral("/modules/kdeconnect/devices/") + id() + QStringLiteral("/") + plugin, 0061 QStringLiteral("org.kde.kdeconnect.device.") + plugin, 0062 method); 0063 QDBusConnection::sessionBus().asyncCall(msg); 0064 } 0065 0066 BatteryDbusInterface::BatteryDbusInterface(const QString &id, QObject *parent) 0067 : OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), 0068 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/battery"), 0069 QDBusConnection::sessionBus(), 0070 parent) 0071 { 0072 connect(this, &OrgKdeKdeconnectDeviceBatteryInterface::refreshed, this, &BatteryDbusInterface::refreshedProxy); 0073 } 0074 0075 BatteryDbusInterface::~BatteryDbusInterface() = default; 0076 0077 ConnectivityReportDbusInterface::ConnectivityReportDbusInterface(const QString &id, QObject *parent) 0078 : OrgKdeKdeconnectDeviceConnectivity_reportInterface(DaemonDbusInterface::activatedService(), 0079 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/connectivity_report"), 0080 QDBusConnection::sessionBus(), 0081 parent) 0082 { 0083 connect(this, &OrgKdeKdeconnectDeviceConnectivity_reportInterface::refreshed, this, &ConnectivityReportDbusInterface::refreshedProxy); 0084 } 0085 0086 ConnectivityReportDbusInterface::~ConnectivityReportDbusInterface() = default; 0087 0088 DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString &id, QObject *parent) 0089 : OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), 0090 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/notifications"), 0091 QDBusConnection::sessionBus(), 0092 parent) 0093 { 0094 } 0095 0096 DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface() 0097 { 0098 } 0099 0100 NotificationDbusInterface::NotificationDbusInterface(const QString &deviceId, const QString ¬ificationId, QObject *parent) 0101 : OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), 0102 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/notifications/") 0103 + notificationId, 0104 QDBusConnection::sessionBus(), 0105 parent) 0106 , id(notificationId) 0107 { 0108 } 0109 0110 NotificationDbusInterface::~NotificationDbusInterface() 0111 { 0112 } 0113 0114 DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString &deviceId, QObject *parent) 0115 : OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), 0116 QStringLiteral("/modules/kdeconnect/devices/") + deviceId, 0117 QDBusConnection::sessionBus(), 0118 parent) 0119 { 0120 } 0121 0122 DeviceConversationsDbusInterface::~DeviceConversationsDbusInterface() 0123 { 0124 } 0125 0126 SftpDbusInterface::SftpDbusInterface(const QString &id, QObject *parent) 0127 : OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), 0128 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/sftp"), 0129 QDBusConnection::sessionBus(), 0130 parent) 0131 { 0132 } 0133 0134 SftpDbusInterface::~SftpDbusInterface() 0135 { 0136 } 0137 0138 MprisDbusInterface::MprisDbusInterface(const QString &id, QObject *parent) 0139 : OrgKdeKdeconnectDeviceMprisremoteInterface(DaemonDbusInterface::activatedService(), 0140 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/mprisremote"), 0141 QDBusConnection::sessionBus(), 0142 parent) 0143 { 0144 connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy); 0145 } 0146 0147 MprisDbusInterface::~MprisDbusInterface() 0148 { 0149 } 0150 0151 RemoteControlDbusInterface::RemoteControlDbusInterface(const QString &id, QObject *parent) 0152 : OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(), 0153 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/remotecontrol"), 0154 QDBusConnection::sessionBus(), 0155 parent) 0156 { 0157 } 0158 0159 RemoteControlDbusInterface::~RemoteControlDbusInterface() 0160 { 0161 } 0162 0163 LockDeviceDbusInterface::LockDeviceDbusInterface(const QString &id, QObject *parent) 0164 : OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(), 0165 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/lockdevice"), 0166 QDBusConnection::sessionBus(), 0167 parent) 0168 { 0169 connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy); 0170 Q_ASSERT(isValid()); 0171 } 0172 0173 LockDeviceDbusInterface::~LockDeviceDbusInterface() 0174 { 0175 } 0176 0177 FindMyPhoneDeviceDbusInterface::FindMyPhoneDeviceDbusInterface(const QString &deviceId, QObject *parent) 0178 : OrgKdeKdeconnectDeviceFindmyphoneInterface(DaemonDbusInterface::activatedService(), 0179 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/findmyphone"), 0180 QDBusConnection::sessionBus(), 0181 parent) 0182 { 0183 } 0184 0185 FindMyPhoneDeviceDbusInterface::~FindMyPhoneDeviceDbusInterface() 0186 { 0187 } 0188 0189 RemoteCommandsDbusInterface::RemoteCommandsDbusInterface(const QString &deviceId, QObject *parent) 0190 : OrgKdeKdeconnectDeviceRemotecommandsInterface(DaemonDbusInterface::activatedService(), 0191 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotecommands"), 0192 QDBusConnection::sessionBus(), 0193 parent) 0194 { 0195 } 0196 0197 RemoteCommandsDbusInterface::~RemoteCommandsDbusInterface() = default; 0198 0199 RemoteKeyboardDbusInterface::RemoteKeyboardDbusInterface(const QString &deviceId, QObject *parent) 0200 : OrgKdeKdeconnectDeviceRemotekeyboardInterface(DaemonDbusInterface::activatedService(), 0201 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotekeyboard"), 0202 QDBusConnection::sessionBus(), 0203 parent) 0204 { 0205 connect(this, &OrgKdeKdeconnectDeviceRemotekeyboardInterface::remoteStateChanged, this, &RemoteKeyboardDbusInterface::remoteStateChanged); 0206 } 0207 0208 RemoteKeyboardDbusInterface::~RemoteKeyboardDbusInterface() = default; 0209 0210 SmsDbusInterface::SmsDbusInterface(const QString &deviceId, QObject *parent) 0211 : OrgKdeKdeconnectDeviceSmsInterface(DaemonDbusInterface::activatedService(), 0212 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sms"), 0213 QDBusConnection::sessionBus(), 0214 parent) 0215 { 0216 } 0217 0218 SmsDbusInterface::~SmsDbusInterface() = default; 0219 0220 ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent) 0221 : OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), 0222 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), 0223 QDBusConnection::sessionBus(), 0224 parent) 0225 { 0226 } 0227 0228 ShareDbusInterface::~ShareDbusInterface() = default; 0229 0230 PhotoDbusInterface::PhotoDbusInterface(const QString& deviceId, QObject* parent): 0231 OrgKdeKdeconnectDevicePhotoInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/photo"), QDBusConnection::sessionBus(), parent) 0232 { 0233 } 0234 0235 PhotoDbusInterface::~PhotoDbusInterface() = default; 0236 0237 RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString& deviceId, QObject* parent): 0238 OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), QDBusConnection::sessionBus(), parent) 0239 { 0240 } 0241 0242 BigscreenDbusInterface::BigscreenDbusInterface(const QString &deviceId, QObject *parent) 0243 : OrgKdeKdeconnectDeviceBigscreenInterface(DaemonDbusInterface::activatedService(), 0244 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/bigscreen"), 0245 QDBusConnection::sessionBus(), 0246 parent) 0247 { 0248 } 0249 0250 BigscreenDbusInterface::~BigscreenDbusInterface() 0251 { 0252 } 0253 0254 VirtualmonitorDbusInterface::VirtualmonitorDbusInterface(const QString &deviceId, QObject *parent) 0255 : OrgKdeKdeconnectDeviceVirtualmonitorInterface(DaemonDbusInterface::activatedService(), 0256 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/virtualmonitor"), 0257 QDBusConnection::sessionBus(), 0258 parent) 0259 { 0260 } 0261 0262 VirtualmonitorDbusInterface::~VirtualmonitorDbusInterface() 0263 { 0264 }