diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-25 04:53:46 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2011-09-25 04:53:46 +0200 |
commit | cf5d24b94d96b722c6d76c2225293a56a50d3c2b (patch) | |
tree | fece0c539fe4c40e1faae109f53c46ddc5b0d222 /sowatchd | |
parent | 2b4e878938215ac743bdc36deace4c2a4cb0c7a2 (diff) | |
download | sowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.tar.gz sowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.zip |
watchlets working!
Diffstat (limited to 'sowatchd')
-rw-r--r-- | sowatchd/daemon.cpp | 31 | ||||
-rw-r--r-- | sowatchd/daemon.h | 1 |
2 files changed, 22 insertions, 10 deletions
diff --git a/sowatchd/daemon.cpp b/sowatchd/daemon.cpp index 26cbad0..0cc6c05 100644 --- a/sowatchd/daemon.cpp +++ b/sowatchd/daemon.cpp @@ -3,7 +3,6 @@ #include <QtCore/QSettings> #include <QtCore/QDir> #include <sowatch.h> -#include <testwatchlet.h> #include "daemon.h" using namespace sowatch; @@ -13,6 +12,7 @@ Daemon::Daemon(QObject *parent) : { loadDrivers(); loadProviders(); + loadWatchlets(); initWatches(); } @@ -121,12 +121,25 @@ void Daemon::initWatch(Watch* watch, QSettings& settings) if (plugin) { NotificationProvider *provider = plugin->getProvider(id, settings, server); server->addProvider(provider); + } else { + qWarning() << "Unknown notification provider" << id; } } + settings.endArray(); - // Initialize test watchlets - new TestWatchlet(server); - + // Initialize watchlets + size = settings.beginReadArray("watchlets"); + for (int i = 0; i < size; i++) { + settings.setArrayIndex(i); + QString id = settings.value("id").toString().toLower(); + WatchletPluginInterface *plugin = _watchlets[id]; + if (plugin) { + plugin->getWatchlet(id, settings, server); + // Watchlets are associated to server via parent-child relationship. + } else { + qWarning() << "Unknown watchlet" << id; + } + } settings.endArray(); } @@ -141,23 +154,21 @@ void Daemon::loadWatchlets() QPluginLoader loader(dir.absoluteFilePath(file)); QObject *pluginObj = loader.instance(); if (pluginObj) { -#if 0 WatchletPluginInterface *plugin = qobject_cast<WatchletPluginInterface*>(pluginObj); if (plugin) { - QStringList providers = plugin->providers(); - foreach (const QString& provider, providers) { - _providers[provider] = plugin; + QStringList watchlets = plugin->watchlets(); + foreach (const QString& watchlet, watchlets) { + _watchlets[watchlet] = plugin; } } else { qWarning() << "Invalid plugin" << file; loader.unload(); } -#endif } else { qWarning() << "Invalid plugin" << file << loader.errorString(); loader.unload(); } } - qDebug() << "loaded watchlets"; + qDebug() << "loaded watchlets" << _watchlets.keys(); } diff --git a/sowatchd/daemon.h b/sowatchd/daemon.h index 607e887..8885d6f 100644 --- a/sowatchd/daemon.h +++ b/sowatchd/daemon.h @@ -20,6 +20,7 @@ public: protected: QMap<QString, WatchPluginInterface*> _drivers; QMap<QString, NotificationPluginInterface*> _providers; + QMap<QString, WatchletPluginInterface*> _watchlets; QList<WatchServer*> _servers; void loadDrivers(); |