MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / LoadAllPlugins

Method LoadAllPlugins

src/render/plugins/plugin_manager.cpp:39–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 }
38
39 void PluginManager::LoadAllPlugins() {
40 auto base_path = QCoreApplication::applicationDirPath();
41 auto base_data_path = QString::fromStdWString(FolderUtil::GetProgramDataPath());
42 LOGI("plugin base path: {}", base_path.toStdString());
43 LOGI("plugin base data path: {}", base_data_path.toStdString());
44 QDir plugin_dir(base_path + R"(/gr_plugins)");
45 QStringList filters;
46#if WIN32
47 filters << QString("*%1").arg(".dll");
48#else
49 filters << QString("*%1").arg(".so");
50#endif
51 plugin_dir.setNameFilters(filters);
52
53 auto entryInfoList = plugin_dir.entryInfoList();
54 for (const auto &info: entryInfoList) {
55 auto target_plugin_path = base_path + R"(/gr_plugins/)" + info.fileName();
56 LOGI("Will load: {}", target_plugin_path.toStdString());
57
58 //HMODULE module = LoadLibraryW(target_plugin_path.toStdWString().c_str());
59 //auto fn_get_instance = GetProcAddress(module, "GetInstance");
60
61 auto library = new QLibrary(target_plugin_path);
62 if (library->isLoaded()) {
63 LOGW("This plugin: {} was already loaded.", target_plugin_path.toStdString());
64 continue;
65 }
66 library->load();
67 auto fn_get_instance = (FnGetInstance)library->resolve("GetInstance");
68
69 auto func = (FnGetInstance) fn_get_instance;
70 if (func) {
71 auto plugin = (GrPluginInterface*)func();
72 if (plugin) {
73 auto plugin_id = plugin->GetPluginId();
74 if (plugins_.contains(plugin_id)) {
75 LOGE("{} repeated loading.", plugin_id);
76 continue;
77 }
78
79 // create it
80 auto filename = info.fileName();
81 auto param = GrPluginParam {
82 .cluster_ = {
83 {"name", filename.toStdString()},
84 {"base_path", base_path.toStdString()},
85 {"base_data_path", base_data_path.toStdString()},
86 {"capture_audio_device_id", settings_->capture_.capture_audio_device_},
87 {"ws-listen-port", (int64_t)settings_->transmission_.listening_port_},
88 {"udp-listen-port", (int64_t)settings_->transmission_.udp_listen_port_},
89 {"device_id", settings_->device_id_},
90 {"relay_enabled", settings_->relay_enabled_},
91 {"relay_host", settings_->relay_host_},
92 {"relay_port", settings_->relay_port_},
93 {"language", (int64_t)settings_->language_},
94 {"appkey", settings_->appkey_}
95 },
96 };

Callers 1

RunMethod · 0.45

Calls 9

pathMethod · 0.80
AttachNetPluginMethod · 0.80
AttachPluginMethod · 0.80
GetPluginIdMethod · 0.45
OnCreateMethod · 0.45
GetPluginNameMethod · 0.45
IsPluginEnabledMethod · 0.45
GetVersionNameMethod · 0.45
GetPluginTypeMethod · 0.45

Tested by

no test coverage detected