public ConnectionInfo( Utilizador u , string server, string proxy)
 {
     this.user = u;
     this.address = new Uri (server);
     this.proxy = new Uri (proxy);
     this.useProxy = true;
 }
 public ConnectionInfo(Utilizador utilizador, string address)
 {
     this.user = utilizador;
     this.address = new Uri(address);
 }
 public ConnectionInfo()
 {
     user = new Utilizador ("", "");
     this.proxy  = null;
     this.address  = null;
 }
        /**
            * retrieves the connection information associated with this weebox instance
         * ::Checked::
            */
        public ConnectionInfo GetConnectionInfo(String username)
        {
            if (string.IsNullOrEmpty(username))
                return null;
            ConnectionInfo conInfo = null;

            SqlConnection con = new SqlConnection(connectionString);
            con.Open();
            SqlCommand query = new SqlCommand(string.Format(
                "SELECT username, password, server, proxy, serial_generator FROM utilizador WHERE username = '******'", username), con);
            SqlDataReader reader = query.ExecuteReader();
            if (reader.Read()) { //only the first occurrence
                Utilizador user = new Utilizador(reader.GetString(0), reader.GetString(1));
                string server = reader.GetString(2);
                string proxy = reader.GetString(3);
                if (!(string.IsNullOrEmpty(proxy) || proxy.Equals("null"))) {
                    //there is a proxy to save
                    conInfo = new ConnectionInfo(user, server, proxy);
                }
                else {
                    //no proxy
                    conInfo = new ConnectionInfo(user, server);
                }
                int defaultInt = reader.GetInt32 (4);
                conInfo.serial_generator = defaultInt;
            }
            reader.Close();
            con.Close();
            return conInfo;
        }