summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-19 01:51:04 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-19 01:51:04 +0200
commit77a98ac21c2520d9fb4bb9c8f70967a8e36dc872 (patch)
tree687d1cc8820296d56e06c8fab3eaf9ef935cba23
parent03af539d69d903dfb5df19b447707a35ebaa4a54 (diff)
downloadsowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.tar.gz
sowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.zip
adding notification provider plugins, idle screen
-rw-r--r--libsowatch/declarativewatchlet.h6
-rw-r--r--libsowatch/declarativewatchwrapper.h6
-rw-r--r--libsowatch/graphicswatchlet.h6
-rw-r--r--libsowatch/libsowatch.pro8
-rw-r--r--libsowatch/notification.h10
-rw-r--r--libsowatch/notificationplugininterface.h17
-rw-r--r--libsowatch/notificationprovider.cpp13
-rw-r--r--libsowatch/notificationprovider.h29
-rw-r--r--libsowatch/sowatch.h13
-rw-r--r--libsowatch/testdeclarativewatchlet.h6
-rw-r--r--libsowatch/testwatchlet.h6
-rw-r--r--libsowatch/watch.h6
-rw-r--r--libsowatch/watchlet.h6
-rw-r--r--libsowatch/watchpaintengine.h6
-rw-r--r--libsowatch/watchplugininterface.h6
-rw-r--r--libsowatch/watchserver.cpp39
-rw-r--r--libsowatch/watchserver.h22
-rw-r--r--libsowatch/watchsimulator.h6
-rw-r--r--meegohandsetnotification/meegohandsetnotification.pro45
-rw-r--r--meegohandsetnotification/meegohandsetnotificationprovider.cpp51
-rw-r--r--meegohandsetnotification/meegohandsetnotificationprovider.h33
-rw-r--r--meegohandsetnotification/meegohandsetplugin.cpp28
-rw-r--r--meegohandsetnotification/meegohandsetplugin.h24
-rw-r--r--meegohandsetnotification/mnotificationmanagerinterface.cpp14
-rw-r--r--meegohandsetnotification/mnotificationmanagerinterface.h56
-rw-r--r--meegohandsetnotification/watchnotificationsink.cpp72
-rw-r--r--meegohandsetnotification/watchnotificationsink.h41
-rw-r--r--metawatch/metawatch.cpp92
-rw-r--r--metawatch/metawatch.h5
-rw-r--r--metawatch/metawatch.pro14
-rw-r--r--metawatch/metawatch_16pt_11pxl.ttfbin0 -> 14576 bytes
-rw-r--r--metawatch/metawatch_8pt_5pxl_CAPS.ttfbin0 -> 12408 bytes
-rw-r--r--metawatch/metawatch_8pt_7pxl_CAPS.ttfbin0 -> 15212 bytes
-rw-r--r--metawatch/metawatchplugin.cpp14
-rw-r--r--metawatch/metawatchplugin.h4
-rw-r--r--metawatch/uires.qrc13
-rw-r--r--metawatch/weather_cloudy.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_rain.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_snow.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_sunny.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_thunderstorm.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_wind.bmpbin0 -> 158 bytes
-rw-r--r--sowatch.pro14
-rw-r--r--sowatch.pro.user28
-rw-r--r--sowatchd/daemon.cpp71
-rw-r--r--sowatchd/daemon.h9
46 files changed, 736 insertions, 103 deletions
diff --git a/libsowatch/declarativewatchlet.h b/libsowatch/declarativewatchlet.h
index ea31a33..2cc4655 100644
--- a/libsowatch/declarativewatchlet.h
+++ b/libsowatch/declarativewatchlet.h
@@ -1,5 +1,5 @@
-#ifndef DECLARATIVEWATCHLET_H
-#define DECLARATIVEWATCHLET_H
+#ifndef SOWATCH_DECLARATIVEWATCHLET_H
+#define SOWATCH_DECLARATIVEWATCHLET_H
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeComponent>
@@ -37,4 +37,4 @@ protected:
}
-#endif // DECLARATIVEWATCHLET_H
+#endif // SOWATCH_DECLARATIVEWATCHLET_H
diff --git a/libsowatch/declarativewatchwrapper.h b/libsowatch/declarativewatchwrapper.h
index 5f78e75..42746ec 100644
--- a/libsowatch/declarativewatchwrapper.h
+++ b/libsowatch/declarativewatchwrapper.h
@@ -1,5 +1,5 @@
-#ifndef DECLARATIVEWATCHWRAPPER_H
-#define DECLARATIVEWATCHWRAPPER_H
+#ifndef SOWATCH_DECLARATIVEWATCHWRAPPER_H
+#define SOWATCH_DECLARATIVEWATCHWRAPPER_H
#include <QtDeclarative/QtDeclarative>
@@ -41,4 +41,4 @@ friend class DeclarativeWatchlet;
QML_DECLARE_TYPE(sowatch::DeclarativeWatchWrapper)
-#endif // DECLARATIVEWATCHWRAPPER_H
+#endif // SOWATCH_DECLARATIVEWATCHWRAPPER_H
diff --git a/libsowatch/graphicswatchlet.h b/libsowatch/graphicswatchlet.h
index d2cbb37..37752a9 100644
--- a/libsowatch/graphicswatchlet.h
+++ b/libsowatch/graphicswatchlet.h
@@ -1,5 +1,5 @@
-#ifndef GRAPHICSWATCHLET_H
-#define GRAPHICSWATCHLET_H
+#ifndef SOWATCH_GRAPHICSWATCHLET_H
+#define SOWATCH_GRAPHICSWATCHLET_H
#include <QtGui/QGraphicsScene>
#include <QtGui/QRegion>
@@ -29,4 +29,4 @@ protected slots:
}
-#endif // GRAPHICSWATCHLET_H
+#endif // SOWATCH_GRAPHICSWATCHLET_H
diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro
index 38d3389..aefdadd 100644
--- a/libsowatch/libsowatch.pro
+++ b/libsowatch/libsowatch.pro
@@ -26,7 +26,8 @@ SOURCES += \
declarativewatchlet.cpp \
watchplugininterface.cpp \
notification.cpp \
- notificationplugininterface.cpp
+ notificationplugininterface.cpp \
+ notificationprovider.cpp
HEADERS +=\
watchsimulator.h \
@@ -43,7 +44,8 @@ HEADERS +=\
sowatch_global.h \
watchplugininterface.h \
notification.h \
- notificationplugininterface.h
+ notificationplugininterface.h \
+ notificationprovider.h
install_headers.files = $$HEADERS
@@ -85,3 +87,5 @@ unix:!symbian {
+
+
diff --git a/libsowatch/notification.h b/libsowatch/notification.h
index 7f463bf..80d7996 100644
--- a/libsowatch/notification.h
+++ b/libsowatch/notification.h
@@ -1,5 +1,5 @@
-#ifndef NOTIFICATION_H
-#define NOTIFICATION_H
+#ifndef SOWATCH_NOTIFICATION_H
+#define SOWATCH_NOTIFICATION_H
#include <QtCore/QString>
#include <QtCore/QDateTime>
@@ -13,10 +13,12 @@ class SOWATCH_EXPORT Notification
public:
enum Type {
OtherNotification = 0,
- EmailNotification,
CallNotification,
+ EmailNotification,
+ MissedCallNotification,
SmsNotification,
ImNotification,
+ CalendarNotification,
TypeCount
};
@@ -37,4 +39,4 @@ protected:
}
-#endif // NOTIFICATION_H
+#endif // SOWATCH_NOTIFICATION_H
diff --git a/libsowatch/notificationplugininterface.h b/libsowatch/notificationplugininterface.h
index 1a312a1..b6c16f7 100644
--- a/libsowatch/notificationplugininterface.h
+++ b/libsowatch/notificationplugininterface.h
@@ -1,29 +1,28 @@
-#ifndef NOTIFICATIONPLUGININTERFACE_H
-#define NOTIFICATIONPLUGININTERFACE_H
+#ifndef SOWATCH_NOTIFICATIONPLUGININTERFACE_H
+#define SOWATCH_NOTIFICATIONPLUGININTERFACE_H
#include <QtPlugin>
+#include <QtCore/QSettings>
+#include <QtCore/QStringList>
#include "sowatch_global.h"
-#include "notification.h"
namespace sowatch
{
class Notification;
+class NotificationProvider;
class SOWATCH_EXPORT NotificationPluginInterface
{
public:
virtual ~NotificationPluginInterface();
- int getCount(Notification::Type type);
-
-signals:
- void incomingNotification(const Notification& n);
- void unreadCountChanged(Notification::Type type);
+ virtual QStringList providers() = 0;
+ virtual NotificationProvider* getProvider(const QString& driver, QSettings& settings, QObject *parent = 0) = 0;
};
}
Q_DECLARE_INTERFACE(sowatch::NotificationPluginInterface, "com.javispedro.sowatch.NotificationPluginInterface")
-#endif // NOTIFICATIONPLUGININTERFACE_H
+#endif // SOWATCH_NOTIFICATIONPLUGININTERFACE_H
diff --git a/libsowatch/notificationprovider.cpp b/libsowatch/notificationprovider.cpp
new file mode 100644
index 0000000..abc8bfc
--- /dev/null
+++ b/libsowatch/notificationprovider.cpp
@@ -0,0 +1,13 @@
+#include "notificationprovider.h"
+
+using namespace sowatch;
+
+NotificationProvider::NotificationProvider(QObject *parent) :
+ QObject(parent)
+{
+}
+
+NotificationProvider::~NotificationProvider()
+{
+
+}
diff --git a/libsowatch/notificationprovider.h b/libsowatch/notificationprovider.h
new file mode 100644
index 0000000..6f31581
--- /dev/null
+++ b/libsowatch/notificationprovider.h
@@ -0,0 +1,29 @@
+#ifndef SOWATCH_NOTIFICATIONPROVIDER_H
+#define SOWATCH_NOTIFICATIONPROVIDER_H
+
+#include <QtCore/QObject>
+#include "notification.h"
+
+namespace sowatch
+{
+
+class NotificationProvider : public QObject
+{
+ Q_OBJECT
+
+protected:
+ explicit NotificationProvider(QObject *parent = 0);
+ virtual ~NotificationProvider();
+
+public:
+ virtual int getCount(Notification::Type type) = 0;
+
+signals:
+ void notification(const Notification& n);
+ void unreadCountChanged(Notification::Type type);
+
+};
+
+}
+
+#endif // SOWATCH_NOTIFICATIONPROVIDER_H
diff --git a/libsowatch/sowatch.h b/libsowatch/sowatch.h
index 8c56954..e294ece 100644
--- a/libsowatch/sowatch.h
+++ b/libsowatch/sowatch.h
@@ -2,13 +2,18 @@
#define SOWATCH_H
#include "sowatch_global.h"
+
#include "watch.h"
-#include "watchlet.h"
-#include "graphicswatchlet.h"
-#include "declarativewatchlet.h"
-#include "notification.h"
#include "watchserver.h"
#include "watchsimulator.h"
#include "watchplugininterface.h"
+#include "notification.h"
+#include "notificationprovider.h"
+#include "notificationplugininterface.h"
+
+#include "watchlet.h"
+#include "graphicswatchlet.h"
+#include "declarativewatchlet.h"
+
#endif // SOWATCH_H
diff --git a/libsowatch/testdeclarativewatchlet.h b/libsowatch/testdeclarativewatchlet.h
index b7b6dcd..a200663 100644
--- a/libsowatch/testdeclarativewatchlet.h
+++ b/libsowatch/testdeclarativewatchlet.h
@@ -1,5 +1,5 @@
-#ifndef TESTDECLARATIVEWATCHLET_H
-#define TESTDECLARATIVEWATCHLET_H
+#ifndef SOWATCH_TESTDECLARATIVEWATCHLET_H
+#define SOWATCH_TESTDECLARATIVEWATCHLET_H
#include "declarativewatchlet.h"
@@ -16,4 +16,4 @@ public:
}
-#endif // TESTDECLARATIVEWATCHLET_H
+#endif // SOWATCH_TESTDECLARATIVEWATCHLET_H
diff --git a/libsowatch/testwatchlet.h b/libsowatch/testwatchlet.h
index caa68da..6556724 100644
--- a/libsowatch/testwatchlet.h
+++ b/libsowatch/testwatchlet.h
@@ -1,5 +1,5 @@
-#ifndef TESTWATCHLET_H
-#define TESTWATCHLET_H
+#ifndef SOWATCH_TESTWATCHLET_H
+#define SOWATCH_TESTWATCHLET_H
#include <QtCore/QTimer>
#include "watchlet.h"
@@ -26,4 +26,4 @@ private:
}
-#endif // TESTWATCHLET_H
+#endif // SOWATCH_TESTWATCHLET_H
diff --git a/libsowatch/watch.h b/libsowatch/watch.h
index 056bfe0..fff4c15 100644
--- a/libsowatch/watch.h
+++ b/libsowatch/watch.h
@@ -1,5 +1,5 @@
-#ifndef WATCH_H
-#define WATCH_H
+#ifndef SOWATCH_WATCH_H
+#define SOWATCH_WATCH_H
#include <QtCore/QObject>
#include <QtCore/QDateTime>
@@ -45,4 +45,4 @@ public slots:
}
-#endif // WATCH_H
+#endif // SOWATCH_WATCH_H
diff --git a/libsowatch/watchlet.h b/libsowatch/watchlet.h
index 06e43a0..7f3413d 100644
--- a/libsowatch/watchlet.h
+++ b/libsowatch/watchlet.h
@@ -1,5 +1,5 @@
-#ifndef WATCHLET_H
-#define WATCHLET_H
+#ifndef SOWATCH_WATCHLET_H
+#define SOWATCH_WATCHLET_H
#include <QtCore/QObject>
#include "sowatch_global.h"
@@ -45,4 +45,4 @@ friend class WatchServer;
}
-#endif // WATCHLET_H
+#endif // SOWATCH_WATCHLET_H
diff --git a/libsowatch/watchpaintengine.h b/libsowatch/watchpaintengine.h
index 14d8f61..74d4e09 100644
--- a/libsowatch/watchpaintengine.h
+++ b/libsowatch/watchpaintengine.h
@@ -1,5 +1,5 @@
-#ifndef WATCHPAINTENGINE_H
-#define WATCHPAINTENGINE_H
+#ifndef SOWATCH_WATCHPAINTENGINE_H
+#define SOWATCH_WATCHPAINTENGINE_H
#include <QtGui/QPaintEngine>
@@ -56,4 +56,4 @@ protected:
}
-#endif // WATCHPAINTENGINE_H
+#endif // SOWATCH_WATCHPAINTENGINE_H
diff --git a/libsowatch/watchplugininterface.h b/libsowatch/watchplugininterface.h
index e360dea..c027c47 100644
--- a/libsowatch/watchplugininterface.h
+++ b/libsowatch/watchplugininterface.h
@@ -1,5 +1,5 @@
-#ifndef WATCHPLUGININTERFACE_H
-#define WATCHPLUGININTERFACE_H
+#ifndef SOWATCH_WATCHPLUGININTERFACE_H
+#define SOWATCH_WATCHPLUGININTERFACE_H
#include <QtPlugin>
#include <QtCore/QSettings>
@@ -24,4 +24,4 @@ public:
Q_DECLARE_INTERFACE(sowatch::WatchPluginInterface, "com.javispedro.sowatch.WatchPluginInterface")
-#endif // WATCHPLUGININTERFACE_H
+#endif // SOWATCH_WATCHPLUGININTERFACE_H
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 5ee8a90..8d00088 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -1,7 +1,11 @@
+#include <QtCore/QDebug>
+
+#include "notificationprovider.h"
#include "watch.h"
#include "watchlet.h"
#include "watchserver.h"
+
using namespace sowatch;
WatchServer::WatchServer(Watch* watch, QObject* parent) :
@@ -16,12 +20,22 @@ Watch* WatchServer::watch()
return _watch;
}
+void WatchServer::addProvider(NotificationProvider *provider)
+{
+ provider->setParent(this);
+
+ connect(provider, SIGNAL(notification(Notification)), SLOT(notificationEmitted(Notification)));
+ connect(provider, SIGNAL(unreadCountChanged(Notification::Type)), SLOT(unreadCountUpdated(Notification::Type)));
+
+ _providers.append(provider);
+}
+
void WatchServer::runWatchlet(const QString& id)
{
if (_currentWatchlet) {
closeWatchlet();
}
- _currentWatchlet = watchlets[id];
+ _currentWatchlet = _watchlets[id];
if (_watch->isConnected()) {
_currentWatchlet->activate();
}
@@ -36,15 +50,10 @@ void WatchServer::closeWatchlet()
_currentWatchlet = 0;
}
-void WatchServer::notification(const Notification &n)
-{
- Q_UNUSED(n);
-}
-
void WatchServer::registerWatchlet(Watchlet *watchlet)
{
Q_ASSERT(watchlet->_server == this);
- watchlets[watchlet->id()] = watchlet;
+ _watchlets[watchlet->id()] = watchlet;
}
void WatchServer::watchConnected()
@@ -60,3 +69,19 @@ void WatchServer::watchDisconnected()
_currentWatchlet->deactivate();
}
}
+
+void WatchServer::notificationEmitted(const Notification &notification)
+{
+ // TODO app loses button focus...
+ _watch->showNotification(notification);
+}
+
+void WatchServer::unreadCountUpdated(Notification::Type type)
+{
+ uint count = 0;
+ foreach(NotificationProvider* provider, _providers)
+ {
+ count += provider->getCount(type);
+ }
+ _watch->updateNotificationCount(type, count);
+}
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index f8bed67..0ca1f4f 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -1,17 +1,19 @@
-#ifndef WATCHSERVER_H
-#define WATCHSERVER_H
+#ifndef SOWATCH_WATCHSERVER_H
+#define SOWATCH_WATCHSERVER_H
#include <QtCore/QObject>
#include <QtCore/QMap>
+#include <QtCore/QSignalMapper>
#include "sowatch_global.h"
+#include "notification.h"
namespace sowatch
{
class Watch;
class Watchlet;
-class Notification;
+class NotificationProvider;
class SOWATCH_EXPORT WatchServer : public QObject
{
@@ -23,29 +25,29 @@ public:
Watch* watch();
+ void addProvider(NotificationProvider* provider);
+
void runWatchlet(const QString& id);
void closeWatchlet();
-signals:
-
-public slots:
- void notification(const Notification& n);
-
protected:
Watch* _watch;
Watchlet* _currentWatchlet;
- QMap<QString, Watchlet*> watchlets;
+ QMap<QString, Watchlet*> _watchlets;
+ QList<NotificationProvider*> _providers;
void registerWatchlet(Watchlet *watchlet);
protected slots:
void watchConnected();
void watchDisconnected();
+ void notificationEmitted(const Notification& notification);
+ void unreadCountUpdated(Notification::Type type);
friend class Watchlet;
};
}
-#endif // WATCHSERVER_H
+#endif // SOWATCH_WATCHSERVER_H
diff --git a/libsowatch/watchsimulator.h b/libsowatch/watchsimulator.h
index aa8586d..c9d69ba 100644
--- a/libsowatch/watchsimulator.h
+++ b/libsowatch/watchsimulator.h
@@ -1,5 +1,5 @@
-#ifndef WATCHSIMULATOR_H
-#define WATCHSIMULATOR_H
+#ifndef SOWATCH_WATCHSIMULATOR_H
+#define SOWATCH_WATCHSIMULATOR_H
#include <QtGui/QImage>
@@ -17,4 +17,4 @@ public:
}
-#endif // WATCHSIMULATOR_H
+#endif // SOWATCH_WATCHSIMULATOR_H
diff --git a/meegohandsetnotification/meegohandsetnotification.pro b/meegohandsetnotification/meegohandsetnotification.pro
new file mode 100644
index 0000000..424eb33
--- /dev/null
+++ b/meegohandsetnotification/meegohandsetnotification.pro
@@ -0,0 +1,45 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-09-18T18:48:13
+#
+#-------------------------------------------------
+
+
+TARGET = meegohandsetnotification
+TEMPLATE = lib
+# CONFIG += plugin # Stupid Qt creator doesn't want to deploy plugins
+QT += dbus
+
+SOURCES += meegohandsetplugin.cpp \
+ meegohandsetnotificationprovider.cpp \
+ watchnotificationsink.cpp \
+ mnotificationmanagerinterface.cpp
+
+HEADERS += meegohandsetplugin.h \
+ meegohandsetnotificationprovider.h \
+ watchnotificationsink.h \
+ mnotificationmanagerinterface.h
+
+CONFIG += notificationsystem
+
+unix: LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch
+
+INCLUDEPATH += $$PWD/../libsowatch
+DEPENDPATH += $$PWD/../libsowatch
+
+unix:!symbian {
+ maemo5 {
+ target.path = /opt/sowatch/notifications
+ } else {
+ target.path = /usr/lib/sowatch/notifications
+ }
+ INSTALLS += target
+}
+
+
+
+
+
+
+
+
diff --git a/meegohandsetnotification/meegohandsetnotificationprovider.cpp b/meegohandsetnotification/meegohandsetnotificationprovider.cpp
new file mode 100644
index 0000000..fc84e46
--- /dev/null
+++ b/meegohandsetnotification/meegohandsetnotificationprovider.cpp
@@ -0,0 +1,51 @@
+#include <QtDBus/QDBusConnection>
+#include <notificationsystem/metatypedeclarations.h>
+#include <notificationsystem/notificationsinkadaptor.h>
+#include "watchnotificationsink.h"
+#include "mnotificationmanagerinterface.h"
+#include "meegohandsetnotificationprovider.h"
+
+using namespace sowatch;
+
+MeegoHandsetNotificationProvider::MeegoHandsetNotificationProvider(QObject *parent) :
+ sowatch::NotificationProvider(parent),
+ _manager(new MNotificationManagerInterface("com.meego.core.MNotificationManager", "/notificationsinkmanager", QDBusConnection::sessionBus(), this)),
+ _sink(new WatchNotificationSink(this))
+{
+ qDBusRegisterMetaType< ::Notification >(); // Avoid a name collision with sowatch::Notification
+ qDBusRegisterMetaType<QList< ::Notification > >();
+ qDBusRegisterMetaType<NotificationGroup>();
+ qDBusRegisterMetaType<QList<NotificationGroup> >();
+ qDBusRegisterMetaType<NotificationParameters>();
+
+ new NotificationSinkAdaptor(_sink);
+ QDBusConnection::sessionBus().registerService("com.javispedro.sowatch.MeegoHandsetNotificationSink");
+ QDBusConnection::sessionBus().registerObject("/meegohandsetnotificationsink", _sink);
+
+ connect(_sink, SIGNAL(incomingNotification(sowatch::Notification)),
+ SLOT(sinkNotification(sowatch::Notification)));
+ connect(_sink, SIGNAL(countsChanged(sowatch::Notification::Type)),
+ SLOT(sinkUnreadCountChanged(sowatch::Notification::Type)));
+
+ _manager->registerSink("com.javispedro.sowatch.MeegoHandsetNotificationSink", "/meegohandsetnotificationsink");
+}
+
+MeegoHandsetNotificationProvider::~MeegoHandsetNotificationProvider()
+{
+
+}
+
+int MeegoHandsetNotificationProvider::getCount(sowatch::Notification::Type type)
+{
+ return _sink->getCount(type);
+}
+
+void MeegoHandsetNotificationProvider::sinkNotification(const Notification &n)
+{
+ emit notification(n);
+}
+
+void MeegoHandsetNotificationProvider::sinkUnreadCountChanged(Notification::Type type)
+{
+ emit unreadCountChanged(type);
+}
diff --git a/meegohandsetnotification/meegohandsetnotificationprovider.h b/meegohandsetnotification/meegohandsetnotificationprovider.h
new file mode 100644
index 0000000..3cf78d3
--- /dev/null
+++ b/meegohandsetnotification/meegohandsetnotificationprovider.h
@@ -0,0 +1,33 @@
+#ifndef MEEGOHANDSETNOTIFICATIONPROVIDER_H
+#define MEEGOHANDSETNOTIFICATIONPROVIDER_H
+
+#include <sowatch.h>
+
+class MNotificationManagerInterface;
+class WatchNotificationSink;
+
+namespace sowatch
+{
+
+class MeegoHandsetNotificationProvider : public NotificationProvider
+{
+ Q_OBJECT
+public:
+ explicit MeegoHandsetNotificationProvider(QObject *parent = 0);
+ ~MeegoHandsetNotificationProvider();
+
+ int getCount(Notification::Type type);
+protected:
+ MNotificationManagerInterface* _manager;
+ WatchNotificationSink* _sink;
+
+protected slots:
+ void sinkNotification(const sowatch::Notification &n);
+ void sinkUnreadCountChanged(sowatch::Notification::Type type);
+
+friend class WatchNoficationSink;
+};
+
+}
+
+#endif // MEEGOHANDSETNOTIFICATIONPROVIDER_H
diff --git a/meegohandsetnotification/meegohandsetplugin.cpp b/meegohandsetnotification/meegohandsetplugin.cpp
new file mode 100644
index 0000000..bac41aa
--- /dev/null
+++ b/meegohandsetnotification/meegohandsetplugin.cpp
@@ -0,0 +1,28 @@
+#include "meegohandsetplugin.h"
+#include "meegohandsetnotificationprovider.h"
+
+using namespace sowatch;
+
+MeegoHandsetPlugin::MeegoHandsetPlugin()
+{
+}
+
+MeegoHandsetPlugin::~MeegoHandsetPlugin()
+{
+}
+
+QStringList MeegoHandsetPlugin::providers()
+{
+ QStringList providers;
+ providers << "meegohandset";
+ return providers;
+}
+
+NotificationProvider* MeegoHandsetPlugin::getProvider(const QString& driver, QSettings& settings, QObject *parent)
+{
+ Q_UNUSED(driver);
+ Q_UNUSED(settings);
+ return new MeegoHandsetNotificationProvider(parent);
+}
+
+Q_EXPORT_PLUGIN2(meegohandsetnotification, MeegoHandsetPlugin)
diff --git a/meegohandsetnotification/meegohandsetplugin.h b/meegohandsetnotification/meegohandsetplugin.h
new file mode 100644
index 0000000..616fb9b
--- /dev/null
+++ b/meegohandsetnotification/meegohandsetplugin.h
@@ -0,0 +1,24 @@
+#ifndef MEEGOHANDSETPLUGIN_H
+#define MEEGOHANDSETPLUGIN_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class MeegoHandsetPlugin : public QObject, public NotificationPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(sowatch::NotificationPluginInterface)
+
+public:
+ MeegoHandsetPlugin();
+ ~MeegoHandsetPlugin();
+
+ QStringList providers();
+ NotificationProvider* getProvider(const QString& driver, QSettings& settings, QObject *parent = 0);
+};
+
+}
+
+#endif // MEEGOHANDSETPLUGIN_H
diff --git a/meegohandsetnotification/mnotificationmanagerinterface.cpp b/meegohandsetnotification/mnotificationmanagerinterface.cpp
new file mode 100644
index 0000000..91adbb4
--- /dev/null
+++ b/meegohandsetnotification/mnotificationmanagerinterface.cpp
@@ -0,0 +1,14 @@
+#include "mnotificationmanagerinterface.h"
+
+/*
+ * Implementation of interface class MNotificationManagerInterface
+ */
+
+MNotificationManagerInterface::MNotificationManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+MNotificationManagerInterface::~MNotificationManagerInterface()
+{
+}
diff --git a/meegohandsetnotification/mnotificationmanagerinterface.h b/meegohandsetnotification/mnotificationmanagerinterface.h
new file mode 100644
index 0000000..d5761c9
--- /dev/null
+++ b/meegohandsetnotification/mnotificationmanagerinterface.h
@@ -0,0 +1,56 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -N -p - dbusinterfacenotificationsink.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef QDBUSXML2CPP_PROXY_1316370481
+#define QDBUSXML2CPP_PROXY_1316370481
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface com.meego.core.MNotificationManager
+ */
+class MNotificationManagerInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "com.meego.core.MNotificationManager"; }
+
+public:
+ MNotificationManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~MNotificationManagerInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> registerSink(const QString &service, const QString &path)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(service) << qVariantFromValue(path);
+ return asyncCallWithArgumentList(QLatin1String("registerSink"), argumentList);
+ }
+
+ inline QDBusPendingReply<> unregisterSink(const QString &service, const QString &path)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(service) << qVariantFromValue(path);
+ return asyncCallWithArgumentList(QLatin1String("unregisterSink"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+#endif
diff --git a/meegohandsetnotification/watchnotificationsink.cpp b/meegohandsetnotification/watchnotificationsink.cpp
new file mode 100644
index 0000000..0d97562
--- /dev/null
+++ b/meegohandsetnotification/watchnotificationsink.cpp
@@ -0,0 +1,72 @@
+#include "meegohandsetnotificationprovider.h"
+#include "watchnotificationsink.h"
+
+WatchNotificationSink::WatchNotificationSink(sowatch::MeegoHandsetNotificationProvider *parent) :
+ NotificationSink(parent), _parent(parent)
+{
+ for (uint i = 0; i < maxTypes; i++) {
+ _counts[i] = 0;
+ }
+}
+
+void WatchNotificationSink::addNotification(const Notification &notification)
+{
+ const NotificationParameters& p = notification.parameters();
+ sowatch::Notification::Type type = notificationTypeFromEventType(p.value("eventType").toString());
+ uint count = p.value("count").toUInt();
+
+ _counts[type] += count;
+ _trackedNotifications[notification.notificationId()] = notification;
+
+ emit countsChanged(type);
+
+ QDateTime dt = QDateTime::fromTime_t(p.value("timestamp").toUInt());
+ QDateTime tenSecondsAgo = QDateTime::currentDateTimeUtc().addSecs(-10);
+ if (dt >= tenSecondsAgo) {
+ // If the notification happened recently, show it.
+ sowatch::Notification n(type, dt, p.value("summary").toString(), p.value("body").toString());
+ emit incomingNotification(n);
+ }
+}
+
+void WatchNotificationSink::removeNotification(uint notificationId)
+{
+ Notification notification = _trackedNotifications[notificationId];
+ const NotificationParameters& p = notification.parameters();
+ sowatch::Notification::Type type = notificationTypeFromEventType(p.value("eventType").toString());
+ uint count = p.value("count").toUInt();
+
+ _counts[type] -= count;
+ _trackedNotifications.remove(notificationId);
+
+ emit countsChanged(type);
+}
+
+void WatchNotificationSink::addGroup(uint groupId, const NotificationParameters &parameters)
+{
+ // We do not care about notification groups
+ Q_UNUSED(groupId);
+ Q_UNUSED(parameters);
+}
+
+void WatchNotificationSink::removeGroup(uint groupId)
+{
+ Q_UNUSED(groupId);
+}
+
+int WatchNotificationSink::getCount(sowatch::Notification::Type type)
+{
+ return _counts[type];
+}
+
+sowatch::Notification::Type WatchNotificationSink::notificationTypeFromEventType(const QString& eventType)
+{
+ if (eventType == "email.arrived")
+ return sowatch::Notification::EmailNotification;
+ else if (eventType == "x-nokia.call.missed")
+ return sowatch::Notification::MissedCallNotification;
+ else if (eventType == "x-nokia.messaging.im")
+ return sowatch::Notification::ImNotification;
+ else
+ return sowatch::Notification::OtherNotification;
+}
diff --git a/meegohandsetnotification/watchnotificationsink.h b/meegohandsetnotification/watchnotificationsink.h
new file mode 100644
index 0000000..dc586a2
--- /dev/null
+++ b/meegohandsetnotification/watchnotificationsink.h
@@ -0,0 +1,41 @@
+#ifndef WATCHNOTIFICATIONSINK_H
+#define WATCHNOTIFICATIONSINK_H
+
+#include <QtCore/QMap>
+#include <sowatch.h>
+#include <notificationsystem/notification.h>
+#include <notificationsystem/notificationsink.h>
+#include <notificationsystem/notificationparameters.h>
+
+namespace sowatch {
+ class MeegoHandsetNotificationProvider;
+}
+
+class WatchNotificationSink : public NotificationSink
+{
+ Q_OBJECT
+public:
+ explicit WatchNotificationSink(sowatch::MeegoHandsetNotificationProvider* parent);
+
+ void addNotification(const Notification &notification);
+ void removeNotification(uint notificationId);
+
+ void addGroup(uint groupId, const NotificationParameters &parameters);
+ void removeGroup(uint groupId);
+
+ int getCount(sowatch::Notification::Type type);
+
+signals:
+ void incomingNotification(const sowatch::Notification& notification);
+ void countsChanged(sowatch::Notification::Type type);
+
+protected:
+ static const uint maxTypes = sowatch::Notification::TypeCount;
+ static sowatch::Notification::Type notificationTypeFromEventType(const QString& eventType);
+
+ sowatch::MeegoHandsetNotificationProvider* _parent;
+ QMap<uint, Notification> _trackedNotifications;
+ uint _counts[maxTypes];
+};
+
+#endif // WATCHNOTIFICATIONSINK_H
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index 08b9890..e6a28f4 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -85,7 +85,8 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QObject *parent) :
_connectAlignedTimer(new QSystemAlignedTimer(this)),
_sendTimer(new QTimer(this)),
_currentMode(IdleMode),
- _paintMode(IdleMode)
+ _paintMode(IdleMode),
+ _nMails(0), _nCalls(0), _nIms(0), _nSms(0)
{
QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB);
baseImage.setColor(0, QColor(Qt::white).rgb());
@@ -191,8 +192,25 @@ void MetaWatch::setDateTime(const QDateTime &dateTime)
void MetaWatch::updateNotificationCount(Notification::Type type, int count)
{
- Q_UNUSED(type);
- Q_UNUSED(count); // TODO
+ switch (type) {
+ case Notification::MissedCallNotification:
+ _nCalls = count;
+ break;
+ case Notification::EmailNotification:
+ _nMails = count;
+ break;
+ case Notification::ImNotification:
+ _nIms = count;
+ break;
+ case Notification::SmsNotification:
+ _nSms = count;
+ break;
+ default:
+ // Ignore
+ break;
+ }
+
+ renderIdleCounts();
}
void MetaWatch::vibrate(bool on)
@@ -202,7 +220,7 @@ void MetaWatch::vibrate(bool on)
void MetaWatch::showNotification(const Notification &n)
{
- Q_UNUSED(n); // TODO
+ qDebug() << "It's time for a notification" << n.title();
}
MetaWatch::Mode MetaWatch::currentMode() const
@@ -248,20 +266,64 @@ void MetaWatch::clear(Mode mode, bool black)
void MetaWatch::renderIdleScreen()
{
_paintMode = IdleMode;
+
+ QFont smallFont("MetaWatch Small caps 8pt", 6);
+ QImage idle_mail(QString(":/metawatch/graphics/idle_gmail.bmp"));
+ QImage idle_call(QString(":/metawatch/graphics/idle_call.bmp"));
+ QImage idle_sms(QString(":/metawatch/graphics/idle_sms.bmp"));
QPainter p(this);
+
p.fillRect(0, 0, screenWidth, screenHeight, Qt::white);
+
p.setPen(QPen(Qt::black, 1.0, Qt::DashLine));
- p.drawLine(0, systemAreaHeight + 2, screenWidth, systemAreaHeight + 2);
- p.drawLine(0, systemAreaHeight * 2 + 3, screenWidth, systemAreaHeight * 2 + 3);
- p.setPen(Qt::black);
- p.drawText(1, systemAreaHeight + 16, "Space Weather!");
- QImage idle_mail(QString(":/metawatch/idle_gmail.bmp"));
- QImage idle_call(QString(":/metawatch/idle_call.bmp"));
- QImage idle_sms(QString(":/metawatch/idle_sms.bmp"));
- p.drawImage(4, systemAreaHeight * 2 + 6, idle_mail);
- p.drawImage(32 + 4, systemAreaHeight * 2 + 6, idle_call);
- p.drawImage(32 * 2 + 4, systemAreaHeight * 2 + 6, idle_sms);
- p.drawText(14, 93, "Too many!");
+ p.drawLine(1, systemAreaHeight + 2, screenWidth - 2, systemAreaHeight + 2);
+ p.drawLine(1, systemAreaHeight * 2 + 3, screenWidth - 2, systemAreaHeight * 2 + 3);
+
+ p.drawImage(3, systemAreaHeight * 2 + 6, idle_mail);
+ p.drawImage(32 + 3, systemAreaHeight * 2 + 6, idle_call);
+ p.drawImage(32 * 2 + 3, systemAreaHeight * 2 + 6, idle_sms);
+
+ p.end();
+ renderIdleWeather();
+ renderIdleCounts();
+ _paintMode = _currentMode;
+}
+
+void MetaWatch::renderIdleWeather()
+{
+ _paintMode = IdleMode;
+ QFont smallFont("MetaWatch Small caps 8pt", 6);
+ QImage rain(QString(":/metawatch/graphics/weather_rain.bmp"));
+ QPainter p(this);
+
+ p.setFont(smallFont);
+ p.drawText(46, systemAreaHeight + 14, "Rain");
+ p.drawImage(screenWidth - 26, systemAreaHeight + 6, rain);
+
+ _paintMode = _currentMode;
+}
+
+void MetaWatch::renderIdleCounts()
+{
+ _paintMode = IdleMode;
+ QFont medFont("MetaWatch Large caps 8pt", 6);
+ QString s;
+ QPainter p(this);
+ QTextOption opt(Qt::AlignCenter);
+ const int y = systemAreaHeight * 2 + 25;
+ const int w = 24;
+ const int h = screenHeight - (y + 1);
+ const int mails = _nMails;
+ const int calls = _nCalls;
+ const int sms = _nSms + _nIms;
+
+ qDebug() << "unread counts" << mails << calls << sms;
+
+ p.setFont(medFont);
+ p.fillRect(QRect(0, y, screenWidth, h), Qt::white);
+ p.drawText(QRect(4, y, w, h), s.sprintf("%d", mails), opt);
+ p.drawText(QRect(32 + 4, y, w, h), s.sprintf("%d", calls), opt);
+ p.drawText(QRect(32 * 2 + 4, y, w, h), s.sprintf("%d", sms), opt);
}
quint16 MetaWatch::calcCrc(const QByteArray &data, int size)
diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h
index 68e24c3..d15054f 100644
--- a/metawatch/metawatch.h
+++ b/metawatch/metawatch.h
@@ -88,6 +88,8 @@ public:
void update(Mode mode, const QList<QRect>& rects = QList<QRect>());
void renderIdleScreen();
+ void renderIdleWeather();
+ void renderIdleCounts();
protected:
mutable MetaWatchPaintEngine* _paintEngine;
@@ -120,6 +122,9 @@ protected:
Mode _paintMode;
quint8 _buttonState;
+ // Notifications: Unread count
+ uint _nMails, _nCalls, _nIms, _nSms;
+
static const quint8 bitRevTable[16];
static const quint16 crcTable[256];
quint16 calcCrc(const QByteArray& data, int size);
diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro
index f4b86f8..9a661ba 100644
--- a/metawatch/metawatch.pro
+++ b/metawatch/metawatch.pro
@@ -32,7 +32,16 @@ RESOURCES += \
OTHER_FILES += \
idle_sms.bmp \
idle_gmail.bmp \
- idle_call.bmp
+ idle_call.bmp \
+ weather_wind.bmp \
+ weather_thunderstorm.bmp \
+ weather_sunny.bmp \
+ weather_snow.bmp \
+ weather_rain.bmp \
+ weather_cloudy.bmp \
+ metawatch_16pt_11pxl.ttf \
+ metawatch_8pt_7pxl_CAPS.ttf \
+ metawatch_8pt_5pxl_CAPS.ttf
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/release/ -lsowatch
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/debug/ -lsowatch
@@ -47,7 +56,7 @@ symbian {
TARGET.UID3 = 0xE4DC26B0
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
- addFiles.sources = metawatch.dll
+ addFiles.sources = metawatchdriver.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}
@@ -60,3 +69,4 @@ unix:!symbian {
}
INSTALLS += target
}
+
diff --git a/metawatch/metawatch_16pt_11pxl.ttf b/metawatch/metawatch_16pt_11pxl.ttf
new file mode 100644
index 0000000..9aeb8b3
--- /dev/null
+++ b/metawatch/metawatch_16pt_11pxl.ttf
Binary files differ
diff --git a/metawatch/metawatch_8pt_5pxl_CAPS.ttf b/metawatch/metawatch_8pt_5pxl_CAPS.ttf
new file mode 100644
index 0000000..a6b8f30
--- /dev/null
+++ b/metawatch/metawatch_8pt_5pxl_CAPS.ttf
Binary files differ
diff --git a/metawatch/metawatch_8pt_7pxl_CAPS.ttf b/metawatch/metawatch_8pt_7pxl_CAPS.ttf
new file mode 100644
index 0000000..72eda9e
--- /dev/null
+++ b/metawatch/metawatch_8pt_7pxl_CAPS.ttf
Binary files differ
diff --git a/metawatch/metawatchplugin.cpp b/metawatch/metawatchplugin.cpp
index e56d6db..751cff9 100644
--- a/metawatch/metawatchplugin.cpp
+++ b/metawatch/metawatchplugin.cpp
@@ -1,3 +1,4 @@
+#include <QtGui/QFontDatabase>
#include <QtConnectivity/QBluetoothAddress>
#include "metawatch.h"
#include "metawatchsimulator.h"
@@ -6,6 +7,19 @@
using namespace sowatch;
QTM_USE_NAMESPACE
+bool MetaWatchPlugin::fontsLoaded = false;
+
+MetaWatchPlugin::MetaWatchPlugin()
+{
+ if (!fontsLoaded) {
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_16pt_11pxl.ttf");
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_8pt_7pxl_CAPS.ttf");
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_8pt_5pxl_CAPS.ttf");
+ // "MetaWatch Large 16pt", "MetaWatch Large caps 8pt", "MetaWatch Small caps 8pt"
+ fontsLoaded = true;
+ }
+}
+
MetaWatchPlugin::~MetaWatchPlugin()
{
diff --git a/metawatch/metawatchplugin.h b/metawatch/metawatchplugin.h
index 9662ec0..57b1029 100644
--- a/metawatch/metawatchplugin.h
+++ b/metawatch/metawatchplugin.h
@@ -11,10 +11,14 @@ class MetaWatchPlugin : public QObject, public WatchPluginInterface {
Q_INTERFACES(sowatch::WatchPluginInterface)
public:
+ MetaWatchPlugin();
~MetaWatchPlugin();
virtual QStringList drivers();
virtual Watch* getWatch(const QString& driver, QSettings& settings, QObject *parent = 0);
+
+protected:
+ static bool fontsLoaded;
};
}
diff --git a/metawatch/uires.qrc b/metawatch/uires.qrc
index 4be7fc8..24d70fb 100644
--- a/metawatch/uires.qrc
+++ b/metawatch/uires.qrc
@@ -1,7 +1,18 @@
<RCC>
- <qresource prefix="/metawatch">
+ <qresource prefix="/metawatch/graphics">
<file>idle_call.bmp</file>
<file>idle_gmail.bmp</file>
<file>idle_sms.bmp</file>
+ <file>weather_cloudy.bmp</file>
+ <file>weather_rain.bmp</file>
+ <file>weather_snow.bmp</file>
+ <file>weather_sunny.bmp</file>
+ <file>weather_thunderstorm.bmp</file>
+ <file>weather_wind.bmp</file>
+ </qresource>
+ <qresource prefix="/metawatch/fonts">
+ <file>metawatch_8pt_5pxl_CAPS.ttf</file>
+ <file>metawatch_8pt_7pxl_CAPS.ttf</file>
+ <file>metawatch_16pt_11pxl.ttf</file>
</qresource>
</RCC>
diff --git a/metawatch/weather_cloudy.bmp b/metawatch/weather_cloudy.bmp
new file mode 100644
index 0000000..506c24a
--- /dev/null
+++ b/metawatch/weather_cloudy.bmp
Binary files differ
diff --git a/metawatch/weather_rain.bmp b/metawatch/weather_rain.bmp
new file mode 100644
index 0000000..fc12c6e
--- /dev/null
+++ b/metawatch/weather_rain.bmp
Binary files differ
diff --git a/metawatch/weather_snow.bmp b/metawatch/weather_snow.bmp
new file mode 100644
index 0000000..d328105
--- /dev/null
+++ b/metawatch/weather_snow.bmp
Binary files differ
diff --git a/metawatch/weather_sunny.bmp b/metawatch/weather_sunny.bmp
new file mode 100644
index 0000000..df9f774
--- /dev/null
+++ b/metawatch/weather_sunny.bmp
Binary files differ
diff --git a/metawatch/weather_thunderstorm.bmp b/metawatch/weather_thunderstorm.bmp
new file mode 100644
index 0000000..f101610
--- /dev/null
+++ b/metawatch/weather_thunderstorm.bmp
Binary files differ
diff --git a/metawatch/weather_wind.bmp b/metawatch/weather_wind.bmp
new file mode 100644
index 0000000..59bd81b
--- /dev/null
+++ b/metawatch/weather_wind.bmp
Binary files differ
diff --git a/sowatch.pro b/sowatch.pro
index 9689ea3..38f2a8c 100644
--- a/sowatch.pro
+++ b/sowatch.pro
@@ -3,6 +3,19 @@ SUBDIRS = libsowatch \
metawatch \
sowatchd
+!isEmpty(MEEGO_VERSION_MAJOR) {
+ SUBDIRS += meegohandsetnotification
+}
+
+unix:!symbian {
+ maemo5 {
+ target.path = /opt/sowatch/notifications
+ } else {
+ target.path = /usr/lib/sowatch/notifications
+ }
+ INSTALLS += target
+}
+
OTHER_FILES += \
qtc_packaging/debian_harmattan/rules \
qtc_packaging/debian_harmattan/README \
@@ -22,3 +35,4 @@ OTHER_FILES += \
+
diff --git a/sowatch.pro.user b/sowatch.pro.user
index 7f97a16..852a8a1 100644
--- a/sowatch.pro.user
+++ b/sowatch.pro.user
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by Qt Creator 2.3.0, 2011-09-18T05:08:05. -->
+<!-- Written by Qt Creator 2.3.0, 2011-09-19T01:50:36. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -227,7 +227,7 @@
<value type="QString"></value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes">
- <value type="QDateTime">2011-09-18T04:20:07</value>
+ <value type="QDateTime">2011-09-18T16:45:58</value>
<value type="QDateTime">2011-09-17T20:53:24</value>
</valuelist>
</valuemap>
@@ -408,11 +408,11 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Harmattan</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Harmattan</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.HarmattanDeviceTarget</value>
- <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
- <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">Qt4ProjectManager.ToolChain.Maemo:/home/javier/opt/QtSDK/Madde/targets/harmattan-nokia-meego-api/bin/gcc.arm-linux-generic-elf-32bit./home/javier/opt/QtSDK/pythongdb/gdb</value>
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">Qt4ProjectManager.ToolChain.Maemo:/home/javier/opt/QtSDK/Madde/targets/harmattan-platform-api/bin/gcc.arm-linux-generic-elf-32bit./home/javier/opt/QtSDK/pythongdb/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
@@ -453,16 +453,16 @@
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MeeGo 1.2 Harmattan API (Qt SDK) Release</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Harmattan Platform API (Qt SDK) Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Harmattan Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/mnt/Fuentes/Javier/Maemo/qt/sowatch-build-harmattan-release</value>
- <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">10</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">12</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
- <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">Qt4ProjectManager.ToolChain.Maemo:/home/javier/opt/QtSDK/Madde/targets/harmattan-nokia-meego-api/bin/gcc.arm-linux-generic-elf-32bit./home/javier/opt/QtSDK/pythongdb/gdb</value>
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">Qt4ProjectManager.ToolChain.Maemo:/home/javier/opt/QtSDK/Madde/targets/harmattan-platform-api/bin/gcc.arm-linux-generic-elf-32bit./home/javier/opt/QtSDK/pythongdb/gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
@@ -503,12 +503,12 @@
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MeeGo 1.2 Harmattan API (Qt SDK) Debug</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Harmattan Platform API (Qt SDK) Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Harmattan Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/mnt/Fuentes/Javier/Maemo/qt/sowatch-build-harmattan-debug</value>
- <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">10</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">12</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
@@ -529,16 +529,20 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">MaemoUploadAndInstallDpkgPackageStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles">
+ <value type="QString">/mnt/Fuentes/Javier/Maemo/qt/sowatch-build-harmattan-debug/sowatch_0.1.1_armel.deb</value>
<value type="QString">/mnt/Fuentes/Javier/Maemo/qt/sowatch-build-harmattan-release/sowatch_0.1.1_armel.deb</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts">
<value type="QString">harm</value>
+ <value type="QString">harm</value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedRemotePaths">
<value type="QString"></value>
+ <value type="QString"></value>
</valuelist>
<valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes">
- <value type="QDateTime">2011-09-18T04:49:50</value>
+ <value type="QDateTime">2011-09-19T01:23:25</value>
+ <value type="QDateTime">2011-09-18T05:14:20</value>
</valuelist>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">3</value>
diff --git a/sowatchd/daemon.cpp b/sowatchd/daemon.cpp
index a2d7b5a..3d9c05c 100644
--- a/sowatchd/daemon.cpp
+++ b/sowatchd/daemon.cpp
@@ -11,14 +11,18 @@ Daemon::Daemon(QObject *parent) :
QObject(parent)
{
loadDrivers();
- loadWatches();
- loadWatchlets();
+ loadProviders();
+ initWatches();
}
void Daemon::loadDrivers()
{
QDir dir(SOWATCH_DRIVERS_DIR);
foreach (QString file, dir.entryList(QDir::Files)) {
+#if defined(Q_OS_UNIX)
+ // Temporary workaround for QtC deploy plugin issues
+ if (!file.endsWith(".so")) continue;
+#endif
QPluginLoader loader(dir.absoluteFilePath(file));
QObject *pluginObj = loader.instance();
if (pluginObj) {
@@ -28,16 +32,50 @@ void Daemon::loadDrivers()
foreach (const QString& driver, drivers) {
_drivers[driver] = plugin;
}
+ } else {
+ qWarning() << "Invalid plugin" << file;
+ loader.unload();
}
} else {
qWarning() << "Invalid plugin" << file;
+ loader.unload();
}
}
qDebug() << "loaded drivers" << _drivers.keys();
}
-void Daemon::loadWatches()
+void Daemon::loadProviders()
+{
+ QDir dir(SOWATCH_NOTIFICATIONS_DIR);
+ foreach (QString file, dir.entryList(QDir::Files)) {
+#if defined(Q_OS_UNIX)
+ // Temporary workaround for QtC deploy plugin issues
+ if (!file.endsWith(".so")) continue;
+#endif
+ QPluginLoader loader(dir.absoluteFilePath(file));
+ QObject *pluginObj = loader.instance();
+ if (pluginObj) {
+ NotificationPluginInterface *plugin = qobject_cast<NotificationPluginInterface*>(pluginObj);
+ if (plugin) {
+ QStringList providers = plugin->providers();
+ foreach (const QString& provider, providers) {
+ _providers[provider] = plugin;
+ }
+ } else {
+ qWarning() << "Invalid plugin" << file;
+ loader.unload();
+ }
+ } else {
+ qWarning() << "Invalid plugin" << file;
+ loader.unload();
+ }
+ }
+
+ qDebug() << "loaded providers" << _providers;
+}
+
+void Daemon::initWatches()
{
QSettings settings;
int size = settings.beginReadArray("watches");
@@ -49,7 +87,7 @@ void Daemon::loadWatches()
if (plugin) {
Watch *watch = plugin->getWatch(driver, settings, this);
if (watch) {
- _watches.append(watch);
+ initWatch(watch, settings);
} else {
qWarning() << "Driver" << driver << "refused to getWatch";
}
@@ -59,7 +97,30 @@ void Daemon::loadWatches()
}
settings.endArray();
- qDebug() << "handling" << _watches.size() << "watches";
+ qDebug() << "handling" << _servers.size() << "watches";
+}
+
+void Daemon::initWatch(Watch* watch, QSettings& settings)
+{
+ int size;
+
+ // Create the server
+ WatchServer* server = new WatchServer(watch, this);
+ _servers.append(server);
+
+ // Initialize providers
+ size = settings.beginReadArray("notifications");
+ for (int i = 0; i < size; i++) {
+ settings.setArrayIndex(i);
+ QString id = settings.value("provider").toString().toLower();
+ NotificationPluginInterface *plugin = _providers[id];
+ if (plugin) {
+ NotificationProvider *provider = plugin->getProvider(id, settings, server);
+ server->addProvider(provider);
+ }
+ }
+
+ settings.endArray();
}
void Daemon::loadWatchlets()
diff --git a/sowatchd/daemon.h b/sowatchd/daemon.h
index 9346a41..607e887 100644
--- a/sowatchd/daemon.h
+++ b/sowatchd/daemon.h
@@ -4,6 +4,7 @@
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QMap>
+#include <QtCore/QSettings>
#include <sowatch.h>
@@ -18,11 +19,15 @@ public:
protected:
QMap<QString, WatchPluginInterface*> _drivers;
- QList<Watch*> _watches;
+ QMap<QString, NotificationPluginInterface*> _providers;
+ QList<WatchServer*> _servers;
void loadDrivers();
- void loadWatches();
+ void loadProviders();
void loadWatchlets();
+
+ void initWatches();
+ void initWatch(Watch* watch, QSettings& settings);
};
}