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");
82 auto pConfig = std::make_unique<FileConfig>(
83 AppName, wxEmptyString, configFileName.GetFullPath(),
84 wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
89 moduleManager.Initialize();
90 moduleManager.DiscoverProviders();
92 mClient = std::make_unique<IPCClient>(connectPort, *
this);
97 std::lock_guard lck(mSync);
115 mInputMessageReader.ConsumeBytes(data,
size);
116 if(mInputMessageReader.CanPop())
119 std::lock_guard lck(mSync);
121 mRequest = mInputMessageReader.Pop();
123 mRequestCondition.notify_one();
134 std::unique_lock lck(
mSync);
145 std::optional<wxString> request;
154 Discover(result, providerId, pluginPath);
156 result.
SetError(
"malformed request string");
175 std::lock_guard lck(
mSync);
192 const auto cmd = wxString::Format(
"\"%s\" %s %d",
197 auto process = std::make_unique<wxProcess>();
199 if(wxExecute(cmd, wxEXEC_ASYNC, process.get()) != 0)
230 wxLog::EnableLogging(
false);
234 while(host.
Serve()) { }
Toolkit-neutral facade for basic user interface services.
const TranslatableString desc
static CommandHandlerObject & ident(AudacityProject &project)
const std::wstring AppName
This program's name.
IMPLEMENT_DYNAMIC_CLASS(PluginHostModule, wxModule)
void InitPreferences(std::unique_ptr< FileConfig > uPrefs)
ComponentInterface provides name / vendor / version functions to identify plugins....
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 FilePath Configuration()
FILES_API void InitializePathList()
void Discover(detail::PluginValidationResult &result, const wxString &providerId, const wxString &pluginPath)
bool ParseRequestString(const wxString &req, wxString &providerId, wxString &pluginPath)
void PutMessage(IPCChannel &channel, const wxString &value)