/// <summary> /// Applies the specified config. /// </summary> /// <param name="config">The config.</param> /// <returns>true if configuration is applied, false if it is already done</returns> public static bool Apply(ProxyConfiguration config) { //ANS-8 ProxyConfiguration ActualConfig = IExplorerProxyConfigurationAdapter.ReadConfig(); if (ActualConfig.Enabled == config.Enabled) { // do nothing, the configuration is the same return(false); } else if ((ActualConfig.Enabled == config.Enabled == true) && (ActualConfig.ServerAddress.Equals(config.ServerAddress))) { // do nothing, the proxy server is the same (and i believe with same configuration) return(false); } else { // apply new configuration IExplorerProxyConfigurationAdapter.ApplyConfig(config); RunningWindowsExecutable firefox = FindFirefoxAndShutdown(); FirexfoxProxyConfigurationAdapter.ApplyConfig(config); RestartFirefox(firefox); return(true); } }
/// <summary> /// Restarts the firefox. /// </summary> /// <param name="item">The item.</param> public static void RestartFirefox(RunningWindowsExecutable item) { if (item != null) { System.Threading.Thread.Sleep(WAIT_FOR_PROXY); item.Kill = false; WindowsExecutor.Execute(item); } }