diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -59,6 +59,8 @@ parser.addOption(QCommandLineOption("share", i18n("Share a file to a said device"), "path")); parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device"))); parser.addOption(QCommandLineOption("lock", i18n("Lock the specified device"))); + parser.addOption(QCommandLineOption("send-sms", i18n("Sends an SMS. Requires destination"), i18n("message"))); + parser.addOption(QCommandLineOption("destination", i18n("Phone number to send the message"), i18n("phone number"))); parser.addOption(QCommandLineOption(QStringList("device") << "d", i18n("Device ID"), "dev")); parser.addOption(QCommandLineOption(QStringList("name") << "n", i18n("Device Name"), "name")); parser.addOption(QCommandLineOption("encryption-info", i18n("Get encryption info about said device"))); @@ -183,6 +185,15 @@ msg.setArguments(QVariantList() << message); } QDBusConnection::sessionBus().call(msg); + } else if(parser.isSet("send-sms")) { + if (parser.isSet("destination")) { + QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/telephony", "org.kde.kdeconnect.device.telephony", "sendSms"); + msg.setArguments({ parser.value("destination"), parser.value("send-sms") }); + QDBusConnection::sessionBus().call(msg); + } else { + QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination "); + return 1; + } } else if(parser.isSet("ring")) { QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/findmyphone", "org.kde.kdeconnect.device.findmyphone", "ring"); QDBusConnection::sessionBus().call(msg); diff --git a/plugins/telephony/telephonyplugin.h b/plugins/telephony/telephonyplugin.h --- a/plugins/telephony/telephonyplugin.h +++ b/plugins/telephony/telephonyplugin.h @@ -37,21 +37,23 @@ : public KdeConnectPlugin { Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.telephony") public: explicit TelephonyPlugin(QObject *parent, const QVariantList &args); bool receivePackage(const NetworkPackage& np) override; - void connected() override { } + void connected() override; public Q_SLOTS: - void sendMutePackage(); + Q_SCRIPTABLE void sendSms(const QString& phoneNumber, const QString& messageBody); private Q_SLOTS: - void sendSms(const QString& phoneNumber, const QString& messageBody); + void sendMutePackage(); void showSendSmsDialog(); private: + QString dbusPath() const; KNotification* createNotification(const NetworkPackage& np); QDBusInterface m_telepathyInterface; diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -161,4 +161,14 @@ dialog->show(); } +void TelephonyPlugin::connected() +{ + QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents); +} + +QString TelephonyPlugin::dbusPath() const +{ + return "/modules/kdeconnect/devices/" + device()->id() + "/telephony"; +} + #include "telephonyplugin.moc"