522 |
char txt_sec[128]; |
char txt_sec[128]; |
523 |
char txt_pub[128]; |
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); |
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")); |
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) |
1151 |
} |
} |
1152 |
} |
} |
1153 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
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 |
|
|
1165 |
refresh_cache_s rcs; |
refresh_cache_s rcs; |
1166 |
|
|
1167 |
memset (&rcs, 0, sizeof rcs); |
memset (&rcs, 0, sizeof rcs); |
1168 |
rcs.kr_reload = rcs.kr_update = 1; |
rcs.kring_update = 1; |
|
rcs.tr_update = 0; |
|
1169 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
1170 |
keycache_dlg_proc, (LPARAM)&rcs); |
keycache_dlg_proc, (LPARAM)&rcs); |
1171 |
} |
} |
1195 |
} |
} |
1196 |
|
|
1197 |
|
|
|
static void |
|
|
reload_keylist (struct km_info_s *kmi) |
|
|
{ |
|
|
gpg_keycache_t c; |
|
|
|
|
|
c = keycache_get_ctx (1); |
|
|
keycache_reload (kmi->dlg); |
|
|
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
|
|
update_status_bar (kmi->statbar, kmi->lv); |
|
|
keyring_check_last_access (); |
|
|
} |
|
|
|
|
|
|
|
1198 |
/* Reload the entire key cache and update the listview. */ |
/* Reload the entire key cache and update the listview. */ |
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 |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
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 |
} |
} |
1245 |
|
|
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 |
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show")); |
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show")); |
1399 |
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New...")); |
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New...")); |
|
SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, |
|
|
(LPCTSTR)IDI_WINPT)); |
|
1400 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
1401 |
kmi->magic = SetTimer (dlg, 1, 1000, NULL); |
kmi->magic = SetTimer (dlg, 1, 1000, NULL); |
1402 |
return TRUE; |
return TRUE; |
1403 |
|
|
1404 |
|
|
1405 |
case WM_TIMER: |
case WM_TIMER: |
1406 |
KillTimer (dlg, kmi->magic); |
KillTimer (dlg, kmi->magic); |
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); |
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: |
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); |