X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/c1f5f956448a2bd052e71ee1a57f48d9327f2741..a1a27668d9b50bf95f517683b35fb4c5f5f16ca6:/windlg.c diff --git a/windlg.c b/windlg.c index d15ebb24..6302c55d 100644 --- a/windlg.c +++ b/windlg.c @@ -5,8 +5,8 @@ #include #include -#include "putty.h" #include "ssh.h" +#include "putty.h" #include "win_res.h" #define NPANELS 7 @@ -42,8 +42,6 @@ static void mungestr(char *in, char *out) { } static void unmungestr(char *in, char *out) { - int candot = 0; - while (*in) { if (*in == '%' && in[1] && in[2]) { int i, j; @@ -95,17 +93,13 @@ static void gppi(HKEY key, LPCTSTR name, int def, int *i) { *i = val; } -typedef struct { - void *posn; - void *temp; - char dataspace[2048]; -} DTemplate; - static HINSTANCE hinst; static char **sessions; static int nsessions; +static int readytogo; + static void save_settings (char *section, int do_host) { int i; HKEY subkey1, sesskey; @@ -153,6 +147,8 @@ static void save_settings (char *section, int do_host) { } wpps (sesskey, "UserName", cfg.username); wppi (sesskey, "NoPTY", cfg.nopty); + wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" : + "3des"); wppi (sesskey, "RFCEnviron", cfg.rfc_environ); wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete); wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend); @@ -217,14 +213,17 @@ static void load_settings (char *section, int do_host) { p = malloc(3*strlen(section)+1); mungestr(section, p); - - if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS || - RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) { + + if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS) { sesskey = NULL; + } else { + if (RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) { + sesskey = NULL; + } + RegCloseKey(subkey1); } free(p); - RegCloseKey(subkey1); if (do_host) { char prot[10]; @@ -265,6 +264,14 @@ static void load_settings (char *section, int do_host) { } gpps (sesskey, "UserName", "", cfg.username, sizeof(cfg.username)); gppi (sesskey, "NoPTY", 0, &cfg.nopty); + { + char cipher[10]; + gpps (sesskey, "Cipher", "3des", cipher, 10); + if (!strcmp(cipher, "blowfish")) + cfg.cipher = CIPHER_BLOWFISH; + else + cfg.cipher = CIPHER_3DES; + } gppi (sesskey, "RFCEnviron", 0, &cfg.rfc_environ); gppi (sesskey, "BackspaceIsDelete", 1, &cfg.bksp_is_delete); gppi (sesskey, "RXVTHomeEnd", 0, &cfg.rxvt_homeend); @@ -361,6 +368,27 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, return 0; } +static int CALLBACK LicenceProc (HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { + switch (msg) { + case WM_INITDIALOG: + return 1; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + abtbox = NULL; + DestroyWindow (hwnd); + return 0; + } + return 0; + case WM_CLOSE: + abtbox = NULL; + DestroyWindow (hwnd); + return 0; + } + return 0; +} + static int CALLBACK AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -381,7 +409,7 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg, case IDA_LICENCE: EnableWindow(hwnd, 0); DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX), - NULL, AboutProc); + NULL, LicenceProc); EnableWindow(hwnd, 1); return 0; } @@ -428,6 +456,15 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, cfg.protocol==PROT_SSH ? IDC0_PROTSSH : IDC0_PROTTELNET); CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit); break; + case WM_LBUTTONUP: + /* + * Button release should trigger WM_OK if there was a + * previous double click on the session list. + */ + ReleaseCapture(); + if (readytogo) + SendMessage (GetParent(hwnd), WM_COMMAND, IDOK, 0); + break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC0_PROTTELNET: @@ -525,8 +562,10 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, * Unless it's Default Settings or some other * host-less set of saved settings. */ - if (*cfg.host) - SendMessage (GetParent(hwnd), WM_COMMAND, IDOK, 0); + if (*cfg.host) { + readytogo = TRUE; + SetCapture(hwnd); + } } break; case IDC0_SESSDEL: @@ -834,6 +873,9 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype); SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username); CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty); + CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERBLOWF, + cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF : + IDC3_CIPHER3DES); break; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -852,6 +894,16 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.nopty = IsDlgButtonChecked (hwnd, IDC3_NOPTY); break; + case IDC3_CIPHER3DES: + case IDC3_CIPHERBLOWF: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES)) + cfg.cipher = CIPHER_3DES; + else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF)) + cfg.cipher = CIPHER_BLOWFISH; + } + break; } break; } @@ -1031,7 +1083,6 @@ static int CALLBACK ColourProc (HWND hwnd, UINT msg, return GeneralPanelProc (hwnd, msg, wParam, lParam); } -static DTemplate negot, main, reconf, panels[NPANELS]; static DLGPROC panelproc[NPANELS] = { ConnectionProc, KeyboardProc, TerminalProc, TelnetProc, SshProc, SelectionProc, ColourProc