Exemple #1
0
        public FTPClientForm(FTPAccount account)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            lblStatus.Text = string.Empty;
            lvFTPList.SubItemEndEditing += lvFTPList_SubItemEndEditing;

            FtpTrace.AddListener(new TextBoxTraceListener(txtDebug));

            Account = account;

            Client = new FTP(account);

            pgAccount.SelectedObject = Client.Account;
            Text = Resources.FTPClientForm_FTPClientForm_ShareX_FTP_client + " - " + account.Name;
            lblConnecting.Text = string.Format(Resources.FTPClientForm_FTPClientForm_Connecting_to__0_, account.FTPAddress);

            TaskEx.Run(() =>
            {
                Client.Connect();
            },
                       () =>
            {
                pConnecting.Visible = false;
                Refresh();
                RefreshDirectory();
            });
        }
Exemple #2
0
        public FTPClientForm(FTPAccount account)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            lblStatus.Text = string.Empty;
            lvFTPList.SubItemEndEditing += lvFTPList_SubItemEndEditing;

            FtpTrace.AddListener(new TextBoxTraceListener(txtDebug));

            Account = account;

            Client = new FTP(account);

            pgAccount.SelectedObject = Client.Account;
            Text = Resources.FTPClientForm_FTPClientForm_ShareX_FTP_client + " - " + account.Name;
            lblConnecting.Text = string.Format(Resources.FTPClientForm_FTPClientForm_Connecting_to__0_, account.FTPAddress);

            TaskEx.Run(() =>
            {
                Client.Connect();
            },
            () =>
            {
                pConnecting.Visible = false;
                Refresh();
                RefreshDirectory();
            });
        }
        private void FTPUpdateURLPreview()
        {
            FTPAccount account = FTPGetSelectedAccount();

            if (account != null)
            {
                lblFTPURLPreviewValue.Text = account.PreviewHttpPath;
            }
        }
        private void FTPLoadSelectedAccount()
        {
            FTPAccount account = FTPGetSelectedAccount();

            if (account != null)
            {
                FTPLoadAccount(account);
            }
        }
 private void FTPAddAccount(FTPAccount account)
 {
     if (account != null)
     {
         Config.FTPAccountList.Add(account);
         cbFTPAccounts.Items.Add(account);
         FTPUpdateControls();
     }
 }
        private void FTPClearFields()
        {
            FTPAccount account = new FTPAccount()
            {
                Name = "",
                HttpHomePathAutoAddSubFolderPath = false
            };

            FTPLoadAccount(account);
        }
 private void FTPOpenClient(FTPAccount account)
 {
     if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
     {
         new FTPClientForm(account).Show();
     }
     else
     {
         MessageBox.Show(Resources.UploadersConfigForm_FTPOpenClient_FTP_client_only_supports_FTP_or_FTPS_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #8
0
        private string GetURL(FtpListItem file)
        {
            if (file != null && file.Type == FtpFileSystemObjectType.File)
            {
                FTPAccount accountClone = Account.Clone();
                accountClone.SubFolderPath = currentDirectory;
                accountClone.HttpHomePathAutoAddSubFolderPath = true;
                return(accountClone.GetUriPath(file.Name));
            }

            return(null);
        }
        private async Task FTPTestAccountAsync(FTPAccount account)
        {
            if (account != null)
            {
                btnFTPTest.Enabled = false;

                await Task.Run(() =>
                {
                    FTPTestAccount(account);
                });

                btnFTPTest.Enabled = true;
            }
        }
        private void FTPLoadAccount(FTPAccount account)
        {
            txtFTPName.Text = account.Name;

            switch (account.Protocol)
            {
            case FTPProtocol.FTP:
                rbFTPProtocolFTP.Checked = true;
                break;

            case FTPProtocol.FTPS:
                rbFTPProtocolFTPS.Checked = true;
                break;

            case FTPProtocol.SFTP:
                rbFTPProtocolSFTP.Checked = true;
                break;
            }

            txtFTPHost.Text     = account.Host;
            nudFTPPort.Value    = account.Port;
            txtFTPUsername.Text = account.Username;
            txtFTPPassword.Text = account.Password;

            if (account.IsActive)
            {
                rbFTPTransferModeActive.Checked = true;
            }
            else
            {
                rbFTPTransferModePassive.Checked = true;
            }

            txtFTPRemoteDirectory.Text         = account.SubFolderPath;
            cbFTPURLPathProtocol.SelectedIndex = (int)account.BrowserProtocol;
            txtFTPURLPath.Text = account.HttpHomePath;
            cbFTPAppendRemoteDirectory.Checked = account.HttpHomePathAutoAddSubFolderPath;
            cbFTPRemoveFileExtension.Checked   = account.HttpHomePathNoExtension;
            lblFTPURLPreviewValue.Text         = account.PreviewHttpPath;

            cbFTPSEncryption.SelectedIndex  = (int)account.FTPSEncryption;
            txtFTPSCertificateLocation.Text = account.FTPSCertificateLocation;

            txtSFTPKeyLocation.Text   = account.Keypath;
            txtSFTPKeyPassphrase.Text = account.Passphrase;

            FTPUpdateEnabledStates();
        }
        private void FTPUpdateEnabledStates()
        {
            cbFTPImage.Enabled   = cbFTPText.Enabled = cbFTPFile.Enabled = cbFTPAccounts.Enabled = cbFTPAccounts.Items.Count > 0;
            btnFTPRemove.Enabled = btnFTPDuplicate.Enabled = gbFTPAccount.Enabled = cbFTPAccounts.SelectedIndex > -1;

            FTPAccount account = FTPGetSelectedAccount();

            if (account != null)
            {
                gbFTPS.Visible           = account.Protocol == FTPProtocol.FTPS;
                gbSFTP.Visible           = account.Protocol == FTPProtocol.SFTP;
                pFTPTransferMode.Enabled = account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS;
            }
            else
            {
                gbFTPS.Visible = gbSFTP.Visible = false;
            }
        }
Exemple #12
0
        public FTPClientForm(FTPAccount account)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            lblStatus.Text = "";
            lvFTPList.SubItemEndEditing += lvFTPList_SubItemEndEditing;

            FtpTrace.AddListener(new TextBoxTraceListener(txtDebug));

            Account = account;

            Client = new FTP(account);

            pgAccount.SelectedObject = Client.Account;
            Text = Resources.FTPClientForm_FTPClientForm_ShareX_FTP_client + " - " + account.Name;
            lblConnecting.Text = string.Format(Resources.FTPClientForm_FTPClientForm_Connecting_to__0_, account.FTPAddress);
        }
        public static void TestFTPAccount(FTPAccount account)
        {
            string msg = string.Empty;
            string remotePath = account.GetSubFolderPath();
            List<string> directories = new List<string>();

            try
            {
                if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
                {
                    using (FTP ftp = new FTP(account))
                    {
                        if (ftp.Connect())
                        {
                            if (!ftp.DirectoryExists(remotePath))
                            {
                                directories = ftp.CreateMultiDirectory(remotePath);
                            }

                            if (ftp.IsConnected)
                            {
                                if (directories.Count > 0)
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
                                }
                                else
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
                                }
                            }
                        }
                    }
                }
                else if (account.Protocol == FTPProtocol.SFTP)
                {
                    using (SFTP sftp = new SFTP(account))
                    {
                        if (sftp.Connect())
                        {
                            if (!sftp.DirectoryExists(remotePath))
                            {
                                directories = sftp.CreateMultiDirectory(remotePath);
                            }

                            if (sftp.IsConnected)
                            {
                                if (directories.Count > 0)
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
                                }
                                else
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                msg = e.Message;
            }

            MessageBox.Show(msg, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public void TestFTPAccountAsync(FTPAccount acc)
        {
            if (acc != null)
            {
                ucFTPAccounts.btnTest.Enabled = false;

                TaskEx.Run(() =>
                {
                    TestFTPAccount(acc);
                },
                () =>
                {
                    ucFTPAccounts.btnTest.Enabled = true;
                });
            }
        }
 public void AddFTPAccount(FTPAccount account)
 {
     if (account != null)
     {
         Config.FTPAccountList.Add(account);
         ucFTPAccounts.AddItem(account);
         FTPSetup(Config.FTPAccountList);
     }
 }
        private void FTPTestAccount(FTPAccount account)
        {
            string        msg         = "";
            string        remotePath  = account.GetSubFolderPath();
            List <string> directories = new List <string>();

            try
            {
                if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
                {
                    using (FTP ftp = new FTP(account))
                    {
                        if (ftp.Connect())
                        {
                            if (!ftp.DirectoryExists(remotePath))
                            {
                                directories = ftp.CreateMultiDirectory(remotePath);
                            }

                            if (ftp.IsConnected)
                            {
                                if (directories.Count > 0)
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
                                }
                                else
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
                                }
                            }
                        }
                    }
                }
                else if (account.Protocol == FTPProtocol.SFTP)
                {
                    using (SFTP sftp = new SFTP(account))
                    {
                        if (sftp.Connect())
                        {
                            if (!sftp.DirectoryExists(remotePath))
                            {
                                directories = sftp.CreateMultiDirectory(remotePath);
                            }

                            if (sftp.IsConnected)
                            {
                                if (directories.Count > 0)
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
                                }
                                else
                                {
                                    msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                msg = e.Message;
            }

            MessageBox.Show(msg, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #17
0
 public FTPOptions(FTPAccount acc, IWebProxy proxy)
 {
     Account = acc;
     ProxySettings = proxy;
 }
Exemple #18
0
 public FTPOptions(FTPAccount acc, IWebProxy proxy)
 {
     Account       = acc;
     ProxySettings = proxy;
 }