Ejemplo n.º 1
0
        public ctlPuttyPanel(frmSuperPutty superPutty, SessionData session, PuttyClosedCallback callback, bool isPutty)
        {
            m_SuperPutty      = superPutty;
            m_Session         = session;
            m_ApplicationExit = callback;

            if (isPutty)
            {
                string args = "-" + session.Proto.ToString().ToLower() + " ";
                args += (!String.IsNullOrEmpty(m_Session.Password) && m_Session.Password.Length > 0) ? "-pw " + m_Session.Password + " " : "";
                args += "-P " + m_Session.Port + " ";
                args += (!String.IsNullOrEmpty(m_Session.PuttySession)) ? "-load \"" + m_Session.PuttySession + "\" " : "";
                args += (!String.IsNullOrEmpty(m_Session.Username) && m_Session.Username.Length > 0) ? m_Session.Username + "@" : "";
                args += m_Session.Host;
                Logger.Log("Args: '{0}'", args);
                this.ApplicationParameters = args;
            }
            else
            {
                this.ApplicationParameters = "-l - /bin/bash -l";
            }

            InitializeComponent();
            this.Text = session.SessionName;
            CreatePanel(isPutty);
        }
Ejemplo n.º 2
0
        public ctlPuttyPanel(frmSuperPutty superPutty, SessionData session, PuttyClosedCallback callback, bool isPutty)
        {
            m_SuperPutty = superPutty;
            m_Session = session;
            m_ApplicationExit = callback;

            if (isPutty)
            {
                string args = "-" + session.Proto.ToString().ToLower() + " ";
                args += (!String.IsNullOrEmpty(m_Session.Password) && m_Session.Password.Length > 0) ? "-pw " + m_Session.Password + " " : "";
                args += "-P " + m_Session.Port + " ";
                args += (!String.IsNullOrEmpty(m_Session.PuttySession)) ? "-load \"" + m_Session.PuttySession + "\" " : "";
                args += (!String.IsNullOrEmpty(m_Session.Username) && m_Session.Username.Length > 0) ? m_Session.Username + "@" : "";
                args += m_Session.Host;
                Logger.Log("Args: '{0}'", args);
                this.ApplicationParameters = args;
            }
            else
            {
                this.ApplicationParameters = "-l - /bin/bash -l";
            }

            InitializeComponent();
            this.Text = session.SessionName;
            CreatePanel(isPutty);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        public CtlPuttyPanel(SessionData session, PuttyClosedCallback callback)
        {
            _mSession         = session;
            _mApplicationExit = callback;
            _mPuttyStartInfo  = new PuttyStartInfo(session);

            InitializeComponent();

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

            CreatePanel();
            AdjustMenu();
        }
Ejemplo n.º 6
0
        public void CreateRemoteFileListPanel(SessionData sessionData)
        {
            RemoteFileListPanel dir = null;
            bool cancelShow         = false;

            if (sessionData != null)
            {
                PuttyClosedCallback callback = delegate(bool error)
                {
                    cancelShow = error;
                };
                PscpTransfer xfer = new PscpTransfer(sessionData);
                xfer.PuttyClosed = callback;

                dir = new RemoteFileListPanel(xfer, dockPanel1, sessionData);
                if (!cancelShow)
                {
                    dir.Show(dockPanel1);
                }
            }
        }
Ejemplo n.º 7
0
        public ctlPuttyPanel(frmPuttyWrap PuttyWrap, SessionData session, PuttyClosedCallback callback)
        {
            m_PuttyWrap = PuttyWrap;
            m_Session = session;
            m_ApplicationExit = callback;

            string args = "-" + session.Proto.ToString().ToLower() + " ";
            args += (!String.IsNullOrEmpty(m_Session.Password) && m_Session.Password.Length > 0) ? "-pw " + m_Session.Password + " " : "";
            args += "-P " + m_Session.Port + " ";
            args += (!String.IsNullOrEmpty(m_Session.PuttySession)) ? "-load \"" + m_Session.PuttySession + "\" " : "";
            args += (!String.IsNullOrEmpty(m_Session.Username) && m_Session.Username.Length > 0) ? m_Session.Username + "@" : "";
            args += m_Session.Host;
            Logger.Log("Args: '{0}'", args);
            this.ApplicationParameters = args;

            InitializeComponent();

            //this.Text = session.SessionName;
            this.TabText = session.SessionName;
            CreatePanel();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Opens the selected session when the node is double clicked in the treeview
        /// </summary>
        /// <param name="sender">The treeview control that was double clicked</param>
        /// <param name="e">An Empty EventArgs object</param>
        private void treeView1_DoubleClick(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode.ImageIndex > 0)
            {
                SessionData   sessionData  = (SessionData)treeView1.SelectedNode.Tag;
                ctlPuttyPanel sessionPanel = null;

                // This is the callback fired when the panel containing the terminal is closed
                // We use this to save the last docking location
                PuttyClosedCallback callback = delegate(bool closed)
                {
                    if (sessionPanel != null)
                    {
                        // save the last dockstate (if it has been changed)
                        if (sessionData.LastDockstate != sessionPanel.DockState &&
                            sessionPanel.DockState != DockState.Unknown &&
                            sessionPanel.DockState != DockState.Hidden)
                        {
                            sessionData.LastDockstate = sessionPanel.DockState;
                            sessionData.SaveToRegistry();
                        }

                        if (sessionPanel.InvokeRequired)
                        {
                            this.BeginInvoke((MethodInvoker) delegate()
                            {
                                sessionPanel.Close();
                            });
                        }
                        else
                        {
                            sessionPanel.Close();
                        }
                    }
                };

                sessionPanel = new ctlPuttyPanel(sessionData, callback);
                sessionPanel.Show(m_DockPanel, sessionData.LastDockstate);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Open a directory listing on the selected nodes host to allow dropping files
        /// for drag + drop copy.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fileBrowserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SessionData         session = (SessionData)treeView1.SelectedNode.Tag;
            RemoteFileListPanel dir     = null;
            bool cancelShow             = false;

            if (session != null)
            {
                PuttyClosedCallback callback = delegate(bool error)
                {
                    cancelShow = error;
                };
                PscpTransfer xfer = new PscpTransfer(session);
                xfer.PuttyClosed = callback;

                dir = new RemoteFileListPanel(xfer, m_DockPanel, session);
                if (!cancelShow)
                {
                    dir.Show(m_DockPanel);
                }
            }
        }
Ejemplo n.º 10
0
        public ctlPuttyPanel(frmPuttyWrap PuttyWrap, SessionData session, PuttyClosedCallback callback)
        {
            m_PuttyWrap       = PuttyWrap;
            m_Session         = session;
            m_ApplicationExit = callback;

            string args = "-" + session.Proto.ToString().ToLower() + " ";

            args += (!String.IsNullOrEmpty(m_Session.Password) && m_Session.Password.Length > 0) ? "-pw " + m_Session.Password + " " : "";
            args += "-P " + m_Session.Port + " ";
            args += (!String.IsNullOrEmpty(m_Session.PuttySession)) ? "-load \"" + m_Session.PuttySession + "\" " : "";
            args += (!String.IsNullOrEmpty(m_Session.Username) && m_Session.Username.Length > 0) ? m_Session.Username + "@" : "";
            args += m_Session.Host;
            Logger.Log("Args: '{0}'", args);
            this.ApplicationParameters = args;

            InitializeComponent();

            //this.Text = session.SessionName;
            this.TabText = session.SessionName;
            CreatePanel();
        }
Ejemplo n.º 11
0
        public void CreatePuttyPanel(SessionData sessionData, bool isPutty)
        {
            ctlPuttyPanel sessionPanel = null;

            // This is the callback fired when the panel containing the terminal is closed
            // We use this to save the last docking location
            PuttyClosedCallback callback = delegate(bool closed)
            {
                if (sessionPanel != null)
                {
                    // save the last dockstate (if it has been changed)
                    if (sessionData.LastDockstate != sessionPanel.DockState &&
                        sessionPanel.DockState != DockState.Unknown &&
                        sessionPanel.DockState != DockState.Hidden)
                    {
                        sessionData.LastDockstate = sessionPanel.DockState;
                        sessionData.SaveToRegistry();
                    }

                    if (sessionPanel.InvokeRequired)
                    {
                        this.BeginInvoke((MethodInvoker) delegate()
                        {
                            sessionPanel.Close();
                        });
                    }
                    else
                    {
                        sessionPanel.Close();
                    }
                }
            };

            sessionPanel = new ctlPuttyPanel(this, sessionData, callback, isPutty);
            sessionPanel.Show(dockPanel1, sessionData.LastDockstate);
            FocusCurrentTab();
        }
Ejemplo n.º 12
0
        public static ctlPuttyPanel NewPanel(SessionData sessionData)
        {
            ctlPuttyPanel puttyPanel = null;
            // This is the callback fired when the panel containing the terminal is closed
            // We use this to save the last docking location
            PuttyClosedCallback callback = delegate(bool closed)
            {
                if (puttyPanel != null)
                {
                    // save the last dockstate (if it has been changed)
                    if (sessionData.LastDockstate != puttyPanel.DockState &&
                        puttyPanel.DockState != DockState.Unknown &&
                        puttyPanel.DockState != DockState.Hidden)
                    {
                        sessionData.LastDockstate = puttyPanel.DockState;
                        SuperPuTTY.SaveSessions();
                        //sessionData.SaveToRegistry();
                    }

                    if (puttyPanel.InvokeRequired)
                    {
                        puttyPanel.BeginInvoke((MethodInvoker) delegate()
                        {
                            puttyPanel.Close();
                        });
                    }
                    else
                    {
                        puttyPanel.Close();
                    }
                }
            };

            puttyPanel = new ctlPuttyPanel(sessionData, callback);
            return(puttyPanel);
        }
Ejemplo n.º 13
0
        static void OpenScpSessionOld(SessionData session)
        {
            Log.InfoFormat("Opening scp session, id={0}", session == null ? "" : session.SessionId);
            if (!IsScpEnabled)
            {
                SuperPuTTY.ReportStatus("Could not open session, pscp not found: {0} [SCP]", session.SessionId);
            }
            else if (session != null)
            {
                RemoteFileListPanel panel = null;
                bool cancelShow           = false;
                if (session != null)
                {
                    PuttyClosedCallback callback = delegate(bool error)
                    {
                        cancelShow = error;
                    };
                    PscpTransfer xfer = new PscpTransfer(session);
                    xfer.PuttyClosed = callback;

                    panel = new RemoteFileListPanel(xfer, SuperPuTTY.MainForm.DockPanel, session);
                    ApplyDockRestrictions(panel);
                    ApplyIconForWindow(panel, session);
                    if (!cancelShow)
                    {
                        panel.Show(MainForm.DockPanel, session.LastDockstate);
                    }
                }

                SuperPuTTY.ReportStatus("Opened session: {0} [SCP]", session.SessionId);
            }
            else
            {
                Log.Warn("Could not open null session");
            }
        }
Ejemplo n.º 14
0
        /// <summary>Open a new putty window with its settings being passed in a <seealso cref="SessionData"/> object</summary>
        /// <param name="session">The <seealso cref="SessionData"/> object containing the settings</param>
        public static ctlPuttyPanel OpenProtoSession(SessionData session)
        {
            Log.InfoFormat("Opening putty session, id={0}", session == null ? "" : session.SessionId);
            ctlPuttyPanel panel = null;

            if (session != null)
            {
                String Executable = PuttyStartInfo.GetExecutable(session);
                if (String.IsNullOrEmpty(Executable))
                {
                    MessageBox.Show("Error trying to create session: " + session.ToString() +
                                    "\nExecutable not set for " + session.Proto.ToString() + " protocol." +
                                    "\nGo to tools->options->General tab to set the path to the executable."
                                    , "Failed to create a session", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
                if (!File.Exists(Executable))
                {
                    MessageBox.Show("Error trying to create session: " + session.ToString() +
                                    "\nExecutable not found for " + session.Proto.ToString() + " protocol." +
                                    "\nThe path for the executable was set as \"" + Executable + "\"." +
                                    "\nGo to tools->options->General tab to set the path to the executable."
                                    , "Failed to create a session", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }

                // This is the callback fired when the panel containing the terminal is closed
                // We use this to save the last docking location and to close the panel
                PuttyClosedCallback callback = delegate
                {
                    if (panel != null)
                    {
                        // save the last dockstate (if it has been changed)
                        if (session.LastDockstate != panel.DockState &&
                            panel.DockState != DockState.Unknown &&
                            panel.DockState != DockState.Hidden)
                        {
                            session.LastDockstate = panel.DockState;
                            SuperPuTTY.SaveSessions();
                        }

                        if (panel.InvokeRequired)
                        {
                            panel.BeginInvoke((MethodInvoker) delegate {
                                panel.Close();
                            });
                        }
                        else
                        {
                            panel.Close();
                        }
                    }
                };

                try {
                    panel = new ctlPuttyPanel(session, callback);

                    ApplyDockRestrictions(panel);
                    ApplyIconForWindow(panel, session);
                    panel.Show(MainForm.DockPanel, session.LastDockstate);
                    ReportStatus("Opened session: {0} [{1}]", session.SessionId, session.Proto);

                    if (!String.IsNullOrEmpty(session.SPSLFileName) &&
                        File.Exists(session.SPSLFileName))
                    {
                        ExecuteScriptEventArgs scriptArgs = new ExecuteScriptEventArgs()
                        {
                            Script = File.ReadAllText(session.SPSLFileName), Handle = panel.AppPanel.AppWindowHandle
                        };
                        if (!String.IsNullOrEmpty(scriptArgs.Script))
                        {
                            SPSL.BeginExecuteScript(scriptArgs);
                        }
                    }
                } catch (InvalidOperationException ex)
                {
                    MessageBox.Show("Error trying to create session " + ex.Message, "Failed to create session panel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(panel);
        }
Ejemplo n.º 15
0
        //********************************************************************************************
        private void OnLoad(object sender, EventArgs e)
        {
            if (server.Port == 0)
            {
                server.Port = 22;
            }

            SuspendLayout();

            switch (server.SshTerminal)
            {
            case 1:
            {
                PuttyClosedCallback closedCallback = delegate(bool closed)
                {
                    BeginInvoke((MethodInvoker) delegate
                        {
                            ((KRBTabControl)(Parent.Parent)).TabPages.Remove((TabPageEx)Parent);
                            DeletePuttySession();
                        });
                };

                PuttyStartedCallback startedCallback = delegate()
                {
                    BeginInvoke((MethodInvoker) delegate
                        {
                            statusLabel.Visible    = false;
                            loadingCircle1.Visible = false;
                            puttyPanel.Visible     = true;
                        });
                };

                puttyPanel                       = new ApplicationPanel();
                puttyPanel.Dock                  = System.Windows.Forms.DockStyle.Fill;
                puttyPanel.ApplicationName       = @"putty\putty.exe";
                puttyPanel.ApplicationParameters = String.Empty;
                puttyPanel.Name                  = "puttyPanel";
                puttyPanel.Margin                = new Padding(10);
                puttyPanel.TabIndex              = 0;
                puttyPanel.m_CloseCallback       = closedCallback;
                puttyPanel.m_StartCallback       = startedCallback;
                puttyPanel.Visible               = false;
                Controls.Add(puttyPanel);
            }
            break;

            case 2:
            {
                poderosaPanel              = new SshTerminalControl();
                poderosaPanel.Dock         = System.Windows.Forms.DockStyle.Fill;
                poderosaPanel.Visible      = false;
                poderosaPanel.SshProtocol  = (server.SSH1) ? SshProtocol.SSH1 : SshProtocol.SSH2;
                poderosaPanel.TerminalType = TerminalType.XTerm;
                poderosaPanel.Font         = new Font("Consolas", Main.config.GetValue("DEFAULT_SSH_FONT_SIZE").ToIntOrDefault(10));
                poderosaPanel.BackColor    = Color.Black;
                poderosaPanel.ForeColor    = Color.LightGray;
                poderosaPanel.HostName     = server.Host;
                poderosaPanel.Port         = server.Port;
                //terminalControl.IdentityFile = loginDialog.IdentityFile;
                poderosaPanel.Username = server.Username;
                poderosaPanel.Password = new SecureString();
                foreach (char character in server.Password)
                {
                    poderosaPanel.Password.AppendChar(character);
                }
                Controls.Add(poderosaPanel);
            }
            break;

            default:
                throw new Exception($"Invalid Terminal Type: {server.SshTerminal}");
            }
            ResumeLayout();
        }
Ejemplo n.º 16
0
        /// <summary>Open a new putty window with its settings being passed in a <seealso cref="SessionData"/> object</summary>
        /// <param name="session">The <seealso cref="SessionData"/> object containing the settings</param>
        public static ctlPuttyPanel OpenProtoSession(SessionData session)
        {
            Log.InfoFormat("Opening putty session, id={0}", session == null ? "" : session.SessionId);
            ctlPuttyPanel panel = null;

            if (session != null)
            {
                String Executable = PuttyStartInfo.GetExecutable(session);
                if (String.IsNullOrEmpty(Executable))
                {
                    MessageBox.Show("Error trying to create session: " + session.ToString() +
                                    "\nExecutable not set for " + session.Proto.ToString() + " protocol." +
                                    "\nGo to tools->options->General tab to set the path to the executable."
                                    , "Failed to create a session", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
                if (!File.Exists(Executable))
                {
                    MessageBox.Show("Error trying to create session: " + session.ToString() +
                                    "\nExecutable not found for " + session.Proto.ToString() + " protocol." +
                                    "\nThe path for the executable was set as \"" + Executable + "\"." +
                                    "\nGo to tools->options->General tab to set the path to the executable."
                                    , "Failed to create a session", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }

                // This is the callback fired when the panel containing the terminal is closed
                // We use this to save the last docking location and to close the panel
                PuttyClosedCallback callback = delegate
                {
                    if (panel != null)
                    {
                        // save the last dockstate (if it has been changed)
                        if (session.LastDockstate != panel.DockState &&
                            panel.DockState != DockState.Unknown &&
                            panel.DockState != DockState.Hidden)
                        {
                            session.LastDockstate = panel.DockState;
                            SuperPuTTY.SaveSessions();
                        }

                        if (panel.InvokeRequired)
                        {
                            panel.BeginInvoke((MethodInvoker) delegate {
                                panel.Close();
                            });
                        }
                        else
                        {
                            panel.Close();
                        }
                    }
                };

                try {
                    panel = new ctlPuttyPanel(session, callback);

                    ApplyDockRestrictions(panel);
                    ApplyIconForWindow(panel, session);
                    panel.Show(MainForm.DockPanel, session.LastDockstate);
                    ReportStatus("Opened session: {0} [{1}]", session.SessionId, session.Proto);

                    if (!String.IsNullOrWhiteSpace(session.SPSLFileName))
                    {
                        String fileName = session.SPSLFileName;
                        String script   = String.Empty;

                        if (Regex.IsMatch(fileName, @"^https?:\/\/", RegexOptions.IgnoreCase))
                        {
                            try
                            {
                                HttpWebRequest req      = WebRequest.CreateHttp(fileName);
                                var            response = req.GetResponse();
                                using (var stream = new StreamReader(response.GetResponseStream()))
                                {
                                    script = stream.ReadToEnd();
                                }
                            }
                            catch (Exception)
                            {
                                script = String.Empty;
                            }
                        }
                        else
                        {
                            if (fileName.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
                            {
                                fileName = fileName.Substring("file://".Length);
                            }

                            if (File.Exists(fileName))
                            {
                                script = File.ReadAllText(fileName);
                            }
                        }

                        if (!String.IsNullOrEmpty(script))
                        {
                            ExecuteScriptEventArgs scriptArgs = new ExecuteScriptEventArgs()
                            {
                                Script = script, Handle = panel.AppPanel.AppWindowHandle
                            };
                            SPSL.BeginExecuteScript(scriptArgs);
                        }
                    }
                } catch (InvalidOperationException ex)
                {
                    MessageBox.Show("Error trying to create session " + ex.Message, "Failed to create session panel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(panel);
        }