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
|
||||
_pluginManagementService.CopyBuiltInPlugins();
|
||||
_pluginManagementService.LoadPlugins(
|
||||
StartupArguments.Contains("--ignore-plugin-lock"),
|
||||
StartupArguments.Contains("--force-elevation"),
|
||||
IsElevated
|
||||
);
|
||||
_pluginManagementService.LoadPlugins(StartupArguments, IsElevated);
|
||||
|
||||
_rgbService.IsRenderPaused = false;
|
||||
OnInitialized();
|
||||
|
||||
@ -26,7 +26,7 @@ namespace Artemis.Core.Services
|
||||
/// <summary>
|
||||
/// Loads all installed plugins. If plugins already loaded this will reload them all
|
||||
/// </summary>
|
||||
void LoadPlugins(bool ignorePluginLock, bool stayElevated, bool isElevated);
|
||||
void LoadPlugins(List<string> startupArguments, bool isElevated);
|
||||
|
||||
/// <summary>
|
||||
/// Unloads all installed plugins.
|
||||
|
||||
@ -179,8 +179,11 @@ namespace Artemis.Core.Services
|
||||
|
||||
#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)
|
||||
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
|
||||
|
||||
@ -217,12 +220,17 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
|
||||
if (isElevated && !adminRequired && !stayElevated)
|
||||
{
|
||||
if (droppedAdmin)
|
||||
_logger.Information("No plugin requires elevation but dropping admin failed before, ignoring");
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
Utilities.Restart(false, TimeSpan.Zero, "--dropped-admin");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Plugin plugin in _plugins.Where(p => p.Entity.IsEnabled))
|
||||
EnablePlugin(plugin, false, ignorePluginLock);
|
||||
|
||||
@ -43,10 +43,9 @@ namespace Artemis.Core.Services
|
||||
Server?.Dispose();
|
||||
Server = null;
|
||||
|
||||
string url = $"http://*:{_webServerPortSetting.Value}/";
|
||||
WebApiModule apiModule = new("/api/", JsonNetSerializer);
|
||||
PluginsModule.ServerUrl = url;
|
||||
WebServer server = new WebServer(o => o.WithUrlPrefix(url).WithMode(HttpListenerMode.EmbedIO))
|
||||
PluginsModule.ServerUrl = $"http://localhost:{_webServerPortSetting.Value}/";
|
||||
WebServer server = new WebServer(o => o.WithUrlPrefix($"http://*:{_webServerPortSetting.Value}/").WithMode(HttpListenerMode.EmbedIO))
|
||||
.WithLocalSessionManager()
|
||||
.WithModule(apiModule)
|
||||
.WithModule(PluginsModule)
|
||||
@ -61,7 +60,7 @@ namespace Artemis.Core.Services
|
||||
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
|
||||
File.WriteAllText(Path.Combine(Constants.DataFolder, "webserver.txt"), $"http://localhost:{_webServerPortSetting.Value}/");
|
||||
File.WriteAllText(Path.Combine(Constants.DataFolder, "webserver.txt"), PluginsModule.ServerUrl);
|
||||
|
||||
return server;
|
||||
}
|
||||
@ -156,7 +155,6 @@ namespace Artemis.Core.Services
|
||||
|
||||
private void HandleDataModelRequest<T>(Module<T> module, T value) where T : DataModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RemovePluginEndPoint(PluginEndPoint endPoint)
|
||||
|
||||
@ -32,6 +32,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private LayerBrushSettingsWindowViewModel? _layerBrushSettingsWindowVm;
|
||||
private LayerEffectSettingsWindowViewModel _layerEffectSettingsWindowVm;
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@ -98,7 +101,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
|
||||
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
||||
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)
|
||||
{
|
||||
@ -185,6 +190,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
protected override void OnClose()
|
||||
{
|
||||
LayerPropertyGroupViewModel.PropertyChanged -= LayerPropertyGroupViewModelOnPropertyChanged;
|
||||
|
||||
// Clean up windows that may be open, sorry but your brush/effect is closed!
|
||||
_layerBrushSettingsWindowVm?.RequestClose();
|
||||
_layerEffectSettingsWindowVm?.RequestClose();
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
||||
Icon="/Resources/Images/Logo/logo-512.png">
|
||||
<materialDesign:DialogHost IsTabStop="False"
|
||||
Focusable="False"
|
||||
Identifier="BrushSettingsDialog"
|
||||
DialogTheme="Inherit">
|
||||
<DockPanel>
|
||||
<controls:AppBar Type="Dense" Title="{Binding ActiveItem.LayerBrush.Descriptor.DisplayName}" DockPanel.Dock="Top" Margin="-18 0 0 0" ShowShadow="False">
|
||||
<controls:AppBar.AppIcon>
|
||||
@ -27,4 +31,5 @@
|
||||
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" />
|
||||
</DockPanel>
|
||||
</materialDesign:DialogHost>
|
||||
</controls:MaterialWindow>
|
||||
Loading…
x
Reference in New Issue
Block a user