summaryrefslogtreecommitdiff
path: root/libsowatch/allwatchscanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/allwatchscanner.cpp')
-rw-r--r--libsowatch/allwatchscanner.cpp40
1 files changed, 40 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();
+ }
+}