LunaHook-mirror/LunaHost/GUI/pluginmanager.h

55 lines
1.5 KiB
C
Raw Normal View History

2024-02-08 19:12:20 +08:00
#ifndef LUNA_PLUGINMANAGER_H
#define LUNA_PLUGINMANAGER_H
2024-04-21 17:38:47 +08:00
#include"Plugin/extension.h"
2024-02-08 16:18:33 +08:00
#include"textthread.h"
#include<nlohmann/json.hpp>
2024-02-08 19:12:20 +08:00
class LunaHost;
class confighelper;
2024-03-29 15:57:38 +08:00
enum class addpluginresult{
success,
invaliddll,
isnotaplugins,
dumplicate
};
struct pluginitem{
std::string path;
bool isQt;
bool isref;
bool enable;
pluginitem(const nlohmann::json&);
pluginitem(const std::wstring&,bool);
std::wstring wpath();
nlohmann::json dump() const;
};
struct plugindata{
bool isQt;
LPVOID funcptr;
HMODULE hmodule;
};
2024-02-09 09:25:26 +08:00
class Pluginmanager{
std::unordered_map<std::wstring,plugindata>OnNewSentenceS;
2024-02-09 09:25:26 +08:00
std::optional<LPVOID> checkisvalidplugin(const std::wstring&);
2024-02-08 16:18:33 +08:00
concurrency::reader_writer_lock OnNewSentenceSLock;
2024-03-29 15:57:38 +08:00
bool checkisdump(const std::wstring&);
confighelper* configs;
2024-02-08 19:12:20 +08:00
LunaHost* host;
std::array<InfoForExtension, 20> GetSentenceInfo(TextThread& thread);
2024-02-09 09:25:26 +08:00
void loadqtdlls(std::vector<std::wstring>&collectQtplugs);
2024-02-08 16:18:33 +08:00
public:
2024-02-09 09:25:26 +08:00
Pluginmanager(LunaHost*);
2024-02-08 19:12:20 +08:00
bool dispatch(TextThread&, std::wstring& sentence);
addpluginresult addplugin(const std::wstring&,bool onlyload=false);
2024-02-08 19:12:20 +08:00
std::optional<std::wstring>selectpluginfile();
pluginitem get(int);
std::wstring getname(int);
bool getenable(int);
void set(int,const pluginitem&);
void setenable(int ,bool);
int count();
void add(const pluginitem&);
void remove(const std::wstring&,bool);
void swaprank(int,int);
2024-02-08 16:18:33 +08:00
};
2024-02-08 19:12:20 +08:00
#endif