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 |
|
|
1019 |
/* Dialog box procedure for the Key Manager. */ |
/* Dialog box procedure for the Key Manager. */ |
1020 |
BOOL CALLBACK |
BOOL CALLBACK |
1021 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
1144 |
LPTBNOTIFY lpTbNotify; |
LPTBNOTIFY lpTbNotify; |
1145 |
lpTbNotify = (LPTBNOTIFY)lparam; |
lpTbNotify = (LPTBNOTIFY)lparam; |
1146 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
1147 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex(myb[lpTbNotify->iItem].icon); |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (myb[lpTbNotify->iItem].icon); |
1148 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
1149 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
1150 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
1183 |
|
|
1184 |
lpttt->hinst = NULL; |
lpttt->hinst = NULL; |
1185 |
switch (lpttt->hdr.idFrom) { |
switch (lpttt->hdr.idFrom) { |
1186 |
|
case ID_KEYMISC_KEYWIZARD: |
1187 |
|
lpttt->lpszText = (char*)_("Generate new key pair"); |
1188 |
|
break; |
1189 |
|
|
1190 |
|
case ID_KEYMISC_SENDRECV: |
1191 |
|
lpttt->lpszText = (char*)_("Search for a specific key"); |
1192 |
|
break; |
1193 |
|
|
1194 |
case ID_KEYMISC_DELETE: |
case ID_KEYMISC_DELETE: |
1195 |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
1196 |
break; |
break; |
1203 |
lpttt->lpszText = (char *)_("Sign key"); |
lpttt->lpszText = (char *)_("Sign key"); |
1204 |
break; |
break; |
1205 |
|
|
1206 |
|
case ID_KEYCTX_COPY: |
1207 |
|
lpttt->lpszText = (char *)_("Copy key to clipboard"); |
1208 |
|
break; |
1209 |
|
|
1210 |
|
case ID_KEYCTX_PASTE: |
1211 |
|
lpttt->lpszText = (char*)_("Paste key from clipboard"); |
1212 |
|
break; |
1213 |
|
|
1214 |
case ID_KEYMISC_IMPORT: |
case ID_KEYMISC_IMPORT: |
1215 |
lpttt->lpszText = (char *)_("Import key to keyring"); |
lpttt->lpszText = (char *)_("Import key to keyring"); |
1216 |
break; |
break; |
1244 |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
1245 |
if (i == 0) |
if (i == 0) |
1246 |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
1247 |
if (!km_check_for_seckey (kmi->lv, l_idx, NULL)) { |
if (!km_check_for_seckey (kmi->lv, l_idx, NULL) || |
1248 |
|
(km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED)) { |
1249 |
set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED); |
1250 |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
1251 |
set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED); |
set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED); |
1484 |
case ID_KEYMISC_RECACHE: |
case ID_KEYMISC_RECACHE: |
1485 |
/* If there is already a reload request, |
/* If there is already a reload request, |
1486 |
don't bother the user with a message. */ |
don't bother the user with a message. */ |
1487 |
if (keycache_get_reload() == 1) |
if (keycache_get_reload () == 1) |
1488 |
l_idx = IDYES; |
l_idx = IDYES; |
1489 |
else { |
else { |
1490 |
char inf[256]; |
char inf[256]; |
1649 |
IDS_WINPT_ABOUT); |
IDS_WINPT_ABOUT); |
1650 |
break; |
break; |
1651 |
|
|
1652 |
|
case ID_KEYMISC_WEBSITE: |
1653 |
|
ShellExecute (dlg, "open", "http://www.winpt.org", |
1654 |
|
NULL, NULL, SW_SHOW); |
1655 |
|
break; |
1656 |
|
|
1657 |
case ID_KEYMISC_HELP: |
case ID_KEYMISC_HELP: |
1658 |
ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW); |
start_help (dlg, 0); |
1659 |
break; |
break; |
1660 |
|
|
1661 |
case ID_KEYMISC_OT: |
case ID_KEYMISC_OT: |
1812 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
1813 |
break; |
break; |
1814 |
|
|
1815 |
case ID_KEYCTX_RECVFROM: |
case ID_KEYCTX_RECVFROM: |
1816 |
km_refresh_from_keyserver (kmi->lv, dlg); |
km_refresh_from_keyserver (kmi->lv, dlg); |
1817 |
break; |
break; |
1818 |
|
|
1833 |
|
|
1834 |
case ID_KEYCTX_FPR_COPY: |
case ID_KEYCTX_FPR_COPY: |
1835 |
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); |
|
1836 |
t = key->subkeys->fpr; |
t = key->subkeys->fpr; |
1837 |
set_clip_text (NULL, t? t : "", t? strlen (t): 0); |
set_clip_text (NULL, t? t : "", t? strlen (t): 0); |
1838 |
break; |
break; |
1906 |
case ID_GROUP_DELETE: |
case ID_GROUP_DELETE: |
1907 |
/* XXX: Implement group manager. */ |
/* XXX: Implement group manager. */ |
1908 |
return TRUE; |
return TRUE; |
1909 |
|
|
1910 |
|
case IDCANCEL: |
1911 |
|
EndDialog (dlg, TRUE); |
1912 |
|
return TRUE; |
1913 |
} |
} |
1914 |
|
|
1915 |
break; |
break; |