Attempts to instantiate plugin module and put plugin descriptors into result
| 29 | { |
| 30 | //Attempts to instantiate plugin module and put plugin descriptors into result |
| 31 | void Discover(detail::PluginValidationResult& result, const wxString& providerId, const wxString& pluginPath) |
| 32 | { |
| 33 | try |
| 34 | { |
| 35 | if(auto provider = ModuleManager::Get().CreateProviderInstance(providerId, wxEmptyString)) |
| 36 | { |
| 37 | TranslatableString errorMessage{}; |
| 38 | auto validator = provider->MakeValidator(); |
| 39 | auto numPlugins = provider->DiscoverPluginsAtPath( |
| 40 | pluginPath, errorMessage, [&](PluginProvider *provider, ComponentInterface *ident) -> const PluginID& |
| 41 | { |
| 42 | //Workaround: use DefaultRegistrationCallback to create all descriptors for us |
| 43 | //and then put a copy into result |
| 44 | auto& id = PluginManager::DefaultRegistrationCallback(provider, ident); |
| 45 | if(const auto ptr = PluginManager::Get().GetPlugin(id)) |
| 46 | { |
| 47 | auto desc = *ptr; |
| 48 | try |
| 49 | { |
| 50 | if(validator) |
| 51 | validator->Validate(*ident); |
| 52 | } |
| 53 | catch(...) |
| 54 | { |
| 55 | desc.SetEnabled(false); |
| 56 | desc.SetValid(false); |
| 57 | } |
| 58 | result.Add(std::move(desc)); |
| 59 | } |
| 60 | return id; |
| 61 | }); |
| 62 | if(!errorMessage.empty()) |
| 63 | result.SetError(errorMessage.Debug()); |
| 64 | else if(numPlugins == 0) |
| 65 | result.SetError("no plugins found"); |
| 66 | } |
| 67 | else |
| 68 | result.SetError("provider not found"); |
| 69 | } |
| 70 | catch(...) |
| 71 | { |
| 72 | result.SetError("unknown error"); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | PluginHost::PluginHost(int connectPort) |
no test coverage detected