Commit b009c5fd authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Add a function to list device names

To ease dbus scripting
parent 749351ec
......@@ -21,6 +21,7 @@
#include "daemon.h"
#include <QDBusConnection>
#include <QDBusMetaType>
#include <QNetworkAccessManager>
#include <QDebug>
#include <QPointer>
......@@ -90,6 +91,7 @@ Daemon::Daemon(QObject* parent, bool testMode)
//Register on DBus
qDBusRegisterMetaType< QMap<QString,QString> >();
QDBusConnection::sessionBus().registerObject(QStringLiteral("/modules/kdeconnect"), this, QDBusConnection::ExportScriptableContents);
......@@ -168,6 +170,17 @@ QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
return ret;
QMap<QString, QString> Daemon::deviceNames(bool onlyReachable, bool onlyTrusted) const
QMap<QString, QString> ret;
for (Device* device : qAsConst(d->m_devices)) {
if (onlyReachable && !device->isReachable()) continue;
if (onlyTrusted && !device->isTrusted()) continue;
ret[device->id()] = device->name();
return ret;
void Daemon::onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl)
const QString& id = identityPacket.get<QString>(QStringLiteral("deviceId"));
......@@ -71,6 +71,8 @@ public Q_SLOTS:
//Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyPaired = false) const;
Q_SCRIPTABLE QMap<QString,QString> deviceNames(bool onlyReachable = false, bool onlyPaired = false) const;
Q_SCRIPTABLE QString deviceIdByName(const QString& name) const;
Q_SCRIPTABLE virtual void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) = 0;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment