コード例 #1
0
 /// <summary>
 /// Copy sessions from PuTTY into PuttyWrap Sessions
 /// </summary>
 public static void copySessionsFromPuTTY()
 {
     RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\SimonTatham\PuTTY\Sessions");
     if (key != null)
     {
         string[] savedSessionNames = key.GetSubKeyNames();
         foreach (string keyName in savedSessionNames)
         {
             if (keyName == "cygterm")
                 continue;
             RegistryKey sessionKey = key.OpenSubKey(keyName);
             if (sessionKey != null)
             {
                 SessionData session = new SessionData();
                 session.Host = (string)sessionKey.GetValue("HostName", "");
                 session.Port = (int)sessionKey.GetValue("PortNumber", 22);
                 session.Proto = (ConnectionProtocol)Enum.Parse(typeof(ConnectionProtocol),
                     (string)sessionKey.GetValue("Protocol", "SSH"), true);
                 session.PuttySession = (string)sessionKey.GetValue("PuttySession", HttpUtility.UrlDecode(keyName));
                 session.SessionName = HttpUtility.UrlDecode(keyName);
                 session.Username = (string)sessionKey.GetValue("UserName", Environment.UserName);
                 session.LastDockstate = DockState.Document;
                 session.AutoStartSession = false;
                 session.SaveToRegistry();
             }
         }
     }
 }
コード例 #2
0
ファイル: dlgLogin.cs プロジェクト: cooldroid/PuttyWrap
        public dlgLogin(SessionData session)
        {
            m_Session = session;
            InitializeComponent();

            if (!String.IsNullOrEmpty(m_Session.Username))
                this.Username = m_Session.Username;

            textBoxUsername.Text = this.Username;
        }
コード例 #3
0
ファイル: SessionData.cs プロジェクト: cooldroid/PuttyWrap
 public SessionData(SessionData data)
 {
     SessionName = data.SessionName;
     Host = data.Host;
     Port = data.Port;
     Proto = data.Proto;
     PuttySession = data.PuttySession;
     Username = data.Username;
     Password = data.Password;
     LastDockstate = data.LastDockstate;
     AutoStartSession = data.AutoStartSession;
 }
コード例 #4
0
        public RemoteFileListPanel(PscpTransfer transfer, DockPanel dockPanel, SessionData session)
        {
            Logger.Log("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);
        }
コード例 #5
0
ファイル: dlgEditSession.cs プロジェクト: cooldroid/PuttyWrap
        public dlgEditSession(SessionData session)
        {
            Session = session;
            InitializeComponent();

            // get putty saved settings from the registry to populate
            // the dropdown
            PopulatePuttySettings();

            if (!String.IsNullOrEmpty(Session.SessionName))
            {
                this.Text = "Edit session: " + session.SessionName;
                this.textBoxSessionName.Text = Session.SessionName;
                this.textBoxHostname.Text = Session.Host;
                this.textBoxPort.Text = Session.Port.ToString();
                this.textBoxUsername.Text = Session.Username;

                if (this.comboBoxPuttyProfile.Items.Contains(session.SessionName))
                    this.comboBoxPuttyProfile.SelectedItem = session.SessionName;

                switch (Session.Proto)
                {
                    case ConnectionProtocol.Raw:
                        radioButtonRaw.Checked = true;
                        break;
                    case ConnectionProtocol.Rlogin:
                        radioButtonRlogin.Checked = true;
                        break;
                    case ConnectionProtocol.Serial:
                        radioButtonSerial.Checked = true;
                        break;
                    case ConnectionProtocol.SSH:
                        radioButtonSSH.Checked = true;
                        break;
                    case ConnectionProtocol.Telnet:
                        radioButtonTelnet.Checked = true;
                        break;
                    default:
                        radioButtonSSH.Checked = true;
                        break;
                }
            }
            else
            {
                this.Text = "Create new session";
                radioButtonSSH.Checked = true;
            }
        }
コード例 #6
0
ファイル: ctlPuttyPanel.cs プロジェクト: cooldroid/PuttyWrap
        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();
        }
コード例 #7
0
ファイル: ctlPuttyPanel.cs プロジェクト: cooldroid/PuttyWrap
 void RestartSessionToolStripMenuItemClick(object sender, EventArgs e)
 {
     SessionData sessionData = new SessionData(m_Session);
     m_PuttyWrap.CreatePuttyPanel(sessionData);
     this.Close();
 }
コード例 #8
0
ファイル: ctlPuttyPanel.cs プロジェクト: cooldroid/PuttyWrap
 private void duplicateSessionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SessionData sessionData = new SessionData(m_Session);
     m_PuttyWrap.CreatePuttyPanel(sessionData);
 }
コード例 #9
0
ファイル: frmPuttyWrap.cs プロジェクト: cooldroid/PuttyWrap
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (this.HostTextBox.Text == "")
            {
                MessageBox.Show("You must enter a host ip or name to connect.", "PuttyWrap", MessageBoxButtons.OK);
            }
            else
            {
                SessionData sessionData = new SessionData();

                sessionData.Host = HostTextBox.Text;
                sessionData.Port = Convert.ToInt32(PortTextBox.Text);
                sessionData.Proto = (ProtocolBox.Text == "SCP") ? (ConnectionProtocol)Enum.Parse(typeof(ConnectionProtocol), "SSH") : (ConnectionProtocol)Enum.Parse(typeof(ConnectionProtocol), ProtocolBox.Text);
                sessionData.PuttySession = "Default Settings";
                sessionData.SessionName = HostTextBox.Text;
                sessionData.Username = LoginTextBox.Text;
                sessionData.Password = PasswordTextBox.Text;

                if (ProtocolBox.Text == "SCP" && IsScpEnabled)
                {
                    CreateRemoteFileListPanel(sessionData);
                }
                else
                {
                    CreatePuttyPanel(sessionData);
                }
            }
        }
コード例 #10
0
ファイル: frmPuttyWrap.cs プロジェクト: cooldroid/PuttyWrap
        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);
                }
            }
        }
コード例 #11
0
ファイル: frmPuttyWrap.cs プロジェクト: cooldroid/PuttyWrap
        public void CreatePuttyPanel(SessionData sessionData)
        {
            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);
            sessionPanel.Show(dockPanel1, sessionData.LastDockstate);
        }
コード例 #12
0
ファイル: PscpTransfer.cs プロジェクト: cooldroid/PuttyWrap
 public PscpTransfer(SessionData session)
 {
     m_Session = session;
     m_Login = new dlgLogin(m_Session);
 }
コード例 #13
0
 public PscpTransfer(SessionData session)
 {
     m_Session = session;
     m_Login   = new dlgLogin(m_Session);
 }
コード例 #14
0
        /// <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;

            if (sender is ToolStripMenuItem)
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                if (menuItem.Text.ToLower().Equals("new") || treeView1.SelectedNode.Tag == null)
                {
                    session = new SessionData();
                }
                else
                {
                    session = (SessionData)treeView1.SelectedNode.Tag;
                    node = treeView1.SelectedNode;
                }
            }

            dlgEditSession form = new dlgEditSession(session);
            if (form.ShowDialog() == DialogResult.OK)
            {
                /* "node" will only be assigned if we're editing an existing session entry */
                if (node == null)
                {
                    node = treeView1.Nodes["root"].Nodes.Add(session.SessionName, session.SessionName, 1, 1);
                }
                else
                {
                    // handle renames
                    node.Text = session.SessionName;
                }

                node.Tag = session;
                treeView1.ExpandAll();
            }
        }
コード例 #15
0
 /// <summary>
 /// Read any existing saved sessions from the registry, decode and populat a list containing the data
 /// </summary>
 /// <returns>A list containing the entries retrieved from the registry</returns>
 private static List<SessionData> LoadSessionsFromRegistry()
 {
     List<SessionData> sessionList = new List<SessionData>();
     RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Morgan Stanley\PuttyWrap\Sessions");
     if (key != null)
     {
         string[] sessionKeys = key.GetSubKeyNames();
         foreach (string session in sessionKeys)
         {
             SessionData sessionData = new SessionData();
             RegistryKey itemKey = key.OpenSubKey(session);
             if (itemKey != null)
             {
                 sessionData.Host = (string)itemKey.GetValue("Host", "");
                 sessionData.Port = (int)itemKey.GetValue("Port", 22);
                 sessionData.Proto = (ConnectionProtocol)Enum.Parse(typeof(ConnectionProtocol), (string)itemKey.GetValue("Proto", "SSH"));
                 sessionData.PuttySession = (string)itemKey.GetValue("PuttySession", "Default%20Settings");
                 sessionData.SessionName = session;
                 sessionData.Username = (string)itemKey.GetValue("Login", Environment.UserName);
                 sessionData.Password = (string)itemKey.GetValue("Password", "");
                 sessionData.LastDockstate = (DockState)itemKey.GetValue("Last Dock", DockState.Document);
                 sessionData.AutoStartSession = bool.Parse((string)itemKey.GetValue("Auto Start", "False"));
                 sessionList.Add(sessionData);
             }
         }
     }
     return sessionList;
 }
コード例 #16
0
ファイル: dlgRename.cs プロジェクト: cooldroid/PuttyWrap
 public dlgRename(SessionData session)
 {
     InitializeComponent();
     this.textBox1.Text = session.SessionName;
 }
コード例 #17
0
        private void duplicateSessionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SessionData sessionData = new SessionData(m_Session);

            m_PuttyWrap.CreatePuttyPanel(sessionData);
        }