#define SETUP_XBMC_PORT "xbmc/port"
#define SETUP_XBMC_PORT_DEFAULT "9090"
+#define SETUP_NOTIFICATION_TIMEOUT "notification/timeout"
+#define SETUP_NOTIFICATION_TIMEOUT_DEFAULT 3000
+
#endif // SETTINGS_H
--- /dev/null
+#ifdef Q_WS_MAEMO_5
+#include <QMaemo5InformationBox>
+#else
+#include <libnotify/notify.h>
+#endif
+
+#include "genericnotify.h"
+#include "constants.h"
+#include <QSettings>
+
+void notify::init()
+{
+#ifdef Q_WS_MAEMO_5
+#else
+ /* Init libnotify library */
+ notify_init(APPLICATION_NAME);
+#endif
+}
+
+void notify::notify(const QString& msg)
+{
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox::information (0, msg);
+#else
+ /* Create notification */
+ NotifyNotification *notification = notify_notification_new(APPLICATION_NAME, qPrintable(msg), 0, 0);
+ if (notification) {
+ QSettings settings;
+ int timeout = settings.value(SETUP_NOTIFICATION_TIMEOUT, SETUP_NOTIFICATION_TIMEOUT_DEFAULT).toInt();
+
+ /* Set timeout */
+ notify_notification_set_timeout(notification, timeout);
+
+ /* Schedule notification for showing */
+ if (!notify_notification_show(notification, NULL)) {
+ qDebug("Failed to send notification");
+ }
+
+ /* Clean up the memory */
+ g_object_unref(notification);
+ }
+#endif
+ qDebug(qPrintable(msg));
+}
--- /dev/null
+#ifndef GENERIC_NOTIFY_H
+#define GENERIC_NOTIFY_H
+
+#include <QString>
+
+namespace notify
+{
+ void init();
+ void notify(const QString& msg);
+}
+
+#endif // GENERIC_NOTIFY_H
#include "mainwindow.h"
#include "constants.h"
+#include "genericnotify.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
+ notify::init();
+
QApplication app(argc, argv);
app.setOrganizationName(APPLICATION_NAME);
app.setApplicationName(ORGANIZATION_NAME);
#include "xbmc.h"
#include "constants.h"
+#include "genericnotify.h"
#include <QSettings>
#include <QTextStream>
QString msg = stream.readAll();
qDebug("Xbmc::commandActionFinished: %s", qPrintable(msg));
} else {
- qDebug("Xbmc::commandActionFinished: error: %s", qPrintable(reply->errorString()));
+ notify::notify(reply->errorString());
}
reply->deleteLater();
}
# Avoid auto screen rotation
#DEFINES += ORIENTATIONLOCK
+maemo5 {
+ message(Compiling for Maemo)
+ QT += maemo5
+ DEFINES += Q_WS_MAEMO_5
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += gtk+-2.0 libnotify
+}
+
# Needs to be defined for Symbian
DEFINES += NETWORKACCESS
QT += network
SOURCES += main.cpp mainwindow.cpp \
setupdialog.cpp \
- xbmc.cpp
+ xbmc.cpp \
+ genericnotify.cpp
HEADERS += mainwindow.h \
setupdialog.h \
constants.h \
- xbmc.h
+ xbmc.h \
+ genericnotify.h
FORMS += mainwindow.ui \
setupdialog.ui