summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-09 16:38:56 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-09 16:38:56 +0200
commitc7c6a2c596637fd4942c7fb80341ca2ef7b47808 (patch)
tree0d4196fa95444dd7e14fbaed61299454609d4762 /libsowatch
parent406332eb6b3199d19388f359d04c9f184e6082b5 (diff)
downloadsowatch-c7c6a2c596637fd4942c7fb80341ca2ef7b47808.tar.gz
sowatch-c7c6a2c596637fd4942c7fb80341ca2ef7b47808.zip
moving scanner logic to ui, new icon
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/allwatchscanner.cpp40
-rw-r--r--libsowatch/allwatchscanner.h29
-rw-r--r--libsowatch/libsowatch.pro2
-rw-r--r--libsowatch/sowatch.h1
4 files changed, 72 insertions, 0 deletions
diff --git a/libsowatch/allwatchscanner.cpp b/libsowatch/allwatchscanner.cpp
new file mode 100644
index 0000000..8a49b86
--- /dev/null
+++ b/libsowatch/allwatchscanner.cpp
@@ -0,0 +1,40 @@
+#include "allwatchscanner.h"
+
+using namespace sowatch;
+
+AllWatchScanner::AllWatchScanner(QObject *parent) :
+ WatchScanner(parent), _finishedCount(0)
+{
+ QList<WatchPluginInterface*> plugins = Registry::registry()->getWatchPlugins();
+ foreach (WatchPluginInterface* driver, plugins) {
+ WatchScanner* scanner = driver->getScanner(this);
+ if (scanner) {
+ _scanners += scanner;
+ connect(scanner, SIGNAL(finished()), this, SLOT(handleFinished()));
+ connect(scanner, SIGNAL(watchFound(QVariantMap)),
+ this, SIGNAL(watchFound(QVariantMap)));
+ }
+ }
+}
+
+void AllWatchScanner::start()
+{
+ if (_scanners.empty()) {
+ emit finished();
+ } else {
+ foreach (WatchScanner* scanner, _scanners) {
+ scanner->start();
+ }
+ emit started();
+ }
+}
+
+void AllWatchScanner::handleFinished()
+{
+ qDebug() << "one finished";
+ _finishedCount++;
+ if (_finishedCount >= _scanners.length()) {
+ qDebug() << "all finished";
+ emit finished();
+ }
+}
diff --git a/libsowatch/allwatchscanner.h b/libsowatch/allwatchscanner.h
new file mode 100644
index 0000000..ac0baae
--- /dev/null
+++ b/libsowatch/allwatchscanner.h
@@ -0,0 +1,29 @@
+#ifndef SOWATCH_ALLWATCHSCANNER_H
+#define SOWATCH_ALLWATCHSCANNER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QList>
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class AllWatchScanner : public WatchScanner
+{
+ Q_OBJECT
+public:
+ explicit AllWatchScanner(QObject *parent = 0);
+ void start();
+
+private:
+ QList<WatchScanner*> _scanners;
+ int _finishedCount;
+
+private slots:
+ void handleFinished();
+};
+
+}
+
+#endif // SOWATCH_ALLWATCHSCANNER_H
diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro
index 7a5b8eb..1057a87 100644
--- a/libsowatch/libsowatch.pro
+++ b/libsowatch/libsowatch.pro
@@ -32,6 +32,7 @@ SOURCES += \
watchletplugininterface.cpp \
registry.cpp \
watchscanner.cpp \
+ allwatchscanner.cpp \
configkey.cpp \
gconfkey.cpp
@@ -54,6 +55,7 @@ HEADERS += \
watchletplugininterface.h \
registry.h \
watchscanner.h \
+ allwatchscanner.h \
configkey.h \
gconfkey.h
diff --git a/libsowatch/sowatch.h b/libsowatch/sowatch.h
index efc5ee8..921e69c 100644
--- a/libsowatch/sowatch.h
+++ b/libsowatch/sowatch.h
@@ -23,5 +23,6 @@
#include "watchletplugininterface.h"
#include "registry.h"
+#include "allwatchscanner.h"
#endif // SOWATCH_H