mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 11:35:48 +00:00
Merge branch 'fix/pluginArgs' into 'main'
fix: wrap single plugin cmd parts in single quotes See merge request gabmus/envision!111
This commit is contained in:
commit
209b65b293
3 changed files with 39 additions and 53 deletions
|
@ -248,15 +248,17 @@ impl App {
|
|||
.plugins
|
||||
.values()
|
||||
.filter_map(|cp| {
|
||||
if cp.plugin.plugin_type.launches_directly() && cp.enabled && cp.plugin.validate() {
|
||||
if cp.enabled && cp.plugin.validate() {
|
||||
if let Err(e) = cp.plugin.mark_as_executable() {
|
||||
error!(
|
||||
"failed to mark plugin {} as executable: {e}",
|
||||
cp.plugin.appid
|
||||
);
|
||||
None
|
||||
} else if !cp.plugin.plugin_type.launches_directly() {
|
||||
None
|
||||
} else {
|
||||
Some(format!("'{}'", {
|
||||
Some({
|
||||
let mut cmd_parts = vec![cp
|
||||
.plugin
|
||||
.executable()
|
||||
|
@ -264,8 +266,12 @@ impl App {
|
|||
.to_string_lossy()
|
||||
.to_string()];
|
||||
cmd_parts.extend(cp.plugin.args.clone().unwrap_or_default());
|
||||
cmd_parts.join(" ")
|
||||
}))
|
||||
cmd_parts
|
||||
.iter()
|
||||
.map(|part| format!("'{part}'"))
|
||||
.collect::<Vec<String>>()
|
||||
.join(" ")
|
||||
})
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -49,15 +49,13 @@ pub enum PluginStoreMsg {
|
|||
Refresh,
|
||||
/// called by Refresh
|
||||
DoRefresh,
|
||||
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
|
||||
InstallFromDetails(Plugin),
|
||||
InstallDownload(Vec<Plugin>, relm4::Sender<StoreRowModelMsg>),
|
||||
Install(Plugin),
|
||||
InstallDownload(Vec<Plugin>),
|
||||
Remove(Plugin),
|
||||
SetEnabled(PluginStoreSignalSource, Plugin, bool),
|
||||
ShowDetails(usize),
|
||||
ShowPluginList,
|
||||
PresentAddCustomPluginWin,
|
||||
AddPluginToConfig(Plugin),
|
||||
AddCustomPlugin(Plugin),
|
||||
}
|
||||
|
||||
|
@ -89,6 +87,16 @@ impl PluginStore {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn add_plugin_to_config(&mut self, sender: &relm4::AsyncComponentSender<Self>, plugin: Plugin) {
|
||||
self.config_plugins
|
||||
.insert(plugin.appid.clone(), PluginConfig::from(&plugin));
|
||||
sender
|
||||
.output(PluginStoreOutMsg::UpdateConfigPlugins(
|
||||
self.config_plugins.clone(),
|
||||
))
|
||||
.expect(SENDER_IO_ERR_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
#[relm4::component(pub async)]
|
||||
|
@ -227,18 +235,9 @@ impl AsyncComponent for PluginStore {
|
|||
);
|
||||
return;
|
||||
}
|
||||
sender.input(Self::Input::AddPluginToConfig(plugin));
|
||||
self.add_plugin_to_config(&sender, plugin);
|
||||
sender.input(Self::Input::Refresh);
|
||||
}
|
||||
Self::Input::AddPluginToConfig(plugin) => {
|
||||
self.config_plugins
|
||||
.insert(plugin.appid.clone(), PluginConfig::from(&plugin));
|
||||
sender
|
||||
.output(Self::Output::UpdateConfigPlugins(
|
||||
self.config_plugins.clone(),
|
||||
))
|
||||
.expect(SENDER_IO_ERR_MSG);
|
||||
}
|
||||
Self::Input::PresentAddCustomPluginWin => {
|
||||
let add_win = AddCustomPluginWin::builder()
|
||||
.launch(AddCustomPluginWinInit {
|
||||
|
@ -291,22 +290,7 @@ impl AsyncComponent for PluginStore {
|
|||
self.refresh_plugin_rows();
|
||||
self.set_refreshing(false);
|
||||
}
|
||||
Self::Input::InstallFromDetails(plugin) => {
|
||||
if let Some(row) = self
|
||||
.plugin_rows
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.guard()
|
||||
.iter()
|
||||
.find(|row| row.is_some_and(|row| row.plugin.appid == plugin.appid))
|
||||
.flatten()
|
||||
{
|
||||
sender.input(Self::Input::Install(plugin, row.input_sender.clone()))
|
||||
} else {
|
||||
error!("could not find corresponding listbox row")
|
||||
}
|
||||
}
|
||||
Self::Input::Install(plugin, row_sender) => {
|
||||
Self::Input::Install(plugin) => {
|
||||
self.set_locked(true);
|
||||
let mut plugins = vec![plugin];
|
||||
for dep in plugins[0].dependencies.clone().unwrap_or_default() {
|
||||
|
@ -333,9 +317,9 @@ impl AsyncComponent for PluginStore {
|
|||
return;
|
||||
}
|
||||
}
|
||||
sender.input(Self::Input::InstallDownload(plugins, row_sender))
|
||||
sender.input(Self::Input::InstallDownload(plugins))
|
||||
}
|
||||
Self::Input::InstallDownload(plugins, row_sender) => {
|
||||
Self::Input::InstallDownload(plugins) => {
|
||||
for plugin in plugins {
|
||||
let mut plugin = plugin.clone();
|
||||
match plugin.exec_url.as_ref() {
|
||||
|
@ -367,22 +351,22 @@ impl AsyncComponent for PluginStore {
|
|||
);
|
||||
return;
|
||||
}
|
||||
sender.input(Self::Input::AddPluginToConfig(plugin.clone()));
|
||||
self.add_plugin_to_config(&sender, plugin.clone());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
alert(
|
||||
"Download failed",
|
||||
Some(&format!(
|
||||
"Downloading {} {} failed:\n\nNo executable url provided for this plugin, this is likely a bug!",
|
||||
plugin.name,
|
||||
plugin.version.as_ref().unwrap_or(&"(no version)".to_string()))
|
||||
),
|
||||
Some(&self.win.as_ref().unwrap().clone().upcast::<gtk::Window>())
|
||||
);
|
||||
"Download failed",
|
||||
Some(&format!(
|
||||
"Downloading {} {} failed:\n\nNo executable url provided for this plugin, this is likely a bug!",
|
||||
plugin.name,
|
||||
plugin.version.as_ref().unwrap_or(&"(no version)".to_string()))
|
||||
),
|
||||
Some(&self.win.as_ref().unwrap().clone().upcast::<gtk::Window>())
|
||||
);
|
||||
}
|
||||
};
|
||||
row_sender.emit(StoreRowModelMsg::Refresh(true, false));
|
||||
self.refresh_plugin_rows();
|
||||
self.details
|
||||
.emit(StoreDetailMsg::Refresh(plugin.appid, true, false));
|
||||
}
|
||||
|
@ -534,7 +518,7 @@ impl AsyncComponent for PluginStore {
|
|||
.launch(())
|
||||
.forward(sender.input_sender(), move |msg| match msg {
|
||||
StoreDetailOutMsg::GoBack => Self::Input::ShowPluginList,
|
||||
StoreDetailOutMsg::Install(plugin) => Self::Input::InstallFromDetails(plugin),
|
||||
StoreDetailOutMsg::Install(plugin) => Self::Input::Install(plugin),
|
||||
StoreDetailOutMsg::Remove(plugin) => Self::Input::Remove(plugin),
|
||||
StoreDetailOutMsg::SetEnabled(plugin, enabled) => {
|
||||
Self::Input::SetEnabled(PluginStoreSignalSource::Detail, plugin, enabled)
|
||||
|
@ -554,9 +538,7 @@ impl AsyncComponent for PluginStore {
|
|||
AsyncFactoryVecDeque::builder()
|
||||
.launch(widgets.listbox.clone())
|
||||
.forward(sender.input_sender(), move |msg| match msg {
|
||||
StoreRowModelOutMsg::Install(appid, row_sender) => {
|
||||
Self::Input::Install(appid, row_sender)
|
||||
}
|
||||
StoreRowModelOutMsg::Install(appid) => Self::Input::Install(appid),
|
||||
StoreRowModelOutMsg::Remove(appid) => Self::Input::Remove(appid),
|
||||
StoreRowModelOutMsg::SetEnabled(plugin, enabled) => {
|
||||
Self::Input::SetEnabled(PluginStoreSignalSource::Row, plugin, enabled)
|
||||
|
|
|
@ -36,7 +36,7 @@ pub enum StoreRowModelMsg {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum StoreRowModelOutMsg {
|
||||
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
|
||||
Install(Plugin),
|
||||
Remove(Plugin),
|
||||
SetEnabled(Plugin, bool),
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ impl AsyncFactoryComponent for StoreRowModel {
|
|||
sender
|
||||
.output(Self::Output::Install(
|
||||
plugin.clone(),
|
||||
sender.input_sender().clone()
|
||||
))
|
||||
.expect(SENDER_IO_ERR_MSG);
|
||||
}
|
||||
|
@ -142,7 +141,6 @@ impl AsyncFactoryComponent for StoreRowModel {
|
|||
sender
|
||||
.output(Self::Output::Install(
|
||||
plugin.clone(),
|
||||
sender.input_sender().clone()
|
||||
))
|
||||
.expect(SENDER_IO_ERR_MSG);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue