From 93f3acd128d6b349efe14e97b12c2703ca4f81f3 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 26 Apr 2012 01:36:20 +0200 Subject: Moved the core framework to GConf & D-Bus --- libsowatch/watchserver.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'libsowatch/watchserver.cpp') 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 WatchServer::liveNotifications() { QList notifications; @@ -67,17 +78,24 @@ QList 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); } } -- cgit v1.2.3