use debian native versioning
[simple-xmbc-rem] / src / genericnotify.cpp
1 #ifdef Q_WS_MAEMO_5
2 #include <QMaemo5InformationBox>
3 #else
4 #include <libnotify/notify.h>
5 #endif
6
7 #include "genericnotify.h"
8 #include "constants.h"
9 #include <QSettings>
10
11 void notify::init()
12 {
13 #ifdef Q_WS_MAEMO_5
14 #else
15     /* Init libnotify library */
16     notify_init(APPLICATION_NAME);
17 #endif
18 }
19
20 void notify::notify(const QString& msg)
21 {
22 #ifdef Q_WS_MAEMO_5
23     QMaemo5InformationBox::information (0, msg);
24 #else
25     /* Create notification */
26     NotifyNotification *notification = notify_notification_new(APPLICATION_NAME, qPrintable(msg), 0, 0);
27     if (notification) {
28         QSettings settings;
29         int timeout = settings.value(SETUP_NOTIFICATION_TIMEOUT, SETUP_NOTIFICATION_TIMEOUT_DEFAULT).toInt();
30
31         /* Set timeout */
32         notify_notification_set_timeout(notification, timeout);
33
34         /* Schedule notification for showing */
35         if (!notify_notification_show(notification, NULL)) {
36             qDebug("Failed to send notification");
37         }
38
39         /* Clean up the memory */
40         g_object_unref(notification);
41     }
42 #endif
43     qDebug(qPrintable(msg));
44 }