X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwindlg.c;h=e29f12914e3428e0b54257a6ae837802cb0ef466;hb=19aefec3e8b33f12e6edbead1028c07b5f486ce0;hp=c24ec58cd351010560dab6bffe6581bb003ec6ef;hpb=a1f3b7a358adaa7c2a98359cd0373aa823eeb14b;p=PuTTY.git diff --git a/windows/windlg.c b/windows/windlg.c index c24ec58c..e29f1291 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -14,6 +14,7 @@ #include "win_res.h" #include "storage.h" #include "dialog.h" +#include "licence.h" #include #include @@ -66,8 +67,8 @@ void force_normal(HWND hwnd) recurse = 0; } -static int CALLBACK LogProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { int i; @@ -161,8 +162,8 @@ static int CALLBACK LogProc(HWND hwnd, UINT msg, return 0; } -static int CALLBACK LicenceProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: @@ -170,6 +171,7 @@ static int CALLBACK LicenceProc(HWND hwnd, UINT msg, char *str = dupprintf("%s Licence", appname); SetWindowText(hwnd, str); sfree(str); + SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n")); } return 1; case WM_COMMAND: @@ -187,8 +189,8 @@ static int CALLBACK LicenceProc(HWND hwnd, UINT msg, return 0; } -static int CALLBACK AboutProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { char *str; @@ -197,8 +199,16 @@ static int CALLBACK AboutProc(HWND hwnd, UINT msg, str = dupprintf("About %s", appname); SetWindowText(hwnd, str); sfree(str); - SetDlgItemText(hwnd, IDA_TEXT1, appname); - SetDlgItemText(hwnd, IDA_VERSION, ver); + { + char *buildinfo_text = buildinfo("\r\n"); + char *text = dupprintf + ("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s", + appname, ver, buildinfo_text, + "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved."); + sfree(buildinfo_text); + SetDlgItemText(hwnd, IDA_TEXT, text); + sfree(text); + } return 1; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -283,8 +293,8 @@ static void SaneEndDialog(HWND hwnd, int ret) /* * Null dialog procedure. */ -static int CALLBACK NullDlgProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK NullDlgProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { return 0; } @@ -367,8 +377,8 @@ static void create_controls(HWND hwnd, char *path) * (Being a dialog procedure, in general it returns 0 if the default * dialog processing should be performed, and 1 if it should not.) */ -static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { HWND hw, treeview; struct treeview_faff tvfaff; @@ -454,6 +464,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, HTREEITEM hfirst = NULL; int i; char *path = NULL; + char *firstpath = NULL; for (i = 0; i < ctrlbox->nctrlsets; i++) { struct controlset *s = ctrlbox->ctrlsets[i]; @@ -486,18 +497,27 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, c++; item = treeview_insert(&tvfaff, j, c, s->pathname); - if (!hfirst) + if (!hfirst) { hfirst = item; + firstpath = s->pathname; + } path = s->pathname; } /* - * Put the treeview selection on to the Session panel. - * This should also cause creation of the relevant - * controls. + * Put the treeview selection on to the first panel in the + * ctrlbox. */ TreeView_SelectItem(treeview, hfirst); + + /* + * And create the actual control set for that panel, to + * match the initial treeview selection. + */ + assert(firstpath); /* config.c must have given us _something_ */ + create_controls(hwnd, firstpath); + dlg_refresh(NULL, &dp); /* and set up control values */ } /* @@ -516,6 +536,18 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, } } + /* + * Now we've finished creating our initial set of controls, + * it's safe to actually show the window without risking setup + * flicker. + */ + ShowWindow(hwnd, SW_SHOWNORMAL); + + /* + * Set the flag that activates a couple of the other message + * handlers below, which were disabled until now to avoid + * spurious firing during the above setup procedure. + */ SetWindowLongPtr(hwnd, GWLP_USERDATA, 1); return 0; case WM_LBUTTONUP: @@ -530,10 +562,21 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, case WM_NOTIFY: if (LOWORD(wParam) == IDCX_TREEVIEW && ((LPNMHDR) lParam)->code == TVN_SELCHANGED) { - HTREEITEM i = - TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom); + /* + * Selection-change events on the treeview cause us to do + * a flurry of control deletion and creation - but only + * after WM_INITDIALOG has finished. The initial + * selection-change event(s) during treeview setup are + * ignored. + */ + HTREEITEM i; TVITEM item; char buffer[64]; + + if (GetWindowLongPtr(hwnd, GWLP_USERDATA) != 1) + return 0; + + i = TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom); SendMessage (hwnd, WM_SETREDRAW, FALSE, 0); @@ -745,8 +788,8 @@ void showabout(HWND hwnd) DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc); } -int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, - char *keystr, char *fingerprint, +int verify_ssh_host_key(void *frontend, char *host, int port, + const char *keytype, char *keystr, char *fingerprint, void (*callback)(void *ctx, int result), void *ctx) { int ret; @@ -854,11 +897,38 @@ int askalg(void *frontend, const char *algtype, const char *algname, return 0; } +int askhk(void *frontend, const char *algname, const char *betteralgs, + void (*callback)(void *ctx, int result), void *ctx) +{ + static const char mbtitle[] = "%s Security Alert"; + static const char msg[] = + "The first host key type we have stored for this server\n" + "is %s, which is below the configured warning threshold.\n" + "The server also provides the following types of host key\n" + "above the threshold, which we do not have stored:\n" + "%s\n" + "Do you want to continue with this connection?\n"; + char *message, *title; + int mbret; + + message = dupprintf(msg, algname, betteralgs); + title = dupprintf(mbtitle, appname); + mbret = MessageBox(NULL, message, title, + MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + socket_reselect_all(); + sfree(message); + sfree(title); + if (mbret == IDYES) + return 1; + else + return 0; +} + /* * Ask whether to wipe a session log file before writing to it. * Returns 2 for wipe, 1 for append, 0 for cancel (don't log). */ -int askappend(void *frontend, Filename filename, +int askappend(void *frontend, Filename *filename, void (*callback)(void *ctx, int result), void *ctx) { static const char msgtemplate[] = @@ -872,7 +942,7 @@ int askappend(void *frontend, Filename filename, char *mbtitle; int mbret; - message = dupprintf(msgtemplate, FILENAME_MAX, filename.path); + message = dupprintf(msgtemplate, FILENAME_MAX, filename->path); mbtitle = dupprintf("%s Log to File", appname); mbret = MessageBox(NULL, message, mbtitle,