summaryrefslogtreecommitdiff
path: root/testnotification
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-11 15:30:38 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-11 15:30:38 +0200
commit51701e30d710ad016ddf2d306cdd7be122ddf25b (patch)
treed4a85bd4926c3f94411d3f6fa572e1a99be6bbb4 /testnotification
parentf0564ad9d210cc68bfb1bfc6e56b86fa941ad830 (diff)
downloadsowatch-51701e30d710ad016ddf2d306cdd7be122ddf25b.tar.gz
sowatch-51701e30d710ad016ddf2d306cdd7be122ddf25b.zip
adding test notification backend
Diffstat (limited to 'testnotification')
-rw-r--r--testnotification/testnotification.cpp48
-rw-r--r--testnotification/testnotification.h34
-rw-r--r--testnotification/testnotification.pro25
-rw-r--r--testnotification/testnotificationplugin.cpp39
-rw-r--r--testnotification/testnotificationplugin.h25
-rw-r--r--testnotification/testnotificationprovider.cpp34
-rw-r--r--testnotification/testnotificationprovider.h29
7 files changed, 234 insertions, 0 deletions
diff --git a/testnotification/testnotification.cpp b/testnotification/testnotification.cpp
new file mode 100644
index 0000000..fa904b9
--- /dev/null
+++ b/testnotification/testnotification.cpp
@@ -0,0 +1,48 @@
+#include "testnotification.h"
+
+using namespace sowatch;
+
+TestNotification::TestNotification(Type type, const QString &title, const QString &body, QObject *parent)
+ : Notification(parent),
+ _type(type),
+ _time(QDateTime::currentDateTime()),
+ _title(title), _body(body)
+{
+}
+
+Notification::Type TestNotification::type() const
+{
+ return _type;
+}
+
+uint TestNotification::count() const
+{
+ return 1;
+}
+
+QDateTime TestNotification::dateTime() const
+{
+ return _time;
+}
+
+QString TestNotification::title() const
+{
+ return _title;
+}
+
+QString TestNotification::body() const
+{
+ return _body;
+}
+
+void TestNotification::activate()
+{
+ // Do nothing
+}
+
+void TestNotification::dismiss()
+{
+ deleteLater(); // We do not want to keep those around.
+}
+
+
diff --git a/testnotification/testnotification.h b/testnotification/testnotification.h
new file mode 100644
index 0000000..f54623d
--- /dev/null
+++ b/testnotification/testnotification.h
@@ -0,0 +1,34 @@
+#ifndef TESTNOTIFICATION_H
+#define TESTNOTIFICATION_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class TestNotification : public Notification
+{
+ Q_OBJECT
+
+public:
+ explicit TestNotification(Type type, const QString& title, const QString& body, QObject *parent = 0);
+
+ Type type() const;
+ uint count() const;
+ QDateTime dateTime() const;
+ QString title() const;
+ QString body() const;
+
+ void activate();
+ void dismiss();
+
+private:
+ Type _type;
+ QDateTime _time;
+ QString _title;
+ QString _body;
+};
+
+}
+
+#endif // TESTNOTIFICATION_H
diff --git a/testnotification/testnotification.pro b/testnotification/testnotification.pro
new file mode 100644
index 0000000..525fdac
--- /dev/null
+++ b/testnotification/testnotification.pro
@@ -0,0 +1,25 @@
+TARGET = testnotification
+TEMPLATE = lib
+CONFIG += plugin
+CONFIG += mobility
+MOBILITY += systeminfo
+
+SOURCES += testnotificationplugin.cpp testnotificationprovider.cpp \
+ testnotification.cpp
+
+HEADERS += testnotificationplugin.h testnotificationprovider.h \
+ testnotification.h
+
+unix: LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch
+INCLUDEPATH += $$PWD/../libsowatch
+DEPENDPATH += $$PWD/../libsowatch
+
+unix {
+ !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 {
+ QMAKE_RPATHDIR += /opt/sowatch/lib
+ target.path = /opt/sowatch/lib/notifications
+ } else {
+ target.path = /usr/lib/sowatch/notifications
+ }
+ INSTALLS += target
+}
diff --git a/testnotification/testnotificationplugin.cpp b/testnotification/testnotificationplugin.cpp
new file mode 100644
index 0000000..7e65851
--- /dev/null
+++ b/testnotification/testnotificationplugin.cpp
@@ -0,0 +1,39 @@
+#include "testnotificationprovider.h"
+#include "testnotificationplugin.h"
+
+using namespace sowatch;
+
+static const QLatin1String providerId("testnotification");
+
+TestNotificationPlugin::TestNotificationPlugin(QObject *parent) :
+ QObject(parent)
+{
+}
+
+TestNotificationPlugin::~TestNotificationPlugin()
+{
+}
+
+QStringList TestNotificationPlugin::providers()
+{
+ QStringList providers;
+ providers << providerId;
+ return providers;
+}
+
+NotificationPluginInterface::NotificationProviderInfo TestNotificationPlugin::describeProvider(const QString &driver)
+{
+ NotificationProviderInfo info;
+ if (driver != providerId) return info;
+ info.name = "Test notifications";
+ return info;
+}
+
+NotificationProvider* TestNotificationPlugin::getProvider(const QString& id, ConfigKey *settings, QObject *parent)
+{
+ Q_UNUSED(settings);
+ if (id != providerId) return 0;
+ return new TestNotificationProvider(parent);
+}
+
+Q_EXPORT_PLUGIN2(testnotification, TestNotificationPlugin)
diff --git a/testnotification/testnotificationplugin.h b/testnotification/testnotificationplugin.h
new file mode 100644
index 0000000..03ebb30
--- /dev/null
+++ b/testnotification/testnotificationplugin.h
@@ -0,0 +1,25 @@
+#ifndef TESTNOTIFICATIONPLUGIN_H
+#define TESTNOTIFICATIONPLUGIN_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class TestNotificationPlugin : public QObject, public NotificationPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(sowatch::NotificationPluginInterface)
+
+public:
+ TestNotificationPlugin(QObject *parent = 0);
+ ~TestNotificationPlugin();
+
+ QStringList providers();
+ NotificationProviderInfo describeProvider(const QString &driver);
+ NotificationProvider* getProvider(const QString& driver, ConfigKey *settings, QObject *parent = 0);
+};
+
+}
+
+#endif // TESTNOTIFICATIONPLUGIN_H
diff --git a/testnotification/testnotificationprovider.cpp b/testnotification/testnotificationprovider.cpp
new file mode 100644
index 0000000..960f450
--- /dev/null
+++ b/testnotification/testnotificationprovider.cpp
@@ -0,0 +1,34 @@
+#include "testnotification.h"
+#include "testnotificationprovider.h"
+
+using namespace sowatch;
+
+TestNotificationProvider::TestNotificationProvider(QObject *parent) :
+ NotificationProvider(parent),
+ _timer(new QTimer(this))
+{
+ QTimer::singleShot(15000, this, SLOT(generateInitialNotification()));
+ connect(_timer, SIGNAL(timeout()), SLOT(generateNotification()));
+ _timer->setInterval(60000);
+ _timer->start();
+}
+
+TestNotificationProvider::~TestNotificationProvider()
+{
+}
+
+void TestNotificationProvider::generateInitialNotification()
+{
+ TestNotification *n = new TestNotification(Notification::EmailNotification,
+ "A friend",
+ "This is a test email notification");
+ emit incomingNotification(n);
+}
+
+void TestNotificationProvider::generateNotification()
+{
+ TestNotification *n = new TestNotification(Notification::ImNotification,
+ "A friend",
+ "I will keep talking to you");
+ emit incomingNotification(n);
+}
diff --git a/testnotification/testnotificationprovider.h b/testnotification/testnotificationprovider.h
new file mode 100644
index 0000000..9931ea0
--- /dev/null
+++ b/testnotification/testnotificationprovider.h
@@ -0,0 +1,29 @@
+#ifndef TESTNOTIFICATIONPROVIDER_H
+#define TESTNOTIFICATIONPROVIDER_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class TestNotification;
+
+class TestNotificationProvider : public NotificationProvider
+{
+ Q_OBJECT
+
+public:
+ explicit TestNotificationProvider(QObject *parent = 0);
+ ~TestNotificationProvider();
+
+private slots:
+ void generateInitialNotification();
+ void generateNotification();
+
+private:
+ QTimer *_timer;
+};
+
+}
+
+#endif // TESTNOTIFICATIONPROVIDER_H