From 702f681a75472eb9cceef551d94be16e7bcad489 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:32:31 +0000 Subject: [PATCH 1/5] Initial plan From a8853bc68fcc257d1e75c2c955a2ea8b9c137a3d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:35:22 +0000 Subject: [PATCH 2/5] Add system-wide config feature to disable update checks Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> --- Source/NETworkManager.Settings/ConfigInfo.cs | 17 ++++ .../NETworkManager.Settings/ConfigManager.cs | 95 +++++++++++++++++++ .../SettingsManager.cs | 22 +++++ Source/NETworkManager/MainWindow.xaml.cs | 2 +- 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 Source/NETworkManager.Settings/ConfigInfo.cs create mode 100644 Source/NETworkManager.Settings/ConfigManager.cs diff --git a/Source/NETworkManager.Settings/ConfigInfo.cs b/Source/NETworkManager.Settings/ConfigInfo.cs new file mode 100644 index 0000000000..ae7a3882e2 --- /dev/null +++ b/Source/NETworkManager.Settings/ConfigInfo.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +namespace NETworkManager.Settings; + +/// +/// Class that represents system-wide configuration that overrides user settings. +/// This configuration is loaded from a config.json file in the application directory. +/// +public class ConfigInfo +{ + /// + /// Disable update check for all users. When set to true, the application will not check for updates at startup. + /// This overrides the user's "Update_CheckForUpdatesAtStartup" setting. + /// + [JsonPropertyName("Update_DisableUpdateCheck")] + public bool? Update_DisableUpdateCheck { get; set; } +} diff --git a/Source/NETworkManager.Settings/ConfigManager.cs b/Source/NETworkManager.Settings/ConfigManager.cs new file mode 100644 index 0000000000..87e8af6011 --- /dev/null +++ b/Source/NETworkManager.Settings/ConfigManager.cs @@ -0,0 +1,95 @@ +using log4net; +using System; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace NETworkManager.Settings; + +/// +/// Manager for system-wide configuration that is loaded from a config.json file +/// in the application directory. This configuration overrides user settings. +/// +public static class ConfigManager +{ + #region Variables + + /// + /// Logger for logging. + /// + private static readonly ILog Log = LogManager.GetLogger(typeof(ConfigManager)); + + /// + /// Config file name. + /// + private static string ConfigFileName => "config.json"; + + /// + /// System-wide configuration that is currently loaded. + /// + public static ConfigInfo Current { get; private set; } + + /// + /// JSON serializer options for consistent serialization/deserialization. + /// + private static readonly JsonSerializerOptions JsonOptions = new() + { + WriteIndented = true, + PropertyNameCaseInsensitive = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Converters = { new JsonStringEnumConverter() } + }; + + #endregion + + #region Methods + + /// + /// Method to get the config file path in the application directory. + /// + /// Config file path. + private static string GetConfigFilePath() + { + return Path.Combine(AssemblyManager.Current.Location, ConfigFileName); + } + + /// + /// Method to load the system-wide configuration from config.json file in the application directory. + /// + public static void Load() + { + var filePath = GetConfigFilePath(); + + // Check if config file exists + if (File.Exists(filePath)) + { + try + { + Log.Info($"Loading system-wide configuration from: {filePath}"); + + var jsonString = File.ReadAllText(filePath); + Current = JsonSerializer.Deserialize(jsonString, JsonOptions); + + Log.Info("System-wide configuration loaded successfully."); + + // Log enabled settings + if (Current.Update_DisableUpdateCheck.HasValue) + { + Log.Info($"System-wide setting - Update_DisableUpdateCheck: {Current.Update_DisableUpdateCheck.Value}"); + } + } + catch (Exception ex) + { + Log.Error($"Failed to load system-wide configuration from: {filePath}", ex); + Current = new ConfigInfo(); + } + } + else + { + Log.Debug($"No system-wide configuration file found at: {filePath}"); + Current = new ConfigInfo(); + } + } + + #endregion +} diff --git a/Source/NETworkManager.Settings/SettingsManager.cs b/Source/NETworkManager.Settings/SettingsManager.cs index 34ff00a850..6223c83d1d 100644 --- a/Source/NETworkManager.Settings/SettingsManager.cs +++ b/Source/NETworkManager.Settings/SettingsManager.cs @@ -56,6 +56,25 @@ public static class SettingsManager /// public static bool HotKeysChanged { get; set; } + /// + /// Gets whether update check should be performed at startup. + /// This respects the system-wide configuration (config.json) which takes precedence over user settings. + /// + public static bool ShouldCheckForUpdatesAtStartup + { + get + { + // System-wide config takes precedence - if it explicitly disables updates, honor it + if (ConfigManager.Current?.Update_DisableUpdateCheck == true) + { + return false; + } + + // Otherwise, use the user's setting + return Current.Update_CheckForUpdatesAtStartup; + } + } + /// /// JSON serializer options for consistent serialization/deserialization. /// @@ -152,6 +171,9 @@ public static void Initialize() /// public static void Load() { + // Load system-wide configuration first (from app directory) + ConfigManager.Load(); + var filePath = GetSettingsFilePath(); var legacyFilePath = GetLegacySettingsFilePath(); diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 6546c727be..ede6f0007c 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -561,7 +561,7 @@ private void Load() NetworkChange.NetworkAddressChanged += (_, _) => OnNetworkHasChanged(); // Search for updates... - if (SettingsManager.Current.Update_CheckForUpdatesAtStartup) + if (SettingsManager.ShouldCheckForUpdatesAtStartup) CheckForUpdates(); } From 83dc909bafdd11f27395af72fb094c880bbb3eae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:36:32 +0000 Subject: [PATCH 3/5] Add documentation for system-wide config feature Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> --- Documentation/config/README.md | 41 ++++++++++++++++++++++++ Documentation/config/config.json.example | 3 ++ 2 files changed, 44 insertions(+) create mode 100644 Documentation/config/README.md create mode 100644 Documentation/config/config.json.example diff --git a/Documentation/config/README.md b/Documentation/config/README.md new file mode 100644 index 0000000000..2f61c5742f --- /dev/null +++ b/Documentation/config/README.md @@ -0,0 +1,41 @@ +# System-Wide Configuration + +This directory contains an example `config.json` file that can be placed in the application installation directory to override user settings for all users on a machine. + +## Usage + +1. Copy `config.json.example` to the NETworkManager installation directory (where `NETworkManager.exe` is located) +2. Rename it to `config.json` +3. Edit the settings as needed +4. Restart NETworkManager + +## Configuration Options + +### Update_DisableUpdateCheck + +When set to `true`, disables the automatic update check at startup for all users. + +**Example:** +```json +{ + "Update_DisableUpdateCheck": true +} +``` + +This is useful for enterprise deployments where you want to: +- Control software updates centrally +- Prevent users from being prompted about updates +- Disable update checks on multiple machines without user intervention + +## File Location + +The `config.json` file should be placed in: +- **Installed version**: `C:\Program Files\NETworkManager\` (or your custom installation path) +- **Portable version**: Same directory as `NETworkManager.exe` + +## Notes + +- System-wide configuration takes precedence over user settings +- If the file doesn't exist or contains invalid JSON, it will be ignored and default user settings will apply +- Changes to `config.json` require restarting the application to take effect +- The file is optional - if not present, user settings will be used as normal diff --git a/Documentation/config/config.json.example b/Documentation/config/config.json.example new file mode 100644 index 0000000000..17f2c6929e --- /dev/null +++ b/Documentation/config/config.json.example @@ -0,0 +1,3 @@ +{ + "Update_DisableUpdateCheck": true +} From 7dc158c72f7b50339d8fefd21df019174f73a842 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:37:11 +0000 Subject: [PATCH 4/5] Fix documentation formatting in config README Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> --- Documentation/config/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/config/README.md b/Documentation/config/README.md index 2f61c5742f..10d4d75fc7 100644 --- a/Documentation/config/README.md +++ b/Documentation/config/README.md @@ -4,8 +4,8 @@ This directory contains an example `config.json` file that can be placed in the ## Usage -1. Copy `config.json.example` to the NETworkManager installation directory (where `NETworkManager.exe` is located) -2. Rename it to `config.json` +1. Copy the example configuration file to the NETworkManager installation directory (where `NETworkManager.exe` is located) +2. Rename `config.json.example` to `config.json` 3. Edit the settings as needed 4. Restart NETworkManager From 36e595cfe7a70ed3de04ee0fe8a9b47e1c596038 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:58:01 +0000 Subject: [PATCH 5/5] Rename ConfigManager to PolicyManager to avoid naming conflict Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> --- .../{ConfigInfo.cs => PolicyInfo.cs} | 4 +-- .../{ConfigManager.cs => PolicyManager.cs} | 30 +++++++++---------- .../SettingsManager.cs | 10 +++---- 3 files changed, 22 insertions(+), 22 deletions(-) rename Source/NETworkManager.Settings/{ConfigInfo.cs => PolicyInfo.cs} (83%) rename Source/NETworkManager.Settings/{ConfigManager.cs => PolicyManager.cs} (64%) diff --git a/Source/NETworkManager.Settings/ConfigInfo.cs b/Source/NETworkManager.Settings/PolicyInfo.cs similarity index 83% rename from Source/NETworkManager.Settings/ConfigInfo.cs rename to Source/NETworkManager.Settings/PolicyInfo.cs index ae7a3882e2..1e16581c8a 100644 --- a/Source/NETworkManager.Settings/ConfigInfo.cs +++ b/Source/NETworkManager.Settings/PolicyInfo.cs @@ -3,10 +3,10 @@ namespace NETworkManager.Settings; /// -/// Class that represents system-wide configuration that overrides user settings. +/// Class that represents system-wide policies that override user settings. /// This configuration is loaded from a config.json file in the application directory. /// -public class ConfigInfo +public class PolicyInfo { /// /// Disable update check for all users. When set to true, the application will not check for updates at startup. diff --git a/Source/NETworkManager.Settings/ConfigManager.cs b/Source/NETworkManager.Settings/PolicyManager.cs similarity index 64% rename from Source/NETworkManager.Settings/ConfigManager.cs rename to Source/NETworkManager.Settings/PolicyManager.cs index 87e8af6011..966c0a3905 100644 --- a/Source/NETworkManager.Settings/ConfigManager.cs +++ b/Source/NETworkManager.Settings/PolicyManager.cs @@ -7,17 +7,17 @@ namespace NETworkManager.Settings; /// -/// Manager for system-wide configuration that is loaded from a config.json file -/// in the application directory. This configuration overrides user settings. +/// Manager for system-wide policies that are loaded from a config.json file +/// in the application directory. These policies override user settings. /// -public static class ConfigManager +public static class PolicyManager { #region Variables /// /// Logger for logging. /// - private static readonly ILog Log = LogManager.GetLogger(typeof(ConfigManager)); + private static readonly ILog Log = LogManager.GetLogger(typeof(PolicyManager)); /// /// Config file name. @@ -25,9 +25,9 @@ public static class ConfigManager private static string ConfigFileName => "config.json"; /// - /// System-wide configuration that is currently loaded. + /// System-wide policies that are currently loaded. /// - public static ConfigInfo Current { get; private set; } + public static PolicyInfo Current { get; private set; } /// /// JSON serializer options for consistent serialization/deserialization. @@ -54,7 +54,7 @@ private static string GetConfigFilePath() } /// - /// Method to load the system-wide configuration from config.json file in the application directory. + /// Method to load the system-wide policies from config.json file in the application directory. /// public static void Load() { @@ -65,29 +65,29 @@ public static void Load() { try { - Log.Info($"Loading system-wide configuration from: {filePath}"); + Log.Info($"Loading system-wide policies from: {filePath}"); var jsonString = File.ReadAllText(filePath); - Current = JsonSerializer.Deserialize(jsonString, JsonOptions); + Current = JsonSerializer.Deserialize(jsonString, JsonOptions); - Log.Info("System-wide configuration loaded successfully."); + Log.Info("System-wide policies loaded successfully."); // Log enabled settings if (Current.Update_DisableUpdateCheck.HasValue) { - Log.Info($"System-wide setting - Update_DisableUpdateCheck: {Current.Update_DisableUpdateCheck.Value}"); + Log.Info($"System-wide policy - Update_DisableUpdateCheck: {Current.Update_DisableUpdateCheck.Value}"); } } catch (Exception ex) { - Log.Error($"Failed to load system-wide configuration from: {filePath}", ex); - Current = new ConfigInfo(); + Log.Error($"Failed to load system-wide policies from: {filePath}", ex); + Current = new PolicyInfo(); } } else { - Log.Debug($"No system-wide configuration file found at: {filePath}"); - Current = new ConfigInfo(); + Log.Debug($"No system-wide policy file found at: {filePath}"); + Current = new PolicyInfo(); } } diff --git a/Source/NETworkManager.Settings/SettingsManager.cs b/Source/NETworkManager.Settings/SettingsManager.cs index 6223c83d1d..58737d0659 100644 --- a/Source/NETworkManager.Settings/SettingsManager.cs +++ b/Source/NETworkManager.Settings/SettingsManager.cs @@ -58,14 +58,14 @@ public static class SettingsManager /// /// Gets whether update check should be performed at startup. - /// This respects the system-wide configuration (config.json) which takes precedence over user settings. + /// This respects the system-wide policies (config.json) which take precedence over user settings. /// public static bool ShouldCheckForUpdatesAtStartup { get { - // System-wide config takes precedence - if it explicitly disables updates, honor it - if (ConfigManager.Current?.Update_DisableUpdateCheck == true) + // System-wide policy takes precedence - if it explicitly disables updates, honor it + if (PolicyManager.Current?.Update_DisableUpdateCheck == true) { return false; } @@ -171,8 +171,8 @@ public static void Initialize() /// public static void Load() { - // Load system-wide configuration first (from app directory) - ConfigManager.Load(); + // Load system-wide policies first (from app directory) + PolicyManager.Load(); var filePath = GetSettingsFilePath(); var legacyFilePath = GetLegacySettingsFilePath();