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 #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::pairStateChanged, this, &DeviceDbusInterface::pairStateChangedProxy); 0043 connect(this, &OrgKdeKdeconnectDeviceInterface::reachableChanged, this, &DeviceDbusInterface::reachableChangedProxy); 0044 connect(this, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DeviceDbusInterface::nameChangedProxy); 0045 } 0046 0047 DeviceDbusInterface::~DeviceDbusInterface() 0048 { 0049 } 0050 0051 QString DeviceDbusInterface::id() const 0052 { 0053 return m_id; 0054 } 0055 0056 void DeviceDbusInterface::pluginCall(const QString &plugin, const QString &method) 0057 { 0058 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), 0059 QStringLiteral("/modules/kdeconnect/devices/") + id() + QStringLiteral("/") + plugin, 0060 QStringLiteral("org.kde.kdeconnect.device.") + plugin, 0061 method); 0062 QDBusConnection::sessionBus().asyncCall(msg); 0063 } 0064 0065 BatteryDbusInterface::BatteryDbusInterface(const QString &id, QObject *parent) 0066 : OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), 0067 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/battery"), 0068 QDBusConnection::sessionBus(), 0069 parent) 0070 { 0071 connect(this, &OrgKdeKdeconnectDeviceBatteryInterface::refreshed, this, &BatteryDbusInterface::refreshedProxy); 0072 } 0073 0074 BatteryDbusInterface::~BatteryDbusInterface() = default; 0075 0076 ConnectivityReportDbusInterface::ConnectivityReportDbusInterface(const QString &id, QObject *parent) 0077 : OrgKdeKdeconnectDeviceConnectivity_reportInterface(DaemonDbusInterface::activatedService(), 0078 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/connectivity_report"), 0079 QDBusConnection::sessionBus(), 0080 parent) 0081 { 0082 connect(this, &OrgKdeKdeconnectDeviceConnectivity_reportInterface::refreshed, this, &ConnectivityReportDbusInterface::refreshedProxy); 0083 } 0084 0085 ConnectivityReportDbusInterface::~ConnectivityReportDbusInterface() = default; 0086 0087 DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString &id, QObject *parent) 0088 : OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), 0089 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/notifications"), 0090 QDBusConnection::sessionBus(), 0091 parent) 0092 { 0093 } 0094 0095 DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface() 0096 { 0097 } 0098 0099 NotificationDbusInterface::NotificationDbusInterface(const QString &deviceId, const QString ¬ificationId, QObject *parent) 0100 : OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), 0101 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/notifications/") 0102 + notificationId, 0103 QDBusConnection::sessionBus(), 0104 parent) 0105 , id(notificationId) 0106 { 0107 } 0108 0109 NotificationDbusInterface::~NotificationDbusInterface() 0110 { 0111 } 0112 0113 DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString &deviceId, QObject *parent) 0114 : OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), 0115 QStringLiteral("/modules/kdeconnect/devices/") + deviceId, 0116 QDBusConnection::sessionBus(), 0117 parent) 0118 { 0119 } 0120 0121 DeviceConversationsDbusInterface::~DeviceConversationsDbusInterface() 0122 { 0123 } 0124 0125 SftpDbusInterface::SftpDbusInterface(const QString &id, QObject *parent) 0126 : OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), 0127 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/sftp"), 0128 QDBusConnection::sessionBus(), 0129 parent) 0130 { 0131 } 0132 0133 SftpDbusInterface::~SftpDbusInterface() 0134 { 0135 } 0136 0137 MprisDbusInterface::MprisDbusInterface(const QString &id, QObject *parent) 0138 : OrgKdeKdeconnectDeviceMprisremoteInterface(DaemonDbusInterface::activatedService(), 0139 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/mprisremote"), 0140 QDBusConnection::sessionBus(), 0141 parent) 0142 { 0143 connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy); 0144 } 0145 0146 MprisDbusInterface::~MprisDbusInterface() 0147 { 0148 } 0149 0150 RemoteControlDbusInterface::RemoteControlDbusInterface(const QString &id, QObject *parent) 0151 : OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(), 0152 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/remotecontrol"), 0153 QDBusConnection::sessionBus(), 0154 parent) 0155 { 0156 } 0157 0158 RemoteControlDbusInterface::~RemoteControlDbusInterface() 0159 { 0160 } 0161 0162 LockDeviceDbusInterface::LockDeviceDbusInterface(const QString &id, QObject *parent) 0163 : OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(), 0164 QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/lockdevice"), 0165 QDBusConnection::sessionBus(), 0166 parent) 0167 { 0168 connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy); 0169 Q_ASSERT(isValid()); 0170 } 0171 0172 LockDeviceDbusInterface::~LockDeviceDbusInterface() 0173 { 0174 } 0175 0176 FindMyPhoneDeviceDbusInterface::FindMyPhoneDeviceDbusInterface(const QString &deviceId, QObject *parent) 0177 : OrgKdeKdeconnectDeviceFindmyphoneInterface(DaemonDbusInterface::activatedService(), 0178 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/findmyphone"), 0179 QDBusConnection::sessionBus(), 0180 parent) 0181 { 0182 } 0183 0184 FindMyPhoneDeviceDbusInterface::~FindMyPhoneDeviceDbusInterface() 0185 { 0186 } 0187 0188 RemoteCommandsDbusInterface::RemoteCommandsDbusInterface(const QString &deviceId, QObject *parent) 0189 : OrgKdeKdeconnectDeviceRemotecommandsInterface(DaemonDbusInterface::activatedService(), 0190 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotecommands"), 0191 QDBusConnection::sessionBus(), 0192 parent) 0193 { 0194 } 0195 0196 RemoteCommandsDbusInterface::~RemoteCommandsDbusInterface() = default; 0197 0198 RemoteKeyboardDbusInterface::RemoteKeyboardDbusInterface(const QString &deviceId, QObject *parent) 0199 : OrgKdeKdeconnectDeviceRemotekeyboardInterface(DaemonDbusInterface::activatedService(), 0200 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotekeyboard"), 0201 QDBusConnection::sessionBus(), 0202 parent) 0203 { 0204 connect(this, &OrgKdeKdeconnectDeviceRemotekeyboardInterface::remoteStateChanged, this, &RemoteKeyboardDbusInterface::remoteStateChanged); 0205 } 0206 0207 RemoteKeyboardDbusInterface::~RemoteKeyboardDbusInterface() = default; 0208 0209 SmsDbusInterface::SmsDbusInterface(const QString &deviceId, QObject *parent) 0210 : OrgKdeKdeconnectDeviceSmsInterface(DaemonDbusInterface::activatedService(), 0211 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sms"), 0212 QDBusConnection::sessionBus(), 0213 parent) 0214 { 0215 } 0216 0217 SmsDbusInterface::~SmsDbusInterface() = default; 0218 0219 ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent) 0220 : OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), 0221 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), 0222 QDBusConnection::sessionBus(), 0223 parent) 0224 { 0225 } 0226 0227 ShareDbusInterface::~ShareDbusInterface() = default; 0228 0229 PhotoDbusInterface::PhotoDbusInterface(const QString &deviceId, QObject *parent) 0230 : OrgKdeKdeconnectDevicePhotoInterface(DaemonDbusInterface::activatedService(), 0231 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/photo"), 0232 QDBusConnection::sessionBus(), 0233 parent) 0234 { 0235 } 0236 0237 PhotoDbusInterface::~PhotoDbusInterface() = default; 0238 0239 RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent) 0240 : OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), 0241 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), 0242 QDBusConnection::sessionBus(), 0243 parent) 0244 { 0245 } 0246 0247 BigscreenDbusInterface::BigscreenDbusInterface(const QString &deviceId, QObject *parent) 0248 : OrgKdeKdeconnectDeviceBigscreenInterface(DaemonDbusInterface::activatedService(), 0249 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/bigscreen"), 0250 QDBusConnection::sessionBus(), 0251 parent) 0252 { 0253 } 0254 0255 BigscreenDbusInterface::~BigscreenDbusInterface() 0256 { 0257 } 0258 0259 VirtualmonitorDbusInterface::VirtualmonitorDbusInterface(const QString &deviceId, QObject *parent) 0260 : OrgKdeKdeconnectDeviceVirtualmonitorInterface(DaemonDbusInterface::activatedService(), 0261 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/virtualmonitor"), 0262 QDBusConnection::sessionBus(), 0263 parent) 0264 { 0265 } 0266 0267 VirtualmonitorDbusInterface::~VirtualmonitorDbusInterface() 0268 { 0269 } 0270 0271 #include <iostream> 0272 ClipboardDbusInterface::ClipboardDbusInterface(const QString &deviceId, QObject *parent) 0273 : OrgKdeKdeconnectDeviceClipboardInterface(DaemonDbusInterface::activatedService(), 0274 QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/clipboard"), 0275 QDBusConnection::sessionBus(), 0276 parent) 0277 { 0278 connect(this, &OrgKdeKdeconnectDeviceClipboardInterface::autoShareDisabledChanged, this, &ClipboardDbusInterface::autoShareDisabledChangedProxy); 0279 } 0280 0281 ClipboardDbusInterface::~ClipboardDbusInterface() 0282 { 0283 }