Oops - check the _rest_ of the SSH2 DES patch back in. D'oh!
[u/mdw/putty] / windlg.c
CommitLineData
374330e2 1#include <windows.h>
2#include <commctrl.h>
3#include <commdlg.h>
374330e2 4#include <stdio.h>
5#include <stdlib.h>
b6c680d4 6#include <ctype.h>
71346075 7#include <time.h>
374330e2 8
374330e2 9#include "ssh.h"
bea1ef5f 10#include "putty.h"
8c3cd914 11#include "winstuff.h"
374330e2 12#include "win_res.h"
d5859615 13#include "storage.h"
374330e2 14
c5e9c988 15static char **events = NULL;
16static int nevents = 0, negsize = 0;
17
1cd246bb 18static int readytogo;
c8d7378d 19static int sesslist_has_focus;
1cd246bb 20
ca20bfcf 21static struct prefslist cipherlist;
22
3da0b1d2 23void force_normal(HWND hwnd)
c9def1b8 24{
a9422f39 25 static int recurse = 0;
c9def1b8 26
27 WINDOWPLACEMENT wp;
28
32874aea 29 if (recurse)
30 return;
c9def1b8 31 recurse = 1;
32
33 wp.length = sizeof(wp);
32874aea 34 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
c9def1b8 35 wp.showCmd = SW_SHOWNORMAL;
36 SetWindowPlacement(hwnd, &wp);
37 }
38 recurse = 0;
39}
40
32874aea 41static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
42{
374330e2 43 BOOL ok;
44 int n;
32874aea 45 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
374330e2 46 if (ok)
47 *result = n;
48}
49
32874aea 50static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
51{
7f4968e6 52 char text[80];
53 BOOL ok;
32874aea 54 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
7f4968e6 55 if (ok && text[0])
56 *result = (int) (scale * atof(text));
57}
58
32874aea 59static void MySetDlgItemFlt(HWND hwnd, int id, double value)
60{
7f4968e6 61 char text[80];
62 sprintf(text, "%g", value);
32874aea 63 SetDlgItemText(hwnd, id, text);
7f4968e6 64}
65
32874aea 66static int CALLBACK LogProc(HWND hwnd, UINT msg,
67 WPARAM wParam, LPARAM lParam)
68{
374330e2 69 int i;
70
71 switch (msg) {
72 case WM_INITDIALOG:
32874aea 73 {
74 static int tabs[4] = { 78, 108 };
75 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
76 (LPARAM) tabs);
77 }
78 for (i = 0; i < nevents; i++)
79 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
80 0, (LPARAM) events[i]);
374330e2 81 return 1;
374330e2 82 case WM_COMMAND:
83 switch (LOWORD(wParam)) {
84 case IDOK:
475eebf9 85 case IDCANCEL:
374330e2 86 logbox = NULL;
32874aea 87 SetActiveWindow(GetParent(hwnd));
88 DestroyWindow(hwnd);
374330e2 89 return 0;
32874aea 90 case IDN_COPY:
989b10e9 91 if (HIWORD(wParam) == BN_CLICKED ||
92 HIWORD(wParam) == BN_DOUBLECLICKED) {
32874aea 93 int selcount;
94 int *selitems;
95 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
96 LB_GETSELCOUNT, 0, 0);
97 if (selcount == 0) { /* don't even try to copy zero items */
98 MessageBeep(0);
99 break;
100 }
101
102 selitems = smalloc(selcount * sizeof(int));
103 if (selitems) {
104 int count = SendDlgItemMessage(hwnd, IDN_LIST,
105 LB_GETSELITEMS,
106 selcount,
107 (LPARAM) selitems);
108 int i;
109 int size;
110 char *clipdata;
111 static unsigned char sel_nl[] = SEL_NL;
112
113 if (count == 0) { /* can't copy zero stuff */
114 MessageBeep(0);
115 break;
116 }
117
118 size = 0;
119 for (i = 0; i < count; i++)
120 size +=
121 strlen(events[selitems[i]]) + sizeof(sel_nl);
122
123 clipdata = smalloc(size);
124 if (clipdata) {
125 char *p = clipdata;
126 for (i = 0; i < count; i++) {
127 char *q = events[selitems[i]];
128 int qlen = strlen(q);
129 memcpy(p, q, qlen);
130 p += qlen;
131 memcpy(p, sel_nl, sizeof(sel_nl));
132 p += sizeof(sel_nl);
133 }
4eeb7d09 134 write_aclip(clipdata, size, TRUE);
32874aea 135 sfree(clipdata);
136 }
137 sfree(selitems);
138
139 for (i = 0; i < nevents; i++)
140 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
141 FALSE, i);
142 }
143 }
144 return 0;
374330e2 145 }
146 return 0;
147 case WM_CLOSE:
148 logbox = NULL;
32874aea 149 SetActiveWindow(GetParent(hwnd));
150 DestroyWindow(hwnd);
374330e2 151 return 0;
152 }
153 return 0;
154}
155
32874aea 156static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
157 WPARAM wParam, LPARAM lParam)
158{
d57835ab 159 switch (msg) {
160 case WM_INITDIALOG:
161 return 1;
162 case WM_COMMAND:
163 switch (LOWORD(wParam)) {
164 case IDOK:
97749503 165 EndDialog(hwnd, 1);
d57835ab 166 return 0;
167 }
168 return 0;
169 case WM_CLOSE:
97749503 170 EndDialog(hwnd, 1);
d57835ab 171 return 0;
172 }
173 return 0;
174}
175
32874aea 176static int CALLBACK AboutProc(HWND hwnd, UINT msg,
177 WPARAM wParam, LPARAM lParam)
178{
374330e2 179 switch (msg) {
180 case WM_INITDIALOG:
32874aea 181 SetDlgItemText(hwnd, IDA_VERSION, ver);
374330e2 182 return 1;
374330e2 183 case WM_COMMAND:
184 switch (LOWORD(wParam)) {
185 case IDOK:
32874aea 186 case IDCANCEL:
187 EndDialog(hwnd, TRUE);
374330e2 188 return 0;
189 case IDA_LICENCE:
190 EnableWindow(hwnd, 0);
32874aea 191 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
192 NULL, LicenceProc);
374330e2 193 EnableWindow(hwnd, 1);
32874aea 194 SetActiveWindow(hwnd);
374330e2 195 return 0;
defab6b8 196
32874aea 197 case IDA_WEB:
198 /* Load web browser */
199 ShellExecute(hwnd, "open",
200 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
201 0, 0, SW_SHOWDEFAULT);
202 return 0;
374330e2 203 }
204 return 0;
205 case WM_CLOSE:
32874aea 206 EndDialog(hwnd, TRUE);
374330e2 207 return 0;
208 }
209 return 0;
210}
211
301b66db 212/*
213 * Null dialog procedure.
214 */
32874aea 215static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
216 WPARAM wParam, LPARAM lParam)
217{
301b66db 218 return 0;
219}
220
c96a8fef 221static char savedsession[2048];
222
32874aea 223enum { IDCX_ABOUT =
224 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
927d4fc5 225
226 sessionpanelstart,
227 IDC_TITLE_SESSION,
3ac9cd9f 228 IDC_BOX_SESSION1,
229 IDC_BOX_SESSION2,
927d4fc5 230 IDC_BOX_SESSION3,
231 IDC_HOSTSTATIC,
232 IDC_HOST,
233 IDC_PORTSTATIC,
234 IDC_PORT,
235 IDC_PROTSTATIC,
236 IDC_PROTRAW,
237 IDC_PROTTELNET,
c91409da 238 IDC_PROTRLOGIN,
927d4fc5 239 IDC_PROTSSH,
240 IDC_SESSSTATIC,
241 IDC_SESSEDIT,
242 IDC_SESSLIST,
243 IDC_SESSLOAD,
244 IDC_SESSSAVE,
245 IDC_SESSDEL,
246 IDC_CLOSEEXIT,
b41069ff 247 IDC_COEALWAYS,
b41069ff 248 IDC_COENEVER,
1cd48051 249 IDC_COENORMAL,
927d4fc5 250 sessionpanelend,
c96a8fef 251
0965bee0 252 loggingpanelstart,
156686ef 253 IDC_TITLE_LOGGING,
0965bee0 254 IDC_BOX_LOGGING1,
255 IDC_LSTATSTATIC,
256 IDC_LSTATOFF,
257 IDC_LSTATASCII,
258 IDC_LSTATRAW,
259 IDC_LGFSTATIC,
260 IDC_LGFEDIT,
261 IDC_LGFBUTTON,
66ee282a 262 IDC_LGFEXPLAIN,
9f89f96e 263 IDC_LSTATXIST,
264 IDC_LSTATXOVR,
265 IDC_LSTATXAPN,
266 IDC_LSTATXASK,
0965bee0 267 loggingpanelend,
268
c96a8fef 269 keyboardpanelstart,
927d4fc5 270 IDC_TITLE_KEYBOARD,
3ac9cd9f 271 IDC_BOX_KEYBOARD1,
272 IDC_BOX_KEYBOARD2,
273 IDC_BOX_KEYBOARD3,
927d4fc5 274 IDC_DELSTATIC,
275 IDC_DEL008,
276 IDC_DEL127,
277 IDC_HOMESTATIC,
278 IDC_HOMETILDE,
279 IDC_HOMERXVT,
280 IDC_FUNCSTATIC,
281 IDC_FUNCTILDE,
282 IDC_FUNCLINUX,
283 IDC_FUNCXTERM,
284 IDC_FUNCVT400,
f37caa11 285 IDC_FUNCVT100P,
286 IDC_FUNCSCO,
927d4fc5 287 IDC_KPSTATIC,
288 IDC_KPNORMAL,
289 IDC_KPAPPLIC,
290 IDC_KPNH,
b00f8b34 291 IDC_NOAPPLICK,
292 IDC_NOAPPLICC,
927d4fc5 293 IDC_CURSTATIC,
294 IDC_CURNORMAL,
295 IDC_CURAPPLIC,
a094ae43 296 IDC_COMPOSEKEY,
95bbe1ae 297 IDC_CTRLALTKEYS,
a5f3e637 298 IDC_TELNETKEY,
c96a8fef 299 keyboardpanelend,
300
301 terminalpanelstart,
927d4fc5 302 IDC_TITLE_TERMINAL,
3ac9cd9f 303 IDC_BOX_TERMINAL1,
304 IDC_BOX_TERMINAL2,
927d4fc5 305 IDC_WRAPMODE,
306 IDC_DECOM,
927d4fc5 307 IDC_LFHASCR,
927d4fc5 308 IDC_BCE,
309 IDC_BLINKTEXT,
e7fbcdd8 310 IDC_ANSWERBACK,
311 IDC_ANSWEREDIT,
0965bee0 312 IDC_ECHOSTATIC,
313 IDC_ECHOBACKEND,
314 IDC_ECHOYES,
315 IDC_ECHONO,
316 IDC_EDITSTATIC,
317 IDC_EDITBACKEND,
318 IDC_EDITYES,
319 IDC_EDITNO,
c96a8fef 320 terminalpanelend,
321
156686ef 322 bellpanelstart,
323 IDC_TITLE_BELL,
324 IDC_BOX_BELL1,
325 IDC_BOX_BELL2,
326 IDC_BELLSTATIC,
327 IDC_BELL_DISABLED,
328 IDC_BELL_DEFAULT,
03169ad0 329 IDC_BELL_WAVEFILE,
156686ef 330 IDC_BELL_VISUAL,
03169ad0 331 IDC_BELL_WAVESTATIC,
332 IDC_BELL_WAVEEDIT,
333 IDC_BELL_WAVEBROWSE,
f8a28d1f 334 IDC_B_IND_STATIC,
335 IDC_B_IND_DISABLED,
336 IDC_B_IND_FLASH,
337 IDC_B_IND_STEADY,
156686ef 338 IDC_BELLOVL,
339 IDC_BELLOVLNSTATIC,
340 IDC_BELLOVLN,
341 IDC_BELLOVLTSTATIC,
342 IDC_BELLOVLT,
343 IDC_BELLOVLEXPLAIN,
344 IDC_BELLOVLSSTATIC,
345 IDC_BELLOVLS,
346 bellpanelend,
347
c96a8fef 348 windowpanelstart,
927d4fc5 349 IDC_TITLE_WINDOW,
3ac9cd9f 350 IDC_BOX_WINDOW1,
351 IDC_BOX_WINDOW2,
4c4f2716 352 IDC_BOX_WINDOW3,
353 IDC_ROWSSTATIC,
354 IDC_ROWSEDIT,
355 IDC_COLSSTATIC,
356 IDC_COLSEDIT,
ad5c93cc 357 IDC_RESIZESTATIC,
358 IDC_RESIZETERM,
359 IDC_RESIZEFONT,
360 IDC_RESIZENONE,
0ed2f48e 361 IDC_RESIZEEITHER,
927d4fc5 362 IDC_SCROLLBAR,
a401e5f3 363 IDC_SCROLLBARFULLSCREEN,
927d4fc5 364 IDC_SAVESTATIC,
365 IDC_SAVEEDIT,
d0cadfcd 366 IDC_SCROLLKEY,
367 IDC_SCROLLDISP,
368 windowpanelend,
369
370 behaviourpanelstart,
371 IDC_TITLE_BEHAVIOUR,
372 IDC_BOX_BEHAVIOUR1,
373 IDC_CLOSEWARN,
927d4fc5 374 IDC_ALTF4,
375 IDC_ALTSPACE,
a094ae43 376 IDC_ALTONLY,
e95edc00 377 IDC_ALWAYSONTOP,
8f57d753 378 IDC_FULLSCREENONALTENTER,
d0cadfcd 379 behaviourpanelend,
c96a8fef 380
4c4f2716 381 appearancepanelstart,
382 IDC_TITLE_APPEARANCE,
3ac9cd9f 383 IDC_BOX_APPEARANCE1,
384 IDC_BOX_APPEARANCE2,
385 IDC_BOX_APPEARANCE3,
386 IDC_BOX_APPEARANCE4,
57d08f2f 387 IDC_BOX_APPEARANCE5,
2d3411e9 388 IDC_CURSORSTATIC,
4e30ff69 389 IDC_CURBLOCK,
390 IDC_CURUNDER,
391 IDC_CURVERT,
4c4f2716 392 IDC_BLINKCUR,
393 IDC_FONTSTATIC,
394 IDC_CHOOSEFONT,
395 IDC_WINTITLE,
396 IDC_WINEDIT,
397 IDC_WINNAME,
554c540d 398 IDC_HIDEMOUSE,
57d08f2f 399 IDC_SUNKENEDGE,
5a73255e 400 IDC_WINBSTATIC,
401 IDC_WINBEDIT,
4c4f2716 402 appearancepanelend,
403
927d4fc5 404 connectionpanelstart,
405 IDC_TITLE_CONNECTION,
3ac9cd9f 406 IDC_BOX_CONNECTION1,
407 IDC_BOX_CONNECTION2,
2184a5d9 408 IDC_BOX_CONNECTION3,
927d4fc5 409 IDC_TTSTATIC,
410 IDC_TTEDIT,
411 IDC_LOGSTATIC,
412 IDC_LOGEDIT,
413 IDC_PINGSTATIC,
414 IDC_PINGEDIT,
2184a5d9 415 IDC_NODELAY,
927d4fc5 416 connectionpanelend,
417
c96a8fef 418 telnetpanelstart,
927d4fc5 419 IDC_TITLE_TELNET,
3ac9cd9f 420 IDC_BOX_TELNET1,
421 IDC_BOX_TELNET2,
927d4fc5 422 IDC_TSSTATIC,
423 IDC_TSEDIT,
424 IDC_ENVSTATIC,
425 IDC_VARSTATIC,
426 IDC_VAREDIT,
427 IDC_VALSTATIC,
428 IDC_VALEDIT,
429 IDC_ENVLIST,
430 IDC_ENVADD,
431 IDC_ENVREMOVE,
432 IDC_EMSTATIC,
433 IDC_EMBSD,
434 IDC_EMRFC,
8faa456c 435 IDC_ACTSTATIC,
436 IDC_TPASSIVE,
437 IDC_TACTIVE,
c96a8fef 438 telnetpanelend,
439
c91409da 440 rloginpanelstart,
441 IDC_TITLE_RLOGIN,
3ac9cd9f 442 IDC_BOX_RLOGIN1,
443 IDC_BOX_RLOGIN2,
c91409da 444 IDC_R_TSSTATIC,
445 IDC_R_TSEDIT,
446 IDC_RLLUSERSTATIC,
447 IDC_RLLUSEREDIT,
448 rloginpanelend,
449
c96a8fef 450 sshpanelstart,
927d4fc5 451 IDC_TITLE_SSH,
3ac9cd9f 452 IDC_BOX_SSH1,
453 IDC_BOX_SSH2,
454 IDC_BOX_SSH3,
927d4fc5 455 IDC_NOPTY,
ca20bfcf 456 IDC_BOX_SSHCIPHER,
457 IDC_CIPHERSTATIC2,
458 IDC_CIPHERLIST,
459 IDC_CIPHERUP,
460 IDC_CIPHERDN,
7591b9ff 461 IDC_BUGGYMAC,
cb4d4768 462 IDC_SSH2DES,
927d4fc5 463 IDC_SSHPROTSTATIC,
464 IDC_SSHPROT1,
465 IDC_SSHPROT2,
927d4fc5 466 IDC_CMDSTATIC,
467 IDC_CMDEDIT,
4ba9b64b 468 IDC_COMPRESS,
c96a8fef 469 sshpanelend,
470
ca20bfcf 471 sshauthpanelstart,
472 IDC_TITLE_SSHAUTH,
473 IDC_BOX_SSHAUTH1,
474 IDC_BOX_SSHAUTH2,
475 IDC_PKSTATIC,
476 IDC_PKEDIT,
477 IDC_PKBUTTON,
478 IDC_AGENTFWD,
479 IDC_AUTHTIS,
f091e308 480 IDC_AUTHKI,
ca20bfcf 481 sshauthpanelend,
482
c96a8fef 483 selectionpanelstart,
927d4fc5 484 IDC_TITLE_SELECTION,
3ac9cd9f 485 IDC_BOX_SELECTION1,
486 IDC_BOX_SELECTION2,
d3a22f79 487 IDC_BOX_SELECTION3,
927d4fc5 488 IDC_MBSTATIC,
489 IDC_MBWINDOWS,
490 IDC_MBXTERM,
b90840c3 491 IDC_MOUSEOVERRIDE,
6908fed7 492 IDC_SELTYPESTATIC,
493 IDC_SELTYPELEX,
494 IDC_SELTYPERECT,
927d4fc5 495 IDC_CCSTATIC,
496 IDC_CCLIST,
497 IDC_CCSET,
498 IDC_CCSTATIC2,
499 IDC_CCEDIT,
d3a22f79 500 IDC_RAWCNP,
a7419ea4 501 IDC_RTFPASTE,
c96a8fef 502 selectionpanelend,
503
504 colourspanelstart,
927d4fc5 505 IDC_TITLE_COLOURS,
3ac9cd9f 506 IDC_BOX_COLOURS1,
507 IDC_BOX_COLOURS2,
927d4fc5 508 IDC_BOLDCOLOUR,
509 IDC_PALETTE,
5055f918 510 IDC_COLOURSTATIC,
511 IDC_COLOURLIST,
927d4fc5 512 IDC_RSTATIC,
513 IDC_GSTATIC,
514 IDC_BSTATIC,
515 IDC_RVALUE,
516 IDC_GVALUE,
517 IDC_BVALUE,
518 IDC_CHANGE,
c96a8fef 519 colourspanelend,
520
521 translationpanelstart,
927d4fc5 522 IDC_TITLE_TRANSLATION,
3ac9cd9f 523 IDC_BOX_TRANSLATION1,
524 IDC_BOX_TRANSLATION2,
a9c02454 525 IDC_BOX_TRANSLATION3,
4eeb7d09 526 IDC_CODEPAGESTATIC,
527 IDC_CODEPAGE,
a9c02454 528 IDC_CAPSLOCKCYR,
927d4fc5 529 IDC_VTSTATIC,
530 IDC_VTXWINDOWS,
531 IDC_VTOEMANSI,
532 IDC_VTOEMONLY,
533 IDC_VTPOORMAN,
4eeb7d09 534 IDC_VTUNICODE,
c96a8fef 535 translationpanelend,
536
9c964e85 537 tunnelspanelstart,
e6ace450 538 IDC_TITLE_TUNNELS,
d74d141c 539 IDC_BOX_TUNNELS1,
540 IDC_BOX_TUNNELS2,
9c964e85 541 IDC_X11_FORWARD,
542 IDC_X11_DISPSTATIC,
543 IDC_X11_DISPLAY,
d74d141c 544 IDC_LPORT_ALL,
545 IDC_PFWDSTATIC,
546 IDC_PFWDSTATIC2,
547 IDC_PFWDREMOVE,
548 IDC_PFWDLIST,
549 IDC_PFWDADD,
550 IDC_SPORTSTATIC,
551 IDC_SPORTEDIT,
552 IDC_DPORTSTATIC,
553 IDC_DPORTEDIT,
554 IDC_PFWDLOCAL,
555 IDC_PFWDREMOTE,
556
9c964e85 557 tunnelspanelend,
558
c96a8fef 559 controlendvalue
560};
561
562static const char *const colours[] = {
563 "Default Foreground", "Default Bold Foreground",
564 "Default Background", "Default Bold Background",
565 "Cursor Text", "Cursor Colour",
566 "ANSI Black", "ANSI Black Bold",
567 "ANSI Red", "ANSI Red Bold",
568 "ANSI Green", "ANSI Green Bold",
569 "ANSI Yellow", "ANSI Yellow Bold",
570 "ANSI Blue", "ANSI Blue Bold",
571 "ANSI Magenta", "ANSI Magenta Bold",
572 "ANSI Cyan", "ANSI Cyan Bold",
573 "ANSI White", "ANSI White Bold"
574};
575static const int permcolour[] = {
576 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
577 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
578 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
579};
580
32874aea 581static void fmtfont(char *buf)
582{
583 sprintf(buf, "Font: %s, ", cfg.font);
c96a8fef 584 if (cfg.fontisbold)
585 strcat(buf, "bold, ");
586 if (cfg.fontheight == 0)
32874aea 587 strcat(buf, "default height");
c96a8fef 588 else
32874aea 589 sprintf(buf + strlen(buf), "%d-point",
590 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
c96a8fef 591}
592
c8d7378d 593/* 2nd arg: NZ => don't redraw session list (use when loading
594 * a new session) */
595static void init_dlg_ctrls(HWND hwnd, int keepsess)
32874aea 596{
c96a8fef 597 int i;
598 char fontstatic[256];
599
32874aea 600 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
601 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
c8d7378d 602 if (!keepsess) {
3ac9cd9f 603 int i, n;
32874aea 604 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
605 for (i = n; i-- > 0;)
606 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
607 for (i = 0; i < nsessions; i++)
608 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
609 0, (LPARAM) (sessions[i]));
3ac9cd9f 610 }
32874aea 611 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
612 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
613 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
614 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
615 cfg.protocol ==
616 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
617 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
2184a5d9 618 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
32874aea 619
620 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
621 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
622 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
623 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
624 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
625 cfg.funky_type == 0 ? IDC_FUNCTILDE :
626 cfg.funky_type == 1 ? IDC_FUNCLINUX :
627 cfg.funky_type == 2 ? IDC_FUNCXTERM :
628 cfg.funky_type == 3 ? IDC_FUNCVT400 :
629 cfg.funky_type == 4 ? IDC_FUNCVT100P :
630 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
631 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
632 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
633 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
634 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
635 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
636 cfg.nethack_keypad ? IDC_KPNH :
637 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
638 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
639 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
640 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
641 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
642 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
a5f3e637 643 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
32874aea 644 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
645 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
646 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
647 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
648 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
649 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
650 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
651 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
8f57d753 652 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
32874aea 653 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
654 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
655
656 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
657 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
658 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
659 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
660 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
661 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
662 fmtfont(fontstatic);
663 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
664 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
665 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
666 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
667 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
668 cfg.beep ==
669 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
f8a28d1f 670 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
671 cfg.beep_ind ==
672 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
673 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
674 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
32874aea 675 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
676 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
677 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
678 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
679 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
680
681 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
682 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
683
684 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
685 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
686 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
687 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
5a73255e 688 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
32874aea 689 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
690 cfg.cursor_type == 0 ? IDC_CURBLOCK :
691 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
692 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
693 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
a401e5f3 694 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
0ed2f48e 695 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
ad5c93cc 696 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
697 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
0ed2f48e 698 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
ad5c93cc 699 IDC_RESIZENONE);
32874aea 700 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
701 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
702 cfg.close_on_exit ==
703 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
704 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
705
706 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
707 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
708 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
709 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
710 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
711 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
e1c8e0ed 712 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
713 cfg.logtype == 0 ? IDC_LSTATOFF :
32874aea 714 cfg.logtype == 1 ? IDC_LSTATASCII : IDC_LSTATRAW);
9f89f96e 715 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
716 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
717 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
718 IDC_LSTATXAPN);
c96a8fef 719 {
720 char *p = cfg.environmt;
1cb2aa45 721 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
c96a8fef 722 while (*p) {
32874aea 723 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
724 (LPARAM) p);
725 p += strlen(p) + 1;
c96a8fef 726 }
d74d141c 727 p = cfg.portfwd;
728 while (*p) {
729 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
730 (LPARAM) p);
731 p += strlen(p) + 1;
732 }
374330e2 733 }
32874aea 734 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
735 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
8faa456c 736 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
737 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
32874aea 738
739 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
740 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
741 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
742 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
743 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
cb4d4768 744 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
32874aea 745 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
32874aea 746 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
747 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
748 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
f091e308 749 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
32874aea 750 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
751 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
752
ca20bfcf 753 {
754 int i;
755 static const struct { char *s; int c; } ciphers[] = {
756 { "3DES", CIPHER_3DES },
757 { "Blowfish", CIPHER_BLOWFISH },
7f1ae1d2 758 { "DES", CIPHER_DES },
ca20bfcf 759 { "AES (SSH 2 only)", CIPHER_AES },
760 { "-- warn below here --", CIPHER_WARN }
761 };
762
763 /* Set up the "selected ciphers" box. */
764 /* (cipherlist assumed to contain all ciphers) */
765 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
766 for (i = 0; i < CIPHER_MAX; i++) {
767 int c = cfg.ssh_cipherlist[i];
768 int j, pos;
769 char *cstr = NULL;
770 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
771 if (ciphers[j].c == c) {
772 cstr = ciphers[j].s;
773 break;
774 }
775 }
776 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
777 0, (LPARAM) cstr);
778 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
779 pos, (LPARAM) c);
780 }
ca20bfcf 781
782 }
783
32874aea 784 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
785 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
6908fed7 786 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
787 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
b90840c3 788 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
32874aea 789 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
a7419ea4 790 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
c96a8fef 791 {
32874aea 792 static int tabs[4] = { 25, 61, 96, 128 };
793 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
794 (LPARAM) tabs);
c96a8fef 795 }
4eeb7d09 796 for (i = 0; i < 128; i++) {
c96a8fef 797 char str[100];
798 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
32874aea 799 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
800 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
801 (LPARAM) str);
c96a8fef 802 }
803
32874aea 804 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
805 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
c96a8fef 806 {
2ceb950f 807 int i, n;
32874aea 808 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
809 for (i = n; i-- > 0;)
810 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
811 LB_DELETESTRING, i, 0);
812 for (i = 0; i < 22; i++)
c96a8fef 813 if (cfg.bold_colour || permcolour[i])
32874aea 814 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
815 (LPARAM) colours[i]);
c96a8fef 816 }
32874aea 817 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
818 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
819 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
820 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
821
875b193f 822 {
823 int i;
824 char *cp;
b8ae1f0f 825 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
875b193f 826 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
a9c02454 827 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
875b193f 828 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
829 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
830 0, (LPARAM) cp);
875b193f 831 }
b8ae1f0f 832 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
875b193f 833 }
834
4eeb7d09 835 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
32874aea 836 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
837 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
838 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
4eeb7d09 839 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
32874aea 840 IDC_VTPOORMAN);
841
842 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
843 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
d74d141c 844
845 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
846 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
374330e2 847}
848
927d4fc5 849struct treeview_faff {
850 HWND treeview;
851 HTREEITEM lastat[4];
852};
853
854static HTREEITEM treeview_insert(struct treeview_faff *faff,
32874aea 855 int level, char *text)
856{
927d4fc5 857 TVINSERTSTRUCT ins;
858 int i;
859 HTREEITEM newitem;
32874aea 860 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
927d4fc5 861 ins.hInsertAfter = faff->lastat[level];
06a03685 862#if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
863#define INSITEM DUMMYUNIONNAME.item
864#else
865#define INSITEM item
866#endif
867 ins.INSITEM.mask = TVIF_TEXT;
868 ins.INSITEM.pszText = text;
927d4fc5 869 newitem = TreeView_InsertItem(faff->treeview, &ins);
870 if (level > 0)
32874aea 871 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
872 TVE_EXPAND);
927d4fc5 873 faff->lastat[level] = newitem;
32874aea 874 for (i = level + 1; i < 4; i++)
875 faff->lastat[i] = NULL;
927d4fc5 876 return newitem;
877}
878
c96a8fef 879/*
3ac9cd9f 880 * Create the panelfuls of controls in the configuration box.
881 */
32874aea 882static void create_controls(HWND hwnd, int dlgtype, int panel)
883{
3ac9cd9f 884 if (panel == sessionpanelstart) {
b41069ff 885 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
32874aea 886 struct ctlpos cp;
887 ctlposinit(&cp, hwnd, 80, 3, 13);
888 bartitle(&cp, "Basic options for your PuTTY session",
889 IDC_TITLE_SESSION);
890 if (dlgtype == 0) {
42ff6345 891 beginbox(&cp, "Specify your connection by host name or IP address",
32874aea 892 IDC_BOX_SESSION1);
893 multiedit(&cp,
42ff6345 894 "Host &Name (or IP address)",
895 IDC_HOSTSTATIC, IDC_HOST, 75,
32874aea 896 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
897 if (backends[3].backend == NULL) {
898 /* this is PuTTYtel, so only three protocols available */
4eeb7d09 899 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
32874aea 900 "&Raw", IDC_PROTRAW,
901 "&Telnet", IDC_PROTTELNET,
902 "Rlog&in", IDC_PROTRLOGIN, NULL);
903 } else {
904 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
905 "&Raw", IDC_PROTRAW,
906 "&Telnet", IDC_PROTTELNET,
907 "Rlog&in", IDC_PROTRLOGIN,
3ac9cd9f 908#ifdef FWHACK
32874aea 909 "SS&H/hack",
3ac9cd9f 910#else
32874aea 911 "SS&H",
3ac9cd9f 912#endif
32874aea 913 IDC_PROTSSH, NULL);
914 }
915 endbox(&cp);
916 beginbox(&cp, "Load, save or delete a stored session",
917 IDC_BOX_SESSION2);
918 sesssaver(&cp, "Sav&ed Sessions",
919 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
920 "&Load", IDC_SESSLOAD,
921 "&Save", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
922 endbox(&cp);
923 }
924 beginbox(&cp, NULL, IDC_BOX_SESSION3);
925 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
926 "Always", IDC_COEALWAYS,
927 "Never", IDC_COENEVER,
928 "Only on clean exit", IDC_COENORMAL, NULL);
929 endbox(&cp);
3ac9cd9f 930 }
931
0965bee0 932 if (panel == loggingpanelstart) {
32874aea 933 /* The Logging panel. Accelerators used: [acgo] tplfwe */
934 struct ctlpos cp;
935 ctlposinit(&cp, hwnd, 80, 3, 13);
936 bartitle(&cp, "Options controlling session logging",
937 IDC_TITLE_LOGGING);
938 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
939 radiobig(&cp,
940 "Session logging:", IDC_LSTATSTATIC,
941 "Logging &turned off completely", IDC_LSTATOFF,
942 "Log &printable output only", IDC_LSTATASCII,
943 "&Log all session output", IDC_LSTATRAW, NULL);
944 editbutton(&cp, "Log &file name:",
945 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
946 IDC_LGFBUTTON);
66ee282a 947 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
948 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
32874aea 949 radiobig(&cp,
950 "What to do if the log file already &exists:",
951 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
952 "Always append to the end of it", IDC_LSTATXAPN,
953 "Ask the user every time", IDC_LSTATXASK, NULL);
954 endbox(&cp);
0965bee0 955 }
956
3ac9cd9f 957 if (panel == terminalpanelstart) {
32874aea 958 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
959 struct ctlpos cp;
960 ctlposinit(&cp, hwnd, 80, 3, 13);
961 bartitle(&cp, "Options controlling the terminal emulation",
962 IDC_TITLE_TERMINAL);
963 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
964 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
965 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
966 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
967 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
968 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
969 multiedit(&cp,
970 "An&swerback to ^E:", IDC_ANSWERBACK,
971 IDC_ANSWEREDIT, 100, NULL);
972 endbox(&cp);
973
974 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
975 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
976 "Auto", IDC_ECHOBACKEND,
977 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
978 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
979 "Auto", IDC_EDITBACKEND,
980 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
981 endbox(&cp);
3ac9cd9f 982 }
983
156686ef 984 if (panel == bellpanelstart) {
f8a28d1f 985 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
32874aea 986 struct ctlpos cp;
987 ctlposinit(&cp, hwnd, 80, 3, 13);
988 bartitle(&cp, "Options controlling the terminal bell",
989 IDC_TITLE_BELL);
990 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
991 radiobig(&cp,
992 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
993 "None (bell disabled)", IDC_BELL_DISABLED,
994 "Play Windows Default Sound", IDC_BELL_DEFAULT,
995 "Play a custom sound file", IDC_BELL_WAVEFILE,
996 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
03169ad0 997 editbutton(&cp, "Custom sound file to play as a bell:",
998 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
999 "Bro&wse...", IDC_BELL_WAVEBROWSE);
f8a28d1f 1000 radioline(&cp, "Taskbar/caption &indication on bell:",
1001 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1002 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1003 NULL);
32874aea 1004 endbox(&cp);
156686ef 1005 beginbox(&cp, "Control the bell overload behaviour",
1006 IDC_BOX_BELL2);
1007 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1008 IDC_BELLOVL);
1009 staticedit(&cp, "Over-use means this &many bells...",
1010 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
9f89f96e 1011 staticedit(&cp, "... in &this many seconds",
156686ef 1012 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
32874aea 1013 statictext(&cp,
1014 "The bell is re-enabled after a few seconds of silence.",
66ee282a 1015 1, IDC_BELLOVLEXPLAIN);
32874aea 1016 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1017 IDC_BELLOVLS, 20);
1018 endbox(&cp);
156686ef 1019 }
1020
3ac9cd9f 1021 if (panel == keyboardpanelstart) {
32874aea 1022 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1023 struct ctlpos cp;
1024 ctlposinit(&cp, hwnd, 80, 3, 13);
d0cadfcd 1025 bartitle(&cp, "Options controlling the effects of keys",
1026 IDC_TITLE_KEYBOARD);
32874aea 1027 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1028 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1029 "Control-H", IDC_DEL008,
1030 "Control-? (127)", IDC_DEL127, NULL);
1031 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
1032 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1033 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1034 "ESC[n~", IDC_FUNCTILDE,
1035 "Linux", IDC_FUNCLINUX,
1036 "Xterm R6", IDC_FUNCXTERM,
f37caa11 1037 "VT400", IDC_FUNCVT400,
32874aea 1038 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1039 endbox(&cp);
1040 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1041 checkbox(&cp,
1042 "Application c&ursor keys totally disabled",
1043 IDC_NOAPPLICC);
1044 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1045 "Normal", IDC_CURNORMAL,
1046 "Application", IDC_CURAPPLIC, NULL);
1047 checkbox(&cp,
1048 "Application ke&ypad keys totally disabled",
1049 IDC_NOAPPLICK);
1050 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1051 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1052 "NetHack", IDC_KPNH, NULL);
1053 endbox(&cp);
1054 beginbox(&cp, "Enable extra keyboard features:",
1055 IDC_BOX_KEYBOARD3);
1056 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1057 checkbox(&cp, "Control-Alt is &different from AltGr",
1058 IDC_CTRLALTKEYS);
1059 endbox(&cp);
3ac9cd9f 1060 }
1061
1062 if (panel == windowpanelstart) {
d0cadfcd 1063 /* The Window panel. Accelerators used: [acgo] rmz sdikp */
32874aea 1064 struct ctlpos cp;
1065 ctlposinit(&cp, hwnd, 80, 3, 13);
1066 bartitle(&cp, "Options controlling PuTTY's window",
1067 IDC_TITLE_WINDOW);
1068 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1069 multiedit(&cp,
1070 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1071 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
d0cadfcd 1072 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1073 "Change the number of rows and columns", IDC_RESIZETERM,
1074 "Change the size of the font", IDC_RESIZEFONT,
1075 "Change font size only when maximised", IDC_RESIZEEITHER,
1076 "Forbid resizing completely", IDC_RESIZENONE, NULL);
32874aea 1077 endbox(&cp);
1078 beginbox(&cp, "Control the scrollback in the window",
1079 IDC_BOX_WINDOW2);
1080 staticedit(&cp, "Lines of &scrollback",
1081 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1082 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
a401e5f3 1083 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
32874aea 1084 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1085 checkbox(&cp, "Reset scrollback on dis&play activity",
1086 IDC_SCROLLDISP);
1087 endbox(&cp);
3ac9cd9f 1088 }
1089
1090 if (panel == appearancepanelstart) {
32874aea 1091 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1092 struct ctlpos cp;
1093 ctlposinit(&cp, hwnd, 80, 3, 13);
d0cadfcd 1094 bartitle(&cp, "Configure the appearance of PuTTY's window",
1095 IDC_TITLE_APPEARANCE);
32874aea 1096 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1097 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1098 "B&lock", IDC_CURBLOCK,
1099 "&Underline", IDC_CURUNDER,
1100 "&Vertical line", IDC_CURVERT, NULL);
1101 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1102 endbox(&cp);
1103 beginbox(&cp, "Set the font used in the terminal window",
1104 IDC_BOX_APPEARANCE2);
1105 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
1106 endbox(&cp);
1107 beginbox(&cp, "Adjust the use of the window title",
1108 IDC_BOX_APPEARANCE3);
1109 multiedit(&cp,
1110 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1111 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1112 endbox(&cp);
1113 beginbox(&cp, "Adjust the use of the mouse pointer",
1114 IDC_BOX_APPEARANCE4);
1115 checkbox(&cp, "Hide mouse &pointer when typing in window",
1116 IDC_HIDEMOUSE);
1117 endbox(&cp);
1118 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1119 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1120 IDC_SUNKENEDGE);
5a73255e 1121 staticedit(&cp, "Gap between text and window edge",
1122 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
32874aea 1123 endbox(&cp);
3ac9cd9f 1124 }
1125
d0cadfcd 1126 if (panel == behaviourpanelstart) {
1127 /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
1128 struct ctlpos cp;
1129 ctlposinit(&cp, hwnd, 80, 3, 13);
1130 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1131 IDC_TITLE_WINDOW);
1132 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1133 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1134 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1135 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1136 checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
1137 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1138 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1139 endbox(&cp);
1140 }
1141
3ac9cd9f 1142 if (panel == translationpanelstart) {
a9c02454 1143 /* The Translation panel. Accelerators used: [acgo] rxbepus */
32874aea 1144 struct ctlpos cp;
1145 ctlposinit(&cp, hwnd, 80, 3, 13);
1146 bartitle(&cp, "Options controlling character set translation",
1147 IDC_TITLE_TRANSLATION);
b682f470 1148 beginbox(&cp, "Character set translation on received data",
a9c02454 1149 IDC_BOX_TRANSLATION1);
8f57d753 1150 combobox(&cp, "&Received data assumed to be in which character set:",
b682f470 1151 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1152 endbox(&cp);
a9c02454 1153 beginbox(&cp, "Enable character set translation on input data",
1154 IDC_BOX_TRANSLATION2);
acb796a2 1155 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
a9c02454 1156 IDC_CAPSLOCKCYR);
1157 endbox(&cp);
32874aea 1158 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
a9c02454 1159 IDC_BOX_TRANSLATION3);
32874aea 1160 radiobig(&cp,
1161 "Handling of line drawing characters:", IDC_VTSTATIC,
1162 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1163 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1164 "Use font in O&EM mode only", IDC_VTOEMONLY,
1165 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
4eeb7d09 1166 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
32874aea 1167 endbox(&cp);
3ac9cd9f 1168 }
1169
1170 if (panel == selectionpanelstart) {
a7419ea4 1171 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
32874aea 1172 struct ctlpos cp;
1173 ctlposinit(&cp, hwnd, 80, 3, 13);
1174 bartitle(&cp, "Options controlling copy and paste",
1175 IDC_TITLE_SELECTION);
1176 beginbox(&cp, "Translation of pasted characters",
1177 IDC_BOX_SELECTION1);
1178 checkbox(&cp,
1179 "&Don't translate line drawing chars into +, - and |",
1180 IDC_RAWCNP);
a7419ea4 1181 checkbox(&cp,
1182 "Paste to clipboard in RT&F as well as plain text",
1183 IDC_RTFPASTE);
32874aea 1184 endbox(&cp);
1185 beginbox(&cp, "Control which mouse button does which thing",
1186 IDC_BOX_SELECTION2);
1187 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1188 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1189 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1190 NULL);
b90840c3 1191 checkbox(&cp,
1192 "Shift overrides a&pplication's use of mouse",
1193 IDC_MOUSEOVERRIDE);
6908fed7 1194 radioline(&cp,
1195 "Default selection mode (Alt+drag does the other one):",
1196 IDC_SELTYPESTATIC, 2,
1197 "&Normal", IDC_SELTYPELEX,
1198 "&Rectangular block", IDC_SELTYPERECT, NULL);
32874aea 1199 endbox(&cp);
1200 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1201 IDC_BOX_SELECTION3);
1202 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1203 "&Set", IDC_CCSET, IDC_CCEDIT,
1204 "&to class", IDC_CCSTATIC2);
1205 endbox(&cp);
3ac9cd9f 1206 }
1207
1208 if (panel == colourspanelstart) {
32874aea 1209 /* The Colours panel. Accelerators used: [acgo] blum */
1210 struct ctlpos cp;
1211 ctlposinit(&cp, hwnd, 80, 3, 13);
1212 bartitle(&cp, "Options controlling use of colours",
1213 IDC_TITLE_COLOURS);
1214 beginbox(&cp, "General options for colour usage",
1215 IDC_BOX_COLOURS1);
1216 checkbox(&cp, "&Bolded text is a different colour",
1217 IDC_BOLDCOLOUR);
1218 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1219 endbox(&cp);
1220 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1221 IDC_BOX_COLOURS2);
1222 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1223 IDC_COLOURSTATIC, IDC_COLOURLIST,
1224 "&Modify...", IDC_CHANGE,
1225 "Red:", IDC_RSTATIC, IDC_RVALUE,
1226 "Green:", IDC_GSTATIC, IDC_GVALUE,
1227 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1228 endbox(&cp);
3ac9cd9f 1229 }
1230
1231 if (panel == connectionpanelstart) {
2184a5d9 1232 /* The Connection panel. Accelerators used: [acgo] tukn */
32874aea 1233 struct ctlpos cp;
1234 ctlposinit(&cp, hwnd, 80, 3, 13);
1235 bartitle(&cp, "Options controlling the connection",
1236 IDC_TITLE_CONNECTION);
1237 if (dlgtype == 0) {
1238 beginbox(&cp, "Data to send to the server",
1239 IDC_BOX_CONNECTION1);
1240 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1241 IDC_TTEDIT, 50);
1242 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1243 IDC_LOGEDIT, 50);
1244 endbox(&cp);
a5f3e637 1245 } else {
1246 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1247 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1248 IDC_TELNETKEY);
1249 endbox(&cp);
32874aea 1250 }
1251 beginbox(&cp, "Sending of null packets to keep session active",
1252 IDC_BOX_CONNECTION2);
1253 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1254 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1255 endbox(&cp);
2184a5d9 1256 if (dlgtype == 0) {
1257 beginbox(&cp, "Low-level TCP connection options",
1258 IDC_BOX_CONNECTION3);
1259 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1260 IDC_NODELAY);
1261 endbox(&cp);
1262 }
3ac9cd9f 1263 }
1264
1265 if (panel == telnetpanelstart) {
a5f3e637 1266 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
32874aea 1267 struct ctlpos cp;
1268 ctlposinit(&cp, hwnd, 80, 3, 13);
1269 if (dlgtype == 0) {
1270 bartitle(&cp, "Options controlling Telnet connections",
1271 IDC_TITLE_TELNET);
1272 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1273 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1274 IDC_TSEDIT, 50);
1275 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1276 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1277 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1278 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1279 endbox(&cp);
1280 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1281 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1282 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1283 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
8faa456c 1284 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1285 "Passive", IDC_TPASSIVE, "Active",
1286 IDC_TACTIVE, NULL);
a5f3e637 1287 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1288 IDC_TELNETKEY);
32874aea 1289 endbox(&cp);
1290 }
3ac9cd9f 1291 }
1292
1293 if (panel == rloginpanelstart) {
32874aea 1294 /* The Rlogin panel. Accelerators used: [acgo] sl */
1295 struct ctlpos cp;
1296 ctlposinit(&cp, hwnd, 80, 3, 13);
1297 if (dlgtype == 0) {
1298 bartitle(&cp, "Options controlling Rlogin connections",
1299 IDC_TITLE_RLOGIN);
1300 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1301 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1302 IDC_R_TSEDIT, 50);
1303 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1304 IDC_RLLUSEREDIT, 50);
1305 endbox(&cp);
1306 }
3ac9cd9f 1307 }
1308
1309 if (panel == sshpanelstart) {
cb4d4768 1310 /* The SSH panel. Accelerators used: [acgo] r pe12i sd */
32874aea 1311 struct ctlpos cp;
1312 ctlposinit(&cp, hwnd, 80, 3, 13);
1313 if (dlgtype == 0) {
1314 bartitle(&cp, "Options controlling SSH connections",
1315 IDC_TITLE_SSH);
1316 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1317 multiedit(&cp,
1318 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1319 NULL);
1320 endbox(&cp);
ca20bfcf 1321 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
32874aea 1322 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1323 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1324 radioline(&cp, "Preferred SSH protocol version:",
1325 IDC_SSHPROTSTATIC, 2,
1326 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
32874aea 1327 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1328 IDC_BUGGYMAC);
1329 endbox(&cp);
ca20bfcf 1330 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1331 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1332 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1333 IDC_CIPHERDN);
cb4d4768 1334 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1335 IDC_SSH2DES);
ca20bfcf 1336 endbox(&cp);
1337 }
1338 }
1339
1340 if (panel == sshauthpanelstart) {
f091e308 1341 /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
ca20bfcf 1342 struct ctlpos cp;
1343 ctlposinit(&cp, hwnd, 80, 3, 13);
1344 if (dlgtype == 0) {
1345 bartitle(&cp, "Options controlling SSH authentication",
1346 IDC_TITLE_SSHAUTH);
1347 beginbox(&cp, "Authentication methods",
1348 IDC_BOX_SSHAUTH1);
f091e308 1349 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
ca20bfcf 1350 IDC_AUTHTIS);
f091e308 1351 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1352 " (SSH2)", IDC_AUTHKI);
ca20bfcf 1353 endbox(&cp);
1354 beginbox(&cp, "Authentication parameters",
1355 IDC_BOX_SSHAUTH2);
1356 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1357 editbutton(&cp, "Private &key file for authentication:",
1358 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1359 IDC_PKBUTTON);
1360 endbox(&cp);
32874aea 1361 }
3ac9cd9f 1362 }
1363
1364 if (panel == tunnelspanelstart) {
d74d141c 1365 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
32874aea 1366 struct ctlpos cp;
1367 ctlposinit(&cp, hwnd, 80, 3, 13);
1368 if (dlgtype == 0) {
1369 bartitle(&cp, "Options controlling SSH tunnelling",
1370 IDC_TITLE_TUNNELS);
d74d141c 1371 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
32874aea 1372 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1373 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1374 IDC_X11_DISPLAY, 50, NULL);
1375 endbox(&cp);
d74d141c 1376 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1377 checkbox(&cp, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL);
1378 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1379 "&Remove", IDC_PFWDREMOVE);
1380 fwdsetter(&cp, IDC_PFWDLIST,
1381 "Add new forwarded port:", IDC_PFWDSTATIC2,
1382 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1383 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1384 "A&dd", IDC_PFWDADD);
1385 bareradioline(&cp, 2,
1386 "&Local", IDC_PFWDLOCAL, "Re&mote", IDC_PFWDREMOTE, NULL);
1387 endbox(&cp);
1388
32874aea 1389 }
3ac9cd9f 1390 }
1391}
1392
c8d7378d 1393/*
1394 * Helper function to load the session selected in SESSLIST
1395 * if any, as this is done in more than one place in
1396 * GenericMainDlgProc(). 0 => failure.
1397 */
1398static int load_selected_session(HWND hwnd)
1399{
1400 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1401 LB_GETCURSEL, 0, 0);
1402 int isdef;
1403 if (n == LB_ERR) {
1404 MessageBeep(0);
1405 return 0;
1406 }
1407 isdef = !strcmp(sessions[n], "Default Settings");
1408 load_settings(sessions[n], !isdef, &cfg);
1409 init_dlg_ctrls(hwnd, TRUE);
1410 if (!isdef)
1411 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1412 else
1413 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1414 /* Restore the selection, which will have been clobbered by
1415 * SESSEDIT handling. */
1416 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1417 return 1;
1418}
1419
3ac9cd9f 1420/*
1421 * This function is the configuration box.
c96a8fef 1422 */
32874aea 1423static int GenericMainDlgProc(HWND hwnd, UINT msg,
1424 WPARAM wParam, LPARAM lParam, int dlgtype)
1425{
927d4fc5 1426 HWND hw, treeview;
1427 struct treeview_faff tvfaff;
1428 HTREEITEM hsession;
c96a8fef 1429 OPENFILENAME of;
1430 char filename[sizeof(cfg.keyfile)];
1431 CHOOSEFONT cf;
1432 LOGFONT lf;
1433 char fontstatic[256];
b278b14a 1434 char portname[32];
32874aea 1435 struct servent *service;
374330e2 1436 int i;
ca20bfcf 1437 static UINT draglistmsg = WM_NULL;
374330e2 1438
1439 switch (msg) {
1440 case WM_INITDIALOG:
a094ae43 1441 readytogo = 0;
c96a8fef 1442 SetWindowLong(hwnd, GWL_USERDATA, 0);
648947d4 1443 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1444 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
c96a8fef 1445 /*
1446 * Centre the window.
1447 */
1448 { /* centre the window */
1449 RECT rs, rd;
1450
1451 hw = GetDesktopWindow();
32874aea 1452 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1453 MoveWindow(hwnd,
1454 (rs.right + rs.left + rd.left - rd.right) / 2,
1455 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1456 rd.right - rd.left, rd.bottom - rd.top, TRUE);
c96a8fef 1457 }
1458
1459 /*
927d4fc5 1460 * Create the tree view.
c96a8fef 1461 */
32874aea 1462 {
1463 RECT r;
c96a8fef 1464 WPARAM font;
32874aea 1465 HWND tvstatic;
1466
1467 r.left = 3;
1468 r.right = r.left + 75;
1469 r.top = 3;
1470 r.bottom = r.top + 10;
1471 MapDialogRect(hwnd, &r);
1472 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1473 WS_CHILD | WS_VISIBLE,
1474 r.left, r.top,
1475 r.right - r.left, r.bottom - r.top,
1476 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1477 NULL);
c96a8fef 1478 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
927d4fc5 1479 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1480
32874aea 1481 r.left = 3;
1482 r.right = r.left + 75;
1483 r.top = 13;
a401e5f3 1484 r.bottom = r.top + 219;
32874aea 1485 MapDialogRect(hwnd, &r);
1486 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1487 WS_CHILD | WS_VISIBLE |
1488 WS_TABSTOP | TVS_HASLINES |
1489 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1490 | TVS_LINESATROOT |
1491 TVS_SHOWSELALWAYS, r.left, r.top,
1492 r.right - r.left, r.bottom - r.top,
1493 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1494 NULL);
927d4fc5 1495 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1496 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
32874aea 1497 tvfaff.treeview = treeview;
1498 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1499 }
c96a8fef 1500
1501 /*
3ac9cd9f 1502 * Set up the tree view contents.
c96a8fef 1503 */
32874aea 1504 hsession = treeview_insert(&tvfaff, 0, "Session");
1505 treeview_insert(&tvfaff, 1, "Logging");
1506 treeview_insert(&tvfaff, 0, "Terminal");
1507 treeview_insert(&tvfaff, 1, "Keyboard");
1508 treeview_insert(&tvfaff, 1, "Bell");
1509 treeview_insert(&tvfaff, 0, "Window");
1510 treeview_insert(&tvfaff, 1, "Appearance");
d0cadfcd 1511 treeview_insert(&tvfaff, 1, "Behaviour");
32874aea 1512 treeview_insert(&tvfaff, 1, "Translation");
1513 treeview_insert(&tvfaff, 1, "Selection");
1514 treeview_insert(&tvfaff, 1, "Colours");
1515 treeview_insert(&tvfaff, 0, "Connection");
1516 if (dlgtype == 0) {
1517 treeview_insert(&tvfaff, 1, "Telnet");
1518 treeview_insert(&tvfaff, 1, "Rlogin");
1519 if (backends[3].backend != NULL) {
1520 treeview_insert(&tvfaff, 1, "SSH");
ca20bfcf 1521 /* XXX long name is ugly */
1522 /* XXX make it closed by default? */
1523 treeview_insert(&tvfaff, 2, "Auth");
32874aea 1524 treeview_insert(&tvfaff, 2, "Tunnels");
1525 }
1526 }
1527
1528 /*
1529 * Put the treeview selection on to the Session panel. This
1530 * should also cause creation of the relevant controls.
1531 */
1532 TreeView_SelectItem(treeview, hsession);
1533
1534 /*
1535 * Set focus into the first available control.
1536 */
1537 {
1538 HWND ctl;
1539 ctl = GetDlgItem(hwnd, IDC_HOST);
1540 if (!ctl)
1541 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1542 SetFocus(ctl);
1543 }
c96a8fef 1544
1545 SetWindowLong(hwnd, GWL_USERDATA, 1);
dc35b97d 1546 sesslist_has_focus = 0;
c96a8fef 1547 return 0;
1cd246bb 1548 case WM_LBUTTONUP:
32874aea 1549 /*
1550 * Button release should trigger WM_OK if there was a
1551 * previous double click on the session list.
1552 */
1553 ReleaseCapture();
1554 if (readytogo)
1555 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1556 break;
c96a8fef 1557 case WM_NOTIFY:
927d4fc5 1558 if (LOWORD(wParam) == IDCX_TREEVIEW &&
32874aea 1559 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1560 HTREEITEM i =
1561 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
927d4fc5 1562 TVITEM item;
32874aea 1563 int j;
c96a8fef 1564 char buffer[64];
78a79d97 1565
1566 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1567
32874aea 1568 item.hItem = i;
c96a8fef 1569 item.pszText = buffer;
1570 item.cchTextMax = sizeof(buffer);
927d4fc5 1571 item.mask = TVIF_TEXT;
32874aea 1572 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
3ac9cd9f 1573 for (j = controlstartvalue; j < controlendvalue; j++) {
32874aea 1574 HWND item = GetDlgItem(hwnd, j);
1575 if (item)
1576 DestroyWindow(item);
1577 }
927d4fc5 1578 if (!strcmp(buffer, "Session"))
3ac9cd9f 1579 create_controls(hwnd, dlgtype, sessionpanelstart);
0965bee0 1580 if (!strcmp(buffer, "Logging"))
1581 create_controls(hwnd, dlgtype, loggingpanelstart);
c96a8fef 1582 if (!strcmp(buffer, "Keyboard"))
3ac9cd9f 1583 create_controls(hwnd, dlgtype, keyboardpanelstart);
c96a8fef 1584 if (!strcmp(buffer, "Terminal"))
3ac9cd9f 1585 create_controls(hwnd, dlgtype, terminalpanelstart);
156686ef 1586 if (!strcmp(buffer, "Bell"))
1587 create_controls(hwnd, dlgtype, bellpanelstart);
c96a8fef 1588 if (!strcmp(buffer, "Window"))
3ac9cd9f 1589 create_controls(hwnd, dlgtype, windowpanelstart);
4c4f2716 1590 if (!strcmp(buffer, "Appearance"))
3ac9cd9f 1591 create_controls(hwnd, dlgtype, appearancepanelstart);
d0cadfcd 1592 if (!strcmp(buffer, "Behaviour"))
1593 create_controls(hwnd, dlgtype, behaviourpanelstart);
9c964e85 1594 if (!strcmp(buffer, "Tunnels"))
3ac9cd9f 1595 create_controls(hwnd, dlgtype, tunnelspanelstart);
927d4fc5 1596 if (!strcmp(buffer, "Connection"))
3ac9cd9f 1597 create_controls(hwnd, dlgtype, connectionpanelstart);
c96a8fef 1598 if (!strcmp(buffer, "Telnet"))
3ac9cd9f 1599 create_controls(hwnd, dlgtype, telnetpanelstart);
c91409da 1600 if (!strcmp(buffer, "Rlogin"))
3ac9cd9f 1601 create_controls(hwnd, dlgtype, rloginpanelstart);
c96a8fef 1602 if (!strcmp(buffer, "SSH"))
3ac9cd9f 1603 create_controls(hwnd, dlgtype, sshpanelstart);
ca20bfcf 1604 if (!strcmp(buffer, "Auth"))
1605 create_controls(hwnd, dlgtype, sshauthpanelstart);
c96a8fef 1606 if (!strcmp(buffer, "Selection"))
3ac9cd9f 1607 create_controls(hwnd, dlgtype, selectionpanelstart);
c96a8fef 1608 if (!strcmp(buffer, "Colours"))
3ac9cd9f 1609 create_controls(hwnd, dlgtype, colourspanelstart);
c96a8fef 1610 if (!strcmp(buffer, "Translation"))
3ac9cd9f 1611 create_controls(hwnd, dlgtype, translationpanelstart);
1612
c8d7378d 1613 init_dlg_ctrls(hwnd, FALSE);
78a79d97 1614
1615 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
1616 InvalidateRect (hwnd, NULL, TRUE);
c96a8fef 1617
32874aea 1618 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
c96a8fef 1619 return 0;
1620 }
1621 break;
374330e2 1622 case WM_COMMAND:
c96a8fef 1623 /*
1624 * Only process WM_COMMAND once the dialog is fully formed.
1625 */
32874aea 1626 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
1627 switch (LOWORD(wParam)) {
1628 case IDOK:
c8d7378d 1629 /* Behaviour of the "Open" button is different if the
1630 * session list has focus, *unless* the user just
1631 * double-clicked... */
1632 if (sesslist_has_focus && !readytogo) {
1633 if (!load_selected_session(hwnd)) {
1634 MessageBeep(0);
1635 return 0;
1636 }
1637 }
1638 /* If at this point we have a valid session, go! */
32874aea 1639 if (*cfg.host)
1640 EndDialog(hwnd, 1);
1641 else
1642 MessageBeep(0);
1643 return 0;
1644 case IDCANCEL:
1645 EndDialog(hwnd, 0);
1646 return 0;
1647 case IDC_PROTTELNET:
1648 case IDC_PROTRLOGIN:
1649 case IDC_PROTSSH:
1650 case IDC_PROTRAW:
1651 if (HIWORD(wParam) == BN_CLICKED ||
1652 HIWORD(wParam) == BN_DOUBLECLICKED) {
1653 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
1654 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
1655 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
1656 cfg.protocol =
1657 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
1658 PROT_RAW;
1659 if ((cfg.protocol == PROT_SSH && cfg.port != 22)
1660 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
1661 || (cfg.protocol == PROT_RLOGIN
1662 && cfg.port != 513)) {
1663 cfg.port = i ? 22 : j ? 23 : 513;
1664 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1665 }
374330e2 1666 }
32874aea 1667 break;
1668 case IDC_HOST:
1669 if (HIWORD(wParam) == EN_CHANGE)
1670 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
1671 sizeof(cfg.host) - 1);
1672 break;
1673 case IDC_PORT:
1674 if (HIWORD(wParam) == EN_CHANGE) {
1675 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
1676 if (isdigit(portname[0]))
1677 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
1678 else {
1679 service = getservbyname(portname, NULL);
1680 if (service)
1681 cfg.port = ntohs(service->s_port);
1682 else
1683 cfg.port = 0;
1684 }
b278b14a 1685 }
32874aea 1686 break;
1687 case IDC_SESSEDIT:
1688 if (HIWORD(wParam) == EN_CHANGE) {
1689 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1690 (WPARAM) - 1, 0);
1691 GetDlgItemText(hwnd, IDC_SESSEDIT,
1692 savedsession, sizeof(savedsession) - 1);
1693 savedsession[sizeof(savedsession) - 1] = '\0';
1694 }
1695 break;
1696 case IDC_SESSSAVE:
1697 if (HIWORD(wParam) == BN_CLICKED ||
1698 HIWORD(wParam) == BN_DOUBLECLICKED) {
1699 /*
1700 * Save a session
1701 */
1702 char str[2048];
1703 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
1704 sizeof(str) - 1);
1705 if (!*str) {
1706 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1707 LB_GETCURSEL, 0, 0);
1708 if (n == LB_ERR) {
1709 MessageBeep(0);
1710 break;
1711 }
1712 strcpy(str, sessions[n]);
1713 }
1714 save_settings(str, !!strcmp(str, "Default Settings"),
1715 &cfg);
1716 get_sesslist(FALSE);
1717 get_sesslist(TRUE);
c8d7378d 1718 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1719 FALSE, 0);
32874aea 1720 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1721 0, 0);
1722 for (i = 0; i < nsessions; i++)
1723 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1724 LB_ADDSTRING, 0,
1725 (LPARAM) (sessions[i]));
1726 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1727 (WPARAM) - 1, 0);
c8d7378d 1728 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1729 TRUE, 0);
1730 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1731 TRUE);
32874aea 1732 }
1733 break;
1734 case IDC_SESSLIST:
1735 case IDC_SESSLOAD:
c8d7378d 1736 if (LOWORD(wParam) == IDC_SESSLIST) {
1737 if (HIWORD(wParam) == LBN_SETFOCUS)
1738 sesslist_has_focus = 1;
1739 else if (HIWORD(wParam) == LBN_KILLFOCUS)
1740 sesslist_has_focus = 0;
1741 }
32874aea 1742 if (LOWORD(wParam) == IDC_SESSLOAD &&
1743 HIWORD(wParam) != BN_CLICKED &&
1744 HIWORD(wParam) != BN_DOUBLECLICKED) break;
1745 if (LOWORD(wParam) == IDC_SESSLIST &&
1746 HIWORD(wParam) != LBN_DBLCLK) break;
c8d7378d 1747 /* Load the session selected in SESSLIST. */
1748 if (load_selected_session(hwnd) &&
1749 LOWORD(wParam) == IDC_SESSLIST) {
32874aea 1750 /*
1751 * A double-click on a saved session should
1752 * actually start the session, not just load it.
1753 * Unless it's Default Settings or some other
1754 * host-less set of saved settings.
1755 */
1756 if (*cfg.host) {
1757 readytogo = TRUE;
1758 SetCapture(hwnd);
1759 }
374330e2 1760 }
32874aea 1761 break;
1762 case IDC_SESSDEL:
1763 if (HIWORD(wParam) == BN_CLICKED ||
1764 HIWORD(wParam) == BN_DOUBLECLICKED) {
1765 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1766 LB_GETCURSEL, 0, 0);
1767 if (n == LB_ERR || n == 0) {
1768 MessageBeep(0);
1769 break;
1770 }
1771 del_settings(sessions[n]);
1772 get_sesslist(FALSE);
1773 get_sesslist(TRUE);
c8d7378d 1774 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1775 FALSE, 0);
32874aea 1776 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1777 0, 0);
1778 for (i = 0; i < nsessions; i++)
1779 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1780 LB_ADDSTRING, 0,
1781 (LPARAM) (sessions[i]));
1782 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1783 (WPARAM) - 1, 0);
c8d7378d 1784 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1785 TRUE, 0);
1786 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1787 TRUE);
374330e2 1788 }
32874aea 1789 case IDC_PINGEDIT:
1790 if (HIWORD(wParam) == EN_CHANGE)
1791 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
1792 &cfg.ping_interval);
1793 break;
2184a5d9 1794 case IDC_NODELAY:
1795 if (HIWORD(wParam) == BN_CLICKED ||
1796 HIWORD(wParam) == BN_DOUBLECLICKED)
1797 cfg.tcp_nodelay =
1798 IsDlgButtonChecked(hwnd, IDC_NODELAY);
1799 break;
32874aea 1800 case IDC_DEL008:
1801 case IDC_DEL127:
1802 if (HIWORD(wParam) == BN_CLICKED ||
1803 HIWORD(wParam) == BN_DOUBLECLICKED)
1804 cfg.bksp_is_delete =
1805 IsDlgButtonChecked(hwnd, IDC_DEL127);
1806 break;
1807 case IDC_HOMETILDE:
1808 case IDC_HOMERXVT:
1809 if (HIWORD(wParam) == BN_CLICKED ||
1810 HIWORD(wParam) == BN_DOUBLECLICKED)
1811 cfg.rxvt_homeend =
1812 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
1813 break;
1814 case IDC_FUNCTILDE:
1815 case IDC_FUNCLINUX:
1816 case IDC_FUNCXTERM:
1817 case IDC_FUNCVT400:
1818 case IDC_FUNCVT100P:
1819 case IDC_FUNCSCO:
1820 if (HIWORD(wParam) == BN_CLICKED ||
1821 HIWORD(wParam) == BN_DOUBLECLICKED)
1822 switch (LOWORD(wParam)) {
1823 case IDC_FUNCTILDE:
1824 cfg.funky_type = 0;
1825 break;
1826 case IDC_FUNCLINUX:
1827 cfg.funky_type = 1;
1828 break;
1829 case IDC_FUNCXTERM:
1830 cfg.funky_type = 2;
1831 break;
1832 case IDC_FUNCVT400:
1833 cfg.funky_type = 3;
1834 break;
1835 case IDC_FUNCVT100P:
1836 cfg.funky_type = 4;
1837 break;
1838 case IDC_FUNCSCO:
1839 cfg.funky_type = 5;
1840 break;
1841 }
1842 break;
1843 case IDC_KPNORMAL:
1844 case IDC_KPAPPLIC:
1845 if (HIWORD(wParam) == BN_CLICKED ||
1846 HIWORD(wParam) == BN_DOUBLECLICKED) {
1847 cfg.app_keypad =
1848 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
1849 cfg.nethack_keypad = FALSE;
f37caa11 1850 }
32874aea 1851 break;
1852 case IDC_KPNH:
1853 if (HIWORD(wParam) == BN_CLICKED ||
1854 HIWORD(wParam) == BN_DOUBLECLICKED) {
1855 cfg.app_keypad = FALSE;
1856 cfg.nethack_keypad = TRUE;
1857 }
1858 break;
1859 case IDC_CURNORMAL:
1860 case IDC_CURAPPLIC:
1861 if (HIWORD(wParam) == BN_CLICKED ||
1862 HIWORD(wParam) == BN_DOUBLECLICKED)
1863 cfg.app_cursor =
1864 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
1865 break;
1866 case IDC_NOAPPLICC:
1867 if (HIWORD(wParam) == BN_CLICKED ||
1868 HIWORD(wParam) == BN_DOUBLECLICKED)
1869 cfg.no_applic_c =
1870 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
1871 break;
1872 case IDC_NOAPPLICK:
1873 if (HIWORD(wParam) == BN_CLICKED ||
1874 HIWORD(wParam) == BN_DOUBLECLICKED)
1875 cfg.no_applic_k =
1876 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
1877 break;
1878 case IDC_ALTF4:
1879 if (HIWORD(wParam) == BN_CLICKED ||
1880 HIWORD(wParam) == BN_DOUBLECLICKED)
1881 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
1882 break;
1883 case IDC_ALTSPACE:
1884 if (HIWORD(wParam) == BN_CLICKED ||
1885 HIWORD(wParam) == BN_DOUBLECLICKED)
1886 cfg.alt_space =
1887 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
1888 break;
1889 case IDC_ALTONLY:
1890 if (HIWORD(wParam) == BN_CLICKED ||
1891 HIWORD(wParam) == BN_DOUBLECLICKED)
1892 cfg.alt_only =
1893 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
1894 break;
1895 case IDC_ECHOBACKEND:
1896 case IDC_ECHOYES:
1897 case IDC_ECHONO:
1898 if (HIWORD(wParam) == BN_CLICKED ||
1899 HIWORD(wParam) == BN_DOUBLECLICKED) {
1900 if (LOWORD(wParam) == IDC_ECHOBACKEND)
1901 cfg.localecho = LD_BACKEND;
1902 if (LOWORD(wParam) == IDC_ECHOYES)
1903 cfg.localecho = LD_YES;
1904 if (LOWORD(wParam) == IDC_ECHONO)
1905 cfg.localecho = LD_NO;
1906 }
1907 break;
1908 case IDC_EDITBACKEND:
1909 case IDC_EDITYES:
1910 case IDC_EDITNO:
1911 if (HIWORD(wParam) == BN_CLICKED ||
1912 HIWORD(wParam) == BN_DOUBLECLICKED) {
1913 if (LOWORD(wParam) == IDC_EDITBACKEND)
1914 cfg.localedit = LD_BACKEND;
1915 if (LOWORD(wParam) == IDC_EDITYES)
1916 cfg.localedit = LD_YES;
1917 if (LOWORD(wParam) == IDC_EDITNO)
1918 cfg.localedit = LD_NO;
1919 }
1920 break;
1921 case IDC_ANSWEREDIT:
1922 if (HIWORD(wParam) == EN_CHANGE)
1923 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
1924 sizeof(cfg.answerback) - 1);
1925 break;
1926 case IDC_ALWAYSONTOP:
1927 if (HIWORD(wParam) == BN_CLICKED ||
1928 HIWORD(wParam) == BN_DOUBLECLICKED)
1929 cfg.alwaysontop =
1930 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
1931 break;
8f57d753 1932 case IDC_FULLSCREENONALTENTER:
1933 if (HIWORD(wParam) == BN_CLICKED ||
1934 HIWORD(wParam) == BN_DOUBLECLICKED)
1935 cfg.fullscreenonaltenter =
1936 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
1937 break;
32874aea 1938 case IDC_SCROLLKEY:
1939 if (HIWORD(wParam) == BN_CLICKED ||
1940 HIWORD(wParam) == BN_DOUBLECLICKED)
1941 cfg.scroll_on_key =
1942 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
1943 break;
1944 case IDC_SCROLLDISP:
1945 if (HIWORD(wParam) == BN_CLICKED ||
1946 HIWORD(wParam) == BN_DOUBLECLICKED)
1947 cfg.scroll_on_disp =
1948 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
1949 break;
1950 case IDC_COMPOSEKEY:
1951 if (HIWORD(wParam) == BN_CLICKED ||
1952 HIWORD(wParam) == BN_DOUBLECLICKED)
1953 cfg.compose_key =
1954 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
1955 break;
1956 case IDC_CTRLALTKEYS:
1957 if (HIWORD(wParam) == BN_CLICKED ||
1958 HIWORD(wParam) == BN_DOUBLECLICKED)
1959 cfg.ctrlaltkeys =
1960 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
1961 break;
a5f3e637 1962 case IDC_TELNETKEY:
1963 if (HIWORD(wParam) == BN_CLICKED ||
1964 HIWORD(wParam) == BN_DOUBLECLICKED)
1965 cfg.telnet_keyboard =
1966 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
1967 break;
32874aea 1968 case IDC_WRAPMODE:
1969 if (HIWORD(wParam) == BN_CLICKED ||
1970 HIWORD(wParam) == BN_DOUBLECLICKED)
1971 cfg.wrap_mode =
1972 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
1973 break;
1974 case IDC_DECOM:
1975 if (HIWORD(wParam) == BN_CLICKED ||
1976 HIWORD(wParam) == BN_DOUBLECLICKED)
1977 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
1978 break;
1979 case IDC_LFHASCR:
1980 if (HIWORD(wParam) == BN_CLICKED ||
1981 HIWORD(wParam) == BN_DOUBLECLICKED)
1982 cfg.lfhascr =
1983 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
1984 break;
1985 case IDC_ROWSEDIT:
1986 if (HIWORD(wParam) == EN_CHANGE)
1987 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
1988 break;
1989 case IDC_COLSEDIT:
1990 if (HIWORD(wParam) == EN_CHANGE)
1991 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
1992 break;
1993 case IDC_SAVEEDIT:
1994 if (HIWORD(wParam) == EN_CHANGE)
1995 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
1996 break;
1997 case IDC_CHOOSEFONT:
c0a18295 1998 {
1999 HDC hdc = GetDC(0);
2000 lf.lfHeight = -MulDiv(cfg.fontheight,
2001 GetDeviceCaps(hdc, LOGPIXELSY),
2002 72);
2003 ReleaseDC(0, hdc);
2004 }
32874aea 2005 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2006 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2007 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2008 lf.lfCharSet = cfg.fontcharset;
2009 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2010 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2011 lf.lfQuality = DEFAULT_QUALITY;
2012 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2013 strncpy(lf.lfFaceName, cfg.font,
2014 sizeof(lf.lfFaceName) - 1);
2015 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2016
2017 cf.lStructSize = sizeof(cf);
2018 cf.hwndOwner = hwnd;
2019 cf.lpLogFont = &lf;
2020 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2021 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2022
2023 if (ChooseFont(&cf)) {
2024 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2025 cfg.font[sizeof(cfg.font) - 1] = '\0';
2026 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2027 cfg.fontcharset = lf.lfCharSet;
2028 cfg.fontheight = cf.iPointSize / 10;
2029 fmtfont(fontstatic);
2030 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2031 }
2032 break;
2033 case IDC_BELL_DISABLED:
2034 case IDC_BELL_DEFAULT:
2035 case IDC_BELL_WAVEFILE:
2036 case IDC_BELL_VISUAL:
2037 if (HIWORD(wParam) == BN_CLICKED ||
2038 HIWORD(wParam) == BN_DOUBLECLICKED) {
2039 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2040 cfg.beep = BELL_DISABLED;
2041 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2042 cfg.beep = BELL_DEFAULT;
2043 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2044 cfg.beep = BELL_WAVEFILE;
2045 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2046 cfg.beep = BELL_VISUAL;
2047 }
2048 break;
f8a28d1f 2049 case IDC_B_IND_DISABLED:
2050 case IDC_B_IND_FLASH:
2051 case IDC_B_IND_STEADY:
2052 if (HIWORD(wParam) == BN_CLICKED ||
2053 HIWORD(wParam) == BN_DOUBLECLICKED) {
2054 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2055 cfg.beep_ind = B_IND_DISABLED;
2056 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2057 cfg.beep_ind = B_IND_FLASH;
2058 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2059 cfg.beep_ind = B_IND_STEADY;
2060 }
2061 break;
32874aea 2062 case IDC_BELL_WAVEBROWSE:
2063 memset(&of, 0, sizeof(of));
03169ad0 2064#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2065 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
03169ad0 2066#else
32874aea 2067 of.lStructSize = sizeof(of);
03169ad0 2068#endif
32874aea 2069 of.hwndOwner = hwnd;
2070 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2071 of.lpstrCustomFilter = NULL;
2072 of.nFilterIndex = 1;
2073 of.lpstrFile = filename;
2074 strcpy(filename, cfg.bell_wavefile);
2075 of.nMaxFile = sizeof(filename);
2076 of.lpstrFileTitle = NULL;
2077 of.lpstrInitialDir = NULL;
2078 of.lpstrTitle = "Select Bell Sound File";
2079 of.Flags = 0;
2080 if (GetOpenFileName(&of)) {
2081 strcpy(cfg.bell_wavefile, filename);
2082 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2083 cfg.bell_wavefile);
2084 }
2085 break;
2086 case IDC_BELL_WAVEEDIT:
2087 if (HIWORD(wParam) == EN_CHANGE)
2088 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2089 cfg.bell_wavefile,
2090 sizeof(cfg.bell_wavefile) - 1);
2091 break;
2092 case IDC_BELLOVL:
2093 if (HIWORD(wParam) == BN_CLICKED ||
2094 HIWORD(wParam) == BN_DOUBLECLICKED)
2095 cfg.bellovl =
2096 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2097 break;
2098 case IDC_BELLOVLN:
2099 if (HIWORD(wParam) == EN_CHANGE)
2100 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2101 break;
2102 case IDC_BELLOVLT:
2103 if (HIWORD(wParam) == EN_CHANGE)
2104 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2105 1000);
2106 break;
2107 case IDC_BELLOVLS:
2108 if (HIWORD(wParam) == EN_CHANGE)
2109 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2110 1000);
2111 break;
2112 case IDC_BLINKTEXT:
2113 if (HIWORD(wParam) == BN_CLICKED ||
2114 HIWORD(wParam) == BN_DOUBLECLICKED)
2115 cfg.blinktext =
2116 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2117 break;
2118 case IDC_BCE:
2119 if (HIWORD(wParam) == BN_CLICKED ||
2120 HIWORD(wParam) == BN_DOUBLECLICKED)
2121 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2122 break;
2123 case IDC_WINNAME:
2124 if (HIWORD(wParam) == BN_CLICKED ||
2125 HIWORD(wParam) == BN_DOUBLECLICKED)
2126 cfg.win_name_always =
2127 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2128 break;
2129 case IDC_HIDEMOUSE:
2130 if (HIWORD(wParam) == BN_CLICKED ||
2131 HIWORD(wParam) == BN_DOUBLECLICKED)
2132 cfg.hide_mouseptr =
2133 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2134 break;
2135 case IDC_SUNKENEDGE:
2136 if (HIWORD(wParam) == BN_CLICKED ||
2137 HIWORD(wParam) == BN_DOUBLECLICKED)
2138 cfg.sunken_edge =
2139 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2140 break;
5a73255e 2141 case IDC_WINBEDIT:
2142 if (HIWORD(wParam) == EN_CHANGE)
2143 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2144 &cfg.window_border);
2145 if (cfg.window_border > 32)
2146 cfg.window_border = 32;
2147 break;
32874aea 2148 case IDC_CURBLOCK:
2149 if (HIWORD(wParam) == BN_CLICKED ||
2150 HIWORD(wParam) == BN_DOUBLECLICKED)
2151 cfg.cursor_type = 0;
2152 break;
2153 case IDC_CURUNDER:
2154 if (HIWORD(wParam) == BN_CLICKED ||
2155 HIWORD(wParam) == BN_DOUBLECLICKED)
2156 cfg.cursor_type = 1;
2157 break;
2158 case IDC_CURVERT:
2159 if (HIWORD(wParam) == BN_CLICKED ||
2160 HIWORD(wParam) == BN_DOUBLECLICKED)
2161 cfg.cursor_type = 2;
2162 break;
2163 case IDC_BLINKCUR:
2164 if (HIWORD(wParam) == BN_CLICKED ||
2165 HIWORD(wParam) == BN_DOUBLECLICKED)
2166 cfg.blink_cur =
2167 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2168 break;
2169 case IDC_SCROLLBAR:
2170 if (HIWORD(wParam) == BN_CLICKED ||
2171 HIWORD(wParam) == BN_DOUBLECLICKED)
2172 cfg.scrollbar =
2173 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2174 break;
a401e5f3 2175 case IDC_SCROLLBARFULLSCREEN:
2176 if (HIWORD(wParam) == BN_CLICKED ||
2177 HIWORD(wParam) == BN_DOUBLECLICKED)
2178 cfg.scrollbar_in_fullscreen =
2179 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2180 break;
ad5c93cc 2181 case IDC_RESIZETERM:
2182 case IDC_RESIZEFONT:
2183 case IDC_RESIZENONE:
0ed2f48e 2184 case IDC_RESIZEEITHER:
32874aea 2185 if (HIWORD(wParam) == BN_CLICKED ||
ad5c93cc 2186 HIWORD(wParam) == BN_DOUBLECLICKED) {
2187 cfg.resize_action =
2188 IsDlgButtonChecked(hwnd,
2189 IDC_RESIZETERM) ? RESIZE_TERM :
2190 IsDlgButtonChecked(hwnd,
2191 IDC_RESIZEFONT) ? RESIZE_FONT :
0ed2f48e 2192 IsDlgButtonChecked(hwnd,
2193 IDC_RESIZEEITHER) ? RESIZE_EITHER :
ad5c93cc 2194 RESIZE_DISABLED;
2195 }
5a73255e 2196 break;
32874aea 2197 case IDC_WINEDIT:
2198 if (HIWORD(wParam) == EN_CHANGE)
2199 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2200 sizeof(cfg.wintitle) - 1);
2201 break;
2202 case IDC_COEALWAYS:
2203 case IDC_COENEVER:
2204 case IDC_COENORMAL:
2205 if (HIWORD(wParam) == BN_CLICKED ||
2206 HIWORD(wParam) == BN_DOUBLECLICKED) {
2207 cfg.close_on_exit =
2208 IsDlgButtonChecked(hwnd,
2209 IDC_COEALWAYS) ? COE_ALWAYS :
2210 IsDlgButtonChecked(hwnd,
2211 IDC_COENEVER) ? COE_NEVER :
2212 COE_NORMAL;
2213 }
2214 break;
2215 case IDC_CLOSEWARN:
2216 if (HIWORD(wParam) == BN_CLICKED ||
2217 HIWORD(wParam) == BN_DOUBLECLICKED)
2218 cfg.warn_on_close =
2219 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2220 break;
2221 case IDC_TTEDIT:
2222 if (HIWORD(wParam) == EN_CHANGE)
2223 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2224 sizeof(cfg.termtype) - 1);
2225 break;
2226 case IDC_LGFEDIT:
2227 if (HIWORD(wParam) == EN_CHANGE)
2228 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2229 sizeof(cfg.logfilename) - 1);
2230 break;
2231 case IDC_LGFBUTTON:
2232 memset(&of, 0, sizeof(of));
e1c8e0ed 2233#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2234 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
e1c8e0ed 2235#else
32874aea 2236 of.lStructSize = sizeof(of);
e1c8e0ed 2237#endif
32874aea 2238 of.hwndOwner = hwnd;
2239 of.lpstrFilter = "All Files\0*\0\0\0";
2240 of.lpstrCustomFilter = NULL;
2241 of.nFilterIndex = 1;
2242 of.lpstrFile = filename;
2243 strcpy(filename, cfg.logfilename);
2244 of.nMaxFile = sizeof(filename);
2245 of.lpstrFileTitle = NULL;
2246 of.lpstrInitialDir = NULL;
2247 of.lpstrTitle = "Select session log file";
2248 of.Flags = 0;
2249 if (GetSaveFileName(&of)) {
2250 strcpy(cfg.logfilename, filename);
2251 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
374330e2 2252 }
32874aea 2253 break;
2254 case IDC_LSTATOFF:
2255 case IDC_LSTATASCII:
2256 case IDC_LSTATRAW:
2257 if (HIWORD(wParam) == BN_CLICKED ||
2258 HIWORD(wParam) == BN_DOUBLECLICKED) {
2259 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2260 cfg.logtype = 0;
2261 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2262 cfg.logtype = 1;
2263 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2264 cfg.logtype = 2;
374330e2 2265 }
32874aea 2266 break;
2267 case IDC_LSTATXASK:
2268 case IDC_LSTATXAPN:
2269 case IDC_LSTATXOVR:
2270 if (HIWORD(wParam) == BN_CLICKED ||
2271 HIWORD(wParam) == BN_DOUBLECLICKED) {
2272 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2273 cfg.logxfovr = LGXF_ASK;
2274 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2275 cfg.logxfovr = LGXF_APN;
2276 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2277 cfg.logxfovr = LGXF_OVR;
374330e2 2278 }
32874aea 2279 break;
2280 case IDC_TSEDIT:
2281 case IDC_R_TSEDIT:
2282 if (HIWORD(wParam) == EN_CHANGE)
2283 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2284 sizeof(cfg.termspeed) - 1);
2285 break;
2286 case IDC_LOGEDIT:
2287 if (HIWORD(wParam) == EN_CHANGE)
2288 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2289 sizeof(cfg.username) - 1);
2290 break;
2291 case IDC_RLLUSEREDIT:
2292 if (HIWORD(wParam) == EN_CHANGE)
2293 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2294 cfg.localusername,
2295 sizeof(cfg.localusername) - 1);
2296 break;
2297 case IDC_EMBSD:
2298 case IDC_EMRFC:
2299 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2300 break;
8faa456c 2301 case IDC_TPASSIVE:
2302 case IDC_TACTIVE:
2303 cfg.passive_telnet =
2304 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2305 break;
32874aea 2306 case IDC_ENVADD:
2307 if (HIWORD(wParam) == BN_CLICKED ||
2308 HIWORD(wParam) == BN_DOUBLECLICKED) {
2309 char str[sizeof(cfg.environmt)];
2310 char *p;
2311 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2312 sizeof(str) - 1);
2313 if (!*str) {
2314 MessageBeep(0);
2315 break;
2316 }
2317 p = str + strlen(str);
2318 *p++ = '\t';
2319 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2320 sizeof(str) - 1 - (p - str));
2321 if (!*p) {
2322 MessageBeep(0);
2323 break;
2324 }
2325 p = cfg.environmt;
2326 while (*p) {
2327 while (*p)
2328 p++;
2329 p++;
2330 }
2331 if ((p - cfg.environmt) + strlen(str) + 2 <
2332 sizeof(cfg.environmt)) {
2333 strcpy(p, str);
2334 p[strlen(str) + 1] = '\0';
2335 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2336 0, (LPARAM) str);
2337 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2338 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2339 } else {
2340 MessageBox(hwnd, "Environment too big",
2341 "PuTTY Error", MB_OK | MB_ICONERROR);
2342 }
374330e2 2343 }
32874aea 2344 break;
2345 case IDC_ENVREMOVE:
2346 if (HIWORD(wParam) != BN_CLICKED &&
2347 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2348 i =
2349 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2350 0);
2351 if (i == LB_ERR)
2352 MessageBeep(0);
2353 else {
2354 char *p, *q;
2355
2356 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2357 i, 0);
2358 p = cfg.environmt;
2359 while (i > 0) {
2360 if (!*p)
2361 goto disaster;
2362 while (*p)
2363 p++;
2364 p++;
2365 i--;
2366 }
2367 q = p;
374330e2 2368 if (!*p)
2369 goto disaster;
374330e2 2370 while (*p)
32874aea 2371 p++;
2372 p++;
2373 while (*p) {
2374 while (*p)
2375 *q++ = *p++;
374330e2 2376 *q++ = *p++;
32874aea 2377 }
2378 *q = '\0';
2379 disaster:;
374330e2 2380 }
32874aea 2381 break;
2382 case IDC_NOPTY:
2383 if (HIWORD(wParam) == BN_CLICKED ||
2384 HIWORD(wParam) == BN_DOUBLECLICKED)
2385 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2386 break;
2387 case IDC_COMPRESS:
2388 if (HIWORD(wParam) == BN_CLICKED ||
2389 HIWORD(wParam) == BN_DOUBLECLICKED)
2390 cfg.compression =
2391 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2392 break;
2393 case IDC_BUGGYMAC:
2394 if (HIWORD(wParam) == BN_CLICKED ||
2395 HIWORD(wParam) == BN_DOUBLECLICKED)
2396 cfg.buggymac =
2397 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2398 break;
cb4d4768 2399 case IDC_SSH2DES:
2400 if (HIWORD(wParam) == BN_CLICKED ||
2401 HIWORD(wParam) == BN_DOUBLECLICKED)
2402 cfg.ssh2_des_cbc =
2403 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
2404 break;
32874aea 2405 case IDC_AGENTFWD:
2406 if (HIWORD(wParam) == BN_CLICKED ||
2407 HIWORD(wParam) == BN_DOUBLECLICKED)
2408 cfg.agentfwd =
2409 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2410 break;
ca20bfcf 2411 case IDC_CIPHERLIST:
2412 case IDC_CIPHERUP:
2413 case IDC_CIPHERDN:
2414 handle_prefslist(&cipherlist,
2415 cfg.ssh_cipherlist, CIPHER_MAX,
2416 0, hwnd, wParam, lParam);
32874aea 2417 break;
2418 case IDC_SSHPROT1:
2419 case IDC_SSHPROT2:
2420 if (HIWORD(wParam) == BN_CLICKED ||
2421 HIWORD(wParam) == BN_DOUBLECLICKED) {
2422 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2423 cfg.sshprot = 1;
2424 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2425 cfg.sshprot = 2;
2426 }
2427 break;
2428 case IDC_AUTHTIS:
2429 if (HIWORD(wParam) == BN_CLICKED ||
2430 HIWORD(wParam) == BN_DOUBLECLICKED)
2431 cfg.try_tis_auth =
2432 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2433 break;
f091e308 2434 case IDC_AUTHKI:
2435 if (HIWORD(wParam) == BN_CLICKED ||
2436 HIWORD(wParam) == BN_DOUBLECLICKED)
2437 cfg.try_ki_auth =
2438 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
2439 break;
32874aea 2440 case IDC_PKEDIT:
2441 if (HIWORD(wParam) == EN_CHANGE)
2442 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2443 sizeof(cfg.keyfile) - 1);
2444 break;
2445 case IDC_CMDEDIT:
2446 if (HIWORD(wParam) == EN_CHANGE)
2447 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2448 sizeof(cfg.remote_cmd) - 1);
2449 break;
2450 case IDC_PKBUTTON:
2451 memset(&of, 0, sizeof(of));
7cca0d81 2452#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2453 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
7cca0d81 2454#else
32874aea 2455 of.lStructSize = sizeof(of);
7cca0d81 2456#endif
32874aea 2457 of.hwndOwner = hwnd;
2458 of.lpstrFilter = "All Files\0*\0\0\0";
2459 of.lpstrCustomFilter = NULL;
2460 of.nFilterIndex = 1;
2461 of.lpstrFile = filename;
2462 strcpy(filename, cfg.keyfile);
2463 of.nMaxFile = sizeof(filename);
2464 of.lpstrFileTitle = NULL;
2465 of.lpstrInitialDir = NULL;
7c0f5956 2466 of.lpstrTitle = "Select Private Key File";
32874aea 2467 of.Flags = 0;
2468 if (GetOpenFileName(&of)) {
2469 strcpy(cfg.keyfile, filename);
2470 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
374330e2 2471 }
32874aea 2472 break;
2473 case IDC_RAWCNP:
2474 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
b90840c3 2475 break;
a7419ea4 2476 case IDC_RTFPASTE:
2477 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
2478 break;
32874aea 2479 case IDC_MBWINDOWS:
2480 case IDC_MBXTERM:
2481 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2482 break;
6908fed7 2483 case IDC_SELTYPELEX:
2484 case IDC_SELTYPERECT:
2485 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
2486 break;
b90840c3 2487 case IDC_MOUSEOVERRIDE:
2488 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2489 break;
32874aea 2490 case IDC_CCSET:
2491 {
2492 BOOL ok;
2493 int i;
2494 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2495
2496 if (!ok)
2497 MessageBeep(0);
2498 else {
4eeb7d09 2499 for (i = 0; i < 128; i++)
32874aea 2500 if (SendDlgItemMessage
2501 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2502 char str[100];
2503 cfg.wordness[i] = n;
2504 SendDlgItemMessage(hwnd, IDC_CCLIST,
2505 LB_DELETESTRING, i, 0);
2506 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2507 (i >= 0x21 && i != 0x7F) ? i : ' ',
2508 cfg.wordness[i]);
2509 SendDlgItemMessage(hwnd, IDC_CCLIST,
2510 LB_INSERTSTRING, i,
2511 (LPARAM) str);
2512 }
2513 }
374330e2 2514 }
32874aea 2515 break;
2516 case IDC_BOLDCOLOUR:
2517 if (HIWORD(wParam) == BN_CLICKED ||
2518 HIWORD(wParam) == BN_DOUBLECLICKED) {
2519 int n, i;
2520 cfg.bold_colour =
2521 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
c8d7378d 2522 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2523 FALSE, 0);
32874aea 2524 n =
2525 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2526 LB_GETCOUNT, 0, 0);
2527 if (n != 12 + 10 * cfg.bold_colour) {
2528 for (i = n; i-- > 0;)
2529 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2530 LB_DELETESTRING, i, 0);
2531 for (i = 0; i < 22; i++)
2532 if (cfg.bold_colour || permcolour[i])
2533 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2534 LB_ADDSTRING, 0,
2535 (LPARAM) colours[i]);
2536 }
c8d7378d 2537 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2538 TRUE, 0);
2539 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
2540 TRUE);
374330e2 2541 }
32874aea 2542 break;
2543 case IDC_PALETTE:
2544 if (HIWORD(wParam) == BN_CLICKED ||
2545 HIWORD(wParam) == BN_DOUBLECLICKED)
2546 cfg.try_palette =
2547 IsDlgButtonChecked(hwnd, IDC_PALETTE);
2548 break;
2549 case IDC_COLOURLIST:
2550 if (HIWORD(wParam) == LBN_DBLCLK ||
2551 HIWORD(wParam) == LBN_SELCHANGE) {
c8d7378d 2552 int i =
2553 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2554 LB_GETCURSEL,
2555 0, 0);
32874aea 2556 if (!cfg.bold_colour)
2557 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2558 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2559 FALSE);
2560 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2561 FALSE);
2562 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2563 FALSE);
2564 }
2565 break;
2566 case IDC_CHANGE:
2567 if (HIWORD(wParam) == BN_CLICKED ||
2568 HIWORD(wParam) == BN_DOUBLECLICKED) {
2569 static CHOOSECOLOR cc;
2570 static DWORD custom[16] = { 0 }; /* zero initialisers */
c8d7378d 2571 int i =
2572 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2573 LB_GETCURSEL,
2574 0, 0);
32874aea 2575 if (!cfg.bold_colour)
2576 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2577 cc.lStructSize = sizeof(cc);
2578 cc.hwndOwner = hwnd;
2579 cc.hInstance = (HWND) hinst;
2580 cc.lpCustColors = custom;
2581 cc.rgbResult =
2582 RGB(cfg.colours[i][0], cfg.colours[i][1],
2583 cfg.colours[i][2]);
2584 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2585 if (ChooseColor(&cc)) {
2586 cfg.colours[i][0] =
2587 (unsigned char) (cc.rgbResult & 0xFF);
2588 cfg.colours[i][1] =
2589 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2590 cfg.colours[i][2] =
2591 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2592 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2593 FALSE);
2594 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2595 FALSE);
2596 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2597 FALSE);
2598 }
2599 }
2600 break;
4eeb7d09 2601 case IDC_CODEPAGE:
875b193f 2602 if (HIWORD(wParam) == CBN_SELCHANGE) {
2603 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
2604 CB_GETCURSEL, 0, 0);
2605 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
2606 index, (LPARAM)cfg.line_codepage);
b8ae1f0f 2607 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
2608 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
2609 sizeof(cfg.line_codepage) - 1);
2610 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
2611 strcpy(cfg.line_codepage,
2612 cp_name(decode_codepage(cfg.line_codepage)));
2613 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
32874aea 2614 }
2615 break;
a9c02454 2616 case IDC_CAPSLOCKCYR:
2617 if (HIWORD(wParam) == BN_CLICKED ||
2618 HIWORD(wParam) == BN_DOUBLECLICKED) {
2619 cfg.xlat_capslockcyr =
2620 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2621 }
2622 break;
32874aea 2623 case IDC_VTXWINDOWS:
2624 case IDC_VTOEMANSI:
2625 case IDC_VTOEMONLY:
2626 case IDC_VTPOORMAN:
4eeb7d09 2627 case IDC_VTUNICODE:
32874aea 2628 cfg.vtmode =
2629 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
2630 : IsDlgButtonChecked(hwnd,
2631 IDC_VTOEMANSI) ? VT_OEMANSI :
2632 IsDlgButtonChecked(hwnd,
2633 IDC_VTOEMONLY) ? VT_OEMONLY :
4eeb7d09 2634 IsDlgButtonChecked(hwnd,
2635 IDC_VTUNICODE) ? VT_UNICODE :
32874aea 2636 VT_POORMAN);
2637 break;
2638 case IDC_X11_FORWARD:
2639 if (HIWORD(wParam) == BN_CLICKED ||
2640 HIWORD(wParam) == BN_DOUBLECLICKED)
2641 cfg.x11_forward =
2642 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
2643 break;
d74d141c 2644 case IDC_LPORT_ALL:
2645 if (HIWORD(wParam) == BN_CLICKED ||
2646 HIWORD(wParam) == BN_DOUBLECLICKED)
2647 cfg.lport_acceptall =
2648 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
2649 break;
32874aea 2650 case IDC_X11_DISPLAY:
2651 if (HIWORD(wParam) == EN_CHANGE)
2652 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
2653 sizeof(cfg.x11_display) - 1);
2654 break;
d74d141c 2655 case IDC_PFWDADD:
2656 if (HIWORD(wParam) == BN_CLICKED ||
2657 HIWORD(wParam) == BN_DOUBLECLICKED) {
2658 char str[sizeof(cfg.portfwd)];
2659 char *p;
2660 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
2661 str[0] = 'L';
2662 else
2663 str[0] = 'R';
2664 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
2665 sizeof(str) - 2);
2666 if (!str[1]) {
2667 MessageBox(hwnd,
2668 "You need to specify a source port number",
2669 "PuTTY Error", MB_OK | MB_ICONERROR);
2670 break;
2671 }
2672 p = str + strlen(str);
2673 *p++ = '\t';
2674 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
2675 sizeof(str) - 1 - (p - str));
2676 if (!*p || !strchr(p, ':')) {
2677 MessageBox(hwnd,
2678 "You need to specify a destination address\n"
2679 "in the form \"host.name:port\"",
2680 "PuTTY Error", MB_OK | MB_ICONERROR);
2681 break;
2682 }
2683 p = cfg.portfwd;
2684 while (*p) {
2685 while (*p)
2686 p++;
2687 p++;
2688 }
2689 if ((p - cfg.portfwd) + strlen(str) + 2 <
2690 sizeof(cfg.portfwd)) {
2691 strcpy(p, str);
2692 p[strlen(str) + 1] = '\0';
2693 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
2694 0, (LPARAM) str);
2695 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
2696 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
2697 } else {
2698 MessageBox(hwnd, "Too many forwardings",
2699 "PuTTY Error", MB_OK | MB_ICONERROR);
2700 }
2701 }
2702 break;
2703 case IDC_PFWDREMOVE:
2704 if (HIWORD(wParam) != BN_CLICKED &&
2705 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2706 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
2707 LB_GETCURSEL, 0, 0);
2708 if (i == LB_ERR)
2709 MessageBeep(0);
2710 else {
2711 char *p, *q;
2712
2713 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
2714 i, 0);
2715 p = cfg.portfwd;
2716 while (i > 0) {
2717 if (!*p)
2718 goto disaster2;
2719 while (*p)
2720 p++;
2721 p++;
2722 i--;
2723 }
2724 q = p;
2725 if (!*p)
2726 goto disaster2;
2727 while (*p)
2728 p++;
2729 p++;
2730 while (*p) {
2731 while (*p)
2732 *q++ = *p++;
2733 *q++ = *p++;
2734 }
2735 *q = '\0';
2736 disaster2:;
2737 }
2738 break;
374330e2 2739 }
374330e2 2740 return 0;
2741 case WM_CLOSE:
32874aea 2742 EndDialog(hwnd, 0);
374330e2 2743 return 0;
c9def1b8 2744
2745 /* Grrr Explorer will maximize Dialogs! */
2746 case WM_SIZE:
2747 if (wParam == SIZE_MAXIMIZED)
32874aea 2748 force_normal(hwnd);
c9def1b8 2749 return 0;
ca20bfcf 2750
2751 default:
2752 /*
2753 * Handle application-defined messages eg. DragListBox
2754 */
2755 /* First find out what the number is (once). */
2756 if (draglistmsg == WM_NULL)
2757 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
2758
2759 if (msg == draglistmsg) {
2760 /* Only process once dialog is fully formed. */
2761 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
2762 case IDC_CIPHERLIST:
2763 return handle_prefslist(&cipherlist,
2764 cfg.ssh_cipherlist, CIPHER_MAX,
2765 1, hwnd, wParam, lParam);
2766 }
2767 }
2768 return 0;
2769
374330e2 2770 }
2771 return 0;
2772}
2773
32874aea 2774static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
2775 WPARAM wParam, LPARAM lParam)
2776{
374330e2 2777 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
374330e2 2778 }
c96a8fef 2779 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
374330e2 2780 EnableWindow(hwnd, 0);
f5eca4f8 2781 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
374330e2 2782 EnableWindow(hwnd, 1);
32874aea 2783 SetActiveWindow(hwnd);
374330e2 2784 }
32874aea 2785 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
374330e2 2786}
2787
32874aea 2788static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
2789 WPARAM wParam, LPARAM lParam)
2790{
2791 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
374330e2 2792}
2793
32874aea 2794void defuse_showwindow(void)
2795{
301b66db 2796 /*
2797 * Work around the fact that the app's first call to ShowWindow
2798 * will ignore the default in favour of the shell-provided
2799 * setting.
2800 */
2801 {
32874aea 2802 HWND hwnd;
2803 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2804 NULL, NullDlgProc);
2805 ShowWindow(hwnd, SW_HIDE);
f5eca4f8 2806 SetActiveWindow(hwnd);
32874aea 2807 DestroyWindow(hwnd);
301b66db 2808 }
2809}
2810
32874aea 2811int do_config(void)
2812{
374330e2 2813 int ret;
2814
2815 get_sesslist(TRUE);
6584031a 2816 savedsession[0] = '\0';
32874aea 2817 ret =
2818 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
374330e2 2819 get_sesslist(FALSE);
2820
2821 return ret;
2822}
2823
32874aea 2824int do_reconfig(HWND hwnd)
2825{
374330e2 2826 Config backup_cfg;
2827 int ret;
2828
2829 backup_cfg = cfg; /* structure copy */
32874aea 2830 ret =
2831 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
374330e2 2832 if (!ret)
2833 cfg = backup_cfg; /* structure copy */
c9def1b8 2834
374330e2 2835 return ret;
2836}
2837
32874aea 2838void logevent(char *string)
2839{
71346075 2840 char timebuf[40];
2841 time_t t;
2842
c5e9c988 2843 if (nevents >= negsize) {
374330e2 2844 negsize += 64;
32874aea 2845 events = srealloc(events, negsize * sizeof(*events));
374330e2 2846 }
71346075 2847
2848 time(&t);
32874aea 2849 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
2850 localtime(&t));
71346075 2851
32874aea 2852 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
71346075 2853 strcpy(events[nevents], timebuf);
2854 strcat(events[nevents], string);
9ad90448 2855 if (logbox) {
32874aea 2856 int count;
2857 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
2858 0, (LPARAM) events[nevents]);
2859 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2860 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
9ad90448 2861 }
bce816e7 2862 nevents++;
374330e2 2863}
2864
32874aea 2865void showeventlog(HWND hwnd)
2866{
374330e2 2867 if (!logbox) {
32874aea 2868 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2869 hwnd, LogProc);
2870 ShowWindow(logbox, SW_SHOWNORMAL);
374330e2 2871 }
9ecf8e5a 2872 SetActiveWindow(logbox);
374330e2 2873}
2874
32874aea 2875void showabout(HWND hwnd)
2876{
2877 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
374330e2 2878}
2879
d4857987 2880void verify_ssh_host_key(char *host, int port, char *keytype,
32874aea 2881 char *keystr, char *fingerprint)
2882{
d5859615 2883 int ret;
374330e2 2884
d5859615 2885 static const char absentmsg[] =
32874aea 2886 "The server's host key is not cached in the registry. You\n"
2887 "have no guarantee that the server is the computer you\n"
2888 "think it is.\n"
2889 "The server's key fingerprint is:\n"
2890 "%s\n"
2891 "If you trust this host, hit Yes to add the key to\n"
2892 "PuTTY's cache and carry on connecting.\n"
d0718310 2893 "If you want to carry on connecting just once, without\n"
2894 "adding the key to the cache, hit No.\n"
2895 "If you do not trust this host, hit Cancel to abandon the\n"
32874aea 2896 "connection.\n";
d5859615 2897
2898 static const char wrongmsg[] =
32874aea 2899 "WARNING - POTENTIAL SECURITY BREACH!\n"
2900 "\n"
2901 "The server's host key does not match the one PuTTY has\n"
2902 "cached in the registry. This means that either the\n"
2903 "server administrator has changed the host key, or you\n"
2904 "have actually connected to another computer pretending\n"
2905 "to be the server.\n"
2906 "The new key fingerprint is:\n"
2907 "%s\n"
2908 "If you were expecting this change and trust the new key,\n"
2909 "hit Yes to update PuTTY's cache and continue connecting.\n"
2910 "If you want to carry on connecting but without updating\n"
2911 "the cache, hit No.\n"
2912 "If you want to abandon the connection completely, hit\n"
2913 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
d5859615 2914
2915 static const char mbtitle[] = "PuTTY Security Alert";
de3df031 2916
32874aea 2917 char message[160 +
c8d7378d 2918 /* sensible fingerprint max size */
32874aea 2919 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2920 sizeof(absentmsg) : sizeof(wrongmsg))];
de3df031 2921
2922 /*
d5859615 2923 * Verify the key against the registry.
de3df031 2924 */
d4857987 2925 ret = verify_host_key(host, port, keytype, keystr);
d5859615 2926
32874aea 2927 if (ret == 0) /* success - key matched OK */
2928 return;
2929 if (ret == 2) { /* key was different */
2930 int mbret;
2931 sprintf(message, wrongmsg, fingerprint);
2932 mbret = MessageBox(NULL, message, mbtitle,
2933 MB_ICONWARNING | MB_YESNOCANCEL);
2934 if (mbret == IDYES)
2935 store_host_key(host, port, keytype, keystr);
2936 if (mbret == IDCANCEL)
2937 exit(0);
de3df031 2938 }
32874aea 2939 if (ret == 1) { /* key was absent */
2940 int mbret;
2941 sprintf(message, absentmsg, fingerprint);
2942 mbret = MessageBox(NULL, message, mbtitle,
d0718310 2943 MB_ICONWARNING | MB_YESNOCANCEL);
2944 if (mbret == IDYES)
2945 store_host_key(host, port, keytype, keystr);
2946 if (mbret == IDCANCEL)
32874aea 2947 exit(0);
de3df031 2948 }
de3df031 2949}
e1c8e0ed 2950
2951/*
ca20bfcf 2952 * Ask whether the selected cipher is acceptable (since it was
2953 * below the configured 'warn' threshold).
2954 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2955 */
2956void askcipher(char *ciphername, int cs)
2957{
2958 static const char mbtitle[] = "PuTTY Security Alert";
2959 static const char msg[] =
2960 "The first %.35scipher supported by the server\n"
2961 "is %.64s, which is below the configured\n"
2962 "warning threshold.\n"
2963 "Do you want to continue with this connection?\n";
2964 /* guessed cipher name + type max length */
2965 char message[100 + sizeof(msg)];
2966 int mbret;
2967
2968 sprintf(message, msg,
2969 (cs == 0) ? "" :
2970 (cs == 1) ? "client-to-server " :
2971 "server-to-client ",
2972 ciphername);
2973 mbret = MessageBox(NULL, message, mbtitle,
2974 MB_ICONWARNING | MB_YESNO);
2975 if (mbret == IDYES)
2976 return;
2977 else
2978 exit(0);
2979}
2980
2981/*
e1c8e0ed 2982 * Ask whether to wipe a session log file before writing to it.
2983 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2984 */
32874aea 2985int askappend(char *filename)
2986{
e1c8e0ed 2987 static const char mbtitle[] = "PuTTY Log to File";
2988 static const char msgtemplate[] =
2989 "The session log file \"%.*s\" already exists.\n"
2990 "You can overwrite it with a new session log,\n"
2991 "append your session log to the end of it,\n"
2992 "or disable session logging for this session.\n"
2993 "Hit Yes to wipe the file, No to append to it,\n"
2994 "or Cancel to disable logging.";
2995 char message[sizeof(msgtemplate) + FILENAME_MAX];
2996 int mbret;
32874aea 2997 if (cfg.logxfovr != LGXF_ASK) {
2998 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
9f89f96e 2999 }
e1c8e0ed 3000 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3001
3002 mbret = MessageBox(NULL, message, mbtitle,
32874aea 3003 MB_ICONQUESTION | MB_YESNOCANCEL);
e1c8e0ed 3004 if (mbret == IDYES)
3005 return 2;
3006 else if (mbret == IDNO)
3007 return 1;
3008 else
3009 return 0;
3010}
7bedb13c 3011
3012/*
3013 * Warn about the obsolescent key file format.
3014 */
3015void old_keyfile_warning(void)
3016{
3017 static const char mbtitle[] = "PuTTY Key File Warning";
3018 static const char message[] =
3019 "You are loading an SSH 2 private key which has an\n"
3020 "old version of the file format. This means your key\n"
3021 "file is not fully tamperproof. Future versions of\n"
3022 "PuTTY may stop supporting this private key format,\n"
3023 "so we recommend you convert your key to the new\n"
3024 "format.\n"
3025 "\n"
3026 "You can perform this conversion by loading the key\n"
3027 "into PuTTYgen and then saving it again.";
3028
3029 MessageBox(NULL, message, mbtitle, MB_OK);
3030}