155 |
} |
} |
156 |
|
|
157 |
|
|
158 |
|
#define ico2idx(ico) imagelist_getindex((ico)) |
159 |
|
|
160 |
static HWND |
static HWND |
161 |
load_toolbar (HWND dlg, struct km_info_s *kmi) |
load_toolbar (HWND dlg, struct km_info_s *kmi) |
162 |
{ |
{ |
163 |
HWND tbwnd; |
HWND tbwnd; |
164 |
TBSAVEPARAMS tbsp; |
TBSAVEPARAMS tbsp; |
165 |
TBBUTTON tb_buttons[] = { |
TBBUTTON tb_buttons[] = { |
166 |
/*{imagelist_getindex(IMI_EXIT), ID_KEYMISC_QUIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0L, 0},*/ |
{ico2idx (IMI_KEY_NEW), ID_KEYMISC_KEYWIZARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L}, |
167 |
{imagelist_getindex(IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
168 |
{imagelist_getindex(IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
169 |
{imagelist_getindex(IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
170 |
|
{ico2idx (IMI_KEY_SEARCH), ID_KEYMISC_SENDRECV, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
171 |
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
172 |
{imagelist_getindex(IMI_KEY_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{ico2idx (IMI_KEY_FILE_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
173 |
{imagelist_getindex(IMI_KEY_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}, |
174 |
|
{ico2idx (IMI_KEY_IMPORT), ID_KEYCTX_PASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
175 |
|
{ico2idx (IMI_KEY_EXPORT), ID_KEYCTX_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
176 |
}; |
}; |
177 |
|
|
178 |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
631 |
} |
} |
632 |
|
|
633 |
|
|
634 |
#define enable_button(hwnd, cid) \ |
#define enable_button(hwnd, cid, item_selected) \ |
635 |
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG (key_selected, 0)) |
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG ((item_selected), 0)) |
636 |
|
|
637 |
|
|
638 |
/* Interactive modification of the dialog item which depend if an item |
/* Interactive modification of the dialog item which depend if an item |
641 |
void |
void |
642 |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
643 |
{ |
{ |
644 |
HWND hwnd_child; |
HWND tb_hwnd; |
645 |
HMENU hmenu; |
HMENU hmenu; |
646 |
|
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
647 |
|
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
648 |
int key_selected = 0; |
int key_selected = 0; |
649 |
int key_has_sec = 0; |
int key_has_sec = 0; |
650 |
int key_inv = 0; |
int key_inv = 0; |
|
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
|
|
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
|
651 |
int i, state=0; |
int i, state=0; |
652 |
|
|
653 |
/* Get some states */ |
/* Get some states */ |
654 |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
655 |
LVM_GETSELECTEDCOUNT, 0, 0) |
LVM_GETSELECTEDCOUNT, 0, 0) |
663 |
} |
} |
664 |
|
|
665 |
/* Enable / disable toolbar buttons */ |
/* Enable / disable toolbar buttons */ |
666 |
hwnd_child = GetDlgItem (hwnd, IDR_WINPT_KMTB); |
tb_hwnd = GetDlgItem (hwnd, IDR_WINPT_KMTB); |
667 |
enable_button (hwnd_child, ID_KEYMISC_DELETE); |
enable_button (tb_hwnd, ID_KEYMISC_DELETE, key_selected); |
668 |
enable_button (hwnd_child, ID_KEYMISC_PROPS); |
enable_button (tb_hwnd, ID_KEYMISC_PROPS, key_selected); |
669 |
enable_button (hwnd_child, ID_KEYMISC_SIGN); |
enable_button (tb_hwnd, ID_KEYMISC_SIGN, key_selected && !key_inv); |
670 |
enable_button (hwnd_child, ID_KEYMISC_EXPORT); |
enable_button (tb_hwnd, ID_KEYMISC_EXPORT, key_selected); |
671 |
|
enable_button (tb_hwnd, ID_KEYCTX_COPY, key_selected); |
672 |
|
|
673 |
/* Enable / disable menu items */ |
/* Enable / disable menu items */ |
674 |
state = key_selected? MF_ENABLED : MF_DISABLED|MF_GRAYED; |
state = key_selected? MF_ENABLED : MF_DISABLED|MF_GRAYED; |
690 |
for (i=0; mult_resids[i] != 0; i++) |
for (i=0; mult_resids[i] != 0; i++) |
691 |
set_menu_state (hmenu, mult_resids[i], MF_GRAYED); |
set_menu_state (hmenu, mult_resids[i], MF_GRAYED); |
692 |
} |
} |
693 |
|
|
694 |
|
/* Disable all secret-key functions when no secret key is available. */ |
695 |
|
{ |
696 |
|
gpg_keycache_t sec = keycache_get_ctx (0); |
697 |
|
if (gpg_keycache_get_size (sec) == 0) { |
698 |
|
enable_button (tb_hwnd, ID_KEYMISC_SIGN, FALSE); |
699 |
|
set_menu_state (hmenu, ID_KEYMISC_SIGN, MF_GRAYED); |
700 |
|
} |
701 |
|
} |
702 |
} |
} |
703 |
|
|
704 |
|
|
900 |
} |
} |
901 |
|
|
902 |
|
|
903 |
|
/* Helper to handle the help file. If @check is 1 |
904 |
|
the existence of the file is checked. |
905 |
|
Otherwise the help file will be loaded. */ |
906 |
|
static bool |
907 |
|
start_help (HWND dlg, int check) |
908 |
|
{ |
909 |
|
DWORD n; |
910 |
|
char path[MAX_PATH+1+32]; |
911 |
|
|
912 |
|
n = GetModuleFileName (NULL, path, sizeof (path)-1-32); |
913 |
|
if (!n) |
914 |
|
return false; |
915 |
|
path[n] = 0; |
916 |
|
while (n-- && path[n] != '\\') |
917 |
|
; |
918 |
|
path[n+1] = 0; |
919 |
|
strcat (path, "winpt.chm"); |
920 |
|
if (!check) |
921 |
|
ShellExecute (dlg, "open", path, NULL, NULL, SW_SHOW); |
922 |
|
return file_exist_check (path) == 0? true : false; |
923 |
|
} |
924 |
|
|
925 |
/* Translate all menu strings. */ |
/* Translate all menu strings. */ |
926 |
static void |
static void |
927 |
translate_menu_strings (HWND dlg) |
translate_menu_strings (HWND dlg) |
971 |
set_menu_text (menu, ID_KEYMISC_VIEWTYPE, _("Type")); |
set_menu_text (menu, ID_KEYMISC_VIEWTYPE, _("Type")); |
972 |
set_menu_text (menu, ID_KEYMISC_VIEWCREAT, _("Creation")); |
set_menu_text (menu, ID_KEYMISC_VIEWCREAT, _("Creation")); |
973 |
|
|
974 |
/* XXX: implement help code. */ |
if (!start_help (NULL, 1)) |
975 |
set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED); |
set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED); |
976 |
|
|
977 |
SetMenu (dlg, menu); |
SetMenu (dlg, menu); |
978 |
} |
} |
1015 |
} |
} |
1016 |
|
|
1017 |
|
|
1018 |
|
/* Add all recently updated keys in the cache to the list. */ |
1019 |
|
static void |
1020 |
|
refresh_keylist (listview_ctrl_t lv) |
1021 |
|
{ |
1022 |
|
struct keycache_s *ctx; |
1023 |
|
gpg_keycache_t kc; |
1024 |
|
|
1025 |
|
kc = keycache_get_ctx (1); |
1026 |
|
while (!gpg_keycache_next_updated_key (kc, &ctx)) { |
1027 |
|
keylist_add_key (lv, KEYLIST_LIST, ctx->key); |
1028 |
|
/*msg_box (NULL, ctx->key->uids->name, "debug", MB_OK);*/ |
1029 |
|
} |
1030 |
|
keylist_sort (lv, KEY_SORT_USERID); |
1031 |
|
} |
1032 |
|
|
1033 |
|
|
1034 |
/* Dialog box procedure for the Key Manager. */ |
/* Dialog box procedure for the Key Manager. */ |
1035 |
BOOL CALLBACK |
BOOL CALLBACK |
1036 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
1159 |
LPTBNOTIFY lpTbNotify; |
LPTBNOTIFY lpTbNotify; |
1160 |
lpTbNotify = (LPTBNOTIFY)lparam; |
lpTbNotify = (LPTBNOTIFY)lparam; |
1161 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
1162 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex(myb[lpTbNotify->iItem].icon); |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (myb[lpTbNotify->iItem].icon); |
1163 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
1164 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
1165 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
1198 |
|
|
1199 |
lpttt->hinst = NULL; |
lpttt->hinst = NULL; |
1200 |
switch (lpttt->hdr.idFrom) { |
switch (lpttt->hdr.idFrom) { |
1201 |
|
case ID_KEYMISC_KEYWIZARD: |
1202 |
|
lpttt->lpszText = (char*)_("Generate new key pair"); |
1203 |
|
break; |
1204 |
|
|
1205 |
|
case ID_KEYMISC_SENDRECV: |
1206 |
|
lpttt->lpszText = (char*)_("Search for a specific key"); |
1207 |
|
break; |
1208 |
|
|
1209 |
case ID_KEYMISC_DELETE: |
case ID_KEYMISC_DELETE: |
1210 |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
1211 |
break; |
break; |
1218 |
lpttt->lpszText = (char *)_("Sign key"); |
lpttt->lpszText = (char *)_("Sign key"); |
1219 |
break; |
break; |
1220 |
|
|
1221 |
|
case ID_KEYCTX_COPY: |
1222 |
|
lpttt->lpszText = (char *)_("Copy key to clipboard"); |
1223 |
|
break; |
1224 |
|
|
1225 |
|
case ID_KEYCTX_PASTE: |
1226 |
|
lpttt->lpszText = (char*)_("Paste key from clipboard"); |
1227 |
|
break; |
1228 |
|
|
1229 |
case ID_KEYMISC_IMPORT: |
case ID_KEYMISC_IMPORT: |
1230 |
lpttt->lpszText = (char *)_("Import key to keyring"); |
lpttt->lpszText = (char *)_("Import key to keyring"); |
1231 |
break; |
break; |
1259 |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
1260 |
if (i == 0) |
if (i == 0) |
1261 |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
1262 |
if (!km_check_for_seckey (kmi->lv, l_idx, NULL)) { |
if (!km_check_for_seckey (kmi->lv, l_idx, NULL) || |
1263 |
|
(km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED)) { |
1264 |
set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED); |
1265 |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
1266 |
set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED); |
1499 |
case ID_KEYMISC_RECACHE: |
case ID_KEYMISC_RECACHE: |
1500 |
/* If there is already a reload request, |
/* If there is already a reload request, |
1501 |
don't bother the user with a message. */ |
don't bother the user with a message. */ |
1502 |
if (keycache_get_reload() == 1) |
if (keycache_get_reload () == 1) |
1503 |
l_idx = IDYES; |
l_idx = IDYES; |
1504 |
else { |
else { |
1505 |
char inf[256]; |
char inf[256]; |
1570 |
return TRUE; |
return TRUE; |
1571 |
|
|
1572 |
case ID_KEYMISC_SENDRECV: |
case ID_KEYMISC_SENDRECV: |
|
memset (&genkey, 0, sizeof (genkey)); |
|
1573 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
1574 |
keyserver_dlg_proc, (LPARAM)&genkey, _("Keyserver Access"), |
keyserver_dlg_proc, 0, _("Keyserver Access"), |
1575 |
IDS_WINPT_KEYSERVER); |
IDS_WINPT_KEYSERVER); |
1576 |
if (genkey.newkey != NULL) { |
refresh_keylist (kmi->lv); |
|
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
|
|
keylist_sort (kmi->lv, KEY_SORT_USERID); |
|
|
} |
|
1577 |
return TRUE; |
return TRUE; |
1578 |
|
|
1579 |
case ID_KEYMISC_GPGPREFS: |
case ID_KEYMISC_GPGPREFS: |
1660 |
IDS_WINPT_ABOUT); |
IDS_WINPT_ABOUT); |
1661 |
break; |
break; |
1662 |
|
|
1663 |
|
case ID_KEYMISC_WEBSITE: |
1664 |
|
ShellExecute (dlg, "open", "http://www.winpt.org", |
1665 |
|
NULL, NULL, SW_SHOW); |
1666 |
|
break; |
1667 |
|
|
1668 |
case ID_KEYMISC_HELP: |
case ID_KEYMISC_HELP: |
1669 |
ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW); |
start_help (dlg, 0); |
1670 |
break; |
break; |
1671 |
|
|
1672 |
case ID_KEYMISC_OT: |
case ID_KEYMISC_OT: |
1823 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
1824 |
break; |
break; |
1825 |
|
|
1826 |
case ID_KEYCTX_RECVFROM: |
case ID_KEYCTX_RECVFROM: |
1827 |
km_refresh_from_keyserver (kmi->lv, dlg); |
km_refresh_from_keyserver (kmi->lv, dlg); |
1828 |
break; |
break; |
1829 |
|
|
1844 |
|
|
1845 |
case ID_KEYCTX_FPR_COPY: |
case ID_KEYCTX_FPR_COPY: |
1846 |
key = (gpgme_key_t) listview_get_item2 (kmi->lv, kmi->lv_idx); |
key = (gpgme_key_t) listview_get_item2 (kmi->lv, kmi->lv_idx); |
|
//t = get_key_fpr (key); |
|
1847 |
t = key->subkeys->fpr; |
t = key->subkeys->fpr; |
1848 |
set_clip_text (NULL, t? t : "", t? strlen (t): 0); |
set_clip_text (NULL, t? t : "", t? strlen (t): 0); |
1849 |
break; |
break; |
1917 |
case ID_GROUP_DELETE: |
case ID_GROUP_DELETE: |
1918 |
/* XXX: Implement group manager. */ |
/* XXX: Implement group manager. */ |
1919 |
return TRUE; |
return TRUE; |
1920 |
|
|
1921 |
|
case IDCANCEL: |
1922 |
|
EndDialog (dlg, TRUE); |
1923 |
|
return TRUE; |
1924 |
} |
} |
1925 |
|
|
1926 |
break; |
break; |