Changeset View
Changeset View
Standalone View
Standalone View
plugins/ping/pingplugin.cpp
Show All 39 Lines | |||||
40 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin constructor for device" << device()->name(); | 40 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin constructor for device" << device()->name(); | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | PingPlugin::~PingPlugin() | 43 | PingPlugin::~PingPlugin() | ||
44 | { | 44 | { | ||
45 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name(); | 45 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name(); | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | bool PingPlugin::receivePackage(const NetworkPackage& np) | 48 | bool PingPlugin::receivePacket(const NetworkPacket& np) | ||
49 | { | 49 | { | ||
50 | KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent | 50 | KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent | ||
51 | notification->setIconName(QStringLiteral("dialog-ok")); | 51 | notification->setIconName(QStringLiteral("dialog-ok")); | ||
52 | notification->setComponentName(QStringLiteral("kdeconnect")); | 52 | notification->setComponentName(QStringLiteral("kdeconnect")); | ||
53 | notification->setTitle(device()->name()); | 53 | notification->setTitle(device()->name()); | ||
54 | notification->setText(np.get<QString>(QStringLiteral("message"),i18n("Ping!"))); //This can be a source of spam | 54 | notification->setText(np.get<QString>(QStringLiteral("message"),i18n("Ping!"))); //This can be a source of spam | ||
55 | notification->sendEvent(); | 55 | notification->sendEvent(); | ||
56 | 56 | | |||
57 | return true; | 57 | return true; | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | void PingPlugin::sendPing() | 60 | void PingPlugin::sendPing() | ||
61 | { | 61 | { | ||
62 | NetworkPackage np(PACKAGE_TYPE_PING); | 62 | NetworkPacket np(PACKET_TYPE_PING); | ||
63 | bool success = sendPackage(np); | 63 | bool success = sendPacket(np); | ||
64 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | 64 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | void PingPlugin::sendPing(const QString& customMessage) | 67 | void PingPlugin::sendPing(const QString& customMessage) | ||
68 | { | 68 | { | ||
69 | NetworkPackage np(PACKAGE_TYPE_PING); | 69 | NetworkPacket np(PACKET_TYPE_PING); | ||
70 | if (!customMessage.isEmpty()) { | 70 | if (!customMessage.isEmpty()) { | ||
71 | np.set(QStringLiteral("message"), customMessage); | 71 | np.set(QStringLiteral("message"), customMessage); | ||
72 | } | 72 | } | ||
73 | bool success = sendPackage(np); | 73 | bool success = sendPacket(np); | ||
74 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | 74 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | QString PingPlugin::dbusPath() const | 77 | QString PingPlugin::dbusPath() const | ||
78 | { | 78 | { | ||
79 | return "/modules/kdeconnect/devices/" + device()->id() + "/ping"; | 79 | return "/modules/kdeconnect/devices/" + device()->id() + "/ping"; | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | #include "pingplugin.moc" | 82 | #include "pingplugin.moc" | ||
83 | 83 | |