File indexing completed on 2023-09-24 12:41:01

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 &notificationId, QObject *parent)
0080     : OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(),
0081                                                                QLatin1String("/modules/kdeconnect/devices/%1/notifications/").arg(deviceId)
0082                                                                    + notificationId,
0083                                                                QDBusConnection::sessionBus(),
0084                                                                parent)
0085     , id(notificationId)
0086 {
0087 }
0088 
0089 DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString &deviceId, QObject *parent)
0090     : OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(),
0091                                                    QStringLiteral("/modules/kdeconnect/devices/") + deviceId,
0092                                                    QDBusConnection::sessionBus(),
0093                                                    parent)
0094 {
0095 }
0096 
0097 SftpDbusInterface::SftpDbusInterface(const QString &id, QObject *parent)
0098     : OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(),
0099                                           QLatin1String("/modules/kdeconnect/devices/%1/sftp").arg(id),
0100                                           QDBusConnection::sessionBus(),
0101                                           parent)
0102 {
0103 }
0104 
0105 MprisDbusInterface::MprisDbusInterface(const QString &id, QObject *parent)
0106     : OrgKdeKdeconnectDeviceMprisremoteInterface(DaemonDbusInterface::activatedService(),
0107                                                  QLatin1String("/modules/kdeconnect/devices/%1/mprisremote").arg(id),
0108                                                  QDBusConnection::sessionBus(),
0109                                                  parent)
0110 {
0111     connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy);
0112 }
0113 
0114 RemoteControlDbusInterface::RemoteControlDbusInterface(const QString &id, QObject *parent)
0115     : OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(),
0116                                                    QLatin1String("/modules/kdeconnect/devices/%1/remotecontrol").arg(id),
0117                                                    QDBusConnection::sessionBus(),
0118                                                    parent)
0119 {
0120 }
0121 
0122 LockDeviceDbusInterface::LockDeviceDbusInterface(const QString &id, QObject *parent)
0123     : OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(),
0124                                                 QLatin1String("/modules/kdeconnect/devices/%1/lockdevice").arg(id),
0125                                                 QDBusConnection::sessionBus(),
0126                                                 parent)
0127 {
0128     connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy);
0129     Q_ASSERT(isValid());
0130 }
0131 
0132 FindMyPhoneDeviceDbusInterface::FindMyPhoneDeviceDbusInterface(const QString &deviceId, QObject *parent)
0133     : OrgKdeKdeconnectDeviceFindmyphoneInterface(DaemonDbusInterface::activatedService(),
0134                                                  QLatin1String("/modules/kdeconnect/devices/%1/findmyphone").arg(deviceId),
0135                                                  QDBusConnection::sessionBus(),
0136                                                  parent)
0137 {
0138 }
0139 
0140 RemoteCommandsDbusInterface::RemoteCommandsDbusInterface(const QString &deviceId, QObject *parent)
0141     : OrgKdeKdeconnectDeviceRemotecommandsInterface(DaemonDbusInterface::activatedService(),
0142                                                     QLatin1String("/modules/kdeconnect/devices/%1/remotecommands").arg(deviceId),
0143                                                     QDBusConnection::sessionBus(),
0144                                                     parent)
0145 {
0146 }
0147 
0148 RemoteKeyboardDbusInterface::RemoteKeyboardDbusInterface(const QString &deviceId, QObject *parent)
0149     : OrgKdeKdeconnectDeviceRemotekeyboardInterface(DaemonDbusInterface::activatedService(),
0150                                                     QLatin1String("/modules/kdeconnect/devices/%1/remotekeyboard").arg(deviceId),
0151                                                     QDBusConnection::sessionBus(),
0152                                                     parent)
0153 {
0154     connect(this, &OrgKdeKdeconnectDeviceRemotekeyboardInterface::remoteStateChanged, this, &RemoteKeyboardDbusInterface::remoteStateChangedProxy);
0155 }
0156 
0157 SmsDbusInterface::SmsDbusInterface(const QString &deviceId, QObject *parent)
0158     : OrgKdeKdeconnectDeviceSmsInterface(DaemonDbusInterface::activatedService(),
0159                                          QLatin1String("/modules/kdeconnect/devices/%1/sms").arg(deviceId),
0160                                          QDBusConnection::sessionBus(),
0161                                          parent)
0162 {
0163 }
0164 
0165 ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent)
0166     : OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(),
0167                                            QLatin1String("/modules/kdeconnect/devices/%1/share").arg(deviceId),
0168                                            QDBusConnection::sessionBus(),
0169                                            parent)
0170 {
0171 }
0172 
0173 RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent)
0174     : OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(),
0175                                                         QLatin1String("/modules/kdeconnect/devices/%1/remotesystemvolume").arg(deviceId),
0176                                                         QDBusConnection::sessionBus(),
0177                                                         parent)
0178 {
0179 }
0180 
0181 BigscreenDbusInterface::BigscreenDbusInterface(const QString &deviceId, QObject *parent)
0182     : OrgKdeKdeconnectDeviceBigscreenInterface(DaemonDbusInterface::activatedService(),
0183                                                QLatin1String("/modules/kdeconnect/devices/%1/bigscreen").arg(deviceId),
0184                                                QDBusConnection::sessionBus(),
0185                                                parent)
0186 {
0187 }
0188 
0189 VirtualmonitorDbusInterface::VirtualmonitorDbusInterface(const QString &deviceId, QObject *parent)
0190     : OrgKdeKdeconnectDeviceVirtualmonitorInterface(DaemonDbusInterface::activatedService(),
0191                                                     QLatin1String("/modules/kdeconnect/devices/%1/virtualmonitor").arg(deviceId),
0192                                                     QDBusConnection::sessionBus(),
0193                                                     parent)
0194 {
0195 }
0196 
0197 ClipboardDbusInterface::ClipboardDbusInterface(const QString &deviceId, QObject *parent)
0198     : OrgKdeKdeconnectDeviceClipboardInterface(DaemonDbusInterface::activatedService(),
0199                                                QLatin1String("/modules/kdeconnect/devices/%1/clipboard").arg(deviceId),
0200                                                QDBusConnection::sessionBus(),
0201                                                parent)
0202 {
0203     connect(this, &OrgKdeKdeconnectDeviceClipboardInterface::autoShareDisabledChanged, this, &ClipboardDbusInterface::autoShareDisabledChangedProxy);
0204 }
0205 
0206 #include "moc_dbusinterfaces.cpp"