Makes it possible to send sms from kdeconnect-cli
Summary: Introduces --send-sms and --destination Test Plan: Sent an sms to Albert Vaca Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Differential Revision: https://phabricator.kde.org/D3252
This commit is contained in:
parent
760c2a8a7e
commit
7d88340da7
3 changed files with 26 additions and 3 deletions
|
@ -59,6 +59,8 @@ int main(int argc, char** argv)
|
|||
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 @@ int main(int argc, char** argv)
|
|||
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 <phone number>");
|
||||
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);
|
||||
|
|
|
@ -161,4 +161,14 @@ void TelephonyPlugin::showSendSmsDialog()
|
|||
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"
|
||||
|
|
|
@ -37,21 +37,23 @@ class TelephonyPlugin
|
|||
: 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;
|
||||
|
|
Loading…
Reference in a new issue