Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
        public static WebProxy GetProxy(bool interactive)
        {
            if (!Properties.Settings.Default.ProxyUse)
                return null;

            string domain_user = Properties.Settings.Default.ProxyUser;
            string pass = Properties.Settings.Default.ProxyPass;
            if (pass=="")
                pass = proxy_password;

            if (pass=="") {
                if (interactive)
                {
                    Login l = new Login(domain_user, pass);
                    if (l.ShowDialog() != DialogResult.OK)
                        return null;

                    if (!Properties.Settings.Default.ProxyUse)
                        return null;

                    domain_user = l.GetUser();
                    pass = l.GetPass();
                }

                Properties.Settings.Default.ProxyUser = domain_user;
                Properties.Settings.Default.Save();

                proxy_password = pass;
            }

            string domain;
            string proxyuser;

            if (domain_user.Contains(@"\")) {
                int pos=domain_user.IndexOf('\\');
                domain = domain_user.Substring(0,pos);
                proxyuser = domain_user.Substring(pos + 1, domain_user.Length - pos - 1);
            }
            else
            {
                domain="";
                proxyuser=domain_user;
            }

            try {
                WebProxy proxyObject = new WebProxy(Properties.Settings.Default.ProxyHost, Int16.Parse(Properties.Settings.Default.ProxyPort));
                proxyObject.Credentials = new NetworkCredential(proxyuser, pass, domain);
                return proxyObject;
            }
            catch(Exception ex)
            {
                FlickrSync.Error("Error connecting to Proxy", ex, ErrorType.Connect);
                return null;
            }
        }
Ejemplo n.º 2
0
        static public WebProxy GetProxy(bool interactive)
        {
            if (!Properties.Settings.Default.ProxyUse)
            {
                return(null);
            }

            string domain_user = Properties.Settings.Default.ProxyUser;
            string pass        = Properties.Settings.Default.ProxyPass;

            if (pass == "")
            {
                pass = proxy_password;
            }

            if (pass == "")
            {
                if (interactive)
                {
                    Login l = new Login(domain_user, pass);
                    if (l.ShowDialog() != DialogResult.OK)
                    {
                        return(null);
                    }

                    if (!Properties.Settings.Default.ProxyUse)
                    {
                        return(null);
                    }

                    domain_user = l.GetUser();
                    pass        = l.GetPass();
                }

                Properties.Settings.Default.ProxyUser = domain_user;
                Properties.Settings.Default.Save();

                proxy_password = pass;
            }

            string domain;
            string proxyuser;

            if (domain_user.Contains(@"\"))
            {
                int pos = domain_user.IndexOf('\\');
                domain    = domain_user.Substring(0, pos);
                proxyuser = domain_user.Substring(pos + 1, domain_user.Length - pos - 1);
            }
            else
            {
                domain    = "";
                proxyuser = domain_user;
            }

            try {
                WebProxy proxyObject = new WebProxy(Properties.Settings.Default.ProxyHost, Int16.Parse(Properties.Settings.Default.ProxyPort));
                proxyObject.Credentials = new NetworkCredential(proxyuser, pass, domain);
                return(proxyObject);
            }
            catch (Exception ex)
            {
                FlickrSync.Error("Error connecting to Proxy", ex, ErrorType.Connect);
                return(null);
            }
        }