mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Avoid restart loop if failing to drop admin permissions
Profile editor - Close brush/effect dialog if said brush/effect is unloaded Webserver - Fixed ServerUrl value containing a wildcard instead of localhost
This commit is contained in:
parent
ebb4aaa46c
commit
a2df88bab9
@ -238,11 +238,7 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
// Initialize the services
|
// Initialize the services
|
||||||
_pluginManagementService.CopyBuiltInPlugins();
|
_pluginManagementService.CopyBuiltInPlugins();
|
||||||
_pluginManagementService.LoadPlugins(
|
_pluginManagementService.LoadPlugins(StartupArguments, IsElevated);
|
||||||
StartupArguments.Contains("--ignore-plugin-lock"),
|
|
||||||
StartupArguments.Contains("--force-elevation"),
|
|
||||||
IsElevated
|
|
||||||
);
|
|
||||||
|
|
||||||
_rgbService.IsRenderPaused = false;
|
_rgbService.IsRenderPaused = false;
|
||||||
OnInitialized();
|
OnInitialized();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace Artemis.Core.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads all installed plugins. If plugins already loaded this will reload them all
|
/// Loads all installed plugins. If plugins already loaded this will reload them all
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadPlugins(bool ignorePluginLock, bool stayElevated, bool isElevated);
|
void LoadPlugins(List<string> startupArguments, bool isElevated);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unloads all installed plugins.
|
/// Unloads all installed plugins.
|
||||||
|
|||||||
@ -179,8 +179,11 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
#region Plugins
|
#region Plugins
|
||||||
|
|
||||||
public void LoadPlugins(bool ignorePluginLock, bool stayElevated, bool isElevated)
|
public void LoadPlugins(List<string> startupArguments, bool isElevated)
|
||||||
{
|
{
|
||||||
|
bool ignorePluginLock = startupArguments.Contains("--ignore-plugin-lock");
|
||||||
|
bool stayElevated = startupArguments.Contains("--force-elevation");
|
||||||
|
bool droppedAdmin = startupArguments.Contains("--dropped-admin");
|
||||||
if (LoadingPlugins)
|
if (LoadingPlugins)
|
||||||
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
|
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
|
||||||
|
|
||||||
@ -218,10 +221,15 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
if (isElevated && !adminRequired && !stayElevated)
|
if (isElevated && !adminRequired && !stayElevated)
|
||||||
{
|
{
|
||||||
// No need for a delay this early on, nothing that needs graceful shutdown is happening yet
|
if (droppedAdmin)
|
||||||
_logger.Information("Restarting because no plugin requires elevation and --force-elevation was not supplied");
|
_logger.Information("No plugin requires elevation but dropping admin failed before, ignoring");
|
||||||
Utilities.Restart(false, TimeSpan.Zero);
|
else
|
||||||
return;
|
{
|
||||||
|
// No need for a delay this early on, nothing that needs graceful shutdown is happening yet
|
||||||
|
_logger.Information("Restarting because no plugin requires elevation and --force-elevation was not supplied");
|
||||||
|
Utilities.Restart(false, TimeSpan.Zero, "--dropped-admin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Plugin plugin in _plugins.Where(p => p.Entity.IsEnabled))
|
foreach (Plugin plugin in _plugins.Where(p => p.Entity.IsEnabled))
|
||||||
|
|||||||
@ -43,10 +43,9 @@ namespace Artemis.Core.Services
|
|||||||
Server?.Dispose();
|
Server?.Dispose();
|
||||||
Server = null;
|
Server = null;
|
||||||
|
|
||||||
string url = $"http://*:{_webServerPortSetting.Value}/";
|
|
||||||
WebApiModule apiModule = new("/api/", JsonNetSerializer);
|
WebApiModule apiModule = new("/api/", JsonNetSerializer);
|
||||||
PluginsModule.ServerUrl = url;
|
PluginsModule.ServerUrl = $"http://localhost:{_webServerPortSetting.Value}/";
|
||||||
WebServer server = new WebServer(o => o.WithUrlPrefix(url).WithMode(HttpListenerMode.EmbedIO))
|
WebServer server = new WebServer(o => o.WithUrlPrefix($"http://*:{_webServerPortSetting.Value}/").WithMode(HttpListenerMode.EmbedIO))
|
||||||
.WithLocalSessionManager()
|
.WithLocalSessionManager()
|
||||||
.WithModule(apiModule)
|
.WithModule(apiModule)
|
||||||
.WithModule(PluginsModule)
|
.WithModule(PluginsModule)
|
||||||
@ -61,7 +60,7 @@ namespace Artemis.Core.Services
|
|||||||
server.StateChanged += (s, e) => _logger.Verbose("WebServer new state - {state}", e.NewState);
|
server.StateChanged += (s, e) => _logger.Verbose("WebServer new state - {state}", e.NewState);
|
||||||
|
|
||||||
// Store the URL in a webserver.txt file so that remote applications can find it
|
// Store the URL in a webserver.txt file so that remote applications can find it
|
||||||
File.WriteAllText(Path.Combine(Constants.DataFolder, "webserver.txt"), $"http://localhost:{_webServerPortSetting.Value}/");
|
File.WriteAllText(Path.Combine(Constants.DataFolder, "webserver.txt"), PluginsModule.ServerUrl);
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
@ -156,7 +155,6 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
private void HandleDataModelRequest<T>(Module<T> module, T value) where T : DataModel
|
private void HandleDataModelRequest<T>(Module<T> module, T value) where T : DataModel
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovePluginEndPoint(PluginEndPoint endPoint)
|
public void RemovePluginEndPoint(PluginEndPoint endPoint)
|
||||||
|
|||||||
@ -32,6 +32,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private readonly IWindowManager _windowManager;
|
private readonly IWindowManager _windowManager;
|
||||||
|
private LayerBrushSettingsWindowViewModel? _layerBrushSettingsWindowVm;
|
||||||
|
private LayerEffectSettingsWindowViewModel _layerEffectSettingsWindowVm;
|
||||||
|
|
||||||
public TreeGroupViewModel(LayerPropertyGroupViewModel layerPropertyGroupViewModel, IProfileEditorService profileEditorService, IDialogService dialogService, IWindowManager windowManager)
|
public TreeGroupViewModel(LayerPropertyGroupViewModel layerPropertyGroupViewModel, IProfileEditorService profileEditorService, IDialogService dialogService, IWindowManager windowManager)
|
||||||
{
|
{
|
||||||
@ -73,7 +75,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
||||||
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||||
|
|
||||||
_windowManager.ShowDialog(new LayerBrushSettingsWindowViewModel(viewModel));
|
_layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel);
|
||||||
|
_windowManager.ShowDialog(_layerBrushSettingsWindowVm);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -98,7 +101,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
|
ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
|
||||||
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
||||||
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||||
_windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(viewModel));
|
|
||||||
|
_layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel);
|
||||||
|
_windowManager.ShowDialog(_layerEffectSettingsWindowVm);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -185,6 +190,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
LayerPropertyGroupViewModel.PropertyChanged -= LayerPropertyGroupViewModelOnPropertyChanged;
|
LayerPropertyGroupViewModel.PropertyChanged -= LayerPropertyGroupViewModelOnPropertyChanged;
|
||||||
|
|
||||||
|
// Clean up windows that may be open, sorry but your brush/effect is closed!
|
||||||
|
_layerBrushSettingsWindowVm?.RequestClose();
|
||||||
|
_layerEffectSettingsWindowVm?.RequestClose();
|
||||||
|
|
||||||
base.OnClose();
|
base.OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,13 +18,18 @@
|
|||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
||||||
Icon="/Resources/Images/Logo/logo-512.png">
|
Icon="/Resources/Images/Logo/logo-512.png">
|
||||||
<DockPanel>
|
<materialDesign:DialogHost IsTabStop="False"
|
||||||
<controls:AppBar Type="Dense" Title="{Binding ActiveItem.LayerBrush.Descriptor.DisplayName}" DockPanel.Dock="Top" Margin="-18 0 0 0" ShowShadow="False">
|
Focusable="False"
|
||||||
<controls:AppBar.AppIcon>
|
Identifier="BrushSettingsDialog"
|
||||||
<materialDesign:PackIcon Kind="{Binding ActiveItem.LayerBrush.Descriptor.Icon}" Width="20" Height="28" />
|
DialogTheme="Inherit">
|
||||||
</controls:AppBar.AppIcon>
|
<DockPanel>
|
||||||
</controls:AppBar>
|
<controls:AppBar Type="Dense" Title="{Binding ActiveItem.LayerBrush.Descriptor.DisplayName}" DockPanel.Dock="Top" Margin="-18 0 0 0" ShowShadow="False">
|
||||||
|
<controls:AppBar.AppIcon>
|
||||||
|
<materialDesign:PackIcon Kind="{Binding ActiveItem.LayerBrush.Descriptor.Icon}" Width="20" Height="28" />
|
||||||
|
</controls:AppBar.AppIcon>
|
||||||
|
</controls:AppBar>
|
||||||
|
|
||||||
<ContentControl s:View.Model="{Binding ActiveItem}" />
|
<ContentControl s:View.Model="{Binding ActiveItem}" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
</materialDesign:DialogHost>
|
||||||
</controls:MaterialWindow>
|
</controls:MaterialWindow>
|
||||||
Loading…
x
Reference in New Issue
Block a user