| 124 | } |
| 125 | |
| 126 | bool PluginHost::Serve() |
| 127 | { |
| 128 | std::unique_lock lck(mSync); |
| 129 | mRequestCondition.wait(lck, [this]{ return !mRunning || mRequest.has_value(); }); |
| 130 | |
| 131 | if(!mRunning) |
| 132 | return false; |
| 133 | |
| 134 | if(mRequest) |
| 135 | { |
| 136 | if(mChannel) |
| 137 | detail::PutMessage(*mChannel, wxEmptyString); |
| 138 | |
| 139 | std::optional<wxString> request; |
| 140 | mRequest.swap(request); |
| 141 | |
| 142 | lck.unlock(); |
| 143 | |
| 144 | wxString providerId; |
| 145 | wxString pluginPath; |
| 146 | detail::PluginValidationResult result; |
| 147 | if(detail::ParseRequestString(*request, providerId, pluginPath)) |
| 148 | Discover(result, providerId, pluginPath); |
| 149 | else |
| 150 | result.SetError("malformed request string"); |
| 151 | |
| 152 | XMLStringWriter xmlWriter; |
| 153 | result.WriteXML(xmlWriter); |
| 154 | |
| 155 | lck.lock(); |
| 156 | if(mChannel) |
| 157 | detail::PutMessage(*mChannel, xmlWriter); |
| 158 | } |
| 159 | |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | void PluginHost::Stop() noexcept |