X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/d0718310cebfcc7b26136d53cc63e1cca2060e5c..6bb26b30935b575ae7e0e4e5b230ab21d151ea5e:/windlg.c diff --git a/windlg.c b/windlg.c index 8ad85bbe..99db197f 100644 --- a/windlg.c +++ b/windlg.c @@ -328,6 +328,10 @@ enum { IDCX_ABOUT = IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT, IDC_BELL_WAVEBROWSE, + IDC_B_IND_STATIC, + IDC_B_IND_DISABLED, + IDC_B_IND_FLASH, + IDC_B_IND_STEADY, IDC_BELLOVL, IDC_BELLOVLNSTATIC, IDC_BELLOVLN, @@ -499,10 +503,24 @@ enum { IDCX_ABOUT = tunnelspanelstart, IDC_TITLE_TUNNELS, - IDC_BOX_TUNNELS, + IDC_BOX_TUNNELS1, + IDC_BOX_TUNNELS2, IDC_X11_FORWARD, IDC_X11_DISPSTATIC, IDC_X11_DISPLAY, + IDC_LPORT_ALL, + IDC_PFWDSTATIC, + IDC_PFWDSTATIC2, + IDC_PFWDREMOVE, + IDC_PFWDLIST, + IDC_PFWDADD, + IDC_SPORTSTATIC, + IDC_SPORTEDIT, + IDC_DPORTSTATIC, + IDC_DPORTEDIT, + IDC_PFWDLOCAL, + IDC_PFWDREMOTE, + tunnelspanelend, controlendvalue @@ -614,6 +632,11 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE : cfg.beep == BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT); + CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY, + cfg.beep_ind == + B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind == + B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind == + B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED); SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile); CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl); SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE); @@ -654,11 +677,18 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) IDC_LSTATXAPN); { char *p = cfg.environmt; + SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0); while (*p) { SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0, (LPARAM) p); p += strlen(p) + 1; } + p = cfg.portfwd; + while (*p) { + SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0, + (LPARAM) p); + p += strlen(p) + 1; + } } CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC, cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD); @@ -716,7 +746,20 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE); SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE); - SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage); + { + int i; + char *cp; + int index = 0; + SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0); + for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) { + SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING, + 0, (LPARAM) cp); + if (!strcmp(cp, cfg.line_codepage)) + index = i; + } + SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_SETCURSEL, index, 0); + } + CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE, cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS : cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI : @@ -726,6 +769,9 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward); SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display); + + CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall); + CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL); } struct treeview_faff { @@ -770,10 +816,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) bartitle(&cp, "Basic options for your PuTTY session", IDC_TITLE_SESSION); if (dlgtype == 0) { - beginbox(&cp, "Specify your connection by host name", + beginbox(&cp, "Specify your connection by host name or IP address", IDC_BOX_SESSION1); multiedit(&cp, - "Host &Name", IDC_HOSTSTATIC, IDC_HOST, 75, + "Host &Name (or IP address)", + IDC_HOSTSTATIC, IDC_HOST, 75, "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL); if (backends[3].backend == NULL) { /* this is PuTTYtel, so only three protocols available */ @@ -861,7 +908,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) } if (panel == bellpanelstart) { - /* The Bell panel. Accelerators used: [acgo] bdsm wt */ + /* The Bell panel. Accelerators used: [acgo] bdsm wit */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the terminal bell", @@ -876,6 +923,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) editbutton(&cp, "Custom sound file to play as a bell:", IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT, "Bro&wse...", IDC_BELL_WAVEBROWSE); + radioline(&cp, "Taskbar/caption &indication on bell:", + IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED, + "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY, + NULL); endbox(&cp); beginbox(&cp, "Control the bell overload behaviour", IDC_BOX_BELL2); @@ -1016,10 +1067,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")", IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL); endbox(&cp); - beginbox(&cp, "Enable character set translation on received data", + beginbox(&cp, "Character set translation on received data", IDC_BOX_TRANSLATION2); - multiedit(&cp, "Line codepage:", IDC_CODEPAGESTATIC, - IDC_CODEPAGE, 100, NULL); + dropdownlist(&cp, + "Received data assumed to be in which character set:", + IDC_CODEPAGESTATIC, IDC_CODEPAGE); endbox(&cp); } @@ -1181,17 +1233,30 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) } if (panel == tunnelspanelstart) { - /* The Tunnels panel. Accelerators used: [acgo] ex */ + /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); if (dlgtype == 0) { bartitle(&cp, "Options controlling SSH tunnelling", IDC_TITLE_TUNNELS); - beginbox(&cp, "X11 forwarding options", IDC_BOX_TUNNELS); + beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1); checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD); multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC, IDC_X11_DISPLAY, 50, NULL); endbox(&cp); + beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2); + checkbox(&cp, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL); + staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC, + "&Remove", IDC_PFWDREMOVE); + fwdsetter(&cp, IDC_PFWDLIST, + "Add new forwarded port:", IDC_PFWDSTATIC2, + "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT, + "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT, + "A&dd", IDC_PFWDADD); + bareradioline(&cp, 2, + "&Local", IDC_PFWDLOCAL, "Re&mote", IDC_PFWDREMOTE, NULL); + endbox(&cp); + } } } @@ -1825,6 +1890,19 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, cfg.beep = BELL_VISUAL; } break; + case IDC_B_IND_DISABLED: + case IDC_B_IND_FLASH: + case IDC_B_IND_STEADY: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (LOWORD(wParam) == IDC_B_IND_DISABLED) + cfg.beep_ind = B_IND_DISABLED; + if (LOWORD(wParam) == IDC_B_IND_FLASH) + cfg.beep_ind = B_IND_FLASH; + if (LOWORD(wParam) == IDC_B_IND_STEADY) + cfg.beep_ind = B_IND_STEADY; + } + break; case IDC_BELL_WAVEBROWSE: memset(&of, 0, sizeof(of)); #ifdef OPENFILENAME_SIZE_VERSION_400 @@ -2328,28 +2406,11 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, } break; case IDC_CODEPAGE: - if (HIWORD(wParam) == EN_CHANGE) - GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage, - sizeof(cfg.line_codepage) - 1); - if (HIWORD(wParam) == EN_KILLFOCUS) { - int cp = decode_codepage(cfg.line_codepage); - char buf[256]; - if (cp < -1) { - if (cp == -2) - sprintf(buf, - "Unable to identify character set '%s', " - "translation disabled.", - cfg.line_codepage); - if (cp == -3) - sprintf(buf, - "Character set '%s' is a DBCS, " - "translation is not available.", - cfg.line_codepage); - MessageBox(hwnd, buf, "PuTTY Error", - MB_ICONERROR | MB_OK); - } - strcpy(cfg.line_codepage, cp_name(cp)); - SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage); + if (HIWORD(wParam) == CBN_SELCHANGE) { + int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE, + CB_GETCURSEL, 0, 0); + SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT, + index, (LPARAM)cfg.line_codepage); } break; case IDC_VTXWINDOWS: @@ -2373,11 +2434,101 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, cfg.x11_forward = IsDlgButtonChecked(hwnd, IDC_X11_FORWARD); break; + case IDC_LPORT_ALL: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.lport_acceptall = + IsDlgButtonChecked(hwnd, IDC_LPORT_ALL); + break; case IDC_X11_DISPLAY: if (HIWORD(wParam) == EN_CHANGE) GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display, sizeof(cfg.x11_display) - 1); break; + case IDC_PFWDADD: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + char str[sizeof(cfg.portfwd)]; + char *p; + if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL)) + str[0] = 'L'; + else + str[0] = 'R'; + GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1, + sizeof(str) - 2); + if (!str[1]) { + MessageBox(hwnd, + "You need to specify a source port number", + "PuTTY Error", MB_OK | MB_ICONERROR); + break; + } + p = str + strlen(str); + *p++ = '\t'; + GetDlgItemText(hwnd, IDC_DPORTEDIT, p, + sizeof(str) - 1 - (p - str)); + if (!*p || !strchr(p, ':')) { + MessageBox(hwnd, + "You need to specify a destination address\n" + "in the form \"host.name:port\"", + "PuTTY Error", MB_OK | MB_ICONERROR); + break; + } + p = cfg.portfwd; + while (*p) { + while (*p) + p++; + p++; + } + if ((p - cfg.portfwd) + strlen(str) + 2 < + sizeof(cfg.portfwd)) { + strcpy(p, str); + p[strlen(str) + 1] = '\0'; + SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, + 0, (LPARAM) str); + SetDlgItemText(hwnd, IDC_SPORTEDIT, ""); + SetDlgItemText(hwnd, IDC_DPORTEDIT, ""); + } else { + MessageBox(hwnd, "Too many forwardings", + "PuTTY Error", MB_OK | MB_ICONERROR); + } + } + break; + case IDC_PFWDREMOVE: + if (HIWORD(wParam) != BN_CLICKED && + HIWORD(wParam) != BN_DOUBLECLICKED) break; + i = SendDlgItemMessage(hwnd, IDC_PFWDLIST, + LB_GETCURSEL, 0, 0); + if (i == LB_ERR) + MessageBeep(0); + else { + char *p, *q; + + SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING, + i, 0); + p = cfg.portfwd; + while (i > 0) { + if (!*p) + goto disaster2; + while (*p) + p++; + p++; + i--; + } + q = p; + if (!*p) + goto disaster2; + while (*p) + p++; + p++; + while (*p) { + while (*p) + *q++ = *p++; + *q++ = *p++; + } + *q = '\0'; + disaster2:; + } + break; } return 0; case WM_CLOSE: @@ -2400,8 +2551,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, } if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) { EnableWindow(hwnd, 0); - DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), - GetParent(hwnd), AboutProc); + DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc); EnableWindow(hwnd, 1); SetActiveWindow(hwnd); } @@ -2426,6 +2576,7 @@ void defuse_showwindow(void) hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), NULL, NullDlgProc); ShowWindow(hwnd, SW_HIDE); + SetActiveWindow(hwnd); DestroyWindow(hwnd); } }