Changeset View
Changeset View
Standalone View
Standalone View
plugins/ping/pingplugin.cpp
Show All 14 Lines | |||||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "pingplugin.h" | 21 | #include "pingplugin.h" | ||
22 | 22 | | |||
23 | #ifdef SAILFISHOS | ||||
24 | #include <notification.h> | ||||
25 | #include <QCoreApplication> | ||||
26 | #else | ||||
23 | #include <KNotification> | 27 | #include <KNotification> | ||
28 | #endif | ||||
24 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
25 | #include <KPluginFactory> | 30 | #include <KPluginFactory> | ||
26 | 31 | | |||
27 | #include <QDebug> | 32 | #include <QDebug> | ||
28 | #include <QDBusConnection> | 33 | #include <QDBusConnection> | ||
29 | #include <QLoggingCategory> | 34 | #include <QLoggingCategory> | ||
30 | 35 | | |||
31 | #include <core/device.h> | 36 | #include <core/device.h> | ||
Show All 10 Lines | |||||
42 | 47 | | |||
43 | PingPlugin::~PingPlugin() | 48 | PingPlugin::~PingPlugin() | ||
44 | { | 49 | { | ||
45 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name(); | 50 | // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name(); | ||
46 | } | 51 | } | ||
47 | 52 | | |||
48 | bool PingPlugin::receivePackage(const NetworkPackage& np) | 53 | bool PingPlugin::receivePackage(const NetworkPackage& np) | ||
49 | { | 54 | { | ||
55 | #ifdef SAILFISHOS | ||||
56 | Notification *notification = new Notification(this); | ||||
57 | | ||||
58 | notification->setAppName(QCoreApplication::applicationName()); | ||||
59 | notification->setPreviewSummary(device()->name()); | ||||
60 | notification->setPreviewBody(np.get<QString>(QStringLiteral("message"),i18n("Ping!"))); | ||||
61 | notification->setIcon("icon-s-alarm"); | ||||
62 | notification->publish(); | ||||
63 | #else | ||||
50 | KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent | 64 | KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent | ||
51 | notification->setIconName(QStringLiteral("dialog-ok")); | 65 | notification->setIconName(QStringLiteral("dialog-ok")); | ||
52 | notification->setComponentName(QStringLiteral("kdeconnect")); | 66 | notification->setComponentName(QStringLiteral("kdeconnect")); | ||
53 | notification->setTitle(device()->name()); | 67 | notification->setTitle(device()->name()); | ||
54 | notification->setText(np.get<QString>(QStringLiteral("message"),i18n("Ping!"))); //This can be a source of spam | 68 | notification->setText(np.get<QString>(QStringLiteral("message"),i18n("Ping!"))); //This can be a source of spam | ||
55 | notification->sendEvent(); | 69 | notification->sendEvent(); | ||
56 | 70 | #endif | |||
57 | return true; | 71 | return true; | ||
58 | } | 72 | } | ||
59 | 73 | | |||
60 | void PingPlugin::sendPing() | 74 | void PingPlugin::sendPing() | ||
61 | { | 75 | { | ||
62 | NetworkPackage np(PACKAGE_TYPE_PING); | 76 | NetworkPackage np(PACKAGE_TYPE_PING); | ||
63 | bool success = sendPackage(np); | 77 | bool success = sendPackage(np); | ||
64 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | 78 | qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; | ||
Show All 19 Lines |