Skip to content

Commit

Permalink
Standardize boolean flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jul 18, 2024
1 parent 38770b9 commit 8825386
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
15 changes: 15 additions & 0 deletions modSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ public static async void SendMessage(string Destination, string MessageType, str
}
}

/// <summary>
/// Stores and sends to the server a single configuration value
/// </summary>
/// <param name="configkey">Key</param>
/// <param name="configvalue">Value</param>
/// <returns>(int) 0</returns>
public static int SendSingleConfig(string configkey, string configvalue)
{
modDatabase.Config ConfigObj = new modDatabase.Config { Key = configkey, Value = configvalue };
modDatabase.AddOrUpdateConfig(ConfigObj);
string SystemDetailsJSON = "{\"systemdetails\":[" + JsonSerializer.Serialize(ConfigObj) + "]}";
modSync.SendMessage("server", "nodedata", "systemdetails", SystemDetailsJSON);
return 0;
}

/// <summary>
/// Handler to launch initial heartbeat on a new Thread
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions modSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static string ShutdownHost()
/// <summary>
/// Configures the system Run dialog, which is frequently used by phone scammers
/// </summary>
/// <param name="action">(string) Action to take</param>
/// <param name="action">(string) "enable" or "disable"</param>
/// <returns>(string) Response</returns>
public static string ConfigureRunDialog(string action)
{
Expand All @@ -230,11 +230,7 @@ public static string ConfigureRunDialog(string action)
explorerPolicies.SetValue("NoRun", newvalue, RegistryValueKind.DWord);
explorerPolicies.Close();

modDatabase.Config ConfigObj = new modDatabase.Config { Key = "Security_RunDialog", Value = action + "d" };
modDatabase.AddOrUpdateConfig(ConfigObj);
string SystemDetailsJSON = "{\"systemdetails\":[" + JsonSerializer.Serialize(ConfigObj) + "]}";
modSync.SendMessage("server", "nodedata", "systemdetails", SystemDetailsJSON);

modSync.SendSingleConfig("Security_RunDialog", action + "d");
return "Run dialog " + action + "d";
}
}
Expand Down
6 changes: 3 additions & 3 deletions modUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static int UpdateAgent()

public static int Autoupdate()
{
if (modDatabase.GetConfig("Update_Autoupdate") == "true")
if (modDatabase.GetConfig("Update_Autoupdate") == "enabled")
{
return UpdateAgent();
} else
Expand All @@ -112,13 +112,13 @@ public static int Autoupdate()

public static string DisableAutoupdate()
{
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "Update_Autoupdate", Value = "false" });
modSync.SendSingleConfig("Update_Autoupdate", "disabled");
return "Autoupdate disabled";
}

public static string EnableAutoupdate()
{
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "Update_Autoupdate", Value = "true" });
modSync.SendSingleConfig("Update_Autoupdate", "enabled");
return "Autoupdate enabled";
}
}
Expand Down

0 comments on commit 8825386

Please sign in to comment.