示例#1
0
        public void Deactivation(bool onExit)
        {
            if (m_current != null)
            {
                if (onExit == false)
                {
                    Engine.Instance.WaitMessageSet(Messages.NetworkLockDeactivation, false);
                    Engine.Instance.Log(Engine.LogType.InfoImportant, Messages.NetworkLockDeactivation);
                }
                else
                {
                    Engine.Instance.Log(Engine.LogType.Verbose, Messages.NetworkLockDeactivation);
                }

                try
                {
                    m_current.Deactivation();
                }
                catch (Exception e)
                {
                    Engine.Instance.Log(e);
                }

                m_current = null;
            }

            // TOCLEAN, < 2.9

            /*
             * if(onExit == false)
             *      Engine.Instance.Storage.SetBool("netlock", false);
             */

            Recovery.Save();
        }
示例#2
0
        public void Activation()
        {
            try
            {
                if (m_current != null)
                {
                    throw new Exception(Messages.NetworkLockUnexpectedAlreadyActive);
                }

                NetworkLockPlugin nextCurrent = null;

                string requestedMode = Engine.Instance.Storage.Get("netlock.mode");

                if (requestedMode != "none")
                {
                    foreach (NetworkLockPlugin plugin in Modes)
                    {
                        if ((requestedMode == "auto") || (requestedMode == plugin.GetCode()))
                        {
                            nextCurrent = plugin;
                            break;
                        }
                    }
                }

                if (nextCurrent == null)
                {
                    Engine.Instance.Log(Engine.LogType.Fatal, Messages.NetworkLockNoMode);
                }
                else
                {
                    string message = Messages.NetworkLockActivation + " - " + nextCurrent.GetName();
                    Engine.Instance.WaitMessageSet(message, false);
                    Engine.Instance.Log(Engine.LogType.InfoImportant, message);

                    nextCurrent.Activation();

                    m_current = nextCurrent;
                }

                // Engine.Instance.Storage.SetBool("netlock", true); // TOCLEAN, < 2.9
            }
            catch (Exception e)
            {
                Engine.Instance.Log(Engine.LogType.Fatal, e);

                // Engine.Instance.Storage.SetBool("netlock", false);  // TOCLEAN, < 2.9
            }

            Recovery.Save();
        }
示例#3
0
        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.Log(Engine.LogType.Warning, Messages.NetworkLockRecoveryUnknownMode);
                    }

                    Deactivation(false);
                }
            }
            catch (Exception e)
            {
                Engine.Instance.Log(e);
            }
        }
示例#4
0
 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.Get("netlock.mode");

				if (requestedMode != "none")
				{
					foreach (NetworkLockPlugin plugin in Modes)
					{
						if( (requestedMode == "auto") || (requestedMode == plugin.GetCode()) )
						{
							nextCurrent = plugin;
							break;
						}
					}
				}

				if (nextCurrent == null)
				{
					Engine.Instance.Log(Engine.LogType.Fatal, Messages.NetworkLockNoMode);
				}
				else
				{
					string message = Messages.NetworkLockActivation + " - " + nextCurrent.GetName();
					Engine.Instance.WaitMessageSet(message, false);
					Engine.Instance.Log(Engine.LogType.InfoImportant, message);

					nextCurrent.Activation();

					m_current = nextCurrent;
				}

				// Engine.Instance.Storage.SetBool("netlock", true); // TOCLEAN, < 2.9
			}
			catch (Exception e)
			{
				Engine.Instance.Log(Engine.LogType.Fatal, e);

				// Engine.Instance.Storage.SetBool("netlock", false);  // TOCLEAN, < 2.9
			}

			Recovery.Save();
		}
		public void AddPlugin(NetworkLockPlugin plugin)
		{
			//Engine.Instance.Storage.SetDefaultBool("advanced.netlock." + plugin.GetCode() + ".enabled", true, "");
			plugin.Init();
			Modes.Add(plugin);
		}
		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.Log(Engine.LogType.Warning, Messages.NetworkLockRecoveryUnknownMode);

					Deactivation(false);
				}
			}
			catch (Exception e)
			{
				Engine.Instance.Log(e);
			}
		}
		public void Deactivation(bool onExit)
		{
			if (m_current != null)
			{
				if (onExit == false)
				{
					Engine.Instance.WaitMessageSet(Messages.NetworkLockDeactivation, false);
					Engine.Instance.Log(Engine.LogType.InfoImportant, Messages.NetworkLockDeactivation);
				}
				else
					Engine.Instance.Log(Engine.LogType.Verbose, Messages.NetworkLockDeactivation);

				try
				{
					m_current.Deactivation();
				}
				catch (Exception e)
				{
					Engine.Instance.Log(e);
				}

				m_current = null;
			}

			// TOCLEAN, < 2.9
			/*
			if(onExit == false)
				Engine.Instance.Storage.SetBool("netlock", false);
			*/

			Recovery.Save();
		}