17#include <wx/process.h>
35 if(
auto provider =
ModuleManager::Get().CreateProviderInstance(providerId, wxEmptyString))
38 auto validator = provider->MakeValidator();
39 auto numPlugins = provider->DiscoverPluginsAtPath(
51 validator->Validate(*
ident);
55 desc.SetEnabled(
false);
62 if(!errorMessage.empty())
63 result.
SetError(errorMessage.Debug());
64 else if(numPlugins == 0)
68 result.
SetError(
"provider not found");
83 moduleManager.Initialize();
84 moduleManager.DiscoverProviders();
86 mClient = std::make_unique<IPCClient>(connectPort, *
this);
91 std::lock_guard lck(mSync);
109 mInputMessageReader.ConsumeBytes(data,
size);
110 if(mInputMessageReader.CanPop())
113 std::lock_guard lck(mSync);
115 mRequest = mInputMessageReader.Pop();
117 mRequestCondition.notify_one();
128 std::unique_lock lck(
mSync);
139 std::optional<wxString> request;
148 Discover(result, providerId, pluginPath);
150 result.
SetError(
"malformed request string");
169 std::lock_guard lck(
mSync);
186 const auto cmd = wxString::Format(
"\"%s\" %s %d",
191 auto process = std::make_unique<wxProcess>();
193 if(wxExecute(cmd, wxEXEC_ASYNC, process.get()) != 0)
224 wxLog::EnableLogging(
false);
228 while(host.
Serve()) { }
Toolkit-neutral facade for basic user interface services.
static CommandHandlerObject & ident(AudacityProject &project)
IMPLEMENT_DYNAMIC_CLASS(PluginHostModule, wxModule)
void InitPreferences(std::unique_ptr< audacity::BasicSettings > uPrefs)
ComponentInterface provides name / vendor / version functions to identify plugins....
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
Interface for sending data from client to server or vice versa, complemented by IPCChannelStatusCallb...
static ModuleManager & Get()
Internal class, processes plugin validation requests from the main app. Request is a simple string fo...
void OnConnectionError() noexcept override
Called when connection attempt fails.
void OnDisconnect() noexcept override
Invalidates IPCChannel passed as argument in OnConnect.
static bool IsHostProcess()
Returns true if current process is considered to be a plugin host process.
static constexpr auto HostArgument
void OnDataAvailable(const void *data, size_t size) noexcept override
Called when data chunk received as a result of a preceding call to IPCChannel::Send....
static bool Start(int connectPort)
Attempts to start a host application (should be called from the main application)
std::optional< wxString > mRequest
std::unique_ptr< IPCClient > mClient
PluginHost(int connectPort)
std::condition_variable mRequestCondition
void OnConnect(IPCChannel &channel) noexcept override
Called when connection established.
static PluginManager & Get()
static const PluginID & DefaultRegistrationCallback(PluginProvider *provider, ComponentInterface *ident)
Holds a msgid for the translation catalog; may also bind format arguments.
Wrapper to output XML data to strings.
void WriteXML(XMLWriter &writer) const
void SetError(const wxString &msg)
void Add(PluginDescriptor &&desc)
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
FILES_API void InitializePathList()
const TranslatableString desc
void Discover(detail::PluginValidationResult &result, const wxString &providerId, const wxString &pluginPath)
const PluginDescriptor * GetPlugin(const PluginID &ID)
bool ParseRequestString(const wxString &req, wxString &providerId, wxString &pluginPath)
void PutMessage(IPCChannel &channel, const wxString &value)