Ejemplo n.º 1
0
 public PscpTransfer(SessionData session)
 {
     m_Session = session;
     m_Login = new dlgLogin(m_Session);
 }
        private bool LoadDirectory(string path)
        {
            Log.InfoFormat("Request directory listing for '{0}/{1}'", m_Session.SessionName, path);
            DirListingCallback dirCallback = delegate(RequestResult result, List<FileEntry> files)
            {
                switch (result)
                {
                    case RequestResult.RetryAuthentication:
                        this.BeginInvoke(new Action(() =>
                        {
                            dlgLogin m_Login = new dlgLogin(m_Session);
                            if (m_Login.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                if (m_Login.Username != null)
                                {
                                    m_Session.Username = m_Login.Username.Trim();
                                }

                                if (m_Login.Password != null)
                                {
                                    m_Session.Password = m_Login.Password.Trim();
                                }

                                LoadDirectory(path);
                            }
                            else
                            {
                                this.Close();
                            }
                        }));

                        break;
                    case RequestResult.ListingFollows:
                        Log.DebugFormat("Remote host returned {0} File entries", files.Count);
                        RefreshListView(files);
                        break;
                    case RequestResult.UnknownError:
                        Log.Info("Unknown Error trying to get file listing");
                        break;
                    case RequestResult.InvalidArguments:
                        Log.Info("Invalid Arguments Passed to scp");
                        break;
                    case RequestResult.SessionInvalid:
                        Log.Info("Session is invalid");
                        break;
                    case RequestResult.CancelLogin:
                        Log.Info("User cancel login");
                        this.BeginInvoke(new MethodInvoker(this.Close));
                        break;
                    default:
                        Log.InfoFormat("Unknown result '{0}'", result);
                        break;
                }
            };

            m_Transfer.BeginGetDirectoryListing(path, dirCallback);
            return true;
        }