mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Auto-update - Don't check for updates until after core init finished
Tray - Attempt to more reliably hide icon on application close Auto-run - Implemented dropping of permissions
This commit is contained in:
1 parent
097a5275e2
commit
ca7af1d142
12 files changed
+150
-54
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
@@ -7,10 +8,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class RestartEventArgs : EventArgs
|
||||
{
|
||||
internal RestartEventArgs(bool elevate, TimeSpan delay)
|
||||
internal RestartEventArgs(bool elevate, TimeSpan delay, List<string>? extraArgs)
|
||||
{
|
||||
Elevate = elevate;
|
||||
Delay = delay;
|
||||
ExtraArgs = extraArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -22,5 +24,10 @@ namespace Artemis.Core
|
||||
/// Gets the delay before killing process and restarting
|
||||
/// </summary>
|
||||
public TimeSpan Delay { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of extra arguments to pass to Artemis when restarting
|
||||
/// </summary>
|
||||
public List<string>? ExtraArgs { get; }
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ namespace Artemis.Core.Services
|
||||
_loggingLevel = settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Debug);
|
||||
_renderScale = settingsService.GetSetting("Core.RenderScale", 0.5);
|
||||
_frameStopWatch = new Stopwatch();
|
||||
StartupArguments = new List<string>();
|
||||
|
||||
UpdatePluginCache();
|
||||
|
||||
@@ -77,7 +78,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
public TimeSpan FrameTime { get; private set; }
|
||||
public bool ModuleRenderingDisabled { get; set; }
|
||||
public List<string>? StartupArguments { get; set; }
|
||||
public List<string> StartupArguments { get; set; }
|
||||
public bool IsElevated { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
@@ -109,12 +110,16 @@ namespace Artemis.Core.Services
|
||||
// Just this line should prevent a certain someone from removing HidSharp as an unused dependency as well
|
||||
Version? hidSharpVersion = Assembly.GetAssembly(typeof(HidDevice))!.GetName().Version;
|
||||
_logger.Debug("Forcing plugins to use HidSharp {hidSharpVersion}", hidSharpVersion);
|
||||
|
||||
|
||||
DeserializationLogger.Initialize(Kernel);
|
||||
|
||||
// Initialize the services
|
||||
_pluginManagementService.CopyBuiltInPlugins();
|
||||
_pluginManagementService.LoadPlugins(StartupArguments != null && StartupArguments.Contains("--ignore-plugin-lock"), IsElevated);
|
||||
_pluginManagementService.LoadPlugins(
|
||||
StartupArguments.Contains("--ignore-plugin-lock"),
|
||||
StartupArguments.Contains("--force-elevation"),
|
||||
IsElevated
|
||||
);
|
||||
|
||||
ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface;
|
||||
_logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Artemis.Core.Services
|
||||
/// <summary>
|
||||
/// Gets or sets a list of startup arguments
|
||||
/// </summary>
|
||||
List<string>? StartupArguments { get; set; }
|
||||
List<string> StartupArguments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether Artemis is running in an elevated environment (admin permissions)
|
||||
|
||||
@@ -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 isElevated);
|
||||
void LoadPlugins(bool ignorePluginLock, bool stayElevated, bool isElevated);
|
||||
|
||||
/// <summary>
|
||||
/// Unloads all installed plugins.
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
#region Plugins
|
||||
|
||||
public void LoadPlugins(bool ignorePluginLock, bool isElevated)
|
||||
public void LoadPlugins(bool ignorePluginLock, bool stayElevated, bool isElevated)
|
||||
{
|
||||
if (LoadingPlugins)
|
||||
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
|
||||
@@ -208,9 +208,10 @@ namespace Artemis.Core.Services
|
||||
return;
|
||||
}
|
||||
|
||||
if (isElevated && !adminRequired)
|
||||
if (isElevated && !adminRequired && !stayElevated)
|
||||
{
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
|
||||
@@ -38,9 +40,10 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
/// <param name="elevate">Whether the application should be restarted with elevated permissions</param>
|
||||
/// <param name="delay">Delay in seconds before killing process and restarting </param>
|
||||
public static void Restart(bool elevate, TimeSpan delay)
|
||||
/// <param name="extraArgs">A list of extra arguments to pass to Artemis when restarting</param>
|
||||
public static void Restart(bool elevate, TimeSpan delay, params string[] extraArgs)
|
||||
{
|
||||
OnRestartRequested(new RestartEventArgs(elevate, delay));
|
||||
OnRestartRequested(new RestartEventArgs(elevate, delay, extraArgs.ToList()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user