summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
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 /libsowatch/watchserver.cpp
parent03af539d69d903dfb5df19b447707a35ebaa4a54 (diff)
downloadsowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.tar.gz
sowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.zip
adding notification provider plugins, idle screen
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp39
1 files changed, 32 insertions, 7 deletions
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);
+}