81 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
82 |
int lv_idx; |
int lv_idx; |
83 |
int keylist_sortby; |
int keylist_sortby; |
84 |
|
int magic; |
85 |
|
|
86 |
|
unsigned int enable_groups:1; |
87 |
}; |
}; |
88 |
|
typedef struct km_info_s *km_info_t; |
89 |
|
|
90 |
/* Toolbar button structure. */ |
/* Toolbar button structure. */ |
91 |
struct mybuttons { |
struct tb_button_s { |
92 |
long icon; |
long icon; |
93 |
long command; |
long command; |
94 |
char *text; |
char *text; |
95 |
}; |
}; |
96 |
|
|
97 |
struct mybuttons myb[] = { |
/* The buttons in the toolbar. */ |
98 |
|
struct tb_button_s tbb[] = { |
99 |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
100 |
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
101 |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
105 |
|
|
106 |
|
|
107 |
static void km_gui_import (struct km_info_s *kmi, int cmd_id, void *param); |
static void km_gui_import (struct km_info_s *kmi, int cmd_id, void *param); |
108 |
|
void key_get_clip_info (const char *keyid, char *buf, size_t buflen); |
109 |
|
|
110 |
|
|
111 |
/* Subclass the keylist listview control to allow extended commands. */ |
/* Subclass the keylist listview control to allow extended commands. */ |
112 |
static BOOL CALLBACK |
static BOOL CALLBACK |
173 |
} |
} |
174 |
|
|
175 |
|
|
176 |
#define ico2idx(ico) imagelist_getindex((ico)) |
#define ico2idx(ico) imagelist_getindex ((ico)) |
177 |
|
|
178 |
|
/* Create a new toolbar window with a pre-defined list of buttons. */ |
179 |
static HWND |
static HWND |
180 |
load_toolbar (HWND dlg, struct km_info_s *kmi) |
create_toolbar (HWND dlg, struct km_info_s *kmi) |
181 |
{ |
{ |
182 |
HWND tbwnd; |
HWND tbwnd; |
183 |
TBSAVEPARAMS tbsp; |
TBSAVEPARAMS tbsp; |
184 |
TBBUTTON tb_buttons[] = { |
TBBUTTON tb_buttons[] = { |
192 |
{ico2idx (IMI_KEY_FILE_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_FILE_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
193 |
{ico2idx (IMI_KEY_IMPORT), ID_KEYCTX_PASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_IMPORT), ID_KEYCTX_PASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
194 |
{ico2idx (IMI_KEY_EXPORT), ID_KEYCTX_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_EXPORT), ID_KEYCTX_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
195 |
}; |
}; |
196 |
|
|
197 |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
198 |
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
199 |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
200 |
if (tbwnd) { |
if (!tbwnd) |
201 |
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
BUG (0); |
202 |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
203 |
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
204 |
ShowWindow (tbwnd, SW_SHOW); |
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
205 |
|
ShowWindow (tbwnd, SW_SHOW); |
206 |
/* Restore toolbar */ |
|
207 |
tbsp.hkr = HKEY_CURRENT_USER; |
/* Restore toolbar */ |
208 |
tbsp.pszSubKey = "Software\\WinPT"; |
tbsp.hkr = HKEY_CURRENT_USER; |
209 |
tbsp.pszValueName = "KM_toolbar"; |
tbsp.pszSubKey = "Software\\WinPT"; |
210 |
if (SendMessage(tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp ) == 0) |
tbsp.pszValueName = "KM_toolbar"; |
211 |
SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]), |
if (SendMessage (tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp) == 0) |
212 |
(LONG)&tb_buttons[0]); |
SendMessage (tbwnd, TB_ADDBUTTONS, |
213 |
} |
sizeof (tb_buttons) / sizeof (tb_buttons[0]), |
214 |
return tbwnd; |
(LONG)&tb_buttons[0]); |
215 |
|
|
216 |
|
return tbwnd; |
217 |
} |
} |
218 |
|
|
219 |
|
|
224 |
{ |
{ |
225 |
WORD *buf; |
WORD *buf; |
226 |
HKEY root; |
HKEY root; |
227 |
DWORD type; |
DWORD type, size, i; |
|
DWORD size = kmi->lv->cols*sizeof (WORD), i; |
|
228 |
LONG ec; |
LONG ec; |
229 |
|
|
230 |
|
size = kmi->lv->cols*sizeof (WORD); |
231 |
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\WinPT", 0, |
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\WinPT", 0, |
232 |
KEY_ALL_ACCESS, &root); |
KEY_ALL_ACCESS, &root); |
233 |
if (ec != ERROR_SUCCESS) |
if (ec != ERROR_SUCCESS) |
306 |
} |
} |
307 |
|
|
308 |
|
|
309 |
|
/* Restore the original size of the dialog. */ |
310 |
|
static void |
311 |
|
restore_window_size (HWND dlg, struct km_info_s *kmi) |
312 |
|
{ |
313 |
|
char *p; |
314 |
|
int height = 0, width = 0; |
315 |
|
|
316 |
|
/* Restore the original window size. */ |
317 |
|
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Width"); |
318 |
|
if (p) { |
319 |
|
width = atoi (p); |
320 |
|
free_if_alloc (p); |
321 |
|
} |
322 |
|
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Height"); |
323 |
|
if (p) { |
324 |
|
height = atoi (p); |
325 |
|
free_if_alloc (p); |
326 |
|
} |
327 |
|
if (height > 0 && width > 0) |
328 |
|
SetWindowPos (dlg, HWND_TOP, kmi->pos_x, kmi->pos_y, |
329 |
|
height, width, SWP_SHOWWINDOW); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
/* Center window @dlg. */ |
/* Center window @dlg. */ |
334 |
static void |
static void |
335 |
do_center_window (HWND dlg, struct km_info_s *kmi) |
do_center_window (HWND dlg, struct km_info_s *kmi) |
352 |
return; |
return; |
353 |
} |
} |
354 |
else if (p) |
else if (p) |
355 |
pos_x = atol (p); |
pos_x = atoi (p); |
356 |
|
|
357 |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y"); |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y"); |
358 |
if (p && !strcmp (p, " ")) { |
if (p && !strcmp (p, " ")) { |
361 |
return; |
return; |
362 |
} |
} |
363 |
else if (p) |
else if (p) |
364 |
pos_y = atol (p); |
pos_y = atoi (p); |
365 |
|
|
366 |
if (!pos_y && !pos_x) { |
if (!pos_y && !pos_x) { |
367 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
374 |
|| pos_y > GetSystemMetrics (SM_CYSCREEN)) { |
|| pos_y > GetSystemMetrics (SM_CYSCREEN)) { |
375 |
pos_x = pos_y = 0; |
pos_x = pos_y = 0; |
376 |
} |
} |
377 |
|
kmi->pos_x = pos_x; |
378 |
|
kmi->pos_y = pos_y; |
379 |
|
|
380 |
GetClientRect (dlg, &rect); |
GetClientRect (dlg, &rect); |
381 |
MoveWindow (dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE); |
MoveWindow (dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE); |
382 |
} |
} |
432 |
|
|
433 |
/* Place the keylist above the separator */ |
/* Place the keylist above the separator */ |
434 |
h = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
h = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
435 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
436 |
kmi->ypos_sep - rclient.top, bRepaint); |
kmi->ypos_sep - rclient.top, bRepaint); |
437 |
rclient.top = kmi->ypos_sep + 5 + 8; |
rclient.top = kmi->ypos_sep + 5 + 8; |
438 |
|
|
439 |
#if 0 /* Disable the code until we support groups again. */ |
if (kmi->enable_groups != 0) { |
440 |
/* Place the group text and the group box below the separator */ |
/* Place the group text and the group box below the separator */ |
441 |
h = GetDlgItem (dlg, IDC_KEYMISC_GTEXT); |
h = GetDlgItem (dlg, IDC_KEYMISC_GTEXT); |
442 |
MoveWindow (h, rclient.left, rclient.top, 100, 14, bRepaint); |
MoveWindow (h, rclient.left, rclient.top, 100, 14, bRepaint); |
443 |
rclient.top += 18; |
rclient.top += 18; |
444 |
|
|
445 |
h = GetDlgItem (dlg, IDC_KEYMISC_GROUP); |
h = GetDlgItem (dlg, IDC_KEYMISC_GROUP); |
446 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
MoveWindow (h, rclient.left, rclient.top, |
447 |
(rclient.bottom < rclient.top) ? |
rclient.right - rclient.left, |
448 |
0 : rclient.bottom - rclient.top, bRepaint); |
(rclient.bottom < rclient.top) ? |
449 |
#endif |
0 : rclient.bottom - rclient.top, bRepaint); |
450 |
|
} |
451 |
|
|
452 |
/* Repaint the whole thing */ |
/* Repaint the whole thing */ |
453 |
InvalidateRect (dlg, NULL, TRUE); |
InvalidateRect (dlg, NULL, TRUE); |
519 |
void |
void |
520 |
update_status_bar (HWND sb, listview_ctrl_t lv) |
update_status_bar (HWND sb, listview_ctrl_t lv) |
521 |
{ |
{ |
522 |
char txt_sec[128], txt_pub[128]; |
char txt_sec[128]; |
523 |
|
char txt_pub[128]; |
524 |
int nkeys = 0, nsec = 0; |
int nkeys = 0, nsec = 0; |
|
int i; |
|
525 |
|
|
526 |
nkeys = listview_count_items (lv, 0); |
nkeys = listview_count_items (lv, 0); |
527 |
for (i = 0; i < nkeys; i++) { |
nsec = gpg_keycache_get_size (keycache_get_ctx (0)); |
528 |
if (km_check_for_seckey (lv, i, NULL)) |
|
|
nsec++; |
|
|
} |
|
529 |
_snprintf (txt_sec, sizeof (txt_sec)-1, _("%d secret keys"), nsec); |
_snprintf (txt_sec, sizeof (txt_sec)-1, _("%d secret keys"), nsec); |
530 |
_snprintf (txt_pub, sizeof (txt_pub)-1, _("%d keys"), nkeys); |
_snprintf (txt_pub, sizeof (txt_pub)-1, _("%d keys"), nkeys); |
531 |
SendMessage (sb, SB_SETTEXT, 1, (LPARAM)txt_sec); |
SendMessage (sb, SB_SETTEXT, 1, (LPARAM)txt_sec); |
537 |
separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
538 |
{ |
{ |
539 |
static POINT last_mouse_pos; |
static POINT last_mouse_pos; |
540 |
|
PAINTSTRUCT ps; |
541 |
|
RECT rect; |
542 |
|
HPEN hpen; |
543 |
|
|
544 |
if (msg == WM_CREATE) |
if (msg == WM_CREATE) |
545 |
SetWindowLong (hwnd, GWL_USERDATA, |
SetWindowLong (hwnd, GWL_USERDATA, |
547 |
|
|
548 |
switch (msg) { |
switch (msg) { |
549 |
case WM_PAINT: |
case WM_PAINT: |
|
PAINTSTRUCT ps; |
|
|
RECT rect; |
|
|
HPEN hpen; |
|
|
|
|
550 |
GetClientRect (hwnd, &rect); |
GetClientRect (hwnd, &rect); |
551 |
BeginPaint (hwnd, &ps); |
BeginPaint (hwnd, &ps); |
552 |
|
|
554 |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
555 |
|
|
556 |
/* The lines from the light into the dark */ |
/* The lines from the light into the dark */ |
557 |
MoveToEx(ps.hdc, 0,0, NULL); |
MoveToEx (ps.hdc, 0,0, NULL); |
558 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DHILIGHT)); |
559 |
|
if (hpen != NULL) { |
560 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
561 |
LineTo (ps.hdc, rect.right, 0); |
LineTo (ps.hdc, rect.right, 0); |
562 |
DeleteObject (hpen); |
DeleteObject (hpen); |
563 |
} |
} |
564 |
MoveToEx(ps.hdc, 0, 1, NULL); |
MoveToEx (ps.hdc, 0, 1, NULL); |
565 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DLIGHT)); |
566 |
|
if (hpen != NULL) { |
567 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
568 |
LineTo (ps.hdc, rect.right, rect.bottom); |
LineTo (ps.hdc, rect.right, rect.bottom); |
569 |
DeleteObject (hpen); |
DeleteObject (hpen); |
570 |
} |
} |
571 |
|
|
572 |
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL); |
MoveToEx (ps.hdc, 0, rect.bottom-1, NULL); |
573 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW)); |
574 |
|
if (hpen != NULL) { |
575 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
576 |
LineTo (ps.hdc, rect.right, rect.bottom-1); |
LineTo (ps.hdc, rect.right, rect.bottom-1); |
577 |
DeleteObject (hpen); |
DeleteObject (hpen); |
578 |
} |
} |
579 |
MoveToEx(ps.hdc, 0, rect.bottom, NULL); |
MoveToEx (ps.hdc, 0, rect.bottom, NULL); |
580 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) { |
hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW)); |
581 |
|
if (hpen != NULL) { |
582 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
583 |
LineTo (ps.hdc, rect.right, rect.bottom); |
LineTo (ps.hdc, rect.right, rect.bottom); |
584 |
DeleteObject (hpen); |
DeleteObject (hpen); |
602 |
if (wparam == MK_LBUTTON) { |
if (wparam == MK_LBUTTON) { |
603 |
struct km_info_s *kmi; |
struct km_info_s *kmi; |
604 |
POINT p; |
POINT p; |
|
RECT r; |
|
605 |
|
|
606 |
kmi = (struct km_info_s *)GetWindowLong (hwnd, GWL_USERDATA); |
kmi = (struct km_info_s *)GetWindowLong (hwnd, GWL_USERDATA); |
607 |
if (kmi == NULL) |
if (kmi == NULL) |
608 |
break; |
break; |
609 |
|
|
610 |
/* Calculate mouse movement */ |
/* Calculate mouse movement */ |
611 |
p.x = LOWORD(lparam); |
p.x = LOWORD (lparam); |
612 |
p.y = HIWORD(lparam); |
p.y = HIWORD (lparam); |
613 |
ClientToScreen (hwnd, &p); |
ClientToScreen (hwnd, &p); |
614 |
|
|
615 |
GetWindowRect (hwnd, &r); |
GetWindowRect (hwnd, &rect); |
616 |
r.top += (short)(p.y - last_mouse_pos.y); |
rect.top += (short)(p.y - last_mouse_pos.y); |
617 |
r.bottom += (short)(p.y - last_mouse_pos.y); |
rect.bottom += (short)(p.y - last_mouse_pos.y); |
618 |
|
|
619 |
last_mouse_pos.y = p.y; |
last_mouse_pos.y = p.y; |
620 |
|
|
621 |
/* Apply mouse movement to window. Beware the MoveWindow is relaive |
/* Apply mouse movement to window. Beware the MoveWindow is relaive |
622 |
to parent NOT screen */ |
to parent NOT screen */ |
623 |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&r, 2); |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
624 |
kmi->ypos_sep = r.top; |
kmi->ypos_sep = rect.top; |
625 |
kmi->ypercent_sep = 0; /* This forces do_resize_window to use abs. position */ |
kmi->ypercent_sep = 0; /* This forces do_resize_window to use abs. position */ |
626 |
do_resize_window (GetParent(hwnd), kmi); |
do_resize_window (GetParent (hwnd), kmi); |
627 |
return 0; |
return 0; |
628 |
} |
} |
629 |
} |
} |
639 |
WNDCLASS wndclass; |
WNDCLASS wndclass; |
640 |
HWND h; |
HWND h; |
641 |
|
|
642 |
|
memset (&wndclass, 0, sizeof (wndclass)); |
643 |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
644 |
wndclass.lpfnWndProc = separator_wnd_proc; |
wndclass.lpfnWndProc = separator_wnd_proc; |
645 |
wndclass.cbClsExtra = 0; |
wndclass.cbClsExtra = 0; |
654 |
|
|
655 |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
656 |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
657 |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
658 |
|
if (!h) |
659 |
|
BUG (NULL); |
660 |
ShowWindow (h, SW_SHOW); |
ShowWindow (h, SW_SHOW); |
661 |
return h; |
return h; |
662 |
} |
} |
676 |
HMENU hmenu; |
HMENU hmenu; |
677 |
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
678 |
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
679 |
int key_selected = 0; |
int key_selected; |
680 |
int key_has_sec = 0; |
int key_has_sec; |
681 |
int key_inv = 0; |
int key_inv = 0; |
682 |
int i, state=0; |
int i, state=0; |
683 |
|
|
724 |
} |
} |
725 |
|
|
726 |
/* Disable all secret-key functions when no secret key is available. */ |
/* Disable all secret-key functions when no secret key is available. */ |
727 |
{ |
if (!secret_key_available ()) { |
728 |
gpg_keycache_t sec = keycache_get_ctx (0); |
enable_button (tb_hwnd, ID_KEYMISC_SIGN, FALSE); |
729 |
if (gpg_keycache_get_size (sec) == 0) { |
set_menu_state (hmenu, ID_KEYMISC_SIGN, MF_GRAYED); |
|
enable_button (tb_hwnd, ID_KEYMISC_SIGN, FALSE); |
|
|
set_menu_state (hmenu, ID_KEYMISC_SIGN, MF_GRAYED); |
|
|
} |
|
730 |
} |
} |
731 |
} |
} |
732 |
|
|
878 |
for (i=1; i <= 3; i++) |
for (i=1; i <= 3; i++) |
879 |
partpos[i-1] = r.right/3*i; |
partpos[i-1] = r.right/3*i; |
880 |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
881 |
"status bar", dlg, KM_SEPARATOR_ID); |
"WinPT_Status_Bar", dlg, KM_SEPARATOR_ID); |
882 |
|
if (!statbar) |
883 |
|
BUG (NULL); |
884 |
ShowWindow (statbar, SW_SHOW); |
ShowWindow (statbar, SW_SHOW); |
885 |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
886 |
|
|
887 |
update_default_key_str (statbar); |
update_default_key_str (statbar); |
888 |
update_status_bar (statbar, lv); |
update_status_bar (statbar, lv); |
|
|
|
889 |
return statbar; |
return statbar; |
890 |
} |
} |
891 |
|
|
955 |
return file_exist_check (path) == 0? true : false; |
return file_exist_check (path) == 0? true : false; |
956 |
} |
} |
957 |
|
|
958 |
|
|
959 |
/* Translate all menu strings. */ |
/* Translate all menu strings. */ |
960 |
static void |
static void |
961 |
translate_menu_strings (HWND dlg) |
translate_menu_strings (HWND dlg) |
990 |
set_menu_text (menu, ID_KEYMISC_EXPORT, _("&Export...")); |
set_menu_text (menu, ID_KEYMISC_EXPORT, _("&Export...")); |
991 |
set_menu_text (menu, ID_KEYMISC_IMPORT, _("&Import...")); |
set_menu_text (menu, ID_KEYMISC_IMPORT, _("&Import...")); |
992 |
set_menu_text (menu, ID_KEYMISC_PROPS, _("&Properties")); |
set_menu_text (menu, ID_KEYMISC_PROPS, _("&Properties")); |
993 |
set_menu_text (menu, ID_KEYMISC_GPGOPT, _("Options")); |
set_menu_text (menu, ID_KEYMISC_GPGOPT, _("GPG &Options")); |
994 |
set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("Preferences")); |
set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("&GPG Preferences")); |
995 |
|
set_menu_text (menu, ID_KEYMISC_WINPTPREFS, _("&WinPT Preferences")); |
996 |
set_menu_text (menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
set_menu_text (menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
997 |
set_menu_text (menu, ID_KEYMISC_EXPORT_PRIVKEY, _("E&xport Secret Key")); |
set_menu_text (menu, ID_KEYMISC_EXPORT_PRIVKEY, _("E&xport Secret Key")); |
998 |
set_menu_text (menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache")); |
set_menu_text (menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache")); |
1021 |
set_menu_text (popup, ID_KEYCTX_KEYID_COPY, _("Copy Key ID to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_KEYID_COPY, _("Copy Key ID to Clipboard")); |
1022 |
set_menu_text (popup, ID_KEYCTX_FPR_COPY, _("Copy Fingerprint to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_FPR_COPY, _("Copy Fingerprint to Clipboard")); |
1023 |
set_menu_text (popup, ID_KEYCTX_KINFO_COPY, _("Copy Key Info to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_KINFO_COPY, _("Copy Key Info to Clipboard")); |
1024 |
|
set_menu_text (popup, ID_KEYCTX_EMAIL_COPY, _("Copy E-Mail to Clipboard")); |
1025 |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
1026 |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
1027 |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
1051 |
} |
} |
1052 |
|
|
1053 |
|
|
1054 |
|
static int |
1055 |
|
km_gui_adjust_column_images (listview_ctrl_t ctx, int sortby) |
1056 |
|
{ |
1057 |
|
HWND hheader; |
1058 |
|
HDITEM hdi; |
1059 |
|
int idx, sort_desc = 0; |
1060 |
|
|
1061 |
|
hheader = ListView_GetHeader (ctx->ctrl); |
1062 |
|
if (!hheader) |
1063 |
|
return 0; |
1064 |
|
|
1065 |
|
/* Remove image from all header fields */ |
1066 |
|
memset (&hdi, 0, sizeof(hdi)); |
1067 |
|
|
1068 |
|
for (int i=0; i < 7; i++) { |
1069 |
|
hdi.mask = HDI_FORMAT; |
1070 |
|
Header_GetItem (hheader, i, &hdi); |
1071 |
|
hdi.fmt &= ~HDF_IMAGE; |
1072 |
|
Header_SetItem (hheader, i, &hdi); |
1073 |
|
} |
1074 |
|
|
1075 |
|
switch (sortby & ~KEYLIST_SORT_DESC) { |
1076 |
|
case KEY_SORT_USERID: idx = 0; break; |
1077 |
|
case KEY_SORT_KEYID: idx = 1; break; |
1078 |
|
case KEY_SORT_IS_SECRET: idx = 2; break; |
1079 |
|
case KEY_SORT_LEN: idx = 3; break; |
1080 |
|
case KEY_SORT_VALIDITY: idx = 5; break; |
1081 |
|
case KEY_SORT_OTRUST: idx = 6; break; |
1082 |
|
case KEY_SORT_CREATED: idx = 7; break; |
1083 |
|
case KEY_SORT_ALGO: idx = 8; break; |
1084 |
|
default: idx = 0; break; |
1085 |
|
} |
1086 |
|
|
1087 |
|
sort_desc = sortby & KEYLIST_SORT_DESC; |
1088 |
|
/* Set image to currently sorted field */ |
1089 |
|
memset (&hdi, 0, sizeof(hdi)); |
1090 |
|
hdi.mask = HDI_IMAGE | HDI_FORMAT; |
1091 |
|
Header_GetItem (hheader, idx, &hdi); |
1092 |
|
hdi.fmt |= HDF_IMAGE | HDF_BITMAP_ON_RIGHT; |
1093 |
|
if (!ctx->ext_chkbox) |
1094 |
|
hdi.iImage = imagelist_getindex (sort_desc? IMI_SORT_DOWNARROW : |
1095 |
|
IMI_SORT_UPARROW); |
1096 |
|
else |
1097 |
|
hdi.iImage = sort_desc? KEY_IMG_SORT_DOWN : KEY_IMG_SORT_UP; |
1098 |
|
Header_SetItem (hheader, idx, &hdi); |
1099 |
|
return 0; |
1100 |
|
} |
1101 |
|
|
1102 |
|
|
1103 |
/* Return true if the cache contain marked keys. */ |
/* Return true if the cache contain marked keys. */ |
1104 |
static bool |
static bool |
1105 |
updated_keys_avail (void) |
updated_keys_avail (void) |
1119 |
static int |
static int |
1120 |
find_keypos (listview_ctrl_t lv, gpgme_key_t key) |
find_keypos (listview_ctrl_t lv, gpgme_key_t key) |
1121 |
{ |
{ |
1122 |
char keyid[16+1]; |
char keyid[32+1]; |
1123 |
int i; |
int i; |
1124 |
|
|
1125 |
for (i=0; i < listview_count_items (lv, 0); i++) { |
for (i=0; i < listview_count_items (lv, 0); i++) { |
1150 |
keylist_upd_key (kmi->lv, pos, ctx, ctx->key); |
keylist_upd_key (kmi->lv, pos, ctx, ctx->key); |
1151 |
} |
} |
1152 |
} |
} |
1153 |
keylist_sort (kmi->lv, KEY_SORT_USERID); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1154 |
|
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1155 |
update_status_bar (kmi->statbar, kmi->lv); |
update_status_bar (kmi->statbar, kmi->lv); |
1156 |
keyring_check_last_access (); |
keyring_check_last_access (); |
1157 |
|
SetForegroundWindow (kmi->dlg); |
1158 |
} |
} |
1159 |
|
|
1160 |
|
|
1161 |
|
/* Reload the key cache. */ |
1162 |
static void |
static void |
1163 |
reload_keylist (struct km_info_s *kmi) |
keycache_reload (HWND dlg) |
1164 |
|
{ |
1165 |
|
refresh_cache_s rcs; |
1166 |
|
|
1167 |
|
memset (&rcs, 0, sizeof rcs); |
1168 |
|
rcs.kring_update = 1; |
1169 |
|
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
1170 |
|
keycache_dlg_proc, (LPARAM)&rcs); |
1171 |
|
} |
1172 |
|
|
1173 |
|
|
1174 |
|
/* Check if the secret keyring contains at least one |
1175 |
|
key with ultimate trust. |
1176 |
|
Return value: 0 on success. */ |
1177 |
|
int |
1178 |
|
check_ultimate_trusted_key (gpg_keycache_t _sec) |
1179 |
{ |
{ |
1180 |
keycache_reload (kmi->dlg); |
struct keycache_s *n; |
1181 |
keylist_reload (kmi->lv, keycache_get_ctx (1), |
int nkeys = 0; |
1182 |
KEYLIST_LIST, KEY_SORT_USERID); |
|
1183 |
update_status_bar (kmi->statbar, kmi->lv); |
for (n = _sec->item; n; n = n->next) { |
1184 |
keyring_check_last_access (); |
if (n->pubpart && |
1185 |
|
n->pubpart->key->owner_trust == GPGME_VALIDITY_ULTIMATE) |
1186 |
|
return 0; |
1187 |
|
nkeys++; |
1188 |
|
} |
1189 |
|
|
1190 |
|
/* if we do not have any secret keys, it does not make sense |
1191 |
|
to return an error. */ |
1192 |
|
if (nkeys == 0) |
1193 |
|
return 0; |
1194 |
|
return -1; |
1195 |
} |
} |
1196 |
|
|
1197 |
|
|
1199 |
static void |
static void |
1200 |
reload_keycache (struct km_info_s *kmi) |
reload_keycache (struct km_info_s *kmi) |
1201 |
{ |
{ |
|
refresh_cache_s rcs = {0}; |
|
1202 |
gpg_keycache_t c; |
gpg_keycache_t c; |
1203 |
|
|
1204 |
rcs.kr_reload = rcs.kr_update = 1; |
keycache_reload (kmi->dlg); |
|
rcs.tr_update = 0; |
|
|
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, kmi->dlg, |
|
|
keycache_dlg_proc, (LPARAM)&rcs); |
|
1205 |
c = keycache_get_ctx (1); |
c = keycache_get_ctx (1); |
1206 |
if (!c) |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
|
BUG (0); |
|
|
keylist_reload (kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID); |
|
1207 |
update_status_bar (kmi->statbar, kmi->lv); |
update_status_bar (kmi->statbar, kmi->lv); |
1208 |
SetForegroundWindow (kmi->dlg); |
SetForegroundWindow (kmi->dlg); |
1209 |
|
keyring_check_last_access (); |
1210 |
} |
} |
1211 |
|
|
1212 |
|
|
1214 |
static void |
static void |
1215 |
km_gui_import (struct km_info_s *kmi, int cmd_id, void *param) |
km_gui_import (struct km_info_s *kmi, int cmd_id, void *param) |
1216 |
{ |
{ |
1217 |
int newkeys=0, newsks=0; |
int newkeys = 0, newsks = 0; |
1218 |
int err = 0; |
int err = 0; |
1219 |
|
|
1220 |
switch (cmd_id) { |
switch (cmd_id) { |
1239 |
if (!err && !newsks && (newkeys > 0 && newkeys < KM_PRELOAD_KEYS)) |
if (!err && !newsks && (newkeys > 0 && newkeys < KM_PRELOAD_KEYS)) |
1240 |
refresh_keylist (kmi); |
refresh_keylist (kmi); |
1241 |
else if (!err) /* avoid to spawn too much processes. */ |
else if (!err) /* avoid to spawn too much processes. */ |
1242 |
reload_keylist (kmi); |
reload_keycache (kmi); |
|
|
|
1243 |
SetForegroundWindow (kmi->dlg); |
SetForegroundWindow (kmi->dlg); |
1244 |
center_window (kmi->dlg, NULL); |
} |
1245 |
|
|
1246 |
|
|
1247 |
|
/* Copy the requested key information (@what) to the clipboard. |
1248 |
|
If multiple items were selected, each key info is copied to |
1249 |
|
the clipboard. The data is separated by \r\n. */ |
1250 |
|
static void |
1251 |
|
copy_key_info (int what, struct km_info_s *kmi) |
1252 |
|
{ |
1253 |
|
gpgme_data_t out; |
1254 |
|
gpgme_key_t key; |
1255 |
|
struct keycache_s *kci = NULL; |
1256 |
|
size_t n=0; |
1257 |
|
char *p, tmp[256]; |
1258 |
|
int i=0, end = listview_count_items (kmi->lv, 0); |
1259 |
|
bool single = false; |
1260 |
|
|
1261 |
|
/* Do not iterate over the entire list if just one item is selected. */ |
1262 |
|
n = listview_count_items (kmi->lv, 1); |
1263 |
|
if (n == 1) { |
1264 |
|
i = kmi->lv_idx; |
1265 |
|
end = i+1; |
1266 |
|
single = true; |
1267 |
|
} |
1268 |
|
|
1269 |
|
gpgme_data_new (&out); |
1270 |
|
for (; i < end; i++) { |
1271 |
|
if (!listview_get_item_state (kmi->lv, i)) |
1272 |
|
continue; |
1273 |
|
switch (what) { |
1274 |
|
|
1275 |
|
case ID_KEYCTX_EMAIL_COPY: |
1276 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1277 |
|
gpgme_data_write (out, key->uids->email, strlen (key->uids->email)); |
1278 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1279 |
|
break; |
1280 |
|
|
1281 |
|
case ID_KEYCTX_UID_COPY: |
1282 |
|
key = km_get_key_ptr (kmi->lv, i, &kci); |
1283 |
|
gpgme_data_write (out, kci->uids->uid, strlen (kci->uids->uid)); |
1284 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1285 |
|
break; |
1286 |
|
|
1287 |
|
case ID_KEYCTX_KEYID_COPY: |
1288 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1289 |
|
gpgme_data_write (out, "0x", 2); |
1290 |
|
gpgme_data_write (out, key->subkeys->keyid+8, 8); |
1291 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1292 |
|
break; |
1293 |
|
|
1294 |
|
case ID_KEYCTX_FPR_COPY: |
1295 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1296 |
|
gpgme_data_write (out, key->subkeys->fpr, strlen (key->subkeys->fpr)); |
1297 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1298 |
|
break; |
1299 |
|
|
1300 |
|
case ID_KEYCTX_KINFO_COPY: |
1301 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1302 |
|
key_get_clip_info (key->subkeys->keyid+8, tmp, sizeof (tmp)-1); |
1303 |
|
gpgme_data_write (out, tmp, strlen (tmp)); |
1304 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1305 |
|
break; |
1306 |
|
} |
1307 |
|
} |
1308 |
|
gpgme_data_write (out, "\0", 1); |
1309 |
|
p = gpgme_data_release_and_get_mem (out, &n); |
1310 |
|
set_clip_text (NULL, p, n); |
1311 |
|
gpgme_free (p); |
1312 |
} |
} |
1313 |
|
|
1314 |
|
|
1316 |
BOOL CALLBACK |
BOOL CALLBACK |
1317 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
1318 |
{ |
{ |
|
struct km_info_s *kmi = NULL; |
|
1319 |
HWND kl; |
HWND kl; |
1320 |
HMENU hm; |
HMENU hm; |
1321 |
struct keycache_s *kci; |
RECT r; |
1322 |
gpg_keycache_t c; |
gpg_keycache_t c; |
1323 |
gpgme_key_t key; |
gpgme_key_t key; |
1324 |
|
km_info_t kmi = NULL; |
1325 |
struct genkey_s genkey; |
struct genkey_s genkey; |
1326 |
struct winpt_key_s k = {0}; |
struct winpt_key_s k = {0}; |
1327 |
struct URL_ctx_s *url; |
struct URL_ctx_s *url; |
1331 |
int l_idx = 0, i=0, rc; |
int l_idx = 0, i=0, rc; |
1332 |
|
|
1333 |
if ((msg != WM_INITDIALOG) |
if ((msg != WM_INITDIALOG) |
1334 |
&& ((kmi = (struct km_info_s*)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
&& ((kmi = (km_info_t)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
1335 |
return FALSE; |
return FALSE; |
1336 |
|
|
1337 |
/* handle dynamic popup items in the keyserver menu. */ |
/* handle dynamic popup items in the keyserver menu. */ |
1357 |
SetWindowText (dlg, _("Key Manager")); |
SetWindowText (dlg, _("Key Manager")); |
1358 |
|
|
1359 |
c = keycache_get_ctx (KEYCACHE_PUB); |
c = keycache_get_ctx (KEYCACHE_PUB); |
|
if (!c) |
|
|
BUG (NULL); |
|
1360 |
kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
1361 |
kmi->keylist_sortby = KEY_SORT_USERID; |
kmi->keylist_sortby = KEY_SORT_USERID; |
1362 |
Header_SetImageList(ListView_GetHeader (kl), glob_imagelist); |
Header_SetImageList(ListView_GetHeader (kl), glob_imagelist); |
1363 |
kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c, |
kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c, |
1364 |
NULL, KEYLIST_LIST, kmi->keylist_sortby); |
NULL, KEYLIST_LIST, kmi->keylist_sortby); |
1365 |
if (check_ultimate_trusted_key ()) { |
if (check_ultimate_trusted_key (keycache_get_ctx (0))) { |
1366 |
msg_box (dlg, _("No ultimately trusted key found.\n" |
msg_box (dlg, _("No ultimately trusted key found.\n" |
1367 |
"Please set at least one secret key to ultimate trust."), |
"Please set at least one secret key to ultimate trust."), |
1368 |
_("Key Manager"), MB_WARN); |
_("Key Manager"), MB_WARN); |
1373 |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
1374 |
keylist_proc.old = (WNDPROC)GetWindowLong(kl, GWL_WNDPROC); |
keylist_proc.old = (WNDPROC)GetWindowLong(kl, GWL_WNDPROC); |
1375 |
if (keylist_proc.old) { |
if (keylist_proc.old) { |
1376 |
if( !SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) { |
if (!SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) { |
1377 |
msg_box (dlg, _("Could not set keylist window procedure."), |
msg_box (dlg, "Could not set keylist window procedure.", |
1378 |
_("Key Manager"), MB_ERR); |
_("Key Manager"), MB_ERR); |
1379 |
BUG (NULL); |
BUG (NULL); |
1380 |
} |
} |
1381 |
} |
} |
1382 |
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
1383 |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
1384 |
kmi->toolbar = load_toolbar (dlg, kmi); |
kmi->toolbar = create_toolbar (dlg, kmi); |
1385 |
kmi->dlg = dlg; |
kmi->dlg = dlg; |
1386 |
|
|
1387 |
do_center_window (dlg, kmi); |
do_center_window (dlg, kmi); |
1388 |
do_resize_window (dlg, kmi); |
do_resize_window (dlg, kmi); |
1389 |
|
restore_window_size (dlg, kmi); |
1390 |
update_ui_items (dlg, kmi->lv); |
update_ui_items (dlg, kmi->lv); |
1391 |
restore_column_info (kmi); |
restore_column_info (kmi); |
1392 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1393 |
|
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1394 |
|
|
1395 |
|
SendMessage (dlg, WM_SETICON, (WPARAM)ICON_SMALL, |
1396 |
|
(LPARAM)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT)); |
1397 |
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups")); |
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups")); |
1398 |
SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, |
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show")); |
1399 |
(LPCTSTR)IDI_WINPT)); |
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New...")); |
1400 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
1401 |
force_foreground_window (dlg, 1000); |
kmi->magic = SetTimer (dlg, 1, 1000, NULL); |
1402 |
return TRUE; |
return TRUE; |
1403 |
|
|
1404 |
|
|
1405 |
|
case WM_TIMER: |
1406 |
|
KillTimer (dlg, kmi->magic); |
1407 |
|
SetForegroundWindow (dlg); |
1408 |
|
break; |
1409 |
|
|
1410 |
case WM_DESTROY: |
case WM_DESTROY: |
1411 |
save_column_info (kmi); |
save_column_info (kmi); |
1419 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type); |
1420 |
ltoa (kmi->pos_y, type, 10); |
ltoa (kmi->pos_y, type, 10); |
1421 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type); |
1422 |
/* XXX: store window size. */ |
|
1423 |
|
GetWindowRect (dlg, &r); |
1424 |
/* Remove runtime information. This should be the last action taken here. */ |
sprintf (type, "%d", (int)(r.bottom-r.top)); |
1425 |
delete kmi; kmi = NULL; |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Width", |
1426 |
|
type); |
1427 |
|
sprintf (type, "%d", (int)(r.right-r.left)); |
1428 |
|
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Height", |
1429 |
|
type); |
1430 |
|
|
1431 |
|
/* Remove runtime information. |
1432 |
|
This should be the last action taken here. */ |
1433 |
|
delete kmi; |
1434 |
|
kmi = NULL; |
1435 |
SetWindowLong (dlg, GWL_USERDATA, 0); |
SetWindowLong (dlg, GWL_USERDATA, 0); |
1436 |
return FALSE; |
return FALSE; |
1437 |
|
|
|
case WM_SHOWWINDOW: |
|
|
break; |
|
|
|
|
1438 |
case WM_MOVE: |
case WM_MOVE: |
|
RECT r; |
|
1439 |
GetWindowRect (dlg, &r); |
GetWindowRect (dlg, &r); |
1440 |
kmi->pos_x = r.left; |
kmi->pos_x = r.left; |
1441 |
kmi->pos_y = r.top; |
kmi->pos_y = r.top; |
1466 |
case TBN_GETBUTTONINFO: |
case TBN_GETBUTTONINFO: |
1467 |
LPTBNOTIFY lpTbNotify; |
LPTBNOTIFY lpTbNotify; |
1468 |
lpTbNotify = (LPTBNOTIFY)lparam; |
lpTbNotify = (LPTBNOTIFY)lparam; |
1469 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
if (lpTbNotify->iItem < (sizeof(tbb) / sizeof(tb_button_s))) { |
1470 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (myb[lpTbNotify->iItem].icon); |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (tbb[lpTbNotify->iItem].icon); |
1471 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
lpTbNotify->tbButton.idCommand = tbb[lpTbNotify->iItem].command; |
1472 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
1473 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
1474 |
lpTbNotify->tbButton.iString = 0; |
lpTbNotify->tbButton.iString = 0; |
1475 |
strncpy (lpTbNotify->pszText, myb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
strncpy (lpTbNotify->pszText, tbb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
1476 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
1477 |
} |
} |
1478 |
return TRUE; |
return TRUE; |
1553 |
break; |
break; |
1554 |
|
|
1555 |
case NM_RCLICK: |
case NM_RCLICK: |
1556 |
|
if (!wait_for_progress_cb (0)) |
1557 |
|
break; |
1558 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1559 |
l_idx =listview_get_curr_pos (kmi->lv); |
l_idx =listview_get_curr_pos (kmi->lv); |
1560 |
if (l_idx == -1) |
if (l_idx == -1) |
1564 |
popup = GetSubMenu (hm, 0); |
popup = GetSubMenu (hm, 0); |
1565 |
translate_popupmenu_strings (popup); |
translate_popupmenu_strings (popup); |
1566 |
|
|
1567 |
if (km_check_for_seckey (kmi->lv, l_idx, &i)) |
if (km_check_for_seckey (kmi->lv, l_idx, &i) && |
1568 |
|
!(km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED)) |
1569 |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
1570 |
if (i == 0) |
if (i == 0) |
1571 |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
1597 |
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED); |
1598 |
if (mapi_init ()) |
if (mapi_init ()) |
1599 |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
1600 |
|
if (!secret_key_available ()) |
1601 |
|
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
1602 |
|
|
1603 |
/* Override 'Default Keyserver' with the actual name. */ |
/* Override 'Default Keyserver' with the actual name. */ |
1604 |
host = kserver_get_hostname (0, -1, &port); |
host = kserver_get_hostname (0, -1, &port); |
1624 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1625 |
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
1626 |
int sortby = 0; |
int sortby = 0; |
1627 |
|
|
1628 |
|
if (!wait_for_progress_cb (0)) |
1629 |
|
break; |
1630 |
switch (nft->iSubItem) { |
switch (nft->iSubItem) { |
1631 |
case 0: sortby = KEY_SORT_USERID; break; |
case 0: sortby = KEY_SORT_USERID; break; |
1632 |
case 1: sortby = KEY_SORT_KEYID; break; |
case 1: sortby = KEY_SORT_KEYID; break; |
1636 |
case 6: sortby = KEY_SORT_OTRUST; break; |
case 6: sortby = KEY_SORT_OTRUST; break; |
1637 |
case 7: sortby = KEY_SORT_CREATED; break; |
case 7: sortby = KEY_SORT_CREATED; break; |
1638 |
case 8: sortby = KEY_SORT_ALGO; break; |
case 8: sortby = KEY_SORT_ALGO; break; |
1639 |
default: return TRUE; //sortby = KEY_SORT_USERID; break; |
default: return TRUE; /*sortby userid.*/ |
1640 |
} |
} |
1641 |
|
|
1642 |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
1644 |
else |
else |
1645 |
kmi->keylist_sortby = sortby; |
kmi->keylist_sortby = sortby; |
1646 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1647 |
|
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1648 |
|
|
1649 |
return TRUE; |
return TRUE; |
1650 |
} |
} |
1651 |
break; |
break; |
1674 |
break; |
break; |
1675 |
|
|
1676 |
case WM_INITMENUPOPUP: |
case WM_INITMENUPOPUP: |
1677 |
if ((UINT)LOWORD (lparam) == 3) { |
hm = (HMENU)wparam; |
1678 |
HMENU h = (HMENU)wparam; |
if ((UINT)LOWORD (lparam) == 3) |
1679 |
set_menu_text_bypos (h, 0, _("New")); |
set_menu_text_bypos (hm, 0, _("New")); |
1680 |
} |
else if ((UINT)LOWORD (lparam) == 1) |
1681 |
/* XXX: before we can use it, we need to find a way to |
set_menu_text_bypos (hm, 8, _("Preferences...")); |
|
update the gpg access timestamp after each operation. |
|
|
if (keyring_check_last_access ()) |
|
|
reload_keylist (kmi); |
|
|
*/ |
|
1682 |
return FALSE; |
return FALSE; |
1683 |
|
|
1684 |
case WM_COMMAND: |
case WM_COMMAND: |
1689 |
return FALSE; |
return FALSE; |
1690 |
} |
} |
1691 |
|
|
1692 |
|
/*wait_for_progress_cb ();*/ |
1693 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
1694 |
case ID_KEYMISC_QUIT: |
case ID_KEYMISC_QUIT: |
1695 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
1755 |
return TRUE; |
return TRUE; |
1756 |
} |
} |
1757 |
km_get_key (kmi->lv, kmi->lv_idx, &k); |
km_get_key (kmi->lv, kmi->lv_idx, &k); |
|
if (!k.key_pair) { |
|
|
msg_box (dlg, _("It does not make any sense with a key pair!"), |
|
|
_("Key Manager"), MB_ERR); |
|
|
return TRUE; |
|
|
} |
|
1758 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
1759 |
keytrust_dlg_proc, (LPARAM)&k, |
keytrust_dlg_proc, (LPARAM)&k, |
1760 |
_("List Trust Path"), IDS_WINPT_KEYTRUST); |
_("List Trust Path"), IDS_WINPT_KEYTRUST); |
1771 |
_("Key Signature List"), IDS_WINPT_KEYSIG); |
_("Key Signature List"), IDS_WINPT_KEYSIG); |
1772 |
if (k.update) |
if (k.update) |
1773 |
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
1774 |
|
if (updated_keys_avail ()) |
1775 |
|
refresh_keylist (kmi); |
1776 |
return TRUE; |
return TRUE; |
1777 |
|
|
1778 |
case ID_KEYMISC_PROPS: |
case ID_KEYMISC_PROPS: |
1853 |
refresh_keylist (kmi); |
refresh_keylist (kmi); |
1854 |
return TRUE; |
return TRUE; |
1855 |
|
|
1856 |
|
case ID_KEYMISC_WINPTPREFS: |
1857 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_PREFS, |
1858 |
|
dlg, prefs_dlg_proc, 0, |
1859 |
|
_("WinPT Preferences"), 0); |
1860 |
|
break; |
1861 |
|
|
1862 |
case ID_KEYMISC_GPGPREFS: |
case ID_KEYMISC_GPGPREFS: |
1863 |
rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, |
rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, |
1864 |
dlg, gpgprefs_dlg_proc, 0, |
dlg, gpgprefs_dlg_proc, 0, |
1944 |
IDS_WINPT_ABOUT); |
IDS_WINPT_ABOUT); |
1945 |
break; |
break; |
1946 |
|
|
1947 |
|
case ID_KEYMISC_DEVWWW: |
1948 |
|
ShellExecute (dlg, "open", "http://wald.intevation.org/projects/winpt", |
1949 |
|
NULL, NULL, SW_SHOW); |
1950 |
|
break; |
1951 |
|
|
1952 |
case ID_KEYMISC_WEBSITE: |
case ID_KEYMISC_WEBSITE: |
1953 |
ShellExecute (dlg, "open", "http://www.winpt.org", |
ShellExecute (dlg, "open", "http://www.winpt.org", |
1954 |
NULL, NULL, SW_SHOW); |
NULL, NULL, SW_SHOW); |
1998 |
_("Key Manager"), MB_INFO); |
_("Key Manager"), MB_INFO); |
1999 |
listview_select_all (kmi->lv); |
listview_select_all (kmi->lv); |
2000 |
} |
} |
2001 |
km_refresh_from_keyserver (kmi->lv, dlg); |
if (!km_refresh_from_keyserver (kmi->lv, dlg)) |
2002 |
|
msg_box (dlg, _("Keyserver refresh finished."), |
2003 |
|
_("Key Manager"), MB_OK); |
2004 |
break; |
break; |
2005 |
|
|
2006 |
/** Context menu **/ |
/** Context menu **/ |
2072 |
break; |
break; |
2073 |
|
|
2074 |
case ID_KEYCTX_UID_COPY: |
case ID_KEYCTX_UID_COPY: |
|
/* XXX: add generic function to support multiple selection |
|
|
with a callback */ |
|
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, &kci); |
|
|
name = kci->uids->name; |
|
|
set_clip_text (NULL, name, strlen (name)); |
|
|
break; |
|
|
|
|
2075 |
case ID_KEYCTX_KEYID_COPY: |
case ID_KEYCTX_KEYID_COPY: |
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
|
|
set_clip_text (NULL, key->subkeys->keyid+8, |
|
|
strlen (key->subkeys->keyid+8)); |
|
|
break; |
|
|
|
|
2076 |
case ID_KEYCTX_FPR_COPY: |
case ID_KEYCTX_FPR_COPY: |
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
|
|
t = key->subkeys->fpr; |
|
|
set_clip_text (NULL, t? t : "", t? strlen (t): 0); |
|
|
break; |
|
|
|
|
2077 |
case ID_KEYCTX_KINFO_COPY: |
case ID_KEYCTX_KINFO_COPY: |
2078 |
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
case ID_KEYCTX_EMAIL_COPY: |
2079 |
km_set_clip_info (key->subkeys->keyid+8); |
copy_key_info (LOWORD (wparam), kmi); |
2080 |
break; |
break; |
2081 |
|
|
2082 |
case ID_KEYCTX_COPY: |
case ID_KEYCTX_COPY: |
2134 |
case ID_GROUP_NEW: |
case ID_GROUP_NEW: |
2135 |
case ID_GROUP_PASTE: |
case ID_GROUP_PASTE: |
2136 |
case ID_GROUP_DELETE: |
case ID_GROUP_DELETE: |
2137 |
|
case ID_GROUP_SHOW: |
2138 |
/* XXX: Implement group manager. */ |
/* XXX: Implement group manager. */ |
2139 |
return TRUE; |
return TRUE; |
|
|
|
|
case IDCANCEL: |
|
|
EndDialog (dlg, TRUE); |
|
|
return TRUE; |
|
2140 |
} |
} |
2141 |
|
|
2142 |
break; |
break; |