LunaHook-mirror/LunaHost/GUI/pluginmanager.h

71 lines
2.0 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;
2024-04-24 09:04:02 +08:00
bool vissetting;
pluginitem(const nlohmann::json&);
pluginitem(const std::wstring&,bool);
std::wstring wpath();
nlohmann::json dump() const;
};
2024-04-24 09:04:02 +08:00
class Pluginmanager;
struct plugindata{
2024-04-23 20:01:57 +08:00
typedef wchar_t* (*OnNewSentence_t)(wchar_t*, const InfoForExtension*);
2024-04-24 09:04:02 +08:00
typedef void (*VisSetting_t)(bool);
std::wstring refpath;
bool isQt;
2024-04-23 20:01:57 +08:00
OnNewSentence_t OnNewSentence;
2024-04-24 09:04:02 +08:00
VisSetting_t VisSetting;
HMODULE hmodule;
2024-04-23 20:01:57 +08:00
void clear();
plugindata(){};
2024-04-24 09:04:02 +08:00
plugindata(const std::wstring&,Pluginmanager*,bool,HMODULE);
bool valid();
void initstatus(const pluginitem&);
};
2024-02-09 09:25:26 +08:00
class Pluginmanager{
std::unordered_map<std::wstring,plugindata>OnNewSentenceS;
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);
2024-04-23 20:01:57 +08:00
addpluginresult addplugin(const std::wstring&);
2024-02-08 19:12:20 +08:00
std::optional<std::wstring>selectpluginfile();
pluginitem get(int);
2024-04-24 09:04:02 +08:00
std::optional<pluginitem> get(const std::wstring&);
std::wstring getname(int);
bool getenable(int);
void set(int,const pluginitem&);
void setenable(int ,bool);
int count();
void add(const pluginitem&);
2024-04-23 20:01:57 +08:00
void remove(const std::wstring&);
void unload(const std::wstring&);
addpluginresult load(const std::wstring&,bool*isqt=0);
void swaprank(int,int);
2024-04-24 09:04:02 +08:00
bool getvisible(int);
bool getvisible_setable(int);
void setvisible(int,bool);
2024-02-08 16:18:33 +08:00
};
2024-02-08 19:12:20 +08:00
#endif