summaryrefslogtreecommitdiff
path: root/libsowatch/registry.h
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/registry.h')
-rw-r--r--libsowatch/registry.h52
1 files changed, 45 insertions, 7 deletions
diff --git a/libsowatch/registry.h b/libsowatch/registry.h
index ca7252a..74e9388 100644
--- a/libsowatch/registry.h
+++ b/libsowatch/registry.h
@@ -1,8 +1,10 @@
#ifndef SOWATCH_REGISTRY_H
#define SOWATCH_REGISTRY_H
+#include <QtCore/QPluginLoader>
#include <QtCore/QString>
#include <QtCore/QMap>
+#include <QtCore/QFileSystemWatcher>
#include "sowatch_global.h"
namespace sowatch
@@ -12,21 +14,35 @@ class WatchPluginInterface;
class NotificationPluginInterface;
class WatchletPluginInterface;
-class SOWATCH_EXPORT Registry
+class SOWATCH_EXPORT Registry : public QObject
{
+ Q_OBJECT
+
public:
static Registry* registry();
+ inline QList<WatchPluginInterface*> getWatchPlugins() {
+ return _drivers;
+ }
+
+ inline QList<NotificationPluginInterface*> getNotificationPlugins() {
+ return _providers;
+ }
+
+ inline QList<WatchletPluginInterface*> getWatchletPlugins() {
+ return _watchlets;
+ }
+
inline WatchPluginInterface* getWatchPlugin(const QString& id) {
- return _drivers.value(id, 0);
+ return _driverIds.value(id, 0);
}
inline NotificationPluginInterface* getNotificationPlugin(const QString& id) {
- return _providers.value(id, 0);
+ return _providerIds.value(id, 0);
}
inline WatchletPluginInterface* getWatchletPlugin(const QString& id) {
- return _watchlets.value(id, 0);
+ return _watchletIds.value(id, 0);
}
protected:
@@ -36,13 +52,35 @@ protected:
private:
static Registry* singleRegistry;
- QMap<QString, WatchPluginInterface*> _drivers;
- QMap<QString, NotificationPluginInterface*> _providers;
- QMap<QString, WatchletPluginInterface*> _watchlets;
+ QFileSystemWatcher* _watcher;
+
+ QList<WatchPluginInterface*> _drivers;
+ QList<NotificationPluginInterface*> _providers;
+ QList<WatchletPluginInterface*> _watchlets;
+
+ QMap<QString, QPluginLoader*> _driverFiles;
+ QMap<QString, QPluginLoader*> _providerFiles;
+ QMap<QString, QPluginLoader*> _watchletFiles;
+
+ QMap<QString, WatchPluginInterface*> _driverIds;
+ QMap<QString, NotificationPluginInterface*> _providerIds;
+ QMap<QString, WatchletPluginInterface*> _watchletIds;
void loadDrivers();
void loadNotificationProviders();
void loadWatchlets();
+
+ void loadDriver(const QString& file);
+ void loadNotificationProvider(const QString& file);
+ void loadWatchlet(const QString& file);
+
+ void unloadDriver(QPluginLoader* loader);
+ void unloadNotificationProvider(QPluginLoader* loader);
+ void unloadWatchlet(QPluginLoader* loader);
+
+private slots:
+ void handlePluginDirectoryChanged(const QString& path);
+ void handlePluginFileChanged(const QString& file);
};
}