예제 #1
0
        public override void Activate(ProxyEntry proxy, Guid networkId)
        {
            IniHelper helper = new IniHelper(GetOperaIniFile());

            if (proxy.IsAutoConf)
            {
                helper.SetValue("Proxy", "Automatic Proxy Configuration URL", proxy.Url.FirstEntry());
                helper.SetValue("Proxy", "Use Automatic Proxy Configuration", "1");
            }
            else
            {
                if (proxy.Url.IsAllSet)
                {
                    helper.SetValue("Proxy", "HTTP server", proxy.Url[ProxyScheme.All] + ":" + proxy.Port[ProxyScheme.All].ToString());
                    helper.SetValue("Proxy", "HTTPS server", proxy.Url[ProxyScheme.All] + ":" + proxy.Port[ProxyScheme.All].ToString());
                    helper.SetValue("Proxy", "Use HTTP", "1");
                    helper.SetValue("Proxy", "Use HTTPS", "1");
                }
                else
                {
                    if (proxy.Url.ContainsKey(ProxyScheme.HTTP))
                    {
                        helper.SetValue("Proxy", "HTTP server", proxy.Url[ProxyScheme.HTTP] + ":" + proxy.Port[ProxyScheme.HTTP].ToString());
                        helper.SetValue("Proxy", "Use HTTP", "1");
                    }
                    if (proxy.Url.ContainsKey(ProxyScheme.HTTPS))
                    {
                        helper.SetValue("Proxy", "HTTPS server", proxy.Url[ProxyScheme.HTTPS] + ":" + proxy.Port[ProxyScheme.HTTPS].ToString());
                        helper.SetValue("Proxy", "Use HTTPS", "1");
                    }
                    if (proxy.Url.ContainsKey(ProxyScheme.FTP))
                    {
                        helper.SetValue("Proxy", "FTP server", proxy.Url[ProxyScheme.FTP] + ":" + proxy.Port[ProxyScheme.FTP].ToString());
                        helper.SetValue("Proxy", "Use FTP", "1");
                    }
                }

                if (String.IsNullOrEmpty(proxy.Exceptions))
                {
                    helper.SetValue("Proxy", "No Proxy Servers Check", "0");
                }
                else
                {
                    helper.SetValue("Proxy", "No Proxy Servers", proxy.Exceptions);
                    helper.SetValue("Proxy", "No Proxy Servers Check", "1");
                }

                if (proxy.ByPassLocal)
                {
                    helper.SetValue("Proxy", "Use Proxy On Local Names Check", "0");
                }
                else
                {
                    helper.SetValue("Proxy", "Use Proxy On Local Names Check", "1");
                }
            }

            helper.Save();
        }
 public override void Activate(Guid networkId, string networkName)
 {
     IniHelper helper = new IniHelper(GetOperaIniFile());
     helper.SetValue("Proxy", "Use HTTP", "0");
     helper.SetValue("Proxy", "Use HTTPS", "0");
     helper.SetValue("Proxy", "Use FTP", "0");
     helper.SetValue("Proxy", "Use Automatic Proxy Configuration", "0");
     helper.Save();
 }
예제 #3
0
        public override void Activate(Guid networkId, string networkName)
        {
            string homepageUrl = Settings[networkId + "_Homepage"];
            if (String.IsNullOrWhiteSpace(homepageUrl))
                return;

            Browsers browsers = (Browsers)Enum.Parse(typeof(Browsers), this.Settings[networkId + "_Browsers"], true);

            if (browsers.HasFlag(Browsers.IE))
            {
                try
                {
                    if (!homepageUrl.Contains("|"))
                    {
                        RegistryHelper.SetStringValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", homepageUrl);
                        RegistryHelper.DeleteEntry(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages");
                    }
                    else
                    {
                        string[] urls = homepageUrl.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        // Set first
                        RegistryHelper.SetStringValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", urls[0]);

                        var list = urls.ToList();
                        list.RemoveAt(0);
                        //RegistryHelper.SetMultiStringValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages", list.ToArray());
                        Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages", list.ToArray(), Microsoft.Win32.RegistryValueKind.MultiString);
                    }
                }
                catch { }
            }
            if (browsers.HasFlag(Browsers.Opera))
            {
                try
                {
                    string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Opera\\Opera");
                    path = Path.Combine(path, "operaprefs.ini");
                    IniHelper helper = new IniHelper(path);
                    helper.SetValue("User Prefs", "Home URL", homepageUrl);
                    helper.Save();
                }
                catch { }
            }
            if (browsers.HasFlag(Browsers.Firefox))
            {
                try
                {
                    SetForAllFirefoxProfiles(homepageUrl);
                }
                catch { }
            }
        }
예제 #4
0
        public override ProxyEntry GetDefaultProxy()
        {
            ProxyEntry proxy = new ProxyEntry();

            IniHelper helper = new IniHelper(GetOperaIniFile());

            proxy.IsAutoConf = (helper.GetValue("Proxy", "Use Automatic Proxy Configuration") == "1");
            if (proxy.IsAutoConf)
            {
                proxy.Url[ProxyScheme.All] = helper.GetValue("Proxy", "Automatic Proxy Configuration URL");
            }
            else
            {
                string[] urlPort = helper.GetValue("Proxy", "HTTP server").Split(':');
                proxy.Url[ProxyScheme.All] = urlPort[0];
                int port;
                if (urlPort.Length > 1 && int.TryParse(urlPort[1], out port))
                    proxy.Port[ProxyScheme.All] = port;
            }

            return proxy;
        }