diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-19 01:51:04 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2011-09-19 01:51:04 +0200 |
commit | 77a98ac21c2520d9fb4bb9c8f70967a8e36dc872 (patch) | |
tree | 687d1cc8820296d56e06c8fab3eaf9ef935cba23 /libsowatch | |
parent | 03af539d69d903dfb5df19b447707a35ebaa4a54 (diff) | |
download | sowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.tar.gz sowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.zip |
adding notification provider plugins, idle screen
Diffstat (limited to 'libsowatch')
-rw-r--r-- | libsowatch/declarativewatchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/declarativewatchwrapper.h | 6 | ||||
-rw-r--r-- | libsowatch/graphicswatchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/libsowatch.pro | 8 | ||||
-rw-r--r-- | libsowatch/notification.h | 10 | ||||
-rw-r--r-- | libsowatch/notificationplugininterface.h | 17 | ||||
-rw-r--r-- | libsowatch/notificationprovider.cpp | 13 | ||||
-rw-r--r-- | libsowatch/notificationprovider.h | 29 | ||||
-rw-r--r-- | libsowatch/sowatch.h | 13 | ||||
-rw-r--r-- | libsowatch/testdeclarativewatchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/testwatchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/watch.h | 6 | ||||
-rw-r--r-- | libsowatch/watchlet.h | 6 | ||||
-rw-r--r-- | libsowatch/watchpaintengine.h | 6 | ||||
-rw-r--r-- | libsowatch/watchplugininterface.h | 6 | ||||
-rw-r--r-- | libsowatch/watchserver.cpp | 39 | ||||
-rw-r--r-- | libsowatch/watchserver.h | 22 | ||||
-rw-r--r-- | libsowatch/watchsimulator.h | 6 |
18 files changed, 145 insertions, 66 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 ¬ification) +{ + // 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 |