Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether this instance can connect to the FTP server. Run as little as possible, since it blocks the main thread while checking.
        /// </summary>
        /// <returns><c>true</c> if this instance can connect to the FTP server; otherwise, <c>false</c>.</returns>
        public bool CanConnectToFTP()
        {
            bool bCanConnectToFTP;

            string FTPURL      = Config.GetFTPUrl();
            string FTPUserName = Config.GetFTPUsername();
            string FTPPassword = Config.GetFTPPassword();

            try
            {
                FtpWebRequest plainRequest = (FtpWebRequest)FtpWebRequest.Create(FTPURL);
                plainRequest.Credentials = new NetworkCredential(FTPUserName, FTPPassword);
                plainRequest.Method      = WebRequestMethods.Ftp.ListDirectory;
                plainRequest.Timeout     = 8000;

                try
                {
                    WebResponse response = plainRequest.GetResponse();

                    plainRequest.Abort();
                    response.Close();

                    bCanConnectToFTP = true;
                }
                catch (WebException wex)
                {
                    Console.WriteLine("WebException in CanConnectToFTP(): " + wex.Message);
                    Console.WriteLine(FTPURL);

                    plainRequest.Abort();
                    bCanConnectToFTP = false;
                }
            }
            catch (WebException wex)
            {
                //case where FTP URL in config is not valid
                Console.WriteLine("WebException CanConnectToFTP() (Invalid URL): " + wex.Message);

                bCanConnectToFTP = false;
                return(bCanConnectToFTP);
            }

            if (!bCanConnectToFTP)
            {
                Console.WriteLine("Failed to connect to FTP server at: {0}", Config.GetBaseFTPUrl());
                bCanConnectToFTP = false;
            }

            return(bCanConnectToFTP);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Launchpad.SettingsDialog"/> class.
        /// </summary>
        public SettingsDialog()
        {
            this.Build();
            //fill in Local settings
            GameName_entry.Text = Config.GetGameName();

            combobox_SystemTarget.Active = (int)Config.GetSystemTarget();

            //fill in remote settings
            FTPURL_entry.Text      = Config.GetBaseFTPUrl();
            FTPUsername_entry.Text = Config.GetFTPUsername();
            FTPPassword_entry.Text = Config.GetFTPPassword();

            progressbar3.Text  = Mono.Unix.Catalog.GetString("Idle");
            buttonOk.Label     = Mono.Unix.Catalog.GetString("OK");
            buttonCancel.Label = Mono.Unix.Catalog.GetString("Cancel");
        }