From 2b4e878938215ac743bdc36deace4c2a4cb0c7a2 Mon Sep 17 00:00:00 2001
From: "Javier S. Pedro" <maemo@javispedro.com>
Date: Sun, 25 Sep 2011 01:36:10 +0200
Subject: preparing for watchlet support

---
 sowatchd/daemon.cpp | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

(limited to 'sowatchd')

diff --git a/sowatchd/daemon.cpp b/sowatchd/daemon.cpp
index 645ecf6..26cbad0 100644
--- a/sowatchd/daemon.cpp
+++ b/sowatchd/daemon.cpp
@@ -3,6 +3,7 @@
 #include <QtCore/QSettings>
 #include <QtCore/QDir>
 #include <sowatch.h>
+#include <testwatchlet.h>
 #include "daemon.h"
 
 using namespace sowatch;
@@ -108,6 +109,9 @@ void Daemon::initWatch(Watch* watch, QSettings& settings)
 	WatchServer* server = new WatchServer(watch, this);
 	_servers.append(server);
 
+	// Configure the server
+	server->setNextWatchletButton(settings.value("nextWatchletButton").toString());
+
 	// Initialize providers
 	size = settings.beginReadArray("notifications");
 	for (int i = 0; i < size; i++) {
@@ -120,25 +124,40 @@ void Daemon::initWatch(Watch* watch, QSettings& settings)
 		}
 	}
 
+	// Initialize test watchlets
+	new TestWatchlet(server);
+
 	settings.endArray();
 }
 
 void Daemon::loadWatchlets()
 {
-#if 0
 	QDir dir(SOWATCH_WATCHLETS_DIR);
 	foreach (QString file, dir.entryList(QDir::Files)) {
+#if defined(Q_OS_UNIX)
+		// Temporary workaround for QtC deploy plugin issues
+		if (!file.endsWith(".so")) continue;
+#endif
 		QPluginLoader loader(dir.absoluteFilePath(file));
 		QObject *pluginObj = loader.instance();
 		if (pluginObj) {
-			WatchPluginInterface *plugin = qobject_cast<WatchPluginInterface*>(pluginObj);
+#if 0
+			WatchletPluginInterface *plugin = qobject_cast<WatchletPluginInterface*>(pluginObj);
 			if (plugin) {
-				QStringList drivers = plugin->drivers();
-				foreach (const QString& driver, drivers) {
-					_drivers[driver] = plugin;
+				QStringList providers = plugin->providers();
+				foreach (const QString& provider, providers) {
+					_providers[provider] = plugin;
 				}
+			} else {
+				qWarning() << "Invalid plugin" << file;
+				loader.unload();
 			}
+#endif
+		} else {
+			qWarning() << "Invalid plugin" << file << loader.errorString();
+			loader.unload();
 		}
 	}
-#endif
+
+	qDebug() << "loaded watchlets";
 }
-- 
cgit v1.2.3