kdeconnect-kde/interfaces/dbusinterfaces.cpp

198 lines
8.3 KiB
C++
Raw Normal View History

/**
2013-06-27 01:13:16 +01:00
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-03-23 16:29:26 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2013-06-27 01:13:16 +01:00
*/
#include "dbusinterfaces.h"
2019-06-09 16:28:49 +01:00
#include <dbushelper.h>
2013-06-27 01:13:16 +01:00
QString DaemonDbusInterface::activatedService() {
static const QString service = QStringLiteral("org.kde.kdeconnect");
2019-06-09 16:28:49 +01:00
auto reply = DbusHelper::sessionBus().interface()->startService(service);
if (!reply.isValid()) {
2019-06-09 16:28:49 +01:00
qWarning() << "error activating kdeconnectd:" << DbusHelper::sessionBus().interface()->lastError();
}
return service;
}
2013-06-27 01:13:16 +01:00
DaemonDbusInterface::DaemonDbusInterface(QObject* parent)
2019-06-09 16:28:49 +01:00
: OrgKdeKdeconnectDaemonInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect"), DbusHelper::sessionBus(), parent)
{
connect(this, &OrgKdeKdeconnectDaemonInterface::pairingRequestsChanged, this, &DaemonDbusInterface::pairingRequestsChangedProxy);
}
DaemonDbusInterface::~DaemonDbusInterface()
{
}
DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
, m_id(id)
2013-06-27 01:13:16 +01:00
{
2015-12-01 18:45:14 +00:00
connect(this, &OrgKdeKdeconnectDeviceInterface::trustedChanged, this, &DeviceDbusInterface::trustedChangedProxy);
connect(this, &OrgKdeKdeconnectDeviceInterface::reachableChanged, this, &DeviceDbusInterface::reachableChangedProxy);
2016-08-21 12:53:40 +01:00
connect(this, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DeviceDbusInterface::nameChangedProxy);
connect(this, &OrgKdeKdeconnectDeviceInterface::hasPairingRequestsChanged, this, &DeviceDbusInterface::hasPairingRequestsChangedProxy);
}
DeviceDbusInterface::~DeviceDbusInterface()
{
}
QString DeviceDbusInterface::id() const
{
return m_id;
}
void DeviceDbusInterface::pluginCall(const QString& plugin, const QString& method)
{
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") +id() + QStringLiteral("/") + plugin, QStringLiteral("org.kde.kdeconnect.device.") + plugin, method);
2019-06-09 16:28:49 +01:00
DbusHelper::sessionBus().asyncCall(msg);
}
DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
{
}
DeviceBatteryDbusInterface::~DeviceBatteryDbusInterface()
{
}
DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
{
}
DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface()
{
}
NotificationDbusInterface::NotificationDbusInterface(const QString& deviceId, const QString& notificationId, QObject* parent)
: OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/notifications/") + notificationId, DbusHelper::sessionBus(), parent)
, id(notificationId)
{
}
NotificationDbusInterface::~NotificationDbusInterface()
{
}
(WIP) Upgrade Telephony plugin to read SMS history (KDE side) Summary: For real usecases of SMS support, we will almost always need access to the message history in some way Specifically resolve T8338 Incidentally resolve T6651 since Telephony shall no longer create a notification Test Plan: Setup: - Build corresponding Android-side diff (D11698) - Build this diff Step 1: Does anything at all work? - Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object - Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations() - Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation Step 2: DBus - Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId> - Poke activeConversations and verify an empty array is returned - Poke requestAllConversationThreads - Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds - Use a conversationId to call getFirstFromConversation - Verify that the returned Message object is one which you recognize - Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!" Step 3: SMS App - Use ccmake (or similar) to set SMSAPP_ENABLE to ON - Build the project - Run ./bin/kdeconnect-sms - Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out) - If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number Reviewers: #kde_connect, nicolasfella, apol Reviewed By: #kde_connect, nicolasfella, apol Subscribers: andyholmes, apol, nicolasfella, #kde_connect Tags: #kde_connect Maniphest Tasks: T8338, T6651 Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString& deviceId, QObject* parent)
: OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId, DbusHelper::sessionBus(), parent)
(WIP) Upgrade Telephony plugin to read SMS history (KDE side) Summary: For real usecases of SMS support, we will almost always need access to the message history in some way Specifically resolve T8338 Incidentally resolve T6651 since Telephony shall no longer create a notification Test Plan: Setup: - Build corresponding Android-side diff (D11698) - Build this diff Step 1: Does anything at all work? - Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object - Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations() - Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation Step 2: DBus - Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId> - Poke activeConversations and verify an empty array is returned - Poke requestAllConversationThreads - Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds - Use a conversationId to call getFirstFromConversation - Verify that the returned Message object is one which you recognize - Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!" Step 3: SMS App - Use ccmake (or similar) to set SMSAPP_ENABLE to ON - Build the project - Run ./bin/kdeconnect-sms - Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out) - If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number Reviewers: #kde_connect, nicolasfella, apol Reviewed By: #kde_connect, nicolasfella, apol Subscribers: andyholmes, apol, nicolasfella, #kde_connect Tags: #kde_connect Maniphest Tasks: T8338, T6651 Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
}
DeviceConversationsDbusInterface::~DeviceConversationsDbusInterface()
{
}
SftpDbusInterface::SftpDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/sftp"), DbusHelper::sessionBus(), parent)
{
}
SftpDbusInterface::~SftpDbusInterface()
{
}
MprisDbusInterface::MprisDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceMprisremoteInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/mprisremote"), DbusHelper::sessionBus(), parent)
{
connect(this, &OrgKdeKdeconnectDeviceMprisremoteInterface::propertiesChanged, this, &MprisDbusInterface::propertiesChangedProxy);
}
MprisDbusInterface::~MprisDbusInterface()
{
}
RemoteControlDbusInterface::RemoteControlDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceRemotecontrolInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/remotecontrol"), DbusHelper::sessionBus(), parent)
{
}
RemoteControlDbusInterface::~RemoteControlDbusInterface()
{
}
LockDeviceDbusInterface::LockDeviceDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceLockdeviceInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/lockdevice"), DbusHelper::sessionBus(), parent)
{
connect(this, &OrgKdeKdeconnectDeviceLockdeviceInterface::lockedChanged, this, &LockDeviceDbusInterface::lockedChangedProxy);
Q_ASSERT(isValid());
}
LockDeviceDbusInterface::~LockDeviceDbusInterface()
{
}
FindMyPhoneDeviceDbusInterface::FindMyPhoneDeviceDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceFindmyphoneInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/findmyphone"), DbusHelper::sessionBus(), parent)
{
}
FindMyPhoneDeviceDbusInterface::~FindMyPhoneDeviceDbusInterface()
{
}
RemoteCommandsDbusInterface::RemoteCommandsDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceRemotecommandsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotecommands"), DbusHelper::sessionBus(), parent)
{
}
RemoteCommandsDbusInterface::~RemoteCommandsDbusInterface() = default;
RemoteKeyboardDbusInterface::RemoteKeyboardDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceRemotekeyboardInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotekeyboard"), DbusHelper::sessionBus(), parent)
{
connect(this, &OrgKdeKdeconnectDeviceRemotekeyboardInterface::remoteStateChanged, this, &RemoteKeyboardDbusInterface::remoteStateChanged);
}
RemoteKeyboardDbusInterface::~RemoteKeyboardDbusInterface() = default;
SmsDbusInterface::SmsDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceSmsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sms"), DbusHelper::sessionBus(), parent)
{
}
SmsDbusInterface::~SmsDbusInterface() = default;
ShareDbusInterface::ShareDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), DbusHelper::sessionBus(), parent)
{
}
ShareDbusInterface::~ShareDbusInterface() = default;
RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString& deviceId, QObject* parent):
OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), DbusHelper::sessionBus(), parent)
{
}