File indexing completed on 2024-04-21 08:46:29
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 0009 QString DaemonDbusInterface::activatedService() 0010 { 0011 static const QString service = QStringLiteral("org.kde.kdeconnect"); 0012 0013 auto reply = QDBusConnection::sessionBus().interface()->startService(service); 0014 if (!reply.isValid()) { 0015 qWarning() << "error activating kdeconnectd:" << reply.error(); 0016 } 0017 0018 return service; 0019 } 0020 0021 DaemonDbusInterface::DaemonDbusInterface(QObject *parent) 0022 : OrgKdeKdeconnectDaemonInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect"), QDBusConnection::sessionBus(), parent) 0023 { 0024 connect(this, &OrgKdeKdeconnectDaemonInterface::customDevicesChanged, this, &DaemonDbusInterface::customDevicesChangedProxy); 0025 } 0026 0027 DeviceDbusInterface::DeviceDbusInterface(const QString &id, QObject *parent) 0028 : OrgKdeKdeconnectDeviceInterface(DaemonDbusInterface::activatedService(), 0029 QStringLiteral("/modules/kdeconnect/devices/") + id, 0030 QDBusConnection::sessionBus(), 0031 parent) 0032 , m_id(id) 0033 { 0034 connect(this, &OrgKdeKdeconnectDeviceInterface::pairStateChanged, this, &DeviceDbusInterface::pairStateChangedProxy); 0035 connect(this, &OrgKdeKdeconnectDeviceInterface::reachableChanged, this, &DeviceDbusInterface::reachableChangedProxy); 0036 connect(this, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DeviceDbusInterface::nameChangedProxy); 0037 } 0038 0039 QString DeviceDbusInterface::id() const 0040 { 0041 return m_id; 0042 } 0043 0044 void DeviceDbusInterface::pluginCall(const QString &plugin, const QString &method) 0045 { 0046 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), 0047 QStringLiteral("/modules/kdeconnect/devices/") + id() + QStringLiteral("/") + plugin, 0048 QStringLiteral("org.kde.kdeconnect.device.") + plugin, 0049 method); 0050 QDBusConnection::sessionBus().asyncCall(msg); 0051 } 0052 0053 BatteryDbusInterface::BatteryDbusInterface(const QString &id, QObject *parent) 0054 : OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), 0055 QLatin1String("/modules/kdeconnect/devices/%1/battery").arg(id), 0056 QDBusConnection::sessionBus(), 0057 parent) 0058 { 0059 connect(this, &OrgKdeKdeconnectDeviceBatteryInterface::refreshed, this, &BatteryDbusInterface::refreshedProxy); 0060 } 0061 0062 ConnectivityReportDbusInterface::ConnectivityReportDbusInterface(const QString &id, QObject *parent) 0063 : OrgKdeKdeconnectDeviceConnectivity_reportInterface(DaemonDbusInterface::activatedService(), 0064 QLatin1String("/modules/kdeconnect/devices/%1/connectivity_report").arg(id), 0065 QDBusConnection::sessionBus(), 0066 parent) 0067 { 0068 connect(this, &OrgKdeKdeconnectDeviceConnectivity_reportInterface::refreshed, this, &ConnectivityReportDbusInterface::refreshedProxy); 0069 } 0070 0071 DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString &id, QObject *parent) 0072 : OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), 0073 QLatin1String("/modules/kdeconnect/devices/%1/notifications").arg(id), 0074 QDBusConnection::sessionBus(), 0075 parent) 0076 { 0077 } 0078 0079 NotificationDbusInterface::NotificationDbusInterface(const QString &deviceId, const QString ¬ificationId, QObject *parent) 0080 : OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), 0081 QLatin1String("/modules/kdeconnect/devices/%1/notifications/").arg(deviceId) + notificationId, 0082 QDBusConnection::sessionBus(), 0083 parent) 0084 , id(notificationId) 0085 { 0086 } 0087 0088 DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString &deviceId, QObject *parent) 0089 : OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), 0090 QStringLiteral("/modules/kdeconnect/devices/") + deviceId, 0091 QDBusConnection::sessionBus(), 0092 parent) 0093 { 0094 } 0095 0096 SftpDbusInterface::SftpDbusInterface(const QString &id, QObject *parent) 0097 : OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), 0098 QLatin1String("/modules/kdeconnect/devices/%1/sftp").arg(id), 0099 QDBusConnection::sessionBus(), 0100 parent) 0101 { 0102 } 0103 0104 MprisDbusInterface::MprisDbusInterface(const QString &id, QObject *parent) 0105 : OrgKdeKdeconnectDeviceMprisremoteInterface(DaemonDbusInterface::activatedService(), 0106 QLatin1String("/modules/kdeconnect/devices/%1/mprisremote").arg(id), 0107 QDBusConnection::sessionBus(), 0108 parent) 0109 { 0110 connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy); 0111 } 0112 0113 RemoteControlDbusInterface::RemoteControlDbusInterface(const QString &id, QObject *parent) 0114 : OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(), 0115 QLatin1String("/modules/kdeconnect/devices/%1/remotecontrol").arg(id), 0116 QDBusConnection::sessionBus(), 0117 parent) 0118 { 0119 } 0120 0121 LockDeviceDbusInterface::LockDeviceDbusInterface(const QString &id, QObject *parent) 0122 : OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(), 0123 QLatin1String("/modules/kdeconnect/devices/%1/lockdevice").arg(id), 0124 QDBusConnection::sessionBus(), 0125 parent) 0126 { 0127 connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy); 0128 Q_ASSERT(isValid()); 0129 } 0130 0131 FindMyPhoneDeviceDbusInterface::FindMyPhoneDeviceDbusInterface(const QString &deviceId, QObject *parent) 0132 : OrgKdeKdeconnectDeviceFindmyphoneInterface(DaemonDbusInterface::activatedService(), 0133 QLatin1String("/modules/kdeconnect/devices/%1/findmyphone").arg(deviceId), 0134 QDBusConnection::sessionBus(), 0135 parent) 0136 { 0137 } 0138 0139 RemoteCommandsDbusInterface::RemoteCommandsDbusInterface(const QString &deviceId, QObject *parent) 0140 : OrgKdeKdeconnectDeviceRemotecommandsInterface(DaemonDbusInterface::activatedService(), 0141 QLatin1String("/modules/kdeconnect/devices/%1/remotecommands").arg(deviceId), 0142 QDBusConnection::sessionBus(), 0143 parent) 0144 { 0145 } 0146 0147 RemoteKeyboardDbusInterface::RemoteKeyboardDbusInterface(const QString &deviceId, QObject *parent) 0148 : OrgKdeKdeconnectDeviceRemotekeyboardInterface(DaemonDbusInterface::activatedService(), 0149 QLatin1String("/modules/kdeconnect/devices/%1/remotekeyboard").arg(deviceId), 0150 QDBusConnection::sessionBus(), 0151 parent) 0152 { 0153 connect(this, &OrgKdeKdeconnectDeviceRemotekeyboardInterface::remoteStateChanged, this, &RemoteKeyboardDbusInterface::remoteStateChangedProxy); 0154 } 0155 0156 SmsDbusInterface::SmsDbusInterface(const QString &deviceId, QObject *parent) 0157 : OrgKdeKdeconnectDeviceSmsInterface(DaemonDbusInterface::activatedService(), 0158 QLatin1String("/modules/kdeconnect/devices/%1/sms").arg(deviceId), 0159 QDBusConnection::sessionBus(), 0160 parent) 0161 { 0162 } 0163 0164 ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent) 0165 : OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), 0166 QLatin1String("/modules/kdeconnect/devices/%1/share").arg(deviceId), 0167 QDBusConnection::sessionBus(), 0168 parent) 0169 { 0170 } 0171 0172 RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent) 0173 : OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), 0174 QLatin1String("/modules/kdeconnect/devices/%1/remotesystemvolume").arg(deviceId), 0175 QDBusConnection::sessionBus(), 0176 parent) 0177 { 0178 } 0179 0180 BigscreenDbusInterface::BigscreenDbusInterface(const QString &deviceId, QObject *parent) 0181 : OrgKdeKdeconnectDeviceBigscreenInterface(DaemonDbusInterface::activatedService(), 0182 QLatin1String("/modules/kdeconnect/devices/%1/bigscreen").arg(deviceId), 0183 QDBusConnection::sessionBus(), 0184 parent) 0185 { 0186 } 0187 0188 VirtualmonitorDbusInterface::VirtualmonitorDbusInterface(const QString &deviceId, QObject *parent) 0189 : OrgKdeKdeconnectDeviceVirtualmonitorInterface(DaemonDbusInterface::activatedService(), 0190 QLatin1String("/modules/kdeconnect/devices/%1/virtualmonitor").arg(deviceId), 0191 QDBusConnection::sessionBus(), 0192 parent) 0193 { 0194 } 0195 0196 ClipboardDbusInterface::ClipboardDbusInterface(const QString &deviceId, QObject *parent) 0197 : OrgKdeKdeconnectDeviceClipboardInterface(DaemonDbusInterface::activatedService(), 0198 QLatin1String("/modules/kdeconnect/devices/%1/clipboard").arg(deviceId), 0199 QDBusConnection::sessionBus(), 0200 parent) 0201 { 0202 connect(this, &OrgKdeKdeconnectDeviceClipboardInterface::autoShareDisabledChanged, this, &ClipboardDbusInterface::autoShareDisabledChangedProxy); 0203 } 0204 0205 #include "moc_dbusinterfaces.cpp"