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"
|
2024-03-29 18:07:15 +08:00
|
|
|
#include<nlohmann/json.hpp>
|
2024-02-08 19:12:20 +08:00
|
|
|
class LunaHost;
|
2024-03-29 18:07:15 +08:00
|
|
|
class confighelper;
|
2024-03-29 15:57:38 +08:00
|
|
|
enum class addpluginresult{
|
|
|
|
success,
|
|
|
|
invaliddll,
|
|
|
|
isnotaplugins,
|
|
|
|
dumplicate
|
|
|
|
};
|
2024-03-29 18:07:15 +08:00
|
|
|
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;
|
|
|
|
};
|
2024-03-30 00:40:49 +08:00
|
|
|
struct plugindata{
|
|
|
|
bool isQt;
|
|
|
|
LPVOID funcptr;
|
|
|
|
HMODULE hmodule;
|
|
|
|
};
|
2024-02-09 09:25:26 +08:00
|
|
|
class Pluginmanager{
|
2024-03-30 00:40:49 +08:00
|
|
|
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&);
|
2024-03-29 18:07:15 +08:00
|
|
|
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-03-30 00:40:49 +08:00
|
|
|
addpluginresult addplugin(const std::wstring&,bool onlyload=false);
|
2024-02-08 19:12:20 +08:00
|
|
|
std::optional<std::wstring>selectpluginfile();
|
2024-03-29 18:07:15 +08:00
|
|
|
|
|
|
|
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&);
|
2024-03-30 00:40:49 +08:00
|
|
|
void remove(const std::wstring&,bool);
|
2024-03-29 18:07:15 +08:00
|
|
|
void swaprank(int,int);
|
2024-02-08 16:18:33 +08:00
|
|
|
};
|
|
|
|
|
2024-02-08 19:12:20 +08:00
|
|
|
#endif
|