Add a function to list device names
To ease dbus scripting
This commit is contained in:
parent
749351ec64
commit
b009c5fd0b
2 changed files with 15 additions and 0 deletions
|
@ -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().registerService(QStringLiteral("org.kde.kdeconnect"));
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue