summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-04-26 01:36:20 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-04-26 01:36:20 +0200
commit93f3acd128d6b349efe14e97b12c2703ca4f81f3 (patch)
tree937f3de2307444f0c28d6d21f26f1580e789b074 /libsowatch/watchserver.cpp
parent1375a26b135547fdd8e07db62acf8116a8482560 (diff)
downloadsowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.tar.gz
sowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.zip
Moved the core framework to GConf & D-Bus
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index da7d282..540eeea 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -56,6 +56,17 @@ void WatchServer::addProvider(NotificationProvider *provider)
connect(provider, SIGNAL(incomingNotification(Notification*)), SLOT(postNotification(Notification*)));
}
+void WatchServer::addWatchlet(Watchlet *watchlet)
+{
+ // A watchlet is best not reparented; just look that the parent is correct
+ Q_ASSERT(watchlet->_server == this);
+ _watchlets.append(watchlet);
+ QString id = watchlet->id();
+ if (!_watchletIds.contains(id)) {
+ _watchletIds[id] = watchlet;
+ }
+}
+
QList<Notification*> WatchServer::liveNotifications()
{
QList<Notification*> notifications;
@@ -67,17 +78,24 @@ QList<Notification*> WatchServer::liveNotifications()
return notifications;
}
-void WatchServer::runWatchlet(const QString& id)
+void WatchServer::runWatchlet(Watchlet *watchlet)
{
+ Q_ASSERT(watchlet->_server == this);
if (_currentWatchlet && _currentWatchletActive) {
deactivateCurrentWatchlet();
}
- _currentWatchlet = _watchlets[id];
+ _currentWatchlet = watchlet;
if (_watch->isConnected()) {
reactivateCurrentWatchlet();
}
}
+void WatchServer::runWatchlet(const QString& id)
+{
+ Q_ASSERT(_watchletIds.contains(id));
+ runWatchlet(_watchletIds[id]);
+}
+
void WatchServer::closeWatchlet()
{
if (_currentWatchlet) {
@@ -91,15 +109,6 @@ void WatchServer::closeWatchlet()
}
}
-void WatchServer::registerWatchlet(Watchlet *watchlet)
-{
- Q_ASSERT(watchlet->_server == this);
- QString id = watchlet->id();
- _watchlets[id] = watchlet;
- _watchletIds.append(id);
-}
-
-
void WatchServer::deactivateCurrentWatchlet()
{
Q_ASSERT(_currentWatchlet != 0);
@@ -123,11 +132,11 @@ void WatchServer::nextWatchlet()
{
qDebug() << "current watchlet index" << _currentWatchletIndex;
_currentWatchletIndex++;
- if (_currentWatchletIndex >= _watchletIds.size() || _currentWatchletIndex < 0) {
+ if (_currentWatchletIndex >= _watchlets.size() || _currentWatchletIndex < 0) {
_currentWatchletIndex = -1;
closeWatchlet();
} else {
- QString watchlet = _watchletIds.at(_currentWatchletIndex);
+ Watchlet* watchlet = _watchlets.at(_currentWatchletIndex);
runWatchlet(watchlet);
}
}