Loose end from r5031: the Kex panel should only be displayed in
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 29 Dec 2004 12:32:25 +0000 (12:32 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 29 Dec 2004 12:32:25 +0000 (12:32 +0000)
mid-session if we are not using SSHv1. I've done this by introducing
a generic `cfg_info' function which every back end can use to
communicate an int's worth of data to setup_config_box; in SSH
that's the protocol version in use, and in everything else it's
currently zero.

git-svn-id: svn://svn.tartarus.org/sgt/putty@5040 cda61777-01e9-0310-a592-d414129be87e

16 files changed:
config.c
mac/macdlg.c
putty.h
raw.c
rlogin.c
ssh.c
telnet.c
testback.c
unix/gtkdlg.c
unix/pterm.c
unix/pty.c
unix/unix.h
unix/uxputty.c
windows/windlg.c
windows/window.c
windows/winstuff.h

index 6d918c2..6a5961c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -770,7 +770,7 @@ static void portfwd_handler(union control *ctrl, void *dlg,
 }
 
 void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
-                     int midsession, int protocol)
+                     int midsession, int protocol, int protcfginfo)
 {
     struct controlset *s;
     struct sessionsaver_data *ssd;
@@ -1583,33 +1583,36 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
 
        /*
         * The Connection/SSH/Kex panel. (Owing to repeat key
-        * exchange, this is all meaningful in mid-session.)
+        * exchange, this is all meaningful in mid-session _if_
+        * we're using SSH2 or haven't decided yet.)
         */
-       ctrl_settitle(b, "Connection/SSH/Kex",
-                     "Options controlling SSH key exchange");
-
-       s = ctrl_getset(b, "Connection/SSH/Kex", "main",
-                       "Key exchange algorithm options");
-       c = ctrl_draglist(s, "Algorithm selection policy", 's',
-                         HELPCTX(ssh_kexlist),
-                         kexlist_handler, P(NULL));
-       c->listbox.height = 5;
-
-       s = ctrl_getset(b, "Connection/SSH/Kex", "repeat",
-                       "Options controlling key re-exchange");
-
-       ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20,
-                    HELPCTX(ssh_kex_repeat),
-                    dlg_stdeditbox_handler,
-                    I(offsetof(Config,ssh_rekey_time)),
-                    I(-1));
-       ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20,
-                    HELPCTX(ssh_kex_repeat),
-                    dlg_stdeditbox_handler,
-                    I(offsetof(Config,ssh_rekey_data)),
-                    I(16));
-       ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)",
-                 HELPCTX(ssh_kex_repeat));
+       if (protcfginfo != 1) {
+           ctrl_settitle(b, "Connection/SSH/Kex",
+                         "Options controlling SSH key exchange");
+
+           s = ctrl_getset(b, "Connection/SSH/Kex", "main",
+                           "Key exchange algorithm options");
+           c = ctrl_draglist(s, "Algorithm selection policy", 's',
+                             HELPCTX(ssh_kexlist),
+                             kexlist_handler, P(NULL));
+           c->listbox.height = 5;
+
+           s = ctrl_getset(b, "Connection/SSH/Kex", "repeat",
+                           "Options controlling key re-exchange");
+
+           ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20,
+                        HELPCTX(ssh_kex_repeat),
+                        dlg_stdeditbox_handler,
+                        I(offsetof(Config,ssh_rekey_time)),
+                        I(-1));
+           ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20,
+                        HELPCTX(ssh_kex_repeat),
+                        dlg_stdeditbox_handler,
+                        I(offsetof(Config,ssh_rekey_data)),
+                        I(16));
+           ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)",
+                     HELPCTX(ssh_kex_repeat));
+       }
 
        if (!midsession) {
 
index 872d189..544d9a1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macdlg.c,v 1.18 2003/04/05 15:01:16 ben Exp $ */
+/* $Id$ */
 /*
  * Copyright (c) 2002 Ben Harris
  * All rights reserved.
@@ -67,7 +67,7 @@ void mac_newsession(void)
 
     get_sesslist(&sesslist, TRUE);
     s->ctrlbox = ctrl_new_box();
-    setup_config_box(s->ctrlbox, &sesslist, FALSE, 0);
+    setup_config_box(s->ctrlbox, &sesslist, FALSE, 0, 0);
 
     s->settings_ctrls.data = &s->cfg;
     s->settings_ctrls.end = &mac_enddlg;
diff --git a/putty.h b/putty.h
index 4b0e3fe..0d74e94 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -340,6 +340,7 @@ struct backend_tag {
      * buffer is clearing.
      */
     void (*unthrottle) (void *handle, int);
+    int (*cfg_info) (void *handle);
     int default_port;
 };
 
@@ -920,7 +921,7 @@ void cmdline_error(char *, ...);
  */
 struct controlbox;
 void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
-                     int midsession, int protocol);
+                     int midsession, int protocol, int protcfginfo);
 
 /*
  * Exports from minibidi.c.
diff --git a/raw.c b/raw.c
index 8b1b1e9..631320c 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -236,6 +236,14 @@ static int raw_exitcode(void *handle)
         return 0;
 }
 
+/*
+ * cfg_info for Raw does nothing at all.
+ */
+static int raw_cfg_info(void *handle)
+{
+    return 0;
+}
+
 Backend raw_backend = {
     raw_init,
     raw_free,
@@ -252,5 +260,6 @@ Backend raw_backend = {
     raw_provide_ldisc,
     raw_provide_logctx,
     raw_unthrottle,
+    raw_cfg_info,
     1
 };
index 06c8b12..2f26230 100644 (file)
--- a/rlogin.c
+++ b/rlogin.c
@@ -303,6 +303,14 @@ static int rlogin_exitcode(void *handle)
         return 0;
 }
 
+/*
+ * cfg_info for rlogin does nothing at all.
+ */
+static int rlogin_cfg_info(void *handle)
+{
+    return 0;
+}
+
 Backend rlogin_backend = {
     rlogin_init,
     rlogin_free,
@@ -319,5 +327,6 @@ Backend rlogin_backend = {
     rlogin_provide_ldisc,
     rlogin_provide_logctx,
     rlogin_unthrottle,
+    rlogin_cfg_info,
     1
 };
diff --git a/ssh.c b/ssh.c
index de768d3..f92975d 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -7861,6 +7861,16 @@ static int ssh_return_exitcode(void *handle)
 }
 
 /*
+ * cfg_info for SSH is the currently running version of the
+ * protocol. (1 for 1; 2 for 2; 0 for not-decided-yet.)
+ */
+static int ssh_cfg_info(void *handle)
+{
+    Ssh ssh = (Ssh) handle;
+    return ssh->version;
+}
+
+/*
  * Gross hack: pscp will try to start SFTP but fall back to scp1 if
  * that fails. This variable is the means by which scp.c can reach
  * into the SSH code and find out which one it got.
@@ -7887,5 +7897,6 @@ Backend ssh_backend = {
     ssh_provide_ldisc,
     ssh_provide_logctx,
     ssh_unthrottle,
+    ssh_cfg_info,
     22
 };
index 8b2c428..13c2d3c 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -1050,6 +1050,14 @@ static int telnet_exitcode(void *handle)
         return 0;
 }
 
+/*
+ * cfg_info for Telnet does nothing at all.
+ */
+static int telnet_cfg_info(void *handle)
+{
+    return 0;
+}
+
 Backend telnet_backend = {
     telnet_init,
     telnet_free,
@@ -1066,5 +1074,6 @@ Backend telnet_backend = {
     telnet_provide_ldisc,
     telnet_provide_logctx,
     telnet_unthrottle,
+    telnet_cfg_info,
     23
 };
index bc2eb31..4bfb52d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: testback.c,v 1.10 2004/06/20 17:07:32 jacob Exp $ */
+/* $Id$ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999 Ben Harris
@@ -57,13 +57,15 @@ static void null_unthrottle(void *, int);
 Backend null_backend = {
     null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size,
     null_special, null_get_specials, null_socket, null_exitcode, null_sendok,
-    null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, 0
+    null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
+    null_cfg_info, 0
 };
 
 Backend loop_backend = {
     loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size,
     null_special, null_get_specials, null_socket, null_exitcode, null_sendok,
-    null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, 0
+    null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
+    null_cfg_info, 0
 };
 
 struct loop_state {
@@ -163,6 +165,12 @@ static void null_provide_logctx(void *handle, void *logctx) {
 
 }
 
+static int null_cfg_info(void *handle)
+{
+    return 0;
+}
+
+
 /*
  * Emacs magic:
  * Local Variables:
index 6b5659c..0ea6615 100644 (file)
@@ -1945,7 +1945,8 @@ int get_listitemheight(void)
     return req.height;
 }
 
-int do_config_box(const char *title, Config *cfg, int midsession)
+int do_config_box(const char *title, Config *cfg, int midsession,
+                 int protcfginfo)
 {
     GtkWidget *window, *hbox, *vbox, *cols, *label,
        *tree, *treescroll, *panels, *panelvbox;
@@ -1974,7 +1975,7 @@ int do_config_box(const char *title, Config *cfg, int midsession)
     window = gtk_dialog_new();
 
     ctrlbox = ctrl_new_box();
-    setup_config_box(ctrlbox, &sl, midsession, cfg->protocol);
+    setup_config_box(ctrlbox, &sl, midsession, cfg->protocol, protcfginfo);
     unix_setup_config_box(ctrlbox, midsession, window);
 
     gtk_window_set_title(GTK_WINDOW(window), title);
index 54ab31d..b1cd7d0 100644 (file)
@@ -2857,7 +2857,8 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
 
     cfg2 = inst->cfg;                  /* structure copy */
 
-    if (do_config_box(title, &cfg2, 1)) {
+    if (do_config_box(title, &cfg2, 1,
+                     inst->back?inst->back->cfg_info(inst->backhandle):0)) {
 
         oldcfg = inst->cfg;            /* structure copy */
         inst->cfg = cfg2;              /* structure copy */
index bef9f2f..d99d4e5 100644 (file)
@@ -804,6 +804,11 @@ static int pty_exitcode(void *handle)
        return pty_exit_code;
 }
 
+static int pty_cfg_info(void *handle)
+{
+    return 0;
+}
+
 Backend pty_backend = {
     pty_init,
     pty_free,
@@ -820,5 +825,6 @@ Backend pty_backend = {
     pty_provide_ldisc,
     pty_provide_logctx,
     pty_unthrottle,
+    pty_cfg_info,
     1
 };
index 969cdbb..909b3d4 100644 (file)
@@ -60,7 +60,8 @@ long get_windowid(void *frontend);
 void *get_window(void *frontend);      /* void * to avoid depending on gtk.h */
 
 /* Things pterm.c needs from gtkdlg.c */
-int do_config_box(const char *title, Config *cfg, int midsession);
+int do_config_box(const char *title, Config *cfg,
+                 int midsession, int protcfginfo);
 void fatal_message_box(void *window, char *msg);
 void about_box(void *window);
 void *eventlogstuff_new(void);
index d71d289..58ae24d 100644 (file)
@@ -40,7 +40,7 @@ Backend *select_backend(Config *cfg)
 
 int cfgbox(Config *cfg)
 {
-    return do_config_box("PuTTY Configuration", cfg, 0);
+    return do_config_box("PuTTY Configuration", cfg, 0, 0);
 }
 
 static int got_host = 0;
index 285691b..ba67ef5 100644 (file)
@@ -598,7 +598,7 @@ int do_config(void)
     int ret;
 
     ctrlbox = ctrl_new_box();
-    setup_config_box(ctrlbox, &sesslist, FALSE, 0);
+    setup_config_box(ctrlbox, &sesslist, FALSE, 0, 0);
     win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), FALSE);
     dp_init(&dp);
     winctrl_init(&ctrls_base);
@@ -624,7 +624,7 @@ int do_config(void)
     return ret;
 }
 
-int do_reconfig(HWND hwnd)
+int do_reconfig(HWND hwnd, int protcfginfo)
 {
     Config backup_cfg;
     int ret;
@@ -632,7 +632,7 @@ int do_reconfig(HWND hwnd)
     backup_cfg = cfg;                 /* structure copy */
 
     ctrlbox = ctrl_new_box();
-    setup_config_box(ctrlbox, &sesslist, TRUE, cfg.protocol);
+    setup_config_box(ctrlbox, &sesslist, TRUE, cfg.protocol, protcfginfo);
     win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), TRUE);
     dp_init(&dp);
     winctrl_init(&ctrls_base);
index b0d7d5c..68ba61f 100644 (file)
@@ -1900,7 +1900,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                GetWindowText(hwnd, cfg.wintitle, sizeof(cfg.wintitle));
                prev_cfg = cfg;
 
-               if (!do_reconfig(hwnd))
+               if (!do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0))
                    break;
 
                {
index 84db7b0..020f43b 100644 (file)
@@ -327,7 +327,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
  */
 void defuse_showwindow(void);
 int do_config(void);
-int do_reconfig(HWND);
+int do_reconfig(HWND, int);
 void showeventlog(HWND);
 void showabout(HWND);
 void force_normal(HWND hwnd);