diff options
| author | Michael VanOverbeek <[email protected]> | 2017-05-21 12:29:53 +0000 |
|---|---|---|
| committer | Michael VanOverbeek <[email protected]> | 2017-05-21 12:29:53 +0000 |
| commit | 76b54853ba726179f9fddb30c6f838991b7aa71a (patch) | |
| tree | 8713f45ce26958659e3f4e507d73ecabebabfe49 /ShiftOS_TheReturn/KernelWatchdog.cs | |
| parent | 31cc9148dd23737df16d8456a42d003cd31dd488 (diff) | |
| download | shiftos_thereturn-76b54853ba726179f9fddb30c6f838991b7aa71a.tar.gz shiftos_thereturn-76b54853ba726179f9fddb30c6f838991b7aa71a.tar.bz2 shiftos_thereturn-76b54853ba726179f9fddb30c6f838991b7aa71a.zip | |
Merge a fuckton of shit.
Diffstat (limited to 'ShiftOS_TheReturn/KernelWatchdog.cs')
| -rw-r--r-- | ShiftOS_TheReturn/KernelWatchdog.cs | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs deleted file mode 100644 index 430d36a..0000000 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using static ShiftOS.Objects.ShiftFS.Utils; - -namespace ShiftOS.Engine -{ - public static class KernelWatchdog - { - public static void Log(string e, string desc) - { - string line = $"[{DateTime.Now}] <{e}> {desc}"; - if (FileExists("0:/system/data/kernel.log")) - { - string contents = ReadAllText("0:/system/data/kernel.log"); - contents += Environment.NewLine + line; - WriteAllText("0:/system/data/kernel.log", contents); - } - else - { - WriteAllText("0:/system/data/kernel.log", line); - } - } - - private static bool _mudConnected = true; - - public static bool InKernelMode { get; private set; } - public static bool MudConnected - { - get - { - return _mudConnected; - } - set - { - if(value == false) - { - foreach(var win in AppearanceManager.OpenForms) - { - foreach(var attr in win.ParentWindow.GetType().GetCustomAttributes(true)) - { - if(attr is MultiplayerOnlyAttribute) - { - ConsoleEx.Bold = true; - ConsoleEx.Underline = false; - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.Write("Error:"); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine("Cannot disconnect from multi-user domain because an app that depends on it is open."); - TerminalBackend.PrintPrompt(); - return; - } - } - } - } - - _mudConnected = value; - Desktop.PopulateAppLauncher(); - } - } - - public static bool IsSafe(Type type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } - - public static bool IsSafe(MethodInfo type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } - - static string regularUsername = ""; - - - public static void EnterKernelMode() - { - regularUsername = SaveSystem.CurrentUser.Username; - SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == "root"); - - } - - public static void LeaveKernelMode() - { - var user = SaveSystem.Users.FirstOrDefault(x => x.Username == regularUsername); - if (user == null) - throw new Exception("User not in root mode."); - SaveSystem.CurrentUser = user; - } - - internal static bool CanRunOffline(Type method) - { - if (MudConnected) - return true; - - foreach (var attr in method.GetCustomAttributes(false)) - { - if (attr is MultiplayerOnlyAttribute) - return false; - } - return true; - } - - internal static bool CanRunOffline(MethodInfo method) - { - if (MudConnected) - return true; - - foreach(var attr in method.GetCustomAttributes(false)) - { - if (attr is MultiplayerOnlyAttribute) - return false; - } - return true; - } - } -} |
