-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
PluginManager.h
71 lines (55 loc) · 2.29 KB
/
PluginManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*---------------------------------------------------------*\
| PluginManager.h |
| |
| OpenRGB plugin manager |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <iostream>
#include <QPluginLoader>
#include <QLabel>
#include <QtPlugin>
#include <QDir>
#include "OpenRGBPluginInterface.h"
typedef struct
{
OpenRGBPluginInfo info;
OpenRGBPluginInterface* plugin;
QPluginLoader* loader;
QWidget* widget;
QMenu* traymenu;
std::string path;
bool enabled;
bool incompatible;
bool is_system;
int api_version;
} OpenRGBPluginEntry;
typedef void (*AddPluginCallback)(void *, OpenRGBPluginEntry* plugin);
typedef void (*RemovePluginCallback)(void *, OpenRGBPluginEntry* plugin);
class PluginManager
{
public:
PluginManager();
void RegisterAddPluginCallback(AddPluginCallback new_callback, void * new_callback_arg);
void RegisterRemovePluginCallback(RemovePluginCallback new_callback, void * new_callback_arg);
void ScanAndLoadPlugins();
void AddPlugin(const filesystem::path& path, bool is_system);
void RemovePlugin(const filesystem::path& path);
void EnablePlugin(const filesystem::path& path);
void DisablePlugin(const filesystem::path& path);
void LoadPlugins();
void UnloadPlugins();
std::vector<OpenRGBPluginEntry> ActivePlugins;
private:
void LoadPlugin(OpenRGBPluginEntry* plugin_entry);
void UnloadPlugin(OpenRGBPluginEntry* plugin_entry);
void ScanAndLoadPluginsFrom(const filesystem::path & plugins_dir, bool is_system);
AddPluginCallback AddPluginCallbackVal;
void * AddPluginCallbackArg;
RemovePluginCallback RemovePluginCallbackVal;
void * RemovePluginCallbackArg;
const char * plugins_path = "plugins/";
};