public void Deactivation(bool onExit) { if (m_current != null) { if (onExit == false) { Engine.Instance.WaitMessageSet(LanguageManager.GetText("NetworkLockDeactivation"), false); Engine.Instance.Logs.Log(LogType.InfoImportant, LanguageManager.GetText("NetworkLockDeactivation")); } else { Engine.Instance.Logs.Log(LogType.Verbose, LanguageManager.GetText("NetworkLockDeactivation")); } try { m_current.Deactivation(); } catch (Exception e) { Engine.Instance.Logs.Log(e); } m_current = null; } Recovery.Save(); }
public void AddPlugin(NetworkLockPlugin plugin) { //Engine.Instance.Storage.SetDefaultBool("advanced.netlock." + plugin.GetCode() + ".enabled", true, ""); if (plugin.GetSupport()) { plugin.Init(); Modes.Add(plugin); } }
public void Activation() { try { if (m_current != null) { throw new Exception(LanguageManager.GetText("NetworkLockUnexpectedAlreadyActive")); } NetworkLockPlugin nextCurrent = null; string requestedMode = Engine.Instance.Storage.GetLower("netlock.mode"); if (requestedMode == "auto") { requestedMode = Platform.Instance.OnNetworkLockRecommendedMode(); } if (requestedMode != "none") { foreach (NetworkLockPlugin plugin in Modes) { if (plugin.GetSupport()) { if (requestedMode == plugin.GetCode()) { nextCurrent = plugin; break; } } } } if (nextCurrent == null) { Engine.Instance.Logs.Log(LogType.Fatal, LanguageManager.GetText("NetworkLockNoMode")); } else { string message = LanguageManager.GetText("NetworkLockActivation") + " - " + nextCurrent.GetName(); Engine.Instance.WaitMessageSet(message, false); Engine.Instance.Logs.Log(LogType.InfoImportant, message); // This is not useless: resolve hostnames (available later as cache) before a possible lock of DNS server. nextCurrent.GetIpsWhiteListOutgoing(true); nextCurrent.Activation(); m_current = nextCurrent; } } catch (Exception e) { Engine.Instance.Logs.Log(LogType.Fatal, e); } Recovery.Save(); }
public void Activation() { try { if (m_current != null) { throw new Exception(Messages.NetworkLockUnexpectedAlreadyActive); } NetworkLockPlugin nextCurrent = null; string requestedMode = Engine.Instance.Storage.GetLower("netlock.mode"); if (requestedMode == "auto") { requestedMode = Platform.Instance.OnNetworkLockRecommendedMode(); } if (requestedMode != "none") { foreach (NetworkLockPlugin plugin in Modes) { if (requestedMode == plugin.GetCode()) { nextCurrent = plugin; break; } } } if (nextCurrent == null) { Engine.Instance.Logs.Log(LogType.Fatal, Messages.NetworkLockNoMode); } else { string message = Messages.NetworkLockActivation + " - " + nextCurrent.GetName(); Engine.Instance.WaitMessageSet(message, false); Engine.Instance.Logs.Log(LogType.InfoImportant, message); nextCurrent.Activation(); m_current = nextCurrent; } } catch (Exception e) { Engine.Instance.Logs.Log(LogType.Fatal, e); } Recovery.Save(); }
public void OnRecoveryLoad(XmlElement root) { try { if (m_current != null) { throw new Exception(LanguageManager.GetText("NetworkLockRecoveryWhenActive")); } XmlElement node = root.GetFirstElementByTagName("netlock"); if (node != null) { string code = node.GetAttribute("mode"); foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes) { if (lockPlugin.GetCode() == code) { m_current = lockPlugin; break; } } if (m_current != null) { m_current.OnRecoveryLoad(node); } else { Engine.Instance.Logs.Log(LogType.Warning, LanguageManager.GetText("NetworkLockRecoveryUnknownMode")); } Deactivation(false); } } catch (Exception e) { Engine.Instance.Logs.Log(e); } }
public void AddPlugin(NetworkLockPlugin plugin) { //Engine.Instance.Storage.SetDefaultBool("advanced.netlock." + plugin.GetCode() + ".enabled", true, ""); plugin.Init(); Modes.Add(plugin); }
public void Activation() { try { if (m_current != null) throw new Exception(Messages.NetworkLockUnexpectedAlreadyActive); NetworkLockPlugin nextCurrent = null; string requestedMode = Engine.Instance.Storage.GetLower("netlock.mode"); if (requestedMode == "auto") requestedMode = Platform.Instance.OnNetworkLockRecommendedMode(); if (requestedMode != "none") { foreach (NetworkLockPlugin plugin in Modes) { if (requestedMode == plugin.GetCode()) { nextCurrent = plugin; break; } } } if (nextCurrent == null) { Engine.Instance.Logs.Log(LogType.Fatal, Messages.NetworkLockNoMode); } else { string message = Messages.NetworkLockActivation + " - " + nextCurrent.GetName(); Engine.Instance.WaitMessageSet(message, false); Engine.Instance.Logs.Log(LogType.InfoImportant, message); nextCurrent.Activation(); m_current = nextCurrent; } } catch (Exception e) { Engine.Instance.Logs.Log(LogType.Fatal, e); } Recovery.Save(); }
public void OnRecoveryLoad(XmlElement root) { try { if (m_current != null) throw new Exception(Messages.NetworkLockRecoveryWhenActive); XmlElement node = Utils.XmlGetFirstElementByTagName(root, "netlock"); if (node != null) { string code = node.GetAttribute("mode"); foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes) { if (lockPlugin.GetCode() == code) { m_current = lockPlugin; break; } } if (m_current != null) m_current.OnRecoveryLoad(node); else Engine.Instance.Logs.Log(LogType.Warning, Messages.NetworkLockRecoveryUnknownMode); Deactivation(false); } } catch (Exception e) { Engine.Instance.Logs.Log(e); } }
public void Deactivation(bool onExit) { if (m_current != null) { if (onExit == false) { Engine.Instance.WaitMessageSet(Messages.NetworkLockDeactivation, false); Engine.Instance.Logs.Log(LogType.InfoImportant, Messages.NetworkLockDeactivation); } else Engine.Instance.Logs.Log(LogType.Verbose, Messages.NetworkLockDeactivation); try { m_current.Deactivation(); } catch (Exception e) { Engine.Instance.Logs.Log(e); } m_current = null; } Recovery.Save(); }