Skip to content

Commit 8825386

Browse files
committed
Standardize boolean flags
1 parent 38770b9 commit 8825386

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

modSync.cs

+15
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ public static async void SendMessage(string Destination, string MessageType, str
105105
}
106106
}
107107

108+
/// <summary>
109+
/// Stores and sends to the server a single configuration value
110+
/// </summary>
111+
/// <param name="configkey">Key</param>
112+
/// <param name="configvalue">Value</param>
113+
/// <returns>(int) 0</returns>
114+
public static int SendSingleConfig(string configkey, string configvalue)
115+
{
116+
modDatabase.Config ConfigObj = new modDatabase.Config { Key = configkey, Value = configvalue };
117+
modDatabase.AddOrUpdateConfig(ConfigObj);
118+
string SystemDetailsJSON = "{\"systemdetails\":[" + JsonSerializer.Serialize(ConfigObj) + "]}";
119+
modSync.SendMessage("server", "nodedata", "systemdetails", SystemDetailsJSON);
120+
return 0;
121+
}
122+
108123
/// <summary>
109124
/// Handler to launch initial heartbeat on a new Thread
110125
/// </summary>

modSystem.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public static string ShutdownHost()
220220
/// <summary>
221221
/// Configures the system Run dialog, which is frequently used by phone scammers
222222
/// </summary>
223-
/// <param name="action">(string) Action to take</param>
223+
/// <param name="action">(string) "enable" or "disable"</param>
224224
/// <returns>(string) Response</returns>
225225
public static string ConfigureRunDialog(string action)
226226
{
@@ -230,11 +230,7 @@ public static string ConfigureRunDialog(string action)
230230
explorerPolicies.SetValue("NoRun", newvalue, RegistryValueKind.DWord);
231231
explorerPolicies.Close();
232232

233-
modDatabase.Config ConfigObj = new modDatabase.Config { Key = "Security_RunDialog", Value = action + "d" };
234-
modDatabase.AddOrUpdateConfig(ConfigObj);
235-
string SystemDetailsJSON = "{\"systemdetails\":[" + JsonSerializer.Serialize(ConfigObj) + "]}";
236-
modSync.SendMessage("server", "nodedata", "systemdetails", SystemDetailsJSON);
237-
233+
modSync.SendSingleConfig("Security_RunDialog", action + "d");
238234
return "Run dialog " + action + "d";
239235
}
240236
}

modUpdate.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static int UpdateAgent()
101101

102102
public static int Autoupdate()
103103
{
104-
if (modDatabase.GetConfig("Update_Autoupdate") == "true")
104+
if (modDatabase.GetConfig("Update_Autoupdate") == "enabled")
105105
{
106106
return UpdateAgent();
107107
} else
@@ -112,13 +112,13 @@ public static int Autoupdate()
112112

113113
public static string DisableAutoupdate()
114114
{
115-
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "Update_Autoupdate", Value = "false" });
115+
modSync.SendSingleConfig("Update_Autoupdate", "disabled");
116116
return "Autoupdate disabled";
117117
}
118118

119119
public static string EnableAutoupdate()
120120
{
121-
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "Update_Autoupdate", Value = "true" });
121+
modSync.SendSingleConfig("Update_Autoupdate", "enabled");
122122
return "Autoupdate enabled";
123123
}
124124
}

0 commit comments

Comments
 (0)