Added an option to the cli to return your own device id

This commit is contained in:
Albert Vaca 2017-02-24 22:37:00 +01:00
parent 6a37a3c1bd
commit 7cc39aada8
3 changed files with 10 additions and 1 deletions

View file

@ -88,6 +88,7 @@ int main(int argc, char** argv)
parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids")));
parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id")));
parser.addOption(QCommandLineOption(QStringList{QStringLiteral("k"), QStringLiteral("send-keys")}, i18n("Sends keys to a said device")));
parser.addOption(QCommandLineOption(QStringLiteral("my-id"), i18n("Display this device's id and exit")));
about.setupCommandLine(&parser);
parser.addHelpOption();
@ -97,7 +98,9 @@ int main(int argc, char** argv)
const QString id = "kdeconnect-cli-"+QString::number(QCoreApplication::applicationPid());
DaemonDbusInterface iface;
if(parser.isSet(QStringLiteral("l")) || parser.isSet(QStringLiteral("a"))) {
if (parser.isSet(QStringLiteral("my-id"))) {
QTextStream(stdout) << iface.selfId() << endl;
} else if (parser.isSet(QStringLiteral("l")) || parser.isSet(QStringLiteral("a"))) {
bool paired = true, reachable = false;
if (parser.isSet(QStringLiteral("a"))) {
reachable = true;

View file

@ -271,3 +271,8 @@ Daemon::~Daemon()
{
}
QString Daemon::selfId() const
{
return KdeConnectConfig::instance()->deviceId();
}

View file

@ -57,6 +57,7 @@ public:
QStringList pairingRequests() const;
Q_SCRIPTABLE QString selfId() const;
public Q_SLOTS:
Q_SCRIPTABLE void acquireDiscoveryMode(const QString &id);
Q_SCRIPTABLE void releaseDiscoveryMode(const QString &id);