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

Customizable ping messages.

parent 2cffbedc
......@@ -37,14 +37,15 @@ int main(int argc, char** argv)
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("l")
.add("list-devices", ki18n("List all devices"));
.add("list-devices", ki18n("List all devices."));
options.add("refresh", ki18n("Search for devices in the network and re-establish connections."));
options.add("pair", ki18n("Request pairing to a said device"));
options.add("unpair", ki18n("Stop pairing to a said device"));
options.add("ping", ki18n("Sends a ping to said device"));
options.add("share <path>", ki18n("Share a file to a said device"));
options.add("list-notifications", ki18n("Display the notifications on a said device"));
options.add("device <dev>", ki18n("Device ID"));
options.add("pair", ki18n("Request pairing to a said device."));
options.add("unpair", ki18n("Stop pairing to a said device."));
options.add("ping", ki18n("Send a ping to said device."));
options.add("ping-msg <message>", ki18n("Same as ping but you can customize the shown message."));
options.add("share <path>", ki18n("Share a file to a said device."));
options.add("list-notifications", ki18n("Display the notifications on a said device."));
options.add("device <dev>", ki18n("Device ID."));
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
KApplication app;
......@@ -103,8 +104,12 @@ int main(int argc, char** argv)
QDBusPendingReply<void> req = dev.unpair();
req.waitForFinished();
}
} else if(args->isSet("ping")) {
} else if(args->isSet("ping") || args->isSet("ping-msg")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/ping", "org.kde.kdeconnect.device.ping", "sendPing");
if (args->isSet("ping-msg")) {
QString message = args->getOption("ping-msg");
msg.setArguments(QVariantList() << message);
}
QDBusConnection::sessionBus().call(msg);
} else if(args->isSet("list-notifications")) {
NotificationsModel notifications;
......
......@@ -52,7 +52,6 @@ bool PingPlugin::receivePackage(const NetworkPackage& np)
notification->sendEvent();
return true;
}
void PingPlugin::sendPing()
......@@ -62,6 +61,16 @@ void PingPlugin::sendPing()
kDebug(debugArea()) << "sendPing:" << success;
}
void PingPlugin::sendPing(const QString& customMessage)
{
NetworkPackage np(PACKAGE_TYPE_PING);
if (!customMessage.isEmpty()) {
np.set("message", customMessage);
}
bool success = sendPackage(np);
kDebug(debugArea()) << "sendPing:" << success;
}
void PingPlugin::connected()
{
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
......
......@@ -36,6 +36,7 @@ public:
virtual ~PingPlugin();
Q_SCRIPTABLE void sendPing();
Q_SCRIPTABLE void sendPing(const QString& customMessage);
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment