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; |
525 |
int i; |
int i; |
526 |
|
|
540 |
separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
541 |
{ |
{ |
542 |
static POINT last_mouse_pos; |
static POINT last_mouse_pos; |
543 |
|
PAINTSTRUCT ps; |
544 |
|
RECT rect; |
545 |
|
HPEN hpen; |
546 |
|
|
547 |
if (msg == WM_CREATE) |
if (msg == WM_CREATE) |
548 |
SetWindowLong (hwnd, GWL_USERDATA, |
SetWindowLong (hwnd, GWL_USERDATA, |
550 |
|
|
551 |
switch (msg) { |
switch (msg) { |
552 |
case WM_PAINT: |
case WM_PAINT: |
|
PAINTSTRUCT ps; |
|
|
RECT rect; |
|
|
HPEN hpen; |
|
|
|
|
553 |
GetClientRect (hwnd, &rect); |
GetClientRect (hwnd, &rect); |
554 |
BeginPaint (hwnd, &ps); |
BeginPaint (hwnd, &ps); |
555 |
|
|
557 |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
558 |
|
|
559 |
/* The lines from the light into the dark */ |
/* The lines from the light into the dark */ |
560 |
MoveToEx(ps.hdc, 0,0, NULL); |
MoveToEx (ps.hdc, 0,0, NULL); |
561 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DHILIGHT)); |
562 |
|
if (hpen != NULL) { |
563 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
564 |
LineTo (ps.hdc, rect.right, 0); |
LineTo (ps.hdc, rect.right, 0); |
565 |
DeleteObject (hpen); |
DeleteObject (hpen); |
566 |
} |
} |
567 |
MoveToEx(ps.hdc, 0, 1, NULL); |
MoveToEx (ps.hdc, 0, 1, NULL); |
568 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DLIGHT)); |
569 |
|
if (hpen != NULL) { |
570 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
571 |
LineTo (ps.hdc, rect.right, rect.bottom); |
LineTo (ps.hdc, rect.right, rect.bottom); |
572 |
DeleteObject (hpen); |
DeleteObject (hpen); |
573 |
} |
} |
574 |
|
|
575 |
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL); |
MoveToEx (ps.hdc, 0, rect.bottom-1, NULL); |
576 |
if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) { |
hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW)); |
577 |
|
if (hpen != NULL) { |
578 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
579 |
LineTo (ps.hdc, rect.right, rect.bottom-1); |
LineTo (ps.hdc, rect.right, rect.bottom-1); |
580 |
DeleteObject (hpen); |
DeleteObject (hpen); |
581 |
} |
} |
582 |
MoveToEx(ps.hdc, 0, rect.bottom, NULL); |
MoveToEx (ps.hdc, 0, rect.bottom, NULL); |
583 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) { |
hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW)); |
584 |
|
if (hpen != NULL) { |
585 |
SelectObject (ps.hdc, (LPVOID)hpen); |
SelectObject (ps.hdc, (LPVOID)hpen); |
586 |
LineTo (ps.hdc, rect.right, rect.bottom); |
LineTo (ps.hdc, rect.right, rect.bottom); |
587 |
DeleteObject (hpen); |
DeleteObject (hpen); |
605 |
if (wparam == MK_LBUTTON) { |
if (wparam == MK_LBUTTON) { |
606 |
struct km_info_s *kmi; |
struct km_info_s *kmi; |
607 |
POINT p; |
POINT p; |
|
RECT r; |
|
608 |
|
|
609 |
kmi = (struct km_info_s *)GetWindowLong (hwnd, GWL_USERDATA); |
kmi = (struct km_info_s *)GetWindowLong (hwnd, GWL_USERDATA); |
610 |
if (kmi == NULL) |
if (kmi == NULL) |
611 |
break; |
break; |
612 |
|
|
613 |
/* Calculate mouse movement */ |
/* Calculate mouse movement */ |
614 |
p.x = LOWORD(lparam); |
p.x = LOWORD (lparam); |
615 |
p.y = HIWORD(lparam); |
p.y = HIWORD (lparam); |
616 |
ClientToScreen (hwnd, &p); |
ClientToScreen (hwnd, &p); |
617 |
|
|
618 |
GetWindowRect (hwnd, &r); |
GetWindowRect (hwnd, &rect); |
619 |
r.top += (short)(p.y - last_mouse_pos.y); |
rect.top += (short)(p.y - last_mouse_pos.y); |
620 |
r.bottom += (short)(p.y - last_mouse_pos.y); |
rect.bottom += (short)(p.y - last_mouse_pos.y); |
621 |
|
|
622 |
last_mouse_pos.y = p.y; |
last_mouse_pos.y = p.y; |
623 |
|
|
624 |
/* Apply mouse movement to window. Beware the MoveWindow is relaive |
/* Apply mouse movement to window. Beware the MoveWindow is relaive |
625 |
to parent NOT screen */ |
to parent NOT screen */ |
626 |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&r, 2); |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
627 |
kmi->ypos_sep = r.top; |
kmi->ypos_sep = rect.top; |
628 |
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 */ |
629 |
do_resize_window (GetParent(hwnd), kmi); |
do_resize_window (GetParent (hwnd), kmi); |
630 |
return 0; |
return 0; |
631 |
} |
} |
632 |
} |
} |
642 |
WNDCLASS wndclass; |
WNDCLASS wndclass; |
643 |
HWND h; |
HWND h; |
644 |
|
|
645 |
|
memset (&wndclass, 0, sizeof (wndclass)); |
646 |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
647 |
wndclass.lpfnWndProc = separator_wnd_proc; |
wndclass.lpfnWndProc = separator_wnd_proc; |
648 |
wndclass.cbClsExtra = 0; |
wndclass.cbClsExtra = 0; |
657 |
|
|
658 |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
659 |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
660 |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
661 |
|
if (!h) |
662 |
|
BUG (NULL); |
663 |
ShowWindow (h, SW_SHOW); |
ShowWindow (h, SW_SHOW); |
664 |
return h; |
return h; |
665 |
} |
} |
679 |
HMENU hmenu; |
HMENU hmenu; |
680 |
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
681 |
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
682 |
int key_selected = 0; |
int key_selected; |
683 |
int key_has_sec = 0; |
int key_has_sec; |
684 |
int key_inv = 0; |
int key_inv = 0; |
685 |
int i, state=0; |
int i, state=0; |
686 |
|
|
727 |
} |
} |
728 |
|
|
729 |
/* Disable all secret-key functions when no secret key is available. */ |
/* Disable all secret-key functions when no secret key is available. */ |
730 |
{ |
if (!secret_key_available ()) { |
731 |
gpg_keycache_t sec = keycache_get_ctx (0); |
enable_button (tb_hwnd, ID_KEYMISC_SIGN, FALSE); |
732 |
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); |
|
|
} |
|
733 |
} |
} |
734 |
} |
} |
735 |
|
|
881 |
for (i=1; i <= 3; i++) |
for (i=1; i <= 3; i++) |
882 |
partpos[i-1] = r.right/3*i; |
partpos[i-1] = r.right/3*i; |
883 |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
884 |
"status bar", dlg, KM_SEPARATOR_ID); |
"WinPT_Status_Bar", dlg, KM_SEPARATOR_ID); |
885 |
|
if (!statbar) |
886 |
|
BUG (NULL); |
887 |
ShowWindow (statbar, SW_SHOW); |
ShowWindow (statbar, SW_SHOW); |
888 |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
889 |
|
|
890 |
update_default_key_str (statbar); |
update_default_key_str (statbar); |
891 |
update_status_bar (statbar, lv); |
update_status_bar (statbar, lv); |
|
|
|
892 |
return statbar; |
return statbar; |
893 |
} |
} |
894 |
|
|
958 |
return file_exist_check (path) == 0? true : false; |
return file_exist_check (path) == 0? true : false; |
959 |
} |
} |
960 |
|
|
961 |
|
|
962 |
/* Translate all menu strings. */ |
/* Translate all menu strings. */ |
963 |
static void |
static void |
964 |
translate_menu_strings (HWND dlg) |
translate_menu_strings (HWND dlg) |
1023 |
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")); |
1024 |
set_menu_text (popup, ID_KEYCTX_FPR_COPY, _("Copy Fingerprint to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_FPR_COPY, _("Copy Fingerprint to Clipboard")); |
1025 |
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")); |
1026 |
|
set_menu_text (popup, ID_KEYCTX_EMAIL_COPY, _("Copy E-Mail to Clipboard")); |
1027 |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
1028 |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
1029 |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
1072 |
static int |
static int |
1073 |
find_keypos (listview_ctrl_t lv, gpgme_key_t key) |
find_keypos (listview_ctrl_t lv, gpgme_key_t key) |
1074 |
{ |
{ |
1075 |
char keyid[16+1]; |
char keyid[32+1]; |
1076 |
int i; |
int i; |
1077 |
|
|
1078 |
for (i=0; i < listview_count_items (lv, 0); i++) { |
for (i=0; i < listview_count_items (lv, 0); i++) { |
1103 |
keylist_upd_key (kmi->lv, pos, ctx, ctx->key); |
keylist_upd_key (kmi->lv, pos, ctx, ctx->key); |
1104 |
} |
} |
1105 |
} |
} |
1106 |
keylist_sort (kmi->lv, KEY_SORT_USERID); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1107 |
update_status_bar (kmi->statbar, kmi->lv); |
update_status_bar (kmi->statbar, kmi->lv); |
1108 |
keyring_check_last_access (); |
keyring_check_last_access (); |
1109 |
} |
} |
1110 |
|
|
1111 |
|
|
1112 |
|
/* Reload the key cache. */ |
1113 |
|
static void |
1114 |
|
keycache_reload (HWND dlg) |
1115 |
|
{ |
1116 |
|
refresh_cache_s rcs; |
1117 |
|
|
1118 |
|
memset (&rcs, 0, sizeof rcs); |
1119 |
|
rcs.kr_reload = rcs.kr_update = 1; |
1120 |
|
rcs.tr_update = 0; |
1121 |
|
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
1122 |
|
keycache_dlg_proc, (LPARAM)&rcs); |
1123 |
|
} |
1124 |
|
|
1125 |
|
|
1126 |
|
/* Check if the secret keyring contains at least one |
1127 |
|
key with ultimate trust. |
1128 |
|
Return value: 0 on success. */ |
1129 |
|
int |
1130 |
|
check_ultimate_trusted_key (gpg_keycache_t _sec) |
1131 |
|
{ |
1132 |
|
struct keycache_s *n; |
1133 |
|
int nkeys = 0; |
1134 |
|
|
1135 |
|
for (n = _sec->item; n; n = n->next) { |
1136 |
|
if (n->pubpart && |
1137 |
|
n->pubpart->key->owner_trust == GPGME_VALIDITY_ULTIMATE) |
1138 |
|
return 0; |
1139 |
|
nkeys++; |
1140 |
|
} |
1141 |
|
|
1142 |
|
/* if we do not have any secret keys, it does not make sense |
1143 |
|
to return an error. */ |
1144 |
|
if (nkeys == 0) |
1145 |
|
return 0; |
1146 |
|
return -1; |
1147 |
|
} |
1148 |
|
|
1149 |
|
|
1150 |
static void |
static void |
1151 |
reload_keylist (struct km_info_s *kmi) |
reload_keylist (struct km_info_s *kmi) |
1152 |
{ |
{ |
1153 |
|
gpg_keycache_t c; |
1154 |
|
|
1155 |
|
c = keycache_get_ctx (1); |
1156 |
keycache_reload (kmi->dlg); |
keycache_reload (kmi->dlg); |
1157 |
keylist_reload (kmi->lv, keycache_get_ctx (1), |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
|
KEYLIST_LIST, KEY_SORT_USERID); |
|
1158 |
update_status_bar (kmi->statbar, kmi->lv); |
update_status_bar (kmi->statbar, kmi->lv); |
1159 |
keyring_check_last_access (); |
keyring_check_last_access (); |
1160 |
} |
} |
1172 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, kmi->dlg, |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, kmi->dlg, |
1173 |
keycache_dlg_proc, (LPARAM)&rcs); |
keycache_dlg_proc, (LPARAM)&rcs); |
1174 |
c = keycache_get_ctx (1); |
c = keycache_get_ctx (1); |
1175 |
if (!c) |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
|
BUG (0); |
|
|
keylist_reload (kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID); |
|
1176 |
update_status_bar (kmi->statbar, kmi->lv); |
update_status_bar (kmi->statbar, kmi->lv); |
1177 |
SetForegroundWindow (kmi->dlg); |
SetForegroundWindow (kmi->dlg); |
1178 |
} |
} |
1210 |
reload_keylist (kmi); |
reload_keylist (kmi); |
1211 |
|
|
1212 |
SetForegroundWindow (kmi->dlg); |
SetForegroundWindow (kmi->dlg); |
1213 |
center_window (kmi->dlg, NULL); |
} |
1214 |
|
|
1215 |
|
|
1216 |
|
/* Copy the requested key information (@what) to the clipboard. |
1217 |
|
If multiple items were selected, each key info is copied to |
1218 |
|
the clipboard. The data is separated by \r\n. */ |
1219 |
|
static void |
1220 |
|
copy_key_info (int what, struct km_info_s *kmi) |
1221 |
|
{ |
1222 |
|
gpgme_data_t out; |
1223 |
|
gpgme_key_t key; |
1224 |
|
struct keycache_s *kci = NULL; |
1225 |
|
size_t n=0; |
1226 |
|
char *p, tmp[256]; |
1227 |
|
int i=0, end = listview_count_items (kmi->lv, 0); |
1228 |
|
bool single = false; |
1229 |
|
|
1230 |
|
/* Do not iterate over the entire list if just one item is selected. */ |
1231 |
|
n = listview_count_items (kmi->lv, 1); |
1232 |
|
if (n == 1) { |
1233 |
|
i = kmi->lv_idx; |
1234 |
|
end = i+1; |
1235 |
|
single = true; |
1236 |
|
} |
1237 |
|
|
1238 |
|
gpgme_data_new (&out); |
1239 |
|
for (; i < end; i++) { |
1240 |
|
if (!listview_get_item_state (kmi->lv, i)) |
1241 |
|
continue; |
1242 |
|
switch (what) { |
1243 |
|
|
1244 |
|
case ID_KEYCTX_EMAIL_COPY: |
1245 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1246 |
|
gpgme_data_write (out, key->uids->email, strlen (key->uids->email)); |
1247 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1248 |
|
break; |
1249 |
|
|
1250 |
|
case ID_KEYCTX_UID_COPY: |
1251 |
|
key = km_get_key_ptr (kmi->lv, i, &kci); |
1252 |
|
gpgme_data_write (out, kci->uids->uid, strlen (kci->uids->uid)); |
1253 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1254 |
|
break; |
1255 |
|
|
1256 |
|
case ID_KEYCTX_KEYID_COPY: |
1257 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1258 |
|
gpgme_data_write (out, "0x", 2); |
1259 |
|
gpgme_data_write (out, key->subkeys->keyid+8, 8); |
1260 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1261 |
|
break; |
1262 |
|
|
1263 |
|
case ID_KEYCTX_FPR_COPY: |
1264 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1265 |
|
gpgme_data_write (out, key->subkeys->fpr, strlen (key->subkeys->fpr)); |
1266 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1267 |
|
break; |
1268 |
|
|
1269 |
|
case ID_KEYCTX_KINFO_COPY: |
1270 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1271 |
|
key_get_clip_info (key->subkeys->keyid+8, tmp, sizeof (tmp)-1); |
1272 |
|
gpgme_data_write (out, tmp, strlen (tmp)); |
1273 |
|
if (!single) gpgme_data_write (out, "\r\n", 2); |
1274 |
|
break; |
1275 |
|
} |
1276 |
|
} |
1277 |
|
gpgme_data_write (out, "\0", 1); |
1278 |
|
p = gpgme_data_release_and_get_mem (out, &n); |
1279 |
|
set_clip_text (NULL, p, n); |
1280 |
|
gpgme_free (p); |
1281 |
} |
} |
1282 |
|
|
1283 |
|
|
1285 |
BOOL CALLBACK |
BOOL CALLBACK |
1286 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
1287 |
{ |
{ |
|
struct km_info_s *kmi = NULL; |
|
1288 |
HWND kl; |
HWND kl; |
1289 |
HMENU hm; |
HMENU hm; |
1290 |
struct keycache_s *kci; |
RECT r; |
1291 |
gpg_keycache_t c; |
gpg_keycache_t c; |
1292 |
gpgme_key_t key; |
gpgme_key_t key; |
1293 |
|
km_info_t kmi = NULL; |
1294 |
struct genkey_s genkey; |
struct genkey_s genkey; |
1295 |
struct winpt_key_s k = {0}; |
struct winpt_key_s k = {0}; |
1296 |
struct URL_ctx_s *url; |
struct URL_ctx_s *url; |
1300 |
int l_idx = 0, i=0, rc; |
int l_idx = 0, i=0, rc; |
1301 |
|
|
1302 |
if ((msg != WM_INITDIALOG) |
if ((msg != WM_INITDIALOG) |
1303 |
&& ((kmi = (struct km_info_s*)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
&& ((kmi = (km_info_t)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
1304 |
return FALSE; |
return FALSE; |
1305 |
|
|
1306 |
/* handle dynamic popup items in the keyserver menu. */ |
/* handle dynamic popup items in the keyserver menu. */ |
1326 |
SetWindowText (dlg, _("Key Manager")); |
SetWindowText (dlg, _("Key Manager")); |
1327 |
|
|
1328 |
c = keycache_get_ctx (KEYCACHE_PUB); |
c = keycache_get_ctx (KEYCACHE_PUB); |
|
if (!c) |
|
|
BUG (NULL); |
|
1329 |
kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
1330 |
kmi->keylist_sortby = KEY_SORT_USERID; |
kmi->keylist_sortby = KEY_SORT_USERID; |
1331 |
Header_SetImageList(ListView_GetHeader (kl), glob_imagelist); |
Header_SetImageList(ListView_GetHeader (kl), glob_imagelist); |
1332 |
kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c, |
kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c, |
1333 |
NULL, KEYLIST_LIST, kmi->keylist_sortby); |
NULL, KEYLIST_LIST, kmi->keylist_sortby); |
1334 |
if (check_ultimate_trusted_key ()) { |
if (check_ultimate_trusted_key (keycache_get_ctx (0))) { |
1335 |
msg_box (dlg, _("No ultimately trusted key found.\n" |
msg_box (dlg, _("No ultimately trusted key found.\n" |
1336 |
"Please set at least one secret key to ultimate trust."), |
"Please set at least one secret key to ultimate trust."), |
1337 |
_("Key Manager"), MB_WARN); |
_("Key Manager"), MB_WARN); |
1342 |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
1343 |
keylist_proc.old = (WNDPROC)GetWindowLong(kl, GWL_WNDPROC); |
keylist_proc.old = (WNDPROC)GetWindowLong(kl, GWL_WNDPROC); |
1344 |
if (keylist_proc.old) { |
if (keylist_proc.old) { |
1345 |
if( !SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) { |
if (!SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) { |
1346 |
msg_box (dlg, _("Could not set keylist window procedure."), |
msg_box (dlg, "Could not set keylist window procedure.", |
1347 |
_("Key Manager"), MB_ERR); |
_("Key Manager"), MB_ERR); |
1348 |
BUG (NULL); |
BUG (NULL); |
1349 |
} |
} |
1350 |
} |
} |
1351 |
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
1352 |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
1353 |
kmi->toolbar = load_toolbar (dlg, kmi); |
kmi->toolbar = create_toolbar (dlg, kmi); |
1354 |
kmi->dlg = dlg; |
kmi->dlg = dlg; |
1355 |
|
|
1356 |
do_center_window (dlg, kmi); |
do_center_window (dlg, kmi); |
1357 |
do_resize_window (dlg, kmi); |
do_resize_window (dlg, kmi); |
1358 |
|
restore_window_size (dlg, kmi); |
1359 |
update_ui_items (dlg, kmi->lv); |
update_ui_items (dlg, kmi->lv); |
1360 |
restore_column_info (kmi); |
restore_column_info (kmi); |
1361 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1362 |
|
|
1363 |
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups")); |
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups")); |
1364 |
|
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show")); |
1365 |
|
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New...")); |
1366 |
SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, |
SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, |
1367 |
(LPCTSTR)IDI_WINPT)); |
(LPCTSTR)IDI_WINPT)); |
1368 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
1369 |
force_foreground_window (dlg, 1000); |
kmi->magic = SetTimer (dlg, 1, 1000, NULL); |
1370 |
return TRUE; |
return TRUE; |
1371 |
|
|
1372 |
|
case WM_TIMER: |
1373 |
|
KillTimer (dlg, kmi->magic); |
1374 |
|
SetForegroundWindow (dlg); |
1375 |
|
break; |
1376 |
|
|
1377 |
case WM_DESTROY: |
case WM_DESTROY: |
1378 |
save_column_info (kmi); |
save_column_info (kmi); |
1386 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type); |
1387 |
ltoa (kmi->pos_y, type, 10); |
ltoa (kmi->pos_y, type, 10); |
1388 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type); |
1389 |
/* XXX: store window size. */ |
|
1390 |
|
GetWindowRect (dlg, &r); |
1391 |
/* Remove runtime information. This should be the last action taken here. */ |
sprintf (type, "%d", (int)(r.bottom-r.top)); |
1392 |
delete kmi; kmi = NULL; |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Width", |
1393 |
|
type); |
1394 |
|
sprintf (type, "%d", (int)(r.right-r.left)); |
1395 |
|
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Height", |
1396 |
|
type); |
1397 |
|
|
1398 |
|
/* Remove runtime information. |
1399 |
|
This should be the last action taken here. */ |
1400 |
|
delete kmi; |
1401 |
|
kmi = NULL; |
1402 |
SetWindowLong (dlg, GWL_USERDATA, 0); |
SetWindowLong (dlg, GWL_USERDATA, 0); |
1403 |
return FALSE; |
return FALSE; |
1404 |
|
|
|
case WM_SHOWWINDOW: |
|
|
break; |
|
|
|
|
1405 |
case WM_MOVE: |
case WM_MOVE: |
|
RECT r; |
|
1406 |
GetWindowRect (dlg, &r); |
GetWindowRect (dlg, &r); |
1407 |
kmi->pos_x = r.left; |
kmi->pos_x = r.left; |
1408 |
kmi->pos_y = r.top; |
kmi->pos_y = r.top; |
1433 |
case TBN_GETBUTTONINFO: |
case TBN_GETBUTTONINFO: |
1434 |
LPTBNOTIFY lpTbNotify; |
LPTBNOTIFY lpTbNotify; |
1435 |
lpTbNotify = (LPTBNOTIFY)lparam; |
lpTbNotify = (LPTBNOTIFY)lparam; |
1436 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
if (lpTbNotify->iItem < (sizeof(tbb) / sizeof(tb_button_s))) { |
1437 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (myb[lpTbNotify->iItem].icon); |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (tbb[lpTbNotify->iItem].icon); |
1438 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
lpTbNotify->tbButton.idCommand = tbb[lpTbNotify->iItem].command; |
1439 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
1440 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
1441 |
lpTbNotify->tbButton.iString = 0; |
lpTbNotify->tbButton.iString = 0; |
1442 |
strncpy (lpTbNotify->pszText, myb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
strncpy (lpTbNotify->pszText, tbb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
1443 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
1444 |
} |
} |
1445 |
return TRUE; |
return TRUE; |
1520 |
break; |
break; |
1521 |
|
|
1522 |
case NM_RCLICK: |
case NM_RCLICK: |
1523 |
|
if (!wait_for_progress_cb (0)) |
1524 |
|
break; |
1525 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1526 |
l_idx =listview_get_curr_pos (kmi->lv); |
l_idx =listview_get_curr_pos (kmi->lv); |
1527 |
if (l_idx == -1) |
if (l_idx == -1) |
1563 |
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED); |
1564 |
if (mapi_init ()) |
if (mapi_init ()) |
1565 |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
1566 |
|
if (!secret_key_available ()) |
1567 |
|
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
1568 |
|
|
1569 |
/* Override 'Default Keyserver' with the actual name. */ |
/* Override 'Default Keyserver' with the actual name. */ |
1570 |
host = kserver_get_hostname (0, -1, &port); |
host = kserver_get_hostname (0, -1, &port); |
1590 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1591 |
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
1592 |
int sortby = 0; |
int sortby = 0; |
1593 |
|
|
1594 |
|
if (!wait_for_progress_cb (0)) |
1595 |
|
break; |
1596 |
switch (nft->iSubItem) { |
switch (nft->iSubItem) { |
1597 |
case 0: sortby = KEY_SORT_USERID; break; |
case 0: sortby = KEY_SORT_USERID; break; |
1598 |
case 1: sortby = KEY_SORT_KEYID; break; |
case 1: sortby = KEY_SORT_KEYID; break; |
1602 |
case 6: sortby = KEY_SORT_OTRUST; break; |
case 6: sortby = KEY_SORT_OTRUST; break; |
1603 |
case 7: sortby = KEY_SORT_CREATED; break; |
case 7: sortby = KEY_SORT_CREATED; break; |
1604 |
case 8: sortby = KEY_SORT_ALGO; break; |
case 8: sortby = KEY_SORT_ALGO; break; |
1605 |
default: return TRUE; //sortby = KEY_SORT_USERID; break; |
default: return TRUE; /*sortby userid.*/ |
1606 |
} |
} |
1607 |
|
|
1608 |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
1657 |
return FALSE; |
return FALSE; |
1658 |
} |
} |
1659 |
|
|
1660 |
|
/*wait_for_progress_cb ();*/ |
1661 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
1662 |
case ID_KEYMISC_QUIT: |
case ID_KEYMISC_QUIT: |
1663 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
1723 |
return TRUE; |
return TRUE; |
1724 |
} |
} |
1725 |
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; |
|
|
} |
|
1726 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
1727 |
keytrust_dlg_proc, (LPARAM)&k, |
keytrust_dlg_proc, (LPARAM)&k, |
1728 |
_("List Trust Path"), IDS_WINPT_KEYTRUST); |
_("List Trust Path"), IDS_WINPT_KEYTRUST); |
1739 |
_("Key Signature List"), IDS_WINPT_KEYSIG); |
_("Key Signature List"), IDS_WINPT_KEYSIG); |
1740 |
if (k.update) |
if (k.update) |
1741 |
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
1742 |
|
if (updated_keys_avail ()) |
1743 |
|
refresh_keylist (kmi); |
1744 |
return TRUE; |
return TRUE; |
1745 |
|
|
1746 |
case ID_KEYMISC_PROPS: |
case ID_KEYMISC_PROPS: |
1955 |
_("Key Manager"), MB_INFO); |
_("Key Manager"), MB_INFO); |
1956 |
listview_select_all (kmi->lv); |
listview_select_all (kmi->lv); |
1957 |
} |
} |
1958 |
km_refresh_from_keyserver (kmi->lv, dlg); |
if (!km_refresh_from_keyserver (kmi->lv, dlg)) |
1959 |
|
msg_box (dlg, _("Keyserver refresh finished."), |
1960 |
|
_("Key Manager"), MB_OK); |
1961 |
break; |
break; |
1962 |
|
|
1963 |
/** Context menu **/ |
/** Context menu **/ |
2029 |
break; |
break; |
2030 |
|
|
2031 |
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; |
|
|
|
|
2032 |
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; |
|
|
|
|
2033 |
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; |
|
|
|
|
2034 |
case ID_KEYCTX_KINFO_COPY: |
case ID_KEYCTX_KINFO_COPY: |
2035 |
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
case ID_KEYCTX_EMAIL_COPY: |
2036 |
km_set_clip_info (key->subkeys->keyid+8); |
copy_key_info (LOWORD (wparam), kmi); |
2037 |
break; |
break; |
2038 |
|
|
2039 |
case ID_KEYCTX_COPY: |
case ID_KEYCTX_COPY: |
2091 |
case ID_GROUP_NEW: |
case ID_GROUP_NEW: |
2092 |
case ID_GROUP_PASTE: |
case ID_GROUP_PASTE: |
2093 |
case ID_GROUP_DELETE: |
case ID_GROUP_DELETE: |
2094 |
|
case ID_GROUP_SHOW: |
2095 |
/* XXX: Implement group manager. */ |
/* XXX: Implement group manager. */ |
2096 |
return TRUE; |
return TRUE; |
|
|
|
|
case IDCANCEL: |
|
|
EndDialog (dlg, TRUE); |
|
|
return TRUE; |
|
2097 |
} |
} |
2098 |
|
|
2099 |
break; |
break; |