public CygtermStartInfo(SessionData session)
        {
            this.session = session;

            // parse host args and starting dir
            Match m = Regex.Match(session.Host, LocalHost + ":(.*)");
            String dir = m.Success ? m.Groups[1].Value : null;
            bool exists = false;
            if (dir != null)
            {
                exists = Directory.Exists(dir);
                Log.DebugFormat("Parsed dir from host. Host={0}, Dir={1}, Exists={2}", session.Host, dir, exists);
            }
            if (dir != null && exists)
            {
                // start bash...will start in process start dir
                this.Args = "-load \"" + session.PuttySession + "\" -cygterm bash -i ";
                this.StartingDir = dir;
            }
            else
            {
                // login shell
                // http://code.google.com/p/puttycyg/wiki/FAQ
                this.Args = "-load \"" + session.PuttySession + "\" -cygterm -";
            }
        }
        public MinttyStartInfo(SessionData session)
        {
            this.session = session;

            // parse host args and starting dir
            Match m = Regex.Match(session.Host, LocalHost + ":(.*)");
            String dir = m.Success ? m.Groups[1].Value : null;
            bool exists = false;
            if (dir != null)
            {
                exists = Directory.Exists(dir);
                Log.DebugFormat("Parsed dir from host. Host={0}, Dir={1}, Exists={2}", session.Host, dir, exists);
            }
            if (dir != null && exists)
            {
                // start bash...will start in process start dir
                // >mintty.exe /bin/env CHERE_INVOKING=1 /bin/bash -l
                this.Args = "/bin/env CHERE_INVOKING=1 /bin/bash -l";
                this.StartingDir = dir;
            }
            else
            {
                // login shell
                // http://code.google.com/p/puttycyg/wiki/FAQ
                this.Args = "-";
            }
        }
        public PuttyStartInfo(SessionData session)
        {
            string argsToLog = null;

            this.Executable = SuperPuTTY.Settings.PuttyExe;

            if (session.Proto == ConnectionProtocol.Cygterm)
            {
                CygtermStartInfo cyg = new CygtermStartInfo(session);
                this.Args = cyg.Args;
                this.WorkingDir = cyg.StartingDir;
            }
            else if (session.Proto == ConnectionProtocol.Mintty)
            {
                MinttyStartInfo mintty = new MinttyStartInfo(session);
                this.Args = mintty.Args;
                this.WorkingDir = mintty.StartingDir;
                this.Executable = SuperPuTTY.Settings.MinttyExe;
            }
            else
            {
                this.Args = MakeArgs(session, true);
                argsToLog = MakeArgs(session, false);
            }

            // attempt to parse env vars
            this.Args = this.Args.Contains('%') ? TryParseEnvVars(this.Args) : this.Args;

            Log.InfoFormat("Putty Args: '{0}'", argsToLog ?? this.Args);
        }
        /// <summary>
        /// Sync call to list directory contents
        /// </summary>
        /// <param name="session"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public ListDirectoryResult ListDirectory(SessionData session, BrowserFileInfo path)
        {
            ListDirectoryResult result;

            if (session == null || session.Username == null)
            {
                result = new ListDirectoryResult(path);
                result.ErrorMsg = "Session invalid";
                result.StatusCode = ResultStatusCode.Error;
            }
            else
            {
                string targetPath = path.Path;
                if (targetPath == null || targetPath == ".")
                {
                    targetPath = ScpUtils.GetHomeDirectory(session);
                    Log.InfoFormat("Defaulting path: {0}->{1}", path.Path, targetPath);
                    path.Path = targetPath;
                }

                PscpClient client = new PscpClient(this.Options, session);
                result = client.ListDirectory(path);
            }

            return result;
        }
Beispiel #5
0
        public static string GetHomeDirectory(SessionData sessionData)
        {
            var plink = SuperPuTTY.Settings.PlinkExe;

            if(!string.IsNullOrEmpty(plink) && File.Exists(plink))
            {
                var info = new ProcessStartInfo(plink);
                info.Arguments = string.Format("-load {0} pwd", sessionData.PuttySession);
                info.UseShellExecute = false;
                info.RedirectStandardOutput = true;
                info.RedirectStandardError = true;
                info.RedirectStandardInput = true;
                info.CreateNoWindow = true;

                using (var process = Process.Start(info))
                {
                    process.WaitForExit();
                    var directory = process.StandardOutput.ReadToEnd().Trim();
                    return directory;
                }
            }

            return (sessionData.Username == "root")
                ? "/root"
                : string.Format("/home/{0}", sessionData.Username);
        }
        public RemoteFileListPanel(PscpTransfer transfer, DockPanel dockPanel, SessionData session)
        {
            Log.InfoFormat("Started new File Transfer Session for {0}", session.SessionName);
            m_Session = session;
            m_DockPanel = dockPanel;
            m_Transfer = transfer;
            m_MouseFollower = new dlgMouseFeedback();
            InitializeComponent();

            this.TabText = session.SessionName;

            LoadDirectory(m_Path);
        }
        public ctlPuttyPanel(SessionData session, PuttyClosedCallback callback)
        {
            m_Session = session;
            m_ApplicationExit = callback;
            m_puttyStartInfo = new PuttyStartInfo(session);

            InitializeComponent();

            this.Text = session.SessionName;
            this.TabText = session.SessionName;
            this.TextOverride = session.SessionName;

            CreatePanel();
            AdjustMenu();
        }
        public ListDirectoryResult ListDirectory(SessionData session, BrowserFileInfo path)
        {
            Log.InfoFormat("GetFilesForPath, path={0}", path.Path);

            ListDirectoryResult result = new ListDirectoryResult(path);
            try
            {
                LoadDirectory(path, result);
            }
            catch (Exception ex)
            {
                result.SetError(null, ex);
                Log.ErrorFormat("Error loading directory: {0}", ex.Message);
            }

            return result;
        }
Beispiel #9
0
        public void ListDirHostNoKey()
        {
            SessionData session = new SessionData
            {
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password,
                Host = ScpConfig.UnKnownHost,
                Port = 22
            };

            PscpClient client = new PscpClient(ScpConfig.DefaultOptions, session);

            ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "." });

            Assert.AreEqual(ResultStatusCode.Error, res.StatusCode);
            Assert.AreEqual(res.Files.Count, 0);

            Log.InfoFormat("Result: {0}", res);
        }
Beispiel #10
0
        public void ListDirBadPath()
        {
            SessionData session = new SessionData
            {
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password,
                Host = ScpConfig.KnownHost,
                Port = 22
            };

            PscpClient client = new PscpClient(ScpConfig.DefaultOptions, session);

            ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "some_non_existant_dir" });

            Assert.AreEqual(ResultStatusCode.Error, res.StatusCode);
            Assert.AreEqual(0, res.Files.Count);
            Assert.IsTrue(res.ErrorMsg != null && res.ErrorMsg.StartsWith("Unable to open"));
            Log.InfoFormat("Result: {0}", res);
        }
        public BrowserPresenter(string name, IBrowserModel model, SessionData session, IFileTransferPresenter fileTransferPresenter)
        {
            this.Model = model;
            this.Session = session;

            this.FileTransferPresenter = fileTransferPresenter;
            this.FileTransferPresenter.ViewModel.FileTransfers.ListChanged += (FileTransfers_ListChanged);

            this.BackgroundWorker = new BackgroundWorker();
            this.BackgroundWorker.WorkerReportsProgress = true;
            this.BackgroundWorker.WorkerSupportsCancellation = true;
            this.BackgroundWorker.DoWork += (BackgroundWorker_DoWork);
            this.BackgroundWorker.ProgressChanged += (BackgroundWorker_ProgressChanged);
            this.BackgroundWorker.RunWorkerCompleted += (BackgroundWorker_RunWorkerCompleted);

            this.ViewModel = new BrowserViewModel
            {
                Name = name,
                BrowserState = BrowserState.Ready
            };
        }
        public void RunCombinedView()
        {
            Form form = new Form();

            SessionData session = new SessionData
            {
                //SessionId = "Test/SessionId",
                SessionName = "Test SessionName",
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password,
                Host = ScpConfig.KnownHost,
                Port = 22
            };

            FileTransferPresenter fileTransferPresenter = new FileTransferPresenter(ScpConfig.DefaultOptions);

            FileTransferView fileTransferView = new FileTransferView(fileTransferPresenter) { Dock = DockStyle.Bottom };
            BrowserView localBrowserView = new BrowserView(
                new BrowserPresenter("Local", new LocalBrowserModel(), session, fileTransferPresenter),
                new BrowserFileInfo(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))));
            localBrowserView.Dock = DockStyle.Fill;

            BrowserView remoteBrowserView = new BrowserView(
                new BrowserPresenter("Remote", new RemoteBrowserModel(ScpConfig.DefaultOptions), session, fileTransferPresenter),
                RemoteBrowserModel.NewDirectory("/home/" + ScpConfig.UserName));
            remoteBrowserView.Dock = DockStyle.Fill;

            SplitContainer browserPanel = new SplitContainer()
            {
                Dock = DockStyle.Fill,
                SplitterDistance = 75,
            };
            browserPanel.Panel1.Controls.Add(localBrowserView);
            browserPanel.Panel2.Controls.Add(remoteBrowserView);

            form.Controls.Add(browserPanel);
            form.Controls.Add(fileTransferView);
            form.Size = new Size(1024, 768);
            form.Show();
        }
        public PscpBrowserPanel(SessionData session, PscpOptions options, string localStartingDir)
            : this()
        {
            var fileTransferSession = (SessionData) session.Clone();

            // if the session doesn't contain a host, a port, or an username
            // try to get them from the putty profile
            if ((string.IsNullOrEmpty(fileTransferSession.Username) || string.IsNullOrEmpty(fileTransferSession.Host) || fileTransferSession.Port == 0)
                && !string.IsNullOrEmpty(fileTransferSession.PuttySession))
            {
                var puttyProfile = PuttyDataHelper.GetSessionData(fileTransferSession.PuttySession);

                fileTransferSession.Username = string.IsNullOrEmpty(fileTransferSession.Username)
                    ? puttyProfile.Username
                    : fileTransferSession.Username;

                fileTransferSession.Host = string.IsNullOrEmpty(fileTransferSession.Host)
                    ? puttyProfile.Host
                    : fileTransferSession.Host;

                fileTransferSession.Port = (fileTransferSession.Port == 0)
                    ? puttyProfile.Port
                    : fileTransferSession.Port;
            }

            this.Name = fileTransferSession.SessionName;
            this.TabText = fileTransferSession.SessionName;

            this.fileTransferPresenter = new FileTransferPresenter(options);
            this.localBrowserPresenter = new BrowserPresenter(
                "Local", new LocalBrowserModel(), fileTransferSession, fileTransferPresenter);
            this.remoteBrowserPresenter = new BrowserPresenter(
                "Remote", new RemoteBrowserModel(options), fileTransferSession, fileTransferPresenter);

            this.browserViewLocal.Initialize(this.localBrowserPresenter, new BrowserFileInfo(new DirectoryInfo(localStartingDir)));
            this.browserViewRemote.Initialize(this.remoteBrowserPresenter, RemoteBrowserModel.NewDirectory(ScpUtils.GetHomeDirectory(fileTransferSession)));
            this.fileTransferView.Initialize(this.fileTransferPresenter);
        }
        void TryConnectFromToolbar()
        {
            String host = this.tbTxtBoxHost.Text;
            String protoString = (string)this.tbComboProtocol.SelectedItem;

            if (!String.IsNullOrEmpty(host))
            {
                HostConnectionString connStr = new HostConnectionString(host);
                bool isScp = "SCP" == protoString;
                ConnectionProtocol proto = isScp
                    ? ConnectionProtocol.SSH
                    : connStr.Protocol.GetValueOrDefault((ConnectionProtocol) Enum.Parse(typeof(ConnectionProtocol), protoString));
                SessionData session = new SessionData
                {
                    Host = connStr.Host,
                    SessionName = connStr.Host,
                    //SessionId = SuperPuTTY.MakeUniqueSessionId(SessionData.CombineSessionIds("ConnectBar", connStr.Host)),
                    Proto = proto,
                    Port = connStr.Port.GetValueOrDefault(dlgEditSession.GetDefaultPort(proto)),
                    Username = this.tbTxtBoxLogin.Text,
                    Password = this.tbTxtBoxPassword.Text,
                    PuttySession = (string)this.tbComboSession.SelectedItem
                };
                SuperPuTTY.OpenSession(new SessionDataStartInfo { Session = session, UseScp = isScp });
                oldHostName = this.tbTxtBoxHost.Text;
                RefreshConnectionToolbarData();
            }
        }
        public void TestGUI()
        {
            Form form = new Form();
            form.Size = new Size(600, 800);

            SessionData session = new SessionData
            {
                Username = ScpConfig.UserName,
                Password = ScpConfig.Password,
                Host = ScpConfig.KnownHost,
                Port = 22
            };

            BrowserPresenter presenter = new BrowserPresenter(
                "Remote",
                new RemoteBrowserModel(ScpConfig.DefaultOptions),
                session,
                new MockFileTransferPresenter());

            BrowserView view = new BrowserView(
                presenter,
                RemoteBrowserModel.NewDirectory("/home/" + ScpConfig.UserName));
            view.Dock = DockStyle.Fill;

            form.Controls.Add(view);
            form.ShowDialog();
        }
        static string MakeArgs(SessionData session, bool includePassword, string path)
        {
            string args = "-ls "; // default arguments
            args += (!String.IsNullOrEmpty(session.PuttySession)) ? "-load \"" + session.PuttySession + "\" " : "";
            args += (!String.IsNullOrEmpty(session.Password) && session.Password.Length > 0)
                ? "-pw " + (includePassword ? session.Password : "******") + " "
                : "";
            args += "-P " + session.Port + " ";
            args += (!String.IsNullOrEmpty(session.Username)) ? session.Username + "@" : "";
            args += session.Host + ":" + path;

            return args;
        }
Beispiel #17
0
 public static Icon GetIconForSession(SessionData session)
 {
     Icon icon = null;
     if (session != null)
     {
         string imageKey = (session.ImageKey == null || !Images.Images.ContainsKey(session.ImageKey))
             ? SessionTreeview.ImageKeySession : session.ImageKey;
         try
         {
             Image img = Images.Images[imageKey];
             Bitmap bmp = img as Bitmap;
             if (bmp != null)
             {
                 icon = Icon.FromHandle(bmp.GetHicon());
             }
         }
         catch (Exception ex)
         {
             Log.Error("Error getting icon for image", ex);
         }
     }
     return icon;
 }
        /// <summary>
        /// Create/Update a session entry
        /// </summary>
        /// <param name="sender">The toolstripmenuitem control that was clicked</param>
        /// <param name="e">An Empty EventArgs object</param>
        private void CreateOrEditSessionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SessionData session = null;
            TreeNode node = null;
            TreeNode nodeRef = this.nodeRoot;
            bool isEdit = false;
            string title = null;
            if (sender is ToolStripMenuItem)
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                bool isFolderNode = IsFolderNode(treeView1.SelectedNode);
                if (menuItem.Text.ToLower().Equals("new") || isFolderNode)
                {
                    session = new SessionData();
                    nodeRef = isFolderNode ? treeView1.SelectedNode : treeView1.SelectedNode.Parent;
                    title = "Create New Session";
                }
                else if (menuItem == this.createLikeToolStripMenuItem)
                {
                    // copy as
                    session = (SessionData) ((SessionData) treeView1.SelectedNode.Tag).Clone();
                    //session.SessionId = SuperPuTTY.MakeUniqueSessionId(session.SessionId);
                    //session.SessionName = SessionData.GetSessionNameFromId(session.SessionId);
                    nodeRef = treeView1.SelectedNode.Parent;
                    title = "Create New Session Like " + session.SessionName;
                }
                else
                {
                    // edit, session node selected
                    session = (SessionData)treeView1.SelectedNode.Tag;
                    node = treeView1.SelectedNode;
                    nodeRef = node.Parent;
                    isEdit = true;
                    title = "Edit Session: " + session.SessionName;
                }
            }

            dlgEditSession form = new dlgEditSession(session, this.treeView1.ImageList);
            form.Text = title;
            form.SessionNameValidator += delegate(string txt, out string error)
            {
                error = String.Empty;
                bool isDupeNode = isEdit ? txt != node.Text && nodeRef.Nodes.ContainsKey(txt) : nodeRef.Nodes.ContainsKey(txt);
                if (isDupeNode)
                {
                    error = "Session with same name exists";
                }
                else if (txt.Contains(SessionIdDelim))
                {
                    error = "Invalid character ( " + SessionIdDelim + " ) in name";
                }
                else if (string.IsNullOrEmpty(txt) || txt.Trim() == String.Empty)
                {
                    error = "Empty name";
                }
                return string.IsNullOrEmpty(error);
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                /* "node" will only be assigned if we're editing an existing session entry */

                if (node == null)
                {
                    SuperPuTTY.AddSession(session, (SessionFolderData) nodeRef.Tag);
                    //this.treeView1.SelectedNode = AddSessionNode(nodeRef, session, true);

                }
                else
                {
                    // handle renames
                    /*node.Text = session.SessionName;
                    node.Name = session.SessionName;
                    node.ImageKey = session.ImageKey;
                    node.SelectedImageKey = session.ImageKey;*/

                    /*try
                    {
                        this.isRenamingNode = true;
                        ((SessionFolderData)(nodeRef.Tag)).Name = session.SessionName;
                    }
                    finally
                    {
                        this.isRenamingNode = false;
                    }*/
                    //this.treeView1.SelectedNode = node;
                }

                CreateTreeview();
                this.treeView1.SelectedNode = getTreeNode(nodeRoot, session);
            }
        }
 public PscpTransfer(SessionData session)
 {
     m_Session = session;
     m_Login = new dlgLogin(m_Session);
 }
        private static string GetSessionToolTip(SessionData session)
        {
            if (string.IsNullOrEmpty(session.PuttySession))
            {
                return session.ToString();
            }

            if (session.Proto != ConnectionProtocol.Auto && !string.IsNullOrEmpty(session.Host) && session.Port > 0)
            {
                return session.ToString();
            }

            var puttyProfile = PuttyDataHelper.GetSessionData(session.SessionName);

            var protocol = (session.Proto == ConnectionProtocol.Auto)
                ? puttyProfile.Proto
                : session.Proto;

            var host = string.IsNullOrEmpty(session.Host)
                ? puttyProfile.Host
                : session.Host;

            var port = (session.Port == 0)
                ? puttyProfile.Port
                : session.Port;

            return string.Format("{0}://{1}:{2}", protocol.ToString().ToLower(), host, port);
        }
Beispiel #21
0
        public static string ToArgs(SessionData session, string password, string path)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("-ls ");

            if (session.PuttySession != null)
            {
                sb.AppendFormat("-load \"{0}\" ", session.PuttySession);
            }
            if (!string.IsNullOrEmpty(session.Password))
            {
                sb.AppendFormat("-pw {0} ", password);
            }
            if (session.Port > 0)
            {
                sb.AppendFormat("-P {0} ", session.Port);
            }
            sb.AppendFormat("{0}@{1}:{2}", session.Username, session.Host, path);

            return sb.ToString();
        }
 public bool IsMatch(SessionData s)
 {
     if (this.Mode == SearchMode.CaseInSensitive)
     {
         return s.SessionName.ToLower().Contains(this.Filter.ToLower());
     }
     else if (this.Mode == SearchMode.Regex)
     {
         return this.Regex != null ? this.Regex.IsMatch(s.SessionName) : true;
     }
     else
     {
         // case sensitive
         return s.SessionName.Contains(this.Filter);
     }
 }
        public TreeNode getTreeNode(TreeNode treeNodeParent, SessionData sessionData)
        {
            foreach (TreeNode treeNode in treeNodeParent.Nodes)
            {
                if (IsSessionNode(treeNode))
                {
                    SessionData tagData = (SessionData)treeNode.Tag;
                    if (tagData == sessionData)
                    {
                        return treeNode;
                    }
                }

                TreeNode childTreeNode = getTreeNode(treeNode, sessionData);
                if (childTreeNode != null)
                {
                    return childTreeNode;
                }
            }
            return null;
        }
Beispiel #24
0
        public static void OpenPuttySession(SessionData session)
        {
            Log.InfoFormat("Opening putty session, id={0}", session == null ? "" : session.SessionName);
            if (session != null)
            {
                bool isFound = false;
                foreach (DockContent dContent in MainForm.DockPanel.Contents)
                {
                    if (dContent is ctlPuttyPanel)
                    {
                        ctlPuttyPanel tab = (ctlPuttyPanel)dContent;

                        if (tab.Session == session)
                        {
                            tab.Activate();
                            isFound = true;
                        }
                        SuperPuTTY.ReportStatus("dContent: {0}", tab.Session);

                    }
                }

                if (!isFound)
                {
                    ctlPuttyPanel sessionPanel = ctlPuttyPanel.NewPanel(session);
                    ApplyDockRestrictions(sessionPanel);
                    ApplyIconForWindow(sessionPanel, session);
                    sessionPanel.Show(MainForm.DockPanel, session.LastDockstate);
                    sessionPanel.FormClosed += sessionPanel_FormClosed;
                    session.IsActive = true;

                    SuperPuTTY.RefreshSessions();
                }
                SuperPuTTY.ReportStatus("Opened session: {0} [{1}]", session.SessionName, session.Proto);
            }
        }
Beispiel #25
0
 public PscpClient(PscpOptions options, SessionData session)
 {
     this.Options = options;
     this.Session = session;
 }
Beispiel #26
0
        public static void OpenScpSession(SessionData session)
        {
            Log.InfoFormat("Opening scp session, id={0}", session == null ? "" : session.SessionName);
            if (!IsScpEnabled)
            {
                SuperPuTTY.ReportStatus("Could not open session, pscp not found: {0} [SCP]", session.SessionName);
            }
            else if (session != null)
            {
                PscpBrowserPanel panel = new PscpBrowserPanel(
                    session, new PscpOptions { PscpLocation = Settings.PscpExe },
                    Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                ApplyDockRestrictions(panel);
                ApplyIconForWindow(panel, session);
                panel.Show(MainForm.DockPanel, session.LastDockstate);

                session.IsActive = true;
                SuperPuTTY.ReportStatus("Opened session: {0} [SCP]", session.SessionName);

                SuperPuTTY.RefreshSessions();
            }
            else
            {
                Log.Warn("Could not open null session");
            }
        }
 public PscpBrowserPanel(SessionData session, PscpOptions options)
     : this(session, options, Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
 {
 }
        private void AddSessionNode(TreeNode parentNode, SessionData session, bool isInitializing)
        {
            if (SelectionFilter.ENABLED_ONLY.Equals(SuperPuTTY.selectionFilter))
            {
                if (!session.Enabled)
                {
                    return;
                }
            }
            else if (SelectionFilter.DISABLED_ONLY.Equals(SuperPuTTY.selectionFilter))
            {
                if (session.Enabled)
                {
                    return;
                }
            }
            else if (SelectionFilter.ACTIVE_ONLY.Equals(SuperPuTTY.selectionFilter))
            {
                // active only
                if (!session.IsActive)
                {
                    return;
                }
            }
            else if (SelectionFilter.UNACTIVE_ONLY.Equals(SuperPuTTY.selectionFilter))
            {
                // inactive only
                if (session.IsActive)
                {
                    return;
                }
            }

            TreeNode addedNode = parentNode.Nodes.Add(session.SessionName, session.SessionName, ImageKeySession, ImageKeySession);
                addedNode.Tag = session;
                addedNode.ContextMenuStrip = this.contextMenuStripAddTreeItem;
                addedNode.ToolTipText = GetSessionToolTip(session);
                if (!session.Enabled)
                {
                    addedNode.ForeColor = SystemColors.GrayText;
                }
                if (session.IsActive)
                {
                    Font boldFont = new Font(this.treeView1.Font, FontStyle.Bold);
                    addedNode.NodeFont = boldFont;
                }
                // Override with custom icon if valid
                if (IsValidImage(session.ImageKey))
                {
                    addedNode.ImageKey = session.ImageKey;
                    addedNode.SelectedImageKey = session.ImageKey;
                }
        }
Beispiel #29
0
        static string ToArgs(SessionData session, string password, List<BrowserFileInfo> source, BrowserFileInfo target)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("-r -agent ");  // default arguments
            if (!String.IsNullOrEmpty(session.PuttySession))
            {
                sb.Append("-load \"").Append(session.PuttySession).Append("\" ");
            }
            if (!String.IsNullOrEmpty(password))
            {
                sb.Append("-pw ").Append(password).Append(" ");
            }
            sb.AppendFormat("-P {0} ", session.Port);

            if (target.Source == SourceType.Remote)
            {
                // possible to send multiple files remotely at a time
                foreach(BrowserFileInfo file in source)
                {
                    sb.AppendFormat("\"{0}\" ", file.Path);
                }
                sb.AppendFormat(" {0}@{1}:\"{2}\"", session.Username, session.Host, EscapeForUnix(target.Path));
            }
            else
            {
                if (source.Count > 1)
                {
                    Log.WarnFormat("Not possible to transfer multiple remote files locally at one time.  Tranfering first only!");
                }
                sb.AppendFormat(" {0}@{1}:\"{2}\" ", session.Username, session.Host, EscapeForUnix(source[0].Path));
                sb.AppendFormat("\"{0}\"", target.Path);
            }

            return sb.ToString();
        }
Beispiel #30
0
 static void ApplyIconForWindow(ToolWindow win, SessionData session)
 {
     win.Icon = GetIconForSession(session);
 }