1 |
/* wptKeyManagerDlg.cpp - WinPT Key Manager |
/* wptKeyManagerDlg.cpp - WinPT Key Manager |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* Copyright (C) 2004 Andreas Jobs |
* Copyright (C) 2004 Andreas Jobs |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
6 |
* |
* |
7 |
* WinPT is free software; you can redistribute it and/or modify |
* WinPT is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
* (at your option) any later version. |
11 |
* |
* |
12 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
16 |
* |
* |
17 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
20 |
*/ |
*/ |
21 |
|
#ifdef HAVE_CONFIG_H |
22 |
#include <windows.h> |
#include <config.h> |
23 |
#include <commctrl.h> |
#endif |
24 |
|
|
25 |
#include "../resource.h" |
#include <windows.h> |
26 |
#include "wptTypes.h" |
#include <commctrl.h> |
27 |
#include "wptGPG.h" |
|
28 |
#include "wptCommonCtl.h" |
#include "resource.h" |
29 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptTypes.h" |
30 |
#include "wptDlgs.h" |
#include "wptGPG.h" |
31 |
#include "wptW32API.h" |
#include "wptCommonCtl.h" |
32 |
#include "wptVersion.h" |
#include "wptContext.h" /* for passphrase_s */ |
33 |
#include "wptKeylist.h" |
#include "wptDlgs.h" |
34 |
#include "wptNLS.h" |
#include "wptW32API.h" |
35 |
#include "wptErrors.h" |
#include "wptVersion.h" |
36 |
#include "wptHotkey.h" |
#include "wptKeylist.h" |
37 |
#include "wptKeyManager.h" |
#include "wptNLS.h" |
38 |
#include "wptKeyserver.h" |
#include "wptErrors.h" |
39 |
#include "wptKeyEdit.h" |
#include "wptHotkey.h" |
40 |
#include "wptRegistry.h" |
#include "wptKeyManager.h" |
41 |
|
#include "wptKeyserver.h" |
42 |
|
#include "wptKeyEdit.h" |
43 |
#define WINDOWCLASS_SEPARATOR_CHILD "WINPT_SEP_CHILD" |
#include "wptRegistry.h" |
44 |
#define SEPARATOR_HEIGHT 5 |
#include "wptUTF8.h" |
45 |
|
|
46 |
void km_dump_key (gpgme_key_t key); |
/* Name and ID of the separator window. */ |
47 |
|
#define KM_SEPARATOR_ID 10000 |
48 |
|
#define WINDOWCLASS_SEPARATOR_CHILD "WINPT_SEP_CHILD" |
49 |
static subclass_s keylist_proc; |
|
50 |
static int km_index = -1; |
/* Virtual key codes. */ |
51 |
|
#ifndef VK_F |
52 |
HIMAGELIST glob_imagelist; |
#define VK_F 70 |
53 |
|
#endif |
54 |
struct km_info { |
#ifndef VK_A |
55 |
/* Window positions */ |
#define VK_A 65 |
56 |
int pos_x, pos_y; |
#endif |
57 |
int ypos_sep; |
#ifndef VK_C |
58 |
int ypercent_sep; |
#define VK_C 67 |
59 |
|
#endif |
60 |
HWND hwnd_sep; |
#ifndef VK_P |
61 |
HWND toolbar; |
#define VK_P 80 |
62 |
HWND statbar; |
#endif |
63 |
|
|
64 |
listview_ctrl_t lv; |
static subclass_s keylist_proc; |
65 |
int keylist_sortby; |
|
66 |
}; |
/* Handle to the global image list. */ |
67 |
|
HIMAGELIST glob_imagelist; |
68 |
struct mybuttons { |
|
69 |
long icon; |
struct km_info_s { |
70 |
long command; |
/* Window positions */ |
71 |
char *text; |
int pos_x, pos_y; |
72 |
}; |
int ypos_sep; |
73 |
|
int ypercent_sep; |
74 |
struct mybuttons myb[] = { |
|
75 |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
/* Different kind of windows. */ |
76 |
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
HWND dlg; |
77 |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
HWND hwnd_sep; |
78 |
{IMI_KEY_IMPORT, ID_KEYMISC_IMPORT, "Import"}, |
HWND toolbar; |
79 |
{IMI_KEY_EXPORT, ID_KEYMISC_EXPORT, "Export"}, |
HWND statbar; |
80 |
}; |
|
81 |
|
listview_ctrl_t lv; |
82 |
|
int lv_idx; |
83 |
#ifndef VK_F |
int keylist_sortby; |
84 |
#define VK_F 70 |
int magic; |
85 |
#endif |
|
86 |
#ifndef VK_A |
unsigned int enable_groups:1; |
87 |
#define VK_A 65 |
}; |
88 |
#endif |
typedef struct km_info_s *km_info_t; |
89 |
#ifndef VK_C |
|
90 |
#define VK_C 67 |
/* Toolbar button structure. */ |
91 |
#endif |
struct tb_button_s { |
92 |
#ifndef VK_P |
long icon; |
93 |
#define VK_P 80 |
long command; |
94 |
#endif |
char *text; |
95 |
|
}; |
96 |
static BOOL CALLBACK |
|
97 |
keylist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
/* The buttons in the toolbar. */ |
98 |
{ |
struct tb_button_s tbb[] = { |
99 |
struct listview_ctrl_s lv; |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
100 |
|
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
101 |
switch (msg) { |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
102 |
case WM_LBUTTONDBLCLK: |
{IMI_KEY_IMPORT, ID_KEYMISC_IMPORT, "Import"}, |
103 |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS); |
{IMI_KEY_EXPORT, ID_KEYMISC_EXPORT, "Export"}, |
104 |
break; |
}; |
105 |
|
|
106 |
case WM_KEYUP: |
|
107 |
int virt_key = (int)wparam; |
static void km_gui_import (struct km_info_s *kmi, int cmd_id, void *param); |
108 |
switch (virt_key) { |
void key_get_clip_info (const char *keyid, char *buf, size_t buflen); |
109 |
case VK_SPACE: |
|
110 |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_PROPS ); |
|
111 |
break; |
/* Subclass the keylist listview control to allow extended commands. */ |
112 |
|
static BOOL CALLBACK |
113 |
case VK_DELETE: |
keylist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
114 |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_DELETE ); |
{ |
115 |
break; |
struct listview_ctrl_s lv; |
116 |
|
struct km_info_s *kmi; |
117 |
case VK_INSERT: |
|
118 |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PASTE); |
switch (msg) { |
119 |
break; |
case WM_DROPFILES: |
120 |
|
kmi = (km_info_s *)keylist_proc.opaque; |
121 |
case VK_A: |
km_gui_import (kmi, WM_DROPFILES, (void*)wparam); |
122 |
if (GetAsyncKeyState (VK_CONTROL)) { |
break; |
123 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
|
124 |
listview_select_all (&lv); |
case WM_LBUTTONDBLCLK: |
125 |
} |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS); |
126 |
break; |
break; |
127 |
|
|
128 |
case VK_C: |
case WM_KEYUP: |
129 |
if (GetAsyncKeyState (VK_CONTROL)) { |
int virt_key = (int)wparam; |
130 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
switch (virt_key) { |
131 |
km_index = listview_get_curr_pos (&lv); |
case VK_SPACE: |
132 |
km_clip_export (keylist_proc.dlg, &lv); |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS); |
133 |
} |
break; |
134 |
break; |
|
135 |
|
case VK_DELETE: |
136 |
case VK_P: |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_DELETE); |
137 |
if (GetAsyncKeyState (VK_CONTROL)) { |
break; |
138 |
km_index = -1; |
|
139 |
km_clip_import (keylist_proc.dlg); |
case VK_INSERT: |
140 |
} |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PASTE); |
141 |
break; |
break; |
142 |
|
|
143 |
case VK_F: |
case VK_A: |
144 |
if (GetAsyncKeyState (VK_CONTROL)) { |
if (GetAsyncKeyState (VK_CONTROL)) { |
145 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
146 |
km_find_key (dlg, &lv); |
listview_select_all (&lv); |
147 |
} |
} |
148 |
break; |
break; |
149 |
} |
|
150 |
break; |
case VK_C: |
151 |
} |
if (GetAsyncKeyState (VK_CONTROL)) { |
152 |
|
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
153 |
return CallWindowProc( keylist_proc.old, dlg, msg, wparam, lparam ); |
km_clip_export (keylist_proc.dlg, &lv); |
154 |
} /* keylist_subclass_proc */ |
} |
155 |
|
break; |
156 |
|
|
157 |
static HWND |
case VK_P: |
158 |
load_toolbar (HWND dlg, struct km_info * kmi) |
if (GetAsyncKeyState (VK_CONTROL)) |
159 |
{ |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PASTE); |
160 |
HWND tbwnd; |
break; |
161 |
TBSAVEPARAMS tbsp; |
|
162 |
TBBUTTON tb_buttons[] = { |
case VK_F: |
163 |
/*{imagelist_getindex(IMI_EXIT), ID_KEYMISC_QUIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0L, 0},*/ |
if (GetAsyncKeyState (VK_CONTROL)) { |
164 |
{imagelist_getindex(IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
165 |
{imagelist_getindex(IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
km_find_key (dlg, &lv); |
166 |
{imagelist_getindex(IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
} |
167 |
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
break; |
168 |
{imagelist_getindex(IMI_KEY_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
} |
169 |
{imagelist_getindex(IMI_KEY_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
break; |
170 |
}; |
} |
171 |
|
|
172 |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
return CallWindowProc (keylist_proc.old, dlg, msg, wparam, lparam); |
173 |
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
} |
174 |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
|
175 |
if (tbwnd) { |
|
176 |
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
#define ico2idx(ico) imagelist_getindex ((ico)) |
177 |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
|
178 |
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
/* Create a new toolbar window with a pre-defined list of buttons. */ |
179 |
ShowWindow (tbwnd, SW_SHOW); |
static HWND |
180 |
|
create_toolbar (HWND dlg, struct km_info_s *kmi) |
181 |
/* Restore toolbar */ |
{ |
182 |
tbsp.hkr = HKEY_CURRENT_USER; |
HWND tbwnd; |
183 |
tbsp.pszSubKey = "Software\\WinPT"; |
TBSAVEPARAMS tbsp; |
184 |
tbsp.pszValueName = "KM_toolbar"; |
TBBUTTON tb_buttons[] = { |
185 |
if (SendMessage(tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp ) == 0) |
{ico2idx (IMI_KEY_NEW), ID_KEYMISC_KEYWIZARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L}, |
186 |
SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]), (LONG)&tb_buttons[0]); |
{ico2idx (IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
187 |
} |
{ico2idx (IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
188 |
return tbwnd; |
{ico2idx (IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
189 |
} /* load_toolbar */ |
{ico2idx (IMI_KEY_SEARCH), ID_KEYMISC_SENDRECV, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
190 |
|
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
191 |
|
{ico2idx (IMI_KEY_FILE_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
192 |
static void |
{ico2idx (IMI_KEY_FILE_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
193 |
do_center_window (HWND dlg, struct km_info * kmi) |
{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}, |
195 |
RECT rect; |
}; |
196 |
char * p; |
|
197 |
int pos_x = 0, pos_y = 0; |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
198 |
|
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
199 |
/* Find bottom of keylist */ |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
200 |
GetWindowRect (GetDlgItem(dlg, IDC_KEYMISC_KEYLIST), &rect); |
if (!tbwnd) |
201 |
MapWindowPoints (NULL, dlg, (POINT*)&rect, 2); |
BUG (0); |
202 |
|
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
203 |
kmi->ypos_sep = rect.bottom; |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
204 |
|
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
205 |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X" ); |
ShowWindow (tbwnd, SW_SHOW); |
206 |
if( p && !strcmp( p, " " ) ) { |
|
207 |
free_if_alloc( p ); |
/* Restore toolbar */ |
208 |
center_window( dlg, NULL ); |
tbsp.hkr = HKEY_CURRENT_USER; |
209 |
return; |
tbsp.pszSubKey = "Software\\WinPT"; |
210 |
} |
tbsp.pszValueName = "KM_toolbar"; |
211 |
else if( p ) |
if (SendMessage (tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp) == 0) |
212 |
pos_x = atol( p ); |
SendMessage (tbwnd, TB_ADDBUTTONS, |
213 |
|
sizeof (tb_buttons) / sizeof (tb_buttons[0]), |
214 |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y" ); |
(LONG)&tb_buttons[0]); |
215 |
if( p && !strcmp( p, " " ) ) { |
|
216 |
free_if_alloc( p ); |
return tbwnd; |
217 |
center_window( dlg, NULL ); |
} |
218 |
return; |
|
219 |
} |
|
220 |
else if( p ) |
/* Restore the width of the columns from the registry. |
221 |
pos_y = atol( p ); |
If no bitstring was found, the default size is used. */ |
222 |
|
int |
223 |
if( !pos_y && !pos_x ) { |
restore_column_info (struct km_info_s *kmi) |
224 |
center_window( dlg, NULL ); |
{ |
225 |
return; |
WORD *buf; |
226 |
} |
HKEY root; |
227 |
|
DWORD type, size, i; |
228 |
if( pos_x > GetSystemMetrics( SM_CXSCREEN ) |
LONG ec; |
229 |
|| pos_y > GetSystemMetrics( SM_CYSCREEN ) ) { |
|
230 |
pos_x = pos_y = 0; |
size = kmi->lv->cols*sizeof (WORD); |
231 |
} |
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\WinPT", 0, |
232 |
GetClientRect( dlg, &rect ); |
KEY_ALL_ACCESS, &root); |
233 |
MoveWindow( dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE ); |
if (ec != ERROR_SUCCESS) |
234 |
} |
return -1; |
235 |
|
|
236 |
|
buf = new WORD[size/2]; |
237 |
static void |
if (!buf) |
238 |
do_resize_window( HWND dlg, struct km_info *kmi) |
BUG (NULL); |
239 |
{ |
ec = RegQueryValueEx (root, "KMColumnSize", NULL, &type, |
240 |
HWND h; |
(BYTE*)buf, &size); |
241 |
RECT rclient, rect; |
if (ec != ERROR_SUCCESS) { |
242 |
BOOL bRepaint = FALSE; |
RegCloseKey (root); |
243 |
|
free_if_alloc (buf); |
244 |
/* Get rect of client area and make life easier */ |
return -1; |
245 |
GetClientRect( dlg, &rclient ); |
} |
246 |
|
|
247 |
/* Move toolbar to the top of the window */ |
/* check for garbled values. */ |
248 |
if (kmi->toolbar) { |
for (i=0; i < size/2; i++) { |
249 |
GetWindowRect(kmi->toolbar, &rect); |
if (buf[i] == 0 || buf[i] > 512) { |
250 |
ScreenToClient(dlg, (POINT*)&rect); |
free_if_alloc (buf); |
251 |
ScreenToClient(dlg, (POINT*)&(rect.right)); |
return -1; |
252 |
|
} |
253 |
rclient.top += rect.bottom - rect.top; |
} |
254 |
MoveWindow (kmi->toolbar, 0, 0, rclient.right - rclient.left, |
for (i=0; i < size/2; i++) |
255 |
rect.bottom - rect.top, bRepaint); |
listview_set_column_width (kmi->lv, i, buf[i]); |
256 |
} |
free_if_alloc (buf); |
257 |
|
|
258 |
/* Move statusbar to the bottom of the window */ |
size = sizeof (kmi->keylist_sortby); |
259 |
if (kmi->statbar) { |
ec = RegQueryValueEx (root, "KMSortBy", NULL, &type, |
260 |
GetWindowRect( kmi->statbar, &rect ); |
(BYTE*)&kmi->keylist_sortby, &size); |
261 |
ScreenToClient(dlg, (POINT*)&rect); |
if (ec != ERROR_SUCCESS) |
262 |
ScreenToClient(dlg, (POINT*)&(rect.right)); |
kmi->keylist_sortby = KEY_SORT_USERID; |
263 |
|
RegCloseKey (root); |
264 |
rclient.bottom -= rect.bottom - rect.top; |
return 0; |
265 |
MoveWindow (kmi->statbar, 0, rclient.bottom, rclient.right - rclient.left, |
} |
266 |
rect.bottom - rect.top, bRepaint); |
|
267 |
} |
|
268 |
|
/* Save the current column width to the registry. */ |
269 |
// Obtain separator information and move it to the desired posistion |
int |
270 |
if (kmi->ypercent_sep) |
save_column_info (struct km_info_s *kmi) |
271 |
kmi->ypos_sep = (rclient.bottom - rclient.top) * kmi->ypercent_sep / 100; |
{ |
272 |
else |
HKEY root; |
273 |
kmi->ypercent_sep = kmi->ypos_sep * 100 / (rclient.bottom - rclient.top); |
WORD *buf; |
274 |
|
LONG ec; |
275 |
// Don't move away |
int i; |
276 |
if (kmi->ypos_sep+5 > rclient.bottom) |
|
277 |
kmi->ypos_sep = rclient.bottom - 5; |
buf = new WORD[kmi->lv->cols]; |
278 |
if (kmi->ypos_sep < rclient.top) |
if (!buf) |
279 |
kmi->ypos_sep = rclient.top; |
BUG (NULL); |
280 |
MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep, (rclient.right - rclient.left), 5, bRepaint); |
for (i=0; i < kmi->lv->cols; i++) { |
281 |
|
LVCOLUMN lvc; |
282 |
// Place the keylist above the separator |
|
283 |
h = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
memset (&lvc, 0, sizeof (lvc)); |
284 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
lvc.mask = LVCF_WIDTH; |
285 |
kmi->ypos_sep - rclient.top, bRepaint); |
ListView_GetColumn (kmi->lv->ctrl, i, &lvc); |
286 |
rclient.top = kmi->ypos_sep + 5 + 8; |
buf[i] = lvc.cx; |
287 |
|
} |
288 |
/* Place the group text and the group box below the separator */ |
|
289 |
h = GetDlgItem( dlg, IDC_KEYMISC_GTEXT ); |
ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\WinPT", 0, |
290 |
MoveWindow( h, rclient.left, rclient.top, 100, 14, bRepaint); |
KEY_ALL_ACCESS, &root); |
291 |
rclient.top += 18; |
if (ec != ERROR_SUCCESS) { |
292 |
|
free_if_alloc (buf); |
293 |
h = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
return -1; |
294 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
} |
295 |
(rclient.bottom < rclient.top) ? 0 : rclient.bottom - rclient.top, bRepaint); |
|
296 |
|
ec = RegSetValueEx (root, "KMColumnSize", 0, REG_BINARY, |
297 |
/* Repaint the whole thing */ |
(const BYTE*)buf, 2*kmi->lv->cols); |
298 |
InvalidateRect (dlg, NULL, TRUE); |
if (ec == ERROR_SUCCESS) { |
299 |
} /* do_resize_window */ |
ec = RegSetValueEx (root, "KMSortBy", 0, REG_DWORD_BIG_ENDIAN, |
300 |
|
(const BYTE*)&kmi->keylist_sortby, |
301 |
|
sizeof (kmi->keylist_sortby)); |
302 |
static void |
} |
303 |
do_create_minpopup (HWND dlg) |
RegCloseKey (root); |
304 |
{ |
free_if_alloc (buf); |
305 |
HMENU hm; |
return ec == ERROR_SUCCESS? 0 : -1; |
306 |
MENUITEMINFO mi; |
} |
307 |
char * s; |
|
308 |
POINT p; |
|
309 |
|
/* Restore the original size of the dialog. */ |
310 |
if (gpg_read_only) |
static void |
311 |
return; |
restore_window_size (HWND dlg, struct km_info_s *kmi) |
312 |
hm = CreatePopupMenu (); |
{ |
313 |
if (!hm) |
char *p; |
314 |
BUG( NULL ); |
int height = 0, width = 0; |
315 |
memset (&mi, 0, sizeof mi); |
|
316 |
mi.cbSize = sizeof mi; |
/* Restore the original window size. */ |
317 |
s = (char *)_("Paste Key from Clipboard"); |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Width"); |
318 |
mi.fType = MF_STRING; |
if (p) { |
319 |
mi.dwTypeData = s; |
width = atoi (p); |
320 |
mi.cch = strlen (s); |
free_if_alloc (p); |
321 |
mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; |
} |
322 |
mi.wID = ID_KEYCTX_PASTE; |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Height"); |
323 |
InsertMenuItem (hm, 0, FALSE, &mi); |
if (p) { |
324 |
GetCursorPos (&p); |
height = atoi (p); |
325 |
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL); |
free_if_alloc (p); |
326 |
DestroyMenu (hm); |
} |
327 |
} /* do_create_minpopup */ |
if (height > 0 && width > 0) |
328 |
|
SetWindowPos (dlg, HWND_TOP, kmi->pos_x, kmi->pos_y, |
329 |
|
height, width, SWP_SHOWWINDOW); |
330 |
static void |
} |
331 |
do_check_cache( listview_ctrl_t lv, HWND dlg, HWND sb ) |
|
332 |
{ |
|
333 |
gpgme_keycache_t cache; |
/* Center window @dlg. */ |
334 |
|
static void |
335 |
if( keycache_get_reload( ) ) { |
do_center_window (HWND dlg, struct km_info_s *kmi) |
336 |
keycache_reload( dlg ); |
{ |
337 |
keycache_set_reload( 0 ); |
RECT rect; |
338 |
cache = keycache_get_ctx( 1 ); |
char *p; |
339 |
if( !cache ) |
int pos_x = 0; |
340 |
BUG( dlg ); |
int pos_y = 0; |
341 |
keylist_reload( lv, cache, KEYLIST_LIST, KEY_SORT_USERID ); |
|
342 |
km_complete_status_bar (sb, lv); |
/* Find bottom of keylist */ |
343 |
} |
GetWindowRect (GetDlgItem(dlg, IDC_KEYMISC_KEYLIST), &rect); |
344 |
} /* do_check_cache */ |
MapWindowPoints (NULL, dlg, (POINT*)&rect, 2); |
345 |
|
|
346 |
|
kmi->ypos_sep = rect.bottom; |
347 |
long CALLBACK |
|
348 |
separator_wnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X"); |
349 |
{ |
if (p && !strcmp (p, " ")) { |
350 |
static POINT last_mouse_pos; |
free_if_alloc (p); |
351 |
|
center_window (dlg, NULL); |
352 |
if (msg == WM_CREATE) |
return; |
353 |
SetWindowLong (hwnd, GWL_USERDATA, (long)(((CREATESTRUCT*)lparam)->lpCreateParams)); |
} |
354 |
|
else if (p) |
355 |
switch (msg) { |
pos_x = atoi (p); |
356 |
case WM_PAINT: |
|
357 |
PAINTSTRUCT ps; |
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y"); |
358 |
RECT rect; |
if (p && !strcmp (p, " ")) { |
359 |
HPEN hpen; |
free_if_alloc (p); |
360 |
|
center_window (dlg, NULL); |
361 |
GetClientRect (hwnd, &rect); |
return; |
362 |
BeginPaint (hwnd, &ps); |
} |
363 |
|
else if (p) |
364 |
// Background |
pos_y = atoi (p); |
365 |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
|
366 |
|
if (!pos_y && !pos_x) { |
367 |
// The lines from the light into the dark |
center_window (dlg, NULL); |
368 |
MoveToEx(ps.hdc, 0,0, NULL); |
return; |
369 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) { |
} |
370 |
SelectObject(ps.hdc, (LPVOID)hpen); |
|
371 |
LineTo(ps.hdc, rect.right, 0); |
if (pos_x < 0 || pos_y < 0) |
372 |
DeleteObject(hpen); |
pos_x = pos_y = 0; |
373 |
} |
if (pos_x > GetSystemMetrics (SM_CXSCREEN) |
374 |
MoveToEx(ps.hdc, 0, 1, NULL); |
|| pos_y > GetSystemMetrics (SM_CYSCREEN)) { |
375 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) { |
pos_x = pos_y = 0; |
376 |
SelectObject(ps.hdc, (LPVOID)hpen); |
} |
377 |
LineTo(ps.hdc, rect.right, rect.bottom); |
kmi->pos_x = pos_x; |
378 |
DeleteObject(hpen); |
kmi->pos_y = pos_y; |
379 |
} |
|
380 |
|
GetClientRect (dlg, &rect); |
381 |
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL); |
MoveWindow (dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE); |
382 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) { |
} |
383 |
SelectObject(ps.hdc, (LPVOID)hpen); |
|
384 |
LineTo(ps.hdc, rect.right, rect.bottom-1); |
|
385 |
DeleteObject(hpen); |
/* Resize the key manager window with the information from @kmi. */ |
386 |
} |
static void |
387 |
MoveToEx(ps.hdc, 0, rect.bottom, NULL); |
do_resize_window (HWND dlg, struct km_info_s *kmi) |
388 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) { |
{ |
389 |
SelectObject(ps.hdc, (LPVOID)hpen); |
HWND h; |
390 |
LineTo(ps.hdc, rect.right, rect.bottom); |
RECT rclient, rect; |
391 |
DeleteObject(hpen); |
BOOL bRepaint = FALSE; |
392 |
} |
|
393 |
|
/* Get rect of client area and make life easier */ |
394 |
EndPaint (hwnd, &ps); |
GetClientRect (dlg, &rclient); |
395 |
return 0; |
|
396 |
|
/* Move toolbar to the top of the window */ |
397 |
case WM_LBUTTONDOWN: |
if (kmi->toolbar) { |
398 |
last_mouse_pos.x = LOWORD(lparam); |
GetWindowRect (kmi->toolbar, &rect); |
399 |
last_mouse_pos.y = HIWORD(lparam); |
ScreenToClient (dlg, (POINT*)&rect); |
400 |
ClientToScreen (hwnd, &last_mouse_pos); |
ScreenToClient (dlg, (POINT*)&(rect.right)); |
401 |
SetCapture (hwnd); |
|
402 |
return 0; |
rclient.top += rect.bottom - rect.top; |
403 |
|
MoveWindow (kmi->toolbar, 0, 0, rclient.right - rclient.left, |
404 |
case WM_LBUTTONUP: |
rect.bottom - rect.top, bRepaint); |
405 |
ReleaseCapture (); |
} |
406 |
return 0; |
|
407 |
|
/* Move statusbar to the bottom of the window */ |
408 |
case WM_MOUSEMOVE: |
if (kmi->statbar) { |
409 |
if (wparam == MK_LBUTTON) { |
GetWindowRect (kmi->statbar, &rect); |
410 |
struct km_info *kmi; |
ScreenToClient (dlg, (POINT*)&rect); |
411 |
POINT p; |
ScreenToClient (dlg, (POINT*)&(rect.right)); |
412 |
RECT rect; |
|
413 |
|
rclient.bottom -= rect.bottom - rect.top; |
414 |
if ((kmi = (struct km_info *)GetWindowLong (hwnd, GWL_USERDATA)) == NULL) |
MoveWindow (kmi->statbar, 0, rclient.bottom, |
415 |
break; |
rclient.right - rclient.left, |
416 |
|
rect.bottom - rect.top, bRepaint); |
417 |
// Calculate mouse movement |
} |
418 |
p.x = LOWORD(lparam); |
|
419 |
p.y = HIWORD(lparam); |
/* Obtain separator information and move it to the desired posistion */ |
420 |
ClientToScreen (hwnd, &p); |
if (kmi->ypercent_sep) |
421 |
|
kmi->ypos_sep = (rclient.bottom - rclient.top) * kmi->ypercent_sep / 100; |
422 |
GetWindowRect (hwnd, &rect); |
else |
423 |
rect.top += (short)(p.y - last_mouse_pos.y); |
kmi->ypercent_sep = kmi->ypos_sep * 100 / (rclient.bottom - rclient.top); |
424 |
rect.bottom += (short)(p.y - last_mouse_pos.y); |
|
425 |
|
/* Don't move away */ |
426 |
last_mouse_pos.y = p.y; |
if (kmi->ypos_sep+5 > rclient.bottom) |
427 |
|
kmi->ypos_sep = rclient.bottom - 5; |
428 |
// Apply mouse movement to window. Beware the MoveWindow is relaive |
if (kmi->ypos_sep < rclient.top) |
429 |
// to parent NOT screen |
kmi->ypos_sep = rclient.top; |
430 |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep, |
431 |
kmi->ypos_sep = rect.top; |
(rclient.right - rclient.left), 5, bRepaint); |
432 |
kmi->ypercent_sep = 0; // This forces do_resize_window to use abs. position |
|
433 |
do_resize_window (GetParent(hwnd), kmi); |
/* Place the keylist above the separator */ |
434 |
return 0; |
h = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
435 |
} |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
436 |
} |
kmi->ypos_sep - rclient.top, bRepaint); |
437 |
|
rclient.top = kmi->ypos_sep + 5 + 8; |
438 |
return DefWindowProc (hwnd, msg, wparam, lparam); |
|
439 |
} |
if (kmi->enable_groups != 0) { |
440 |
|
/* Place the group text and the group box below the separator */ |
441 |
|
h = GetDlgItem (dlg, IDC_KEYMISC_GTEXT); |
442 |
static HWND |
MoveWindow (h, rclient.left, rclient.top, 100, 14, bRepaint); |
443 |
regist_sep_wnd (HWND dlg, struct km_info * kmi) |
rclient.top += 18; |
444 |
{ |
|
445 |
WNDCLASS wndclass; |
h = GetDlgItem (dlg, IDC_KEYMISC_GROUP); |
446 |
HWND h; |
MoveWindow (h, rclient.left, rclient.top, |
447 |
|
rclient.right - rclient.left, |
448 |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
(rclient.bottom < rclient.top) ? |
449 |
wndclass.lpfnWndProc = separator_wnd_proc; |
0 : rclient.bottom - rclient.top, bRepaint); |
450 |
wndclass.cbClsExtra = 0; |
} |
451 |
wndclass.cbWndExtra = sizeof (long); |
|
452 |
wndclass.hInstance = glob_hinst; |
/* Repaint the whole thing */ |
453 |
wndclass.hIcon = NULL; |
InvalidateRect (dlg, NULL, TRUE); |
454 |
wndclass.hCursor = LoadCursor (NULL, IDC_SIZENS); |
} |
455 |
wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); |
|
456 |
wndclass.lpszMenuName = 0; |
|
457 |
wndclass.lpszClassName = WINDOWCLASS_SEPARATOR_CHILD; |
/* Return true if the clipboard contains an OpenPGP key. */ |
458 |
RegisterClass (&wndclass); |
static bool |
459 |
|
clip_contains_pgpkey (void) |
460 |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
{ |
461 |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
char *ctxt; |
462 |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
bool val = false; |
463 |
ShowWindow (h, SW_SHOW); |
|
464 |
return h; |
ctxt = get_clip_text (NULL); |
465 |
} /* regist_sep_wnd */ |
if (!ctxt || strlen (ctxt) < 512) |
466 |
|
val = false; |
467 |
|
else if (strstr (ctxt, "BEGIN PGP") && strstr (ctxt, "KEY BLOCK") && |
468 |
|
strstr (ctxt, "END PGP")) |
469 |
#define enable_button(hwnd, cid) \ |
val = true; |
470 |
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG (key_selected, 0)) |
free_if_alloc (ctxt); |
471 |
|
return val; |
472 |
void |
} |
473 |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
|
474 |
{ |
|
475 |
int key_selected = 0, key_has_sec = 0; |
/* Show a mini popup menu to import keys. */ |
476 |
int i, key_inv = 0; |
static void |
477 |
HWND hwnd_child; |
do_create_minpopup (HWND dlg) |
478 |
HMENU hmenu; |
{ |
479 |
|
HMENU hm; |
480 |
/* Get some states */ |
POINT p; |
481 |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
|
482 |
LVM_GETSELECTEDCOUNT, 0, 0) |
if (gpg_read_only || !clip_contains_pgpkey ()) |
483 |
? TRUE : FALSE; |
return; |
484 |
key_has_sec = FALSE; |
hm = CreatePopupMenu (); |
485 |
if (key_selected) { |
if (!hm) |
486 |
i = listview_get_curr_pos (lv); |
BUG (0); |
487 |
key_has_sec = km_check_for_seckey( lv, i, NULL ) ? TRUE : FALSE; |
insert_menu_item (hm, 0, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
488 |
key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED; |
GetCursorPos (&p); |
489 |
} |
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL); |
490 |
|
DestroyMenu (hm); |
491 |
/* Enable / disable toolbar buttons */ |
} |
492 |
hwnd_child = GetDlgItem(hwnd, IDR_WINPT_KMTB); |
|
493 |
enable_button (hwnd_child, ID_KEYMISC_DELETE); |
|
494 |
enable_button (hwnd_child, ID_KEYMISC_PROPS); |
/* Update the default key entry in the status bar for dialog @dlg. */ |
495 |
enable_button (hwnd_child, ID_KEYMISC_SIGN); |
void |
496 |
enable_button (hwnd_child, ID_KEYMISC_EXPORT); |
update_default_key_str (HWND dlg) |
497 |
|
{ |
498 |
/* Enable / disable menu items */ |
const char *fmt; |
499 |
hmenu = GetMenu (hwnd); |
char *keyid; |
500 |
set_menu_state (hmenu, ID_KEYMISC_EXPORT, key_selected ? MF_ENABLED : MF_GRAYED); |
char defkeyinf[128]; |
501 |
set_menu_state (hmenu, ID_KEYMISC_EXPORT_PRIVKEY, key_has_sec ? MF_ENABLED : MF_GRAYED); |
|
502 |
set_menu_state (hmenu, ID_KEYMISC_REVCERT, key_has_sec ? MF_ENABLED : MF_GRAYED); |
keyid = get_gnupg_default_key (); |
503 |
set_menu_state (hmenu, ID_KEYMISC_DELETE, key_selected ? MF_ENABLED : MF_GRAYED); |
if (!keyid) |
504 |
set_menu_state (hmenu, ID_KEYMISC_PROPS, key_selected ? MF_ENABLED : MF_GRAYED); |
return; |
505 |
set_menu_state (hmenu, ID_KEYMISC_SIGN, key_selected && !key_inv ? MF_ENABLED : MF_GRAYED); |
if ((keyid[0] >= 'A' && keyid[0] <= 'Z') || |
506 |
} /* update_ui_items */ |
(keyid[0] >= 'a' && keyid[0] <= 'z') || |
507 |
|
(keyid[0] == '0' && keyid[1] == 'x')) |
508 |
|
fmt = _("Default Key: %s"); |
509 |
static void |
else |
510 |
popup_gpg_readonly (HWND dlg, HMENU hm) |
fmt = _("Default Key: 0x%s"); |
511 |
{ |
_snprintf (defkeyinf, sizeof (defkeyinf) - 1, fmt, keyid); |
512 |
int resids[] = { |
SendMessage (dlg, SB_SETTEXT, 0, (LPARAM)defkeyinf); |
513 |
ID_KEYCTX_PASTE, |
gpg_keycache_set_default_key (keycache_get_ctx (0), keyid); |
514 |
ID_KEYCTX_EDIT, |
free_if_alloc (keyid); |
515 |
ID_KEYCTX_SIGN, |
} |
516 |
ID_KEYCTX_REV, |
|
517 |
ID_KEYCTX_DEL, |
|
518 |
ID_KEYCTX_ENABLE, |
/* Count all keys and show from @lv results in the status bar @sb. */ |
519 |
ID_KEYCTX_DISABLE, |
void |
520 |
ID_KEYCTX_RECVFROM, |
update_status_bar (HWND sb, listview_ctrl_t lv) |
521 |
ID_KEYCTX_ADDKEY, |
{ |
522 |
ID_KEYCTX_ADDPHOTO, |
char txt_sec[128]; |
523 |
ID_KEYCTX_ADDUID, |
char txt_pub[128]; |
524 |
ID_KEYCTX_ADDREV, |
int nkeys = 0, nsec = 0; |
525 |
0 |
|
526 |
}; |
nkeys = listview_count_items (lv, 0); |
527 |
int i; |
nsec = gpg_keycache_get_size (keycache_get_ctx (0)); |
528 |
|
|
529 |
if (gpg_read_only == 0) |
_snprintf (txt_sec, sizeof (txt_sec)-1, _("%d secret keys"), nsec); |
530 |
return; |
_snprintf (txt_pub, sizeof (txt_pub)-1, _("%d keys"), nkeys); |
531 |
for (i=0; resids[i] != 0; i++) |
SendMessage (sb, SB_SETTEXT, 1, (LPARAM)txt_sec); |
532 |
set_menu_state (hm, resids[i], MF_GRAYED); |
SendMessage (sb, SB_SETTEXT, 2, (LPARAM)txt_pub); |
533 |
} |
} |
534 |
|
|
535 |
|
|
536 |
static void |
long CALLBACK |
537 |
menu_gpg_readonly (HWND dlg, HMENU hm, int id) |
separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) |
538 |
{ |
{ |
539 |
int key_resids[] = { |
static POINT last_mouse_pos; |
540 |
ID_KEYMISC_SIGN, |
PAINTSTRUCT ps; |
541 |
ID_KEYMISC_DELETE, |
RECT rect; |
542 |
ID_KEYMISC_REVCERT, |
HPEN hpen; |
543 |
ID_KEYMISC_IMPORT_HTTP, |
|
544 |
ID_KEYMISC_IMPORT, |
if (msg == WM_CREATE) |
545 |
ID_KEYMISC_REFRESH_KEYS, |
SetWindowLong (hwnd, GWL_USERDATA, |
546 |
ID_KEYMISC_REBUILD, |
(long)(((CREATESTRUCT*)lparam)->lpCreateParams)); |
547 |
ID_KEYMISC_KEYWIZARD, |
|
548 |
ID_KEYMISC_CARDNEW, |
switch (msg) { |
549 |
ID_KEYMISC_NEWKEY, |
case WM_PAINT: |
550 |
0, |
GetClientRect (hwnd, &rect); |
551 |
}; |
BeginPaint (hwnd, &ps); |
552 |
int edit_resids[] = { |
|
553 |
ID_KEYMISC_PASTE, |
/* Background */ |
554 |
ID_KEYMISC_OT, |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
555 |
ID_KEYMISC_EDITKEY, |
|
556 |
0 |
/* The lines from the light into the dark */ |
557 |
}; |
MoveToEx (ps.hdc, 0,0, NULL); |
558 |
int * resids; |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DHILIGHT)); |
559 |
int i; |
if (hpen != NULL) { |
560 |
|
SelectObject (ps.hdc, (LPVOID)hpen); |
561 |
|
LineTo (ps.hdc, rect.right, 0); |
562 |
if (gpg_read_only == 0) |
DeleteObject (hpen); |
563 |
return; |
} |
564 |
switch (id) { |
MoveToEx (ps.hdc, 0, 1, NULL); |
565 |
case 0: return; |
hpen = CreatePen (PS_SOLID, 0, GetSysColor (COLOR_3DLIGHT)); |
566 |
case 3: resids = key_resids; break; |
if (hpen != NULL) { |
567 |
case 1: resids = edit_resids;break; |
SelectObject (ps.hdc, (LPVOID)hpen); |
568 |
} |
LineTo (ps.hdc, rect.right, rect.bottom); |
569 |
|
DeleteObject (hpen); |
570 |
for (i=0; resids[i] != 0; i++) |
} |
571 |
set_menu_state (hm, resids[i], MF_GRAYED); |
|
572 |
} |
MoveToEx (ps.hdc, 0, rect.bottom-1, NULL); |
573 |
|
hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW)); |
574 |
|
if (hpen != NULL) { |
575 |
static char* |
SelectObject (ps.hdc, (LPVOID)hpen); |
576 |
gen_export_filename (const char *keyid, int is_secret) |
LineTo (ps.hdc, rect.right, rect.bottom-1); |
577 |
{ |
DeleteObject (hpen); |
578 |
gpgme_key_t key; |
} |
579 |
const char *s; |
MoveToEx (ps.hdc, 0, rect.bottom, NULL); |
580 |
char *p; |
hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW)); |
581 |
|
if (hpen != NULL) { |
582 |
if (get_pubkey (keyid, &key)) |
SelectObject (ps.hdc, (LPVOID)hpen); |
583 |
return m_strdup (keyid); |
LineTo (ps.hdc, rect.right, rect.bottom); |
584 |
s = key->uids->name; |
DeleteObject (hpen); |
585 |
if (!s) |
} |
586 |
return m_strdup (keyid); |
|
587 |
p = new char[strlen (s) + 8 + 16]; |
EndPaint (hwnd, &ps); |
588 |
if (!p) |
return 0; |
589 |
BUG (0); |
|
590 |
sprintf (p, "%s%s.asc", s, is_secret? "_sec" : ""); |
case WM_LBUTTONDOWN: |
591 |
for (size_t i=0; i < strlen (p); i++) { |
last_mouse_pos.x = LOWORD (lparam); |
592 |
if (p[i] == ' ' || p[i] == ':' || p[i] == '?' || p[i] == '|') |
last_mouse_pos.y = HIWORD (lparam); |
593 |
p[i] = '_'; |
ClientToScreen (hwnd, &last_mouse_pos); |
594 |
} |
SetCapture (hwnd); |
595 |
return p; |
return 0; |
596 |
} |
|
597 |
|
case WM_LBUTTONUP: |
598 |
|
ReleaseCapture (); |
599 |
static void |
return 0; |
600 |
update_key (listview_ctrl_t lv, int pos, const char *keyid, int keypair) |
|
601 |
{ |
case WM_MOUSEMOVE: |
602 |
gpgme_key_t key; |
if (wparam == MK_LBUTTON) { |
603 |
|
struct km_info_s *kmi; |
604 |
keycache_update (0, keyid); |
POINT p; |
605 |
if (keypair) |
|
606 |
keycache_update (1, keyid); |
kmi = (struct km_info_s *)GetWindowLong (hwnd, GWL_USERDATA); |
607 |
|
if (kmi == NULL) |
608 |
/* because we replaced the key item, we need to update the |
break; |
609 |
address of the pointer in the ListView control. */ |
|
610 |
get_pubkey (keyid, &key); |
/* Calculate mouse movement */ |
611 |
keylist_upd_key (lv, pos, key); |
p.x = LOWORD (lparam); |
612 |
} |
p.y = HIWORD (lparam); |
613 |
|
ClientToScreen (hwnd, &p); |
614 |
|
|
615 |
|
GetWindowRect (hwnd, &rect); |
616 |
BOOL CALLBACK |
rect.top += (short)(p.y - last_mouse_pos.y); |
617 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
rect.bottom += (short)(p.y - last_mouse_pos.y); |
618 |
{ |
|
619 |
struct km_info *kmi; |
last_mouse_pos.y = p.y; |
620 |
static km_group_s *gc = NULL; |
|
621 |
static HMENU menu = NULL; |
/* Apply mouse movement to window. Beware the MoveWindow is relaive |
622 |
static int refresh_keys = 0; |
to parent NOT screen */ |
623 |
INITCOMMONCONTROLSEX icex; |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
624 |
HWND kl; |
kmi->ypos_sep = rect.top; |
625 |
HMENU hm; |
kmi->ypercent_sep = 0; /* This forces do_resize_window to use abs. position */ |
626 |
gpgme_keycache_t c; |
do_resize_window (GetParent (hwnd), kmi); |
627 |
gpgme_key_t key; |
return 0; |
628 |
/*km_group_cb_s gcb; XXX */ |
} |
629 |
struct genkey_s genkey; |
} |
630 |
struct winpt_key_s k = {0}; |
|
631 |
struct URL_ctx_s *url; |
return DefWindowProc (hwnd, msg, wparam, lparam); |
632 |
refresh_cache_s rcs = {0}; |
} |
633 |
char keyid[48], uid[128], type[32], *name; |
|
634 |
const char *t, * host; |
|
635 |
u16 port = 0; |
/* Register the separator window with @dlg as the parent window. */ |
636 |
int idx = 0, i=0, rc; |
static HWND |
637 |
size_t size = 0; |
regist_sep_wnd (HWND dlg, struct km_info_s *kmi) |
638 |
|
{ |
639 |
if ((msg != WM_INITDIALOG) |
WNDCLASS wndclass; |
640 |
&& ((kmi = (struct km_info*)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
HWND h; |
641 |
return FALSE; |
|
642 |
|
memset (&wndclass, 0, sizeof (wndclass)); |
643 |
switch (msg) { |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
644 |
case WM_INITDIALOG: |
wndclass.lpfnWndProc = separator_wnd_proc; |
645 |
kmi = new struct km_info; |
wndclass.cbClsExtra = 0; |
646 |
memset (kmi, 0, sizeof (struct km_info)); |
wndclass.cbWndExtra = sizeof (long); |
647 |
icex.dwSize = sizeof (INITCOMMONCONTROLSEX); |
wndclass.hInstance = glob_hinst; |
648 |
icex.dwICC = ICC_BAR_CLASSES; |
wndclass.hIcon = NULL; |
649 |
InitCommonControlsEx (&icex); |
wndclass.hCursor = LoadCursor (NULL, IDC_SIZENS); |
650 |
kmi->hwnd_sep = regist_sep_wnd (dlg, kmi); |
wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); |
651 |
imagelist_load (dlg); |
wndclass.lpszMenuName = 0; |
652 |
|
wndclass.lpszClassName = WINDOWCLASS_SEPARATOR_CHILD; |
653 |
#ifndef LANG_DE |
RegisterClass (&wndclass); |
654 |
SetWindowText( dlg, _("Key Manager") ); |
|
655 |
#endif |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
656 |
menu = LoadMenu( glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC ); |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
657 |
#ifndef LANG_DE |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
658 |
set_menu_text( menu, ID_KEYMISC_QUIT, _("&Quit") ); |
if (!h) |
659 |
set_menu_text( menu, ID_KEYMISC_UID, _("User ID") ); |
BUG (NULL); |
660 |
set_menu_text( menu, ID_KEYMISC_NEWKEY, _("&Expert") ); |
ShowWindow (h, SW_SHOW); |
661 |
set_menu_text( menu, ID_KEYMISC_KEYWIZARD, _("&Normal") ); |
return h; |
662 |
set_menu_text( menu, ID_KEYMISC_EDIT, _("Edit") ); |
} |
663 |
set_menu_text( menu, ID_KEYMISC_SIGN, _("&Sign") ); |
|
664 |
set_menu_text( menu, ID_KEYMISC_DELETE, _("&Delete") ); |
|
665 |
set_menu_text( menu, ID_KEYMISC_REVCERT, _("&Revoke") ); |
#define enable_button(hwnd, cid, item_selected) \ |
666 |
set_menu_text( menu, ID_KEYMISC_CHECKSIGS, _("&List Signatures") ); |
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG ((item_selected), 0)) |
667 |
set_menu_text( menu, ID_KEYMISC_TRUSTPATH, _("List Trust Path") ); |
|
668 |
set_menu_text( menu, ID_KEYMISC_PROPS, _("&Properties") ); |
|
669 |
set_menu_text( menu, ID_KEYMISC_GPGOPT, _("Options") ); |
/* Interactive modification of the dialog item which depend if an item |
670 |
set_menu_text( menu, ID_KEYMISC_GPGPREFS, _("Preferences") ); |
is selected or not and what kind of item. @lv is the list view with |
671 |
set_menu_text( menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
the items. */ |
672 |
set_menu_text( menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache") ); |
void |
673 |
set_menu_text( menu, ID_KEYMISC_REBUILD, _("R&everify Signatures") ); |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
674 |
set_menu_text( menu, ID_KEYMISC_INFO, _("Info") ); |
{ |
675 |
set_menu_text (menu, ID_KEYMISC_HELP, _("Help")); |
HWND tb_hwnd; |
676 |
#endif |
HMENU hmenu; |
677 |
SetMenu( dlg, menu ); |
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY, |
678 |
if( keyring_check_last_access() ) |
ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0}; |
679 |
keycache_set_reload( 1 ); |
int key_selected; |
680 |
if( keycache_get_reload( ) ) |
int key_has_sec; |
681 |
keycache_reload( dlg ); |
int key_inv = 0; |
682 |
c = keycache_get_ctx( KEYCACHE_PUB ); |
int i, state=0; |
683 |
if( !c ) |
|
684 |
BUG( NULL ); |
/* Get some states */ |
685 |
kmi->keylist_sortby = KEY_SORT_USERID; |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
686 |
Header_SetImageList(ListView_GetHeader(GetDlgItem( dlg, IDC_KEYMISC_KEYLIST )), |
LVM_GETSELECTEDCOUNT, 0, 0) |
687 |
glob_imagelist); |
? TRUE : FALSE; |
688 |
kmi->lv = keylist_load( GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ), c, |
key_has_sec = FALSE; |
689 |
NULL, KEYLIST_LIST, kmi->keylist_sortby ); |
if (key_selected) { |
690 |
/* init subclassing for the listview */ |
i = listview_get_curr_pos (lv); |
691 |
kl = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
key_has_sec = km_check_for_seckey (lv, i, NULL) ? TRUE : FALSE; |
692 |
keylist_proc.dlg = dlg; |
key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED || |
693 |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
km_get_key_status (lv, i) & KM_FLAG_EXPIRED; |
694 |
keylist_proc.old = (WNDPROC)GetWindowLong( kl, GWL_WNDPROC ); |
} |
695 |
if( keylist_proc.old ) { |
|
696 |
if( !SetWindowLong( kl, GWL_WNDPROC, (LONG)keylist_proc.current) ) { |
/* Enable / disable toolbar buttons */ |
697 |
msg_box( dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR ); |
tb_hwnd = GetDlgItem (hwnd, IDR_WINPT_KMTB); |
698 |
BUG( NULL ); |
enable_button (tb_hwnd, ID_KEYMISC_DELETE, key_selected); |
699 |
} |
enable_button (tb_hwnd, ID_KEYMISC_PROPS, key_selected); |
700 |
} |
enable_button (tb_hwnd, ID_KEYMISC_SIGN, key_selected && !key_inv); |
701 |
#if 0 |
enable_button (tb_hwnd, ID_KEYMISC_EXPORT, key_selected); |
702 |
km_groups_new( &gc, GetDlgItem( dlg, IDC_KEYMISC_GROUP ) ); |
enable_button (tb_hwnd, ID_KEYCTX_COPY, key_selected); |
703 |
km_groups_load( gc ); |
enable_button (tb_hwnd, ID_KEYCTX_PASTE, clip_contains_pgpkey ()); |
704 |
#endif |
|
705 |
SetForegroundWindow( dlg ); |
/* Enable / disable menu items */ |
706 |
|
state = key_selected? MF_ENABLED : MF_DISABLED|MF_GRAYED; |
707 |
int partpos[3]; |
hmenu = GetMenu (hwnd); |
708 |
RECT r; |
set_menu_state (hmenu, ID_KEYMISC_EXPORT, state); |
709 |
|
set_menu_state (hmenu, ID_KEYMISC_DELETE, state); |
710 |
GetClientRect (dlg, &r); |
set_menu_state (hmenu, ID_KEYMISC_PROPS, state); |
711 |
for (i=1; i <= 3; i++) |
set_menu_state (hmenu, ID_KEYMISC_EDITKEY, state); |
712 |
partpos[i-1] = r.right/3*i; |
set_menu_state (hmenu, ID_KEYMISC_CHECKSIGS, state); |
713 |
kmi->statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
set_menu_state (hmenu, ID_KEYMISC_SIGN, |
714 |
"status bar", dlg, 100000); |
key_selected && !key_inv ? MF_ENABLED : MF_GRAYED); |
715 |
ShowWindow (kmi->statbar, SW_SHOW); |
set_menu_state (hmenu, ID_KEYMISC_EXPORT_PRIVKEY, |
716 |
SendMessage (kmi->statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
key_selected && key_has_sec? MF_ENABLED : MF_GRAYED); |
717 |
|
set_menu_state (hmenu, ID_KEYMISC_REVCERT, |
718 |
km_update_default_key_str (kmi->statbar); |
key_selected && key_has_sec? MF_ENABLED : MF_GRAYED); |
719 |
km_complete_status_bar( kmi->statbar, kmi->lv); |
|
720 |
|
/* Disable some menu items when multiple keys are selected. */ |
721 |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
if (listview_count_items (lv, 1) > 1) { |
722 |
kmi->toolbar = load_toolbar (dlg, kmi); |
for (i=0; mult_resids[i] != 0; i++) |
723 |
|
set_menu_state (hmenu, mult_resids[i], MF_GRAYED); |
724 |
do_center_window( dlg, kmi ); |
} |
725 |
do_resize_window( dlg, kmi ); |
|
726 |
update_ui_items (dlg, kmi->lv); |
/* Disable all secret-key functions when no secret key is available. */ |
727 |
return TRUE; |
if (!secret_key_available ()) { |
728 |
|
enable_button (tb_hwnd, ID_KEYMISC_SIGN, FALSE); |
729 |
case WM_DESTROY: |
set_menu_state (hmenu, ID_KEYMISC_SIGN, MF_GRAYED); |
730 |
if (kmi->lv) { |
} |
731 |
keylist_delete (kmi->lv); |
} |
732 |
kmi->lv = NULL; |
|
733 |
|
|
734 |
/* |
/* Disable some context menu items when multiple keys are selected. */ |
735 |
if (gc) { |
static void |
736 |
km_groups_release (gc); |
popup_multiple (HWND dlg, HMENU hm) |
737 |
gc = NULL; |
{ |
738 |
}*/ |
int resids[] = { |
739 |
imagelist_destroy (); |
ID_KEYCTX_EDIT, |
740 |
|
ID_KEYCTX_SIGN, |
741 |
char buf[32]; |
ID_KEYCTX_REV, |
742 |
ltoa (kmi->pos_x, buf, 10); |
ID_KEYCTX_ENABLE, |
743 |
set_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", buf ); |
ID_KEYCTX_DISABLE, |
744 |
ltoa (kmi->pos_y, buf, 10); |
ID_KEYCTX_ADDKEY, |
745 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", buf); |
ID_KEYCTX_ADDPHOTO, |
746 |
/* Remove runtime information. This should be the last action taken here. */ |
ID_KEYCTX_ADDUID, |
747 |
delete kmi; kmi = NULL; |
ID_KEYCTX_ADDREV, |
748 |
SetWindowLong (dlg, GWL_USERDATA, NULL); |
ID_KEYCTX_LISTSIGS, |
749 |
keycache_set_reload (refresh_keys); |
ID_KEYCTX_MAXTRUST, |
750 |
return FALSE; |
ID_KEYCTX_PROPS, |
751 |
|
ID_KEYCTX_SENDMAIL, |
752 |
case WM_MOVE: |
0}; |
753 |
/* kmi->pos_x = (int)(short)LOWORD(lparam); |
int i; |
754 |
kmi->pos_y = (int)(short)HIWORD(lparam); */ |
for (i=0; i < resids[i] != 0; i++) |
755 |
RECT r; |
set_menu_state (hm, resids[i], MF_GRAYED); |
756 |
GetWindowRect (dlg, &r); |
} |
757 |
kmi->pos_x = r.left; |
|
758 |
kmi->pos_y = r.top; |
|
759 |
break; |
/* The items which are shown when GPG is in read-only mode. */ |
760 |
|
static void |
761 |
|
popup_gpg_readonly (HWND dlg, HMENU hm) |
762 |
case WM_RBUTTONUP: |
{ |
763 |
do_create_minpopup (dlg); |
int resids[] = { |
764 |
break; |
ID_KEYCTX_PASTE, |
765 |
|
ID_KEYCTX_EDIT, |
766 |
case WM_NOTIFY: |
ID_KEYCTX_SIGN, |
767 |
NMHDR * notify; |
ID_KEYCTX_REV, |
768 |
POINT p; |
ID_KEYCTX_DEL, |
769 |
HMENU popup; |
ID_KEYCTX_ENABLE, |
770 |
|
ID_KEYCTX_DISABLE, |
771 |
notify = (NMHDR *)lparam; |
ID_KEYCTX_RECVFROM, |
772 |
if (notify == NULL) |
ID_KEYCTX_ADDKEY, |
773 |
break; |
ID_KEYCTX_ADDPHOTO, |
774 |
switch (notify->code) |
ID_KEYCTX_ADDUID, |
775 |
{ |
ID_KEYCTX_ADDREV, |
776 |
case TBN_QUERYDELETE: |
0 |
777 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
}; |
778 |
return TRUE; |
int i; |
779 |
|
|
780 |
case TBN_QUERYINSERT: |
if (gpg_read_only == 0) |
781 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
return; |
782 |
return TRUE; |
for (i=0; resids[i] != 0; i++) |
783 |
|
set_menu_state (hm, resids[i], MF_GRAYED); |
784 |
case TBN_GETBUTTONINFO: |
} |
785 |
LPTBNOTIFY lpTbNotify; |
|
786 |
lpTbNotify = (LPTBNOTIFY)lparam; |
|
787 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
/* Change the 'Edit' menu based on the current state. */ |
788 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex(myb[lpTbNotify->iItem].icon); |
static void |
789 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
change_edit_menu (listview_ctrl_t lv, HMENU hm, int id) |
790 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
{ |
791 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
enum item { EDIT_MENU = 1 }; |
792 |
lpTbNotify->tbButton.iString = 0; |
int no_sel; |
793 |
strncpy (lpTbNotify->pszText, myb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
|
794 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
if (id != EDIT_MENU) |
795 |
} |
return; |
796 |
return TRUE; |
|
797 |
|
if (!clip_contains_pgpkey ()) |
798 |
case TBN_RESET: /* Restore last saved toolbar status */ |
set_menu_state (hm, ID_KEYMISC_PASTE, MF_GRAYED); |
799 |
TBSAVEPARAMS tbsp; |
else |
800 |
|
set_menu_state (hm, ID_KEYMISC_PASTE, MF_ENABLED); |
801 |
tbsp.hkr = HKEY_CURRENT_USER; |
no_sel = listview_get_curr_pos (lv) == -1? 1 : 0; |
802 |
tbsp.pszSubKey = "Software\\WinPT"; |
set_menu_state (hm, ID_KEYMISC_DELETE2, no_sel? MF_GRAYED: MF_ENABLED); |
803 |
tbsp.pszValueName = "KM_toolbar"; |
set_menu_state (hm, ID_KEYMISC_COPY, no_sel? MF_GRAYED : MF_ENABLED); |
804 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp); |
} |
805 |
break; |
|
806 |
|
|
807 |
case TBN_BEGINADJUST: /* User is about to change the toolbar. Save it */ |
|
808 |
tbsp.hkr = HKEY_CURRENT_USER; |
/* Show limited key menu entries when GPG is in read-only mode. */ |
809 |
tbsp.pszSubKey = "Software\\WinPT"; |
static void |
810 |
tbsp.pszValueName = "KM_toolbar"; |
change_key_menu (HMENU hm, int id) |
811 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
{ |
812 |
break; |
int key_resids[] = { |
813 |
|
ID_KEYMISC_SIGN, |
814 |
case TBN_ENDADJUST: /* User has finished customizing the toolbar. Save it. */ |
ID_KEYMISC_DELETE, |
815 |
tbsp.hkr = HKEY_CURRENT_USER; |
ID_KEYMISC_REVCERT, |
816 |
tbsp.pszSubKey = "Software\\WinPT"; |
ID_KEYMISC_IMPORT_HTTP, |
817 |
tbsp.pszValueName = "KM_toolbar"; |
ID_KEYMISC_IMPORT, |
818 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
ID_KEYMISC_REFRESH_KEYS, |
819 |
break; |
ID_KEYMISC_REBUILD, |
820 |
|
ID_KEYMISC_KEYWIZARD, |
821 |
case TTN_GETDISPINFO: |
ID_KEYMISC_CARDNEW, |
822 |
LPTOOLTIPTEXT lpttt; |
ID_KEYMISC_NEWKEY, |
823 |
lpttt = (LPTOOLTIPTEXT)lparam; |
0, |
824 |
|
}; |
825 |
lpttt->hinst = NULL; |
int edit_resids[] = { |
826 |
switch (lpttt->hdr.idFrom) { |
ID_KEYMISC_PASTE, |
827 |
case ID_KEYMISC_DELETE: |
ID_KEYMISC_OT, |
828 |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
ID_KEYMISC_EDITKEY, |
829 |
break; |
0 |
830 |
|
}; |
831 |
case ID_KEYMISC_PROPS: |
int *resids; |
832 |
lpttt->lpszText = (char *)_("Show key properties"); |
int i; |
833 |
break; |
|
834 |
|
|
835 |
case ID_KEYMISC_SIGN: |
if (gpg_read_only == 0) |
836 |
lpttt->lpszText = (char *)_("Sign key"); |
return; |
837 |
break; |
switch (id) { |
838 |
|
case 0: return; |
839 |
case ID_KEYMISC_IMPORT: |
case 3: resids = key_resids; break; |
840 |
lpttt->lpszText = (char *)_("Import key to keyring"); |
case 1: resids = edit_resids;break; |
841 |
break; |
default:resids = edit_resids; break; |
842 |
|
} |
843 |
case ID_KEYMISC_EXPORT: |
|
844 |
lpttt->lpszText = (char *)_("Export key to a file"); |
for (i=0; resids[i] != 0; i++) |
845 |
break; |
set_menu_state (hm, resids[i], MF_GRAYED); |
846 |
} |
} |
847 |
return TRUE; |
|
848 |
|
|
849 |
case LVN_ITEMCHANGED: |
/* Reload a single key in the cache. */ |
850 |
if (((LPNMLISTVIEW)lparam)->uNewState) /* item selected? */ |
static void |
851 |
{ |
update_key (listview_ctrl_t lv, int pos, const char *keyid, int keypair) |
852 |
update_ui_items (dlg, kmi->lv); |
{ |
853 |
return TRUE; |
struct winpt_key_s key; |
854 |
} |
|
855 |
break; |
keycache_update (0, keyid); |
856 |
|
if (keypair) |
857 |
case NM_RCLICK: |
keycache_update (1, keyid); |
858 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
|
859 |
if (listview_get_curr_pos (kmi->lv) == -1) |
/* because we replaced the key item, we need to update the |
860 |
return TRUE; /* Popup only when a item was selected */ |
address of the pointer in the ListView control. */ |
861 |
do_check_cache (kmi->lv, dlg, kmi->statbar); |
memset (&key, 0, sizeof (key)); |
862 |
GetCursorPos (&p); |
winpt_get_pubkey (keyid, &key); |
863 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYMISC_CTX)); |
keylist_upd_key (lv, pos, key.ext, key.ctx); |
864 |
popup = GetSubMenu (hm, 0); |
keyring_check_last_access (); |
865 |
#ifndef LANG_DE |
} |
866 |
set_menu_text( popup, ID_KEYCTX_UID_COPY, _("Copy User ID to Clipboard") ); |
|
867 |
set_menu_text( popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard") ); |
|
868 |
set_menu_text( popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard") ); |
/* Setup status bar for the main window @dlg. */ |
869 |
set_menu_text( popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver") ); |
static HWND |
870 |
#endif |
setup_status_bar (HWND dlg, listview_ctrl_t lv) |
871 |
idx = listview_get_curr_pos (kmi->lv); |
{ |
872 |
if (km_check_for_seckey (kmi->lv, idx, &i)) |
HWND statbar; |
873 |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
RECT r; |
874 |
if (i == 0) |
int partpos[3]; |
875 |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
int i; |
876 |
if (!km_check_for_seckey (kmi->lv, idx, NULL)) { |
|
877 |
set_menu_state( popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED ); |
GetClientRect (dlg, &r); |
878 |
set_menu_state( popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED ); |
for (i=1; i <= 3; i++) |
879 |
set_menu_state( popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED ); |
partpos[i-1] = r.right/3*i; |
880 |
set_menu_state( popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED ); |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
881 |
set_menu_state( popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED ); |
"WinPT_Status_Bar", dlg, KM_SEPARATOR_ID); |
882 |
set_menu_state (popup, ID_KEYCTX_SETPREFKS, MF_DISABLED|MF_GRAYED); |
if (!statbar) |
883 |
} |
BUG (NULL); |
884 |
else if( km_check_for_seckey( kmi->lv, idx, NULL ) |
ShowWindow (statbar, SW_SHOW); |
885 |
&& km_key_is_v3( kmi->lv, idx ) ) |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
886 |
{ |
|
887 |
/* PGP 2 keys, version 3 have no no support for photo-id's, |
update_default_key_str (statbar); |
888 |
designated revokers and secondary keys. */ |
update_status_bar (statbar, lv); |
889 |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
return statbar; |
890 |
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED); |
} |
891 |
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED); |
|
892 |
} |
|
893 |
if( km_get_key_status( kmi->lv, idx ) & KM_FLAG_DISABLED ) |
/* Remove or add columns which depends on the state of @checked. */ |
894 |
set_menu_state( popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED ); |
void |
895 |
else |
modify_listview_columns (km_info_s *kmi, UINT m_uid, BOOL checked) |
896 |
set_menu_state( popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED ); |
{ |
897 |
if (km_get_key_status (kmi->lv, idx) & KM_FLAG_REVOKED) |
UINT resids[] = { |
898 |
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
0, |
899 |
if (mapi_init()) |
ID_KEYMISC_VIEWKEYID, |
900 |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
ID_KEYMISC_VIEWTYPE, |
901 |
/* Override 'Default Keyserver' with the actual name. */ |
0, |
902 |
host = kserver_get_hostname (0, -1, &port); |
ID_KEYMISC_VIEWCIPHER, |
903 |
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host); |
0, |
904 |
popup_gpg_readonly (dlg, popup); |
0, |
905 |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
ID_KEYMISC_VIEWCREAT, |
906 |
DestroyMenu (popup); |
ID_KEYMISC_VIEWDESC, |
907 |
DestroyMenu (hm); |
-1 |
908 |
return TRUE; |
}; |
909 |
} |
listview_column_s cols[] = { |
910 |
#if 0 /* XXX */ |
{0, 240, (char *)_("User ID")}, |
911 |
if( notify->idFrom == IDC_KEYMISC_GROUP ) { |
{1, 78, (char *)_("Key ID")}, |
912 |
HWND tree = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
{2, 52, (char *)_("Type")}, |
913 |
if( TreeView_GetSelection( tree ) ) { |
{3, 66, (char *)_("Size")}, |
914 |
GetCursorPos( &p ); |
{4, 60, (char *)_("Cipher")}, |
915 |
hm = LoadMenu( glob_hinst, MAKEINTRESOURCE(IDR_WINPT_GROUP_CTX) ); |
{5, 66, (char *)_("Validity")}, |
916 |
popup = GetSubMenu( hm, 0 ); |
{6, 58, (char *)_("Trust")}, |
917 |
if( km_index == -1 ) |
{7, 72, (char *)_("Creation")}, |
918 |
set_menu_state( popup, ID_GROUP_PASTE, MF_DISABLED|MF_GRAYED ); |
{8, 160,(char *)_("Description")}, |
919 |
set_menu_text( popup, ID_GROUP_PASTE, _("Paste into this group") ); |
{0, 0, NULL} |
920 |
set_menu_text( popup, ID_GROUP_DELETE, _("Delete") ); |
}; |
921 |
TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL ); |
UINT pos; |
922 |
DestroyMenu( popup ); |
|
923 |
DestroyMenu( hm ); |
for (pos=0; resids[pos] != -1; pos++) { |
924 |
return TRUE; |
if (m_uid == resids[pos]) |
925 |
} |
break; |
926 |
} |
} |
927 |
#endif |
if (!checked) |
928 |
break; |
listview_del_column (kmi->lv, (int)pos); |
929 |
|
else { |
930 |
case LVN_COLUMNCLICK: |
listview_add_column (kmi->lv, &cols[pos]); |
931 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
keylist_upd_col (kmi->lv, pos); |
932 |
NMLISTVIEW * p = (LPNMLISTVIEW) lparam; |
} |
933 |
int sortby = 0; |
} |
934 |
switch (p->iSubItem) { |
|
935 |
case 0: sortby = KEY_SORT_USERID; break; |
|
936 |
case 1: sortby = KEY_SORT_KEYID; break; |
/* Helper to handle the help file. If @check is 1 |
937 |
case 2: sortby = KEY_SORT_IS_SECRET; break; |
the existence of the file is checked. |
938 |
case 3: sortby = KEY_SORT_LEN; break; |
Otherwise the help file will be loaded. */ |
939 |
case 5: sortby = KEY_SORT_VALIDITY; break; |
static bool |
940 |
case 6: sortby = KEY_SORT_OTRUST; break; |
start_help (HWND dlg, int check) |
941 |
case 7: sortby = KEY_SORT_CREATED; break; |
{ |
942 |
case 8: sortby = KEY_SORT_ALGO; break; |
DWORD n; |
943 |
default: return TRUE; //sortby = KEY_SORT_USERID; break; |
char path[MAX_PATH+1+32]; |
944 |
} |
|
945 |
|
n = GetModuleFileName (NULL, path, sizeof (path)-1-32); |
946 |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
if (!n) |
947 |
kmi->keylist_sortby ^= KEYLIST_SORT_DESC; |
return false; |
948 |
else |
path[n] = 0; |
949 |
kmi->keylist_sortby = sortby; |
while (n-- && path[n] != '\\') |
950 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
; |
951 |
return TRUE; |
path[n+1] = 0; |
952 |
} |
strcat (path, "winpt.chm"); |
953 |
break; |
if (!check) |
954 |
} |
ShellExecute (dlg, "open", path, NULL, NULL, SW_SHOW); |
955 |
break; |
return file_exist_check (path) == 0? true : false; |
956 |
} |
} |
957 |
|
|
958 |
case WM_WINDOWPOSCHANGING: |
|
959 |
if (((WINDOWPOS*)lparam)->cx < 400) |
/* Translate all menu strings. */ |
960 |
((WINDOWPOS*)lparam)->cx = 400; |
static void |
961 |
if (((WINDOWPOS*)lparam)->cy < 200) |
translate_menu_strings (HWND dlg) |
962 |
((WINDOWPOS*)lparam)->cy = 200; |
{ |
963 |
return TRUE; |
HMENU menu; |
964 |
|
|
965 |
case WM_SIZE: |
menu = LoadMenu (glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC); |
966 |
do_resize_window (dlg, kmi); |
set_menu_text_bypos (menu, 0, _("File")); |
967 |
return TRUE; |
set_menu_text_bypos (menu, 1, _("Edit")); |
968 |
|
set_menu_text_bypos (menu, 2, _("View")); |
969 |
case WM_SYSCOMMAND: |
set_menu_text_bypos (menu, 3, _("Key")); |
970 |
if( LOWORD (wparam) == SC_CLOSE ) |
set_menu_text_bypos (menu, 4, _("Groups")); |
971 |
EndDialog( dlg, TRUE ); |
|
972 |
return FALSE; |
set_menu_text (menu, ID_KEYMISC_EDITKEY, _("Edit")); |
973 |
|
set_menu_text (menu, ID_KEYMISC_MAIL, _("Send Mail...")); |
974 |
case WM_MENUSELECT: |
set_menu_text (menu, ID_KEYMISC_OT, _("Ownertrust")); /* XXX */ |
975 |
menu_gpg_readonly (dlg, (HMENU)lparam, LOWORD (wparam)); |
set_menu_text (menu, ID_KEYMISC_COPY, _("&Copy\tCtrl+C")); |
976 |
break; |
set_menu_text (menu, ID_KEYMISC_PASTE, _("&Paste\tCtrl+V")); |
977 |
|
set_menu_text (menu, ID_KEYMISC_FIND, _("Search...\tCtrl+F")); |
978 |
case WM_COMMAND: |
set_menu_text (menu, ID_KEYMISC_SELALL, _("Select All\tCtrl+A")); |
979 |
if( gnupg_access_keyring( 1 ) ) { |
set_menu_text (menu, ID_KEYMISC_QUIT, _("&Quit")); |
980 |
msg_box( dlg, _("Could not access public keyring"), _("Key Manager"), MB_ERR ); |
set_menu_text (menu, ID_KEYMISC_UID, _("User ID")); |
981 |
return FALSE; |
set_menu_text (menu, ID_KEYMISC_NEWKEY, _("&Expert")); |
982 |
} |
set_menu_text (menu, ID_KEYMISC_KEYWIZARD, _("&Normal")); |
983 |
do_check_cache( kmi->lv, dlg, kmi->statbar ); |
set_menu_text (menu, ID_KEYMISC_EDIT, _("Edit")); |
984 |
switch( LOWORD( wparam ) ) { |
set_menu_text (menu, ID_KEYMISC_SIGN, _("&Sign")); |
985 |
case ID_KEYMISC_QUIT: |
set_menu_text (menu, ID_KEYMISC_DELETE, _("&Delete")); |
986 |
EndDialog( dlg, TRUE ); |
set_menu_text (menu, ID_KEYMISC_DELETE2, _("&Delete")); |
987 |
return TRUE; |
set_menu_text (menu, ID_KEYMISC_REVCERT, _("&Revoke Cert")); |
988 |
|
set_menu_text (menu, ID_KEYMISC_CHECKSIGS, _("&List Signatures")); |
989 |
case ID_KEYMISC_MAIL: |
set_menu_text (menu, ID_KEYMISC_TRUSTPATH, _("List Trust Path")); |
990 |
/* XXX |
set_menu_text (menu, ID_KEYMISC_EXPORT, _("&Export...")); |
991 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_MAIL, GetDesktopWindow (), |
set_menu_text (menu, ID_KEYMISC_IMPORT, _("&Import...")); |
992 |
winpt_mail_proc, NULL);*/ |
set_menu_text (menu, ID_KEYMISC_PROPS, _("&Properties")); |
993 |
break; |
set_menu_text (menu, ID_KEYMISC_GPGOPT, _("GPG &Options")); |
994 |
|
set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("&GPG Preferences")); |
995 |
case ID_KEYMISC_FIND: |
set_menu_text (menu, ID_KEYMISC_WINPTPREFS, _("&WinPT Preferences")); |
996 |
km_find_key (dlg, kmi->lv); |
set_menu_text (menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
997 |
break; |
set_menu_text (menu, ID_KEYMISC_EXPORT_PRIVKEY, _("E&xport Secret Key")); |
998 |
|
set_menu_text (menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache")); |
999 |
case ID_KEYMISC_DELETE: |
set_menu_text (menu, ID_KEYMISC_REBUILD, _("R&everify Signatures")); |
1000 |
km_delete_keys (kmi->lv, dlg); |
set_menu_text (menu, ID_KEYMISC_REFRESH_KEYS, _("Refresh &Keys (Keyserver)")); |
1001 |
return TRUE; |
set_menu_text (menu, ID_KEYMISC_INFO, _("Info") ); |
1002 |
|
set_menu_text (menu, ID_KEYMISC_HELP, _("&Help")); |
1003 |
case ID_KEYMISC_SIGN: |
|
1004 |
if ( (idx = listview_get_curr_pos( kmi->lv )) == -1 ) { |
set_menu_text (menu, ID_KEYMISC_VIEWKEYID, _("Key ID")); |
1005 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), |
set_menu_text (menu, ID_KEYMISC_VIEWCIPHER, _("Cipher")); |
1006 |
MB_ERR ); |
set_menu_text (menu, ID_KEYMISC_VIEWTYPE, _("Type")); |
1007 |
return TRUE;; |
set_menu_text (menu, ID_KEYMISC_VIEWCREAT, _("Creation")); |
1008 |
} |
|
1009 |
if (km_check_key_status (kmi->lv, idx)) |
if (!start_help (NULL, 1)) |
1010 |
return TRUE; |
set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED); |
1011 |
key = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
|
1012 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
SetMenu (dlg, menu); |
1013 |
memset (&k, 0, sizeof (k)); |
} |
1014 |
k.ctx = key; |
|
1015 |
k.keyid = keyid; |
|
1016 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIGN, dlg, |
/* Translate popup menu strings. */ |
1017 |
keysign_dlg_proc, (LPARAM)&k, |
static void |
1018 |
_("Key Signing"), IDS_WINPT_KEYSIGN); |
translate_popupmenu_strings (HMENU popup) |
1019 |
if (k.update) |
{ |
1020 |
update_key (kmi->lv, idx, k.keyid, 0); |
set_menu_text (popup, ID_KEYCTX_UID_COPY, _("Copy User ID to Clipboard")); |
1021 |
return TRUE; |
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")); |
1023 |
case ID_KEYMISC_REVCERT: |
set_menu_text (popup, ID_KEYCTX_KINFO_COPY, _("Copy Key Info to Clipboard")); |
1024 |
idx = listview_get_curr_pos( kmi->lv ); |
set_menu_text (popup, ID_KEYCTX_EMAIL_COPY, _("Copy E-Mail to Clipboard")); |
1025 |
if( idx == -1 ) { |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
1026 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
1027 |
return TRUE; |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
1028 |
} |
set_menu_text (popup, ID_KEYCTX_MAXTRUST, _("Set Implicit &Trust")); |
1029 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
set_menu_text (popup, ID_KEYCTX_LISTSIGS, _("&List Signatures")); |
1030 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid-1 ); |
set_menu_text (popup, ID_KEYCTX_PROPS, _("&Properties")); |
1031 |
if ( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
set_menu_text (popup, ID_KEYCTX_EDIT, _("Key Edit")); |
1032 |
msg_box( dlg, _("There is no secret key available!"), _("Key Manager"), MB_ERR ); |
set_menu_text (popup, ID_KEYCTX_DEL, _("&Delete")); |
1033 |
return TRUE; |
set_menu_text (popup, ID_KEYCTX_REV, _("&Revoke Cert")); |
1034 |
} |
set_menu_text (popup, ID_KEYCTX_SIGN, _("&Sign")); |
1035 |
|
set_menu_text (popup, ID_KEYCTX_ENABLE, _("&Enable")); |
1036 |
{ |
set_menu_text (popup, ID_KEYCTX_DISABLE, _("&Disable")); |
1037 |
char t[128]; |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Re&fresh from Keyserver")); |
1038 |
listview_get_item_text( kmi->lv, idx, 5, t, sizeof t -1 ); |
set_menu_text (popup, ID_KEYCTX_SETPREFKS, _("Set preferred Keyserver URL")); |
1039 |
if( strchr( t, 'R' ) ) { |
set_menu_text (popup, ID_KEYCTX_SENDMAIL, _("Send Key to Mail Recipient")); |
1040 |
msg_box( dlg, _("Key already revoked!"), _("Key Manager"), MB_INFO ); |
set_menu_text (popup, ID_KEYCTX_SETDEFKEY, _("Set as Default Key")); |
1041 |
return TRUE; |
|
1042 |
} |
set_menu_text (popup, ID_KEYCTX_ADDKEY, _("Key...")); |
1043 |
} |
set_menu_text (popup, ID_KEYCTX_ADDUID, _("User ID...")); |
1044 |
|
set_menu_text (popup, ID_KEYCTX_ADDPHOTO, _("Photo ID...")); |
1045 |
name = km_quote_uid (uid); |
set_menu_text (popup, ID_KEYCTX_ADDREV, _("Revoker...")); |
1046 |
memset (&k, 0, sizeof (k)); |
|
1047 |
k.key_pair = 1; |
/* change popup texts */ |
1048 |
k.keyid = keyid; |
set_menu_text_bypos (popup, 0, _("Key Attributes")); |
1049 |
k.uid = name; |
set_menu_text_bypos (popup, 6, _("Add")); |
1050 |
k.is_protected = km_check_if_protected( kmi->lv, idx ); |
set_menu_text_bypos (popup, 19, _("Send to Keyserver")); |
1051 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYREVOKE, dlg, |
} |
1052 |
key_revoke_dlg_proc, (LPARAM)&k, |
|
1053 |
_("Key Revocation"), IDS_WINPT_KEYREVOKE ); |
|
1054 |
free_if_alloc (name); |
static int |
1055 |
return TRUE; |
km_gui_adjust_column_images (listview_ctrl_t ctx, int sortby) |
1056 |
|
{ |
1057 |
case ID_KEYMISC_TRUSTPATH: |
HWND hheader; |
1058 |
idx = listview_get_curr_pos( kmi->lv ); |
HDITEM hdi; |
1059 |
if( idx == -1 ) { |
int idx, sort_desc = 0; |
1060 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1061 |
return TRUE; |
hheader = ListView_GetHeader (ctx->ctrl); |
1062 |
} |
if (!hheader) |
1063 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
return 0; |
1064 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid -1 ); |
|
1065 |
if( km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
/* Remove image from all header fields */ |
1066 |
msg_box( dlg, _("It does not make any sense with a key pair!"), _("Key Manager"), MB_OK ); |
memset (&hdi, 0, sizeof(hdi)); |
1067 |
return FALSE; |
|
1068 |
} |
for (int i=0; i < 7; i++) { |
1069 |
memset (&k, 0, sizeof (k)); |
hdi.mask = HDI_FORMAT; |
1070 |
k.keyid = keyid; |
Header_GetItem (hheader, i, &hdi); |
1071 |
k.uid = uid; |
hdi.fmt &= ~HDF_IMAGE; |
1072 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
Header_SetItem (hheader, i, &hdi); |
1073 |
keytrust_dlg_proc, (LPARAM)&k, |
} |
1074 |
_("List Trust Path"), IDS_WINPT_KEYTRUST ); |
|
1075 |
return TRUE; |
switch (sortby & ~KEYLIST_SORT_DESC) { |
1076 |
|
case KEY_SORT_USERID: idx = 0; break; |
1077 |
case ID_KEYMISC_CHECKSIGS: |
case KEY_SORT_KEYID: idx = 1; break; |
1078 |
idx = listview_get_curr_pos (kmi->lv); |
case KEY_SORT_IS_SECRET: idx = 2; break; |
1079 |
if( idx == -1 ) { |
case KEY_SORT_LEN: idx = 3; break; |
1080 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
case KEY_SORT_VALIDITY: idx = 5; break; |
1081 |
return FALSE; |
case KEY_SORT_OTRUST: idx = 6; break; |
1082 |
} |
case KEY_SORT_CREATED: idx = 7; break; |
1083 |
listview_get_item_text (kmi->lv, idx, 0, uid, DIM (uid)-1); |
case KEY_SORT_ALGO: idx = 8; break; |
1084 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
default: idx = 0; break; |
1085 |
memset (&k, 0, sizeof (k)); |
} |
1086 |
k.keyid = keyid; |
|
1087 |
k.uid = uid; |
sort_desc = sortby & KEYLIST_SORT_DESC; |
1088 |
k.ctx = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
/* Set image to currently sorted field */ |
1089 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIG, dlg, |
memset (&hdi, 0, sizeof(hdi)); |
1090 |
keysig_dlg_proc, (LPARAM)&k, |
hdi.mask = HDI_IMAGE | HDI_FORMAT; |
1091 |
_("Key Signature List" ), IDS_WINPT_KEYSIG); |
Header_GetItem (hheader, idx, &hdi); |
1092 |
return TRUE; |
hdi.fmt |= HDF_IMAGE | HDF_BITMAP_ON_RIGHT; |
1093 |
|
if (!ctx->ext_chkbox) |
1094 |
case ID_KEYMISC_PROPS: |
hdi.iImage = imagelist_getindex (sort_desc? IMI_SORT_DOWNARROW : |
1095 |
idx = listview_get_curr_pos( kmi->lv ); |
IMI_SORT_UPARROW); |
1096 |
if( idx == -1 ) { |
else |
1097 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
hdi.iImage = sort_desc? KEY_IMG_SORT_DOWN : KEY_IMG_SORT_UP; |
1098 |
return FALSE; |
Header_SetItem (hheader, idx, &hdi); |
1099 |
} |
return 0; |
1100 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
} |
1101 |
listview_get_item_text (kmi->lv, idx, 2, type, DIM (type)-1); |
|
1102 |
memset (&k, 0, sizeof (k)); |
|
1103 |
k.key_pair = 0; |
/* Return true if the cache contain marked keys. */ |
1104 |
k.keyid = keyid; |
static bool |
1105 |
if( !strcmp( type, "pub/sec" ) || !strcmp( type, "pub/crd" ) ) |
updated_keys_avail (void) |
1106 |
k.key_pair = 1; |
{ |
1107 |
k.callback.ctl = kmi->lv; |
gpg_keycache_t kc = keycache_get_ctx (1); |
1108 |
k.callback.idx = idx; |
struct keycache_s *k; |
1109 |
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
|
1110 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYPROPS, dlg, |
for (k = kc->item; k; k = k->next) { |
1111 |
keyprops_dlg_proc, (LPARAM)&k, |
if (k->flags) |
1112 |
_("Key Properties"), IDS_WINPT_KEYPROPS ); |
return true; |
1113 |
if (k.callback.new_val != 0) { |
} |
1114 |
t = get_key_trust_str (k.callback.new_val); |
return false; |
1115 |
listview_add_sub_item (kmi->lv, idx, 6, t); |
} |
1116 |
} |
|
1117 |
return TRUE; |
|
1118 |
|
/* Find the index of the key identified by @key. */ |
1119 |
case ID_KEYMISC_RECACHE: |
static int |
1120 |
/* If there is already a reload request, don't bother the user with a message. */ |
find_keypos (listview_ctrl_t lv, gpgme_key_t key) |
1121 |
if( keycache_get_reload() == 1 ) |
{ |
1122 |
idx = IDYES; |
char keyid[32+1]; |
1123 |
else { |
int i; |
1124 |
char t[256]; |
|
1125 |
_snprintf( t, sizeof t -1, |
for (i=0; i < listview_count_items (lv, 0); i++) { |
1126 |
_("This is only useful when the keyring has been " |
listview_get_item_text (lv, i, KM_COL_KEYID, keyid, sizeof (keyid)-1); |
1127 |
"modified (sign a key...).\n" |
if (!strcmp (key->subkeys->keyid+8, keyid+2)) |
1128 |
"Do you really want to reload the keycache?") ); |
return i; |
1129 |
idx = msg_box( dlg, t, _("Key Manager"), MB_YESNO ); |
} |
1130 |
} |
return -1; |
1131 |
if( idx == IDYES ) { |
} |
1132 |
rcs.kr_reload = rcs.kr_update = 1; |
|
1133 |
rcs.tr_update = 0; |
|
1134 |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
/* Add all recently updated keys in the cache to the list |
1135 |
keycache_dlg_proc, (LPARAM)&rcs ); |
and refresh all GUI elements. */ |
1136 |
c = keycache_get_ctx( 1 ); |
static void |
1137 |
if( !c ) |
refresh_keylist (struct km_info_s *kmi) |
1138 |
BUG( dlg ); |
{ |
1139 |
keylist_reload( kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID ); |
struct keycache_s *ctx; |
1140 |
refresh_keys = 0; |
gpg_keycache_t kc; |
1141 |
} |
int status=0, pos; |
1142 |
return TRUE; |
|
1143 |
|
kc = keycache_get_ctx (1); |
1144 |
case ID_KEYMISC_REBUILD: |
while (!gpg_keycache_next_updated_key (kc, &ctx, &status)) { |
1145 |
name=NULL; |
if (status == KC_FLAG_ADD) |
1146 |
gpg_rebuild_cache (&name); |
keylist_add_key (kmi->lv, KEYLIST_LIST, ctx, ctx->key); |
1147 |
if (name) { |
else { |
1148 |
char *p = strchr (name, '\n'); |
pos = find_keypos (kmi->lv, ctx->key); |
1149 |
show_msg (dlg, 2000, p? name + (p-name)+1 : name); |
if (pos != -1) |
1150 |
free (name); |
keylist_upd_key (kmi->lv, pos, ctx, ctx->key); |
1151 |
} |
} |
1152 |
return TRUE; |
} |
1153 |
|
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1154 |
case ID_KEYMISC_NEWKEY: |
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1155 |
memset (&genkey, 0, sizeof (genkey)); |
update_status_bar (kmi->statbar, kmi->lv); |
1156 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYGEN, dlg, |
keyring_check_last_access (); |
1157 |
keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"), |
SetForegroundWindow (kmi->dlg); |
1158 |
IDS_WINPT_KEYGEN); |
} |
1159 |
if (genkey.newkey != NULL) |
|
1160 |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
|
1161 |
return TRUE; |
/* Reload the key cache. */ |
1162 |
|
static void |
1163 |
case ID_KEYMISC_CARDNEW: |
keycache_reload (HWND dlg) |
1164 |
if( !scard_support ) { |
{ |
1165 |
msg_box( dlg, _("Smart Card support is not available."), _("Key Manager"), MB_INFO ); |
refresh_cache_s rcs; |
1166 |
return TRUE; |
|
1167 |
} |
memset (&rcs, 0, sizeof rcs); |
1168 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg, |
rcs.kring_update = 1; |
1169 |
card_keygen_dlg_proc, NULL, _("Card Key Generation"), |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
1170 |
IDS_WINPT_CARD_KEYGEN ); |
keycache_dlg_proc, (LPARAM)&rcs); |
1171 |
/* XXX: use new code */ |
} |
1172 |
if( keycache_get_reload() ) |
|
1173 |
send_cmd_id( dlg, ID_KEYMISC_RECACHE ); |
|
1174 |
return TRUE; |
/* Check if the secret keyring contains at least one |
1175 |
|
key with ultimate trust. |
1176 |
case ID_KEYMISC_KEYWIZARD: |
Return value: 0 on success. */ |
1177 |
memset (&genkey, 0, sizeof (genkey)); |
int |
1178 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, dlg, |
check_ultimate_trusted_key (gpg_keycache_t _sec) |
1179 |
keygen_wizard_dlg_proc, (LPARAM)&genkey, _("Key Generation Wizard"), |
{ |
1180 |
IDS_WINPT_KEYWIZARD); |
struct keycache_s *n; |
1181 |
if (genkey.newkey != NULL) |
int nkeys = 0; |
1182 |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
|
1183 |
return TRUE; |
for (n = _sec->item; n; n = n->next) { |
1184 |
|
if (n->pubpart && |
1185 |
case ID_KEYMISC_SENDRECV: |
n->pubpart->key->owner_trust == GPGME_VALIDITY_ULTIMATE) |
1186 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
return 0; |
1187 |
keyserver_dlg_proc, NULL, _("Keyserver Access"), |
nkeys++; |
1188 |
IDS_WINPT_KEYSERVER ); |
} |
1189 |
return TRUE; |
|
1190 |
|
/* if we do not have any secret keys, it does not make sense |
1191 |
case ID_KEYMISC_GPGPREFS: |
to return an error. */ |
1192 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, dlg, |
if (nkeys == 0) |
1193 |
gpgprefs_dlg_proc, NULL, _("GnuPG Preferences"), |
return 0; |
1194 |
IDS_WINPT_GPGPREFS ); |
return -1; |
1195 |
return TRUE; |
} |
1196 |
|
|
1197 |
case ID_KEYMISC_GPGOPT: |
|
1198 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGOPT, dlg, |
/* Reload the entire key cache and update the listview. */ |
1199 |
gpgopt_dlg_proc, NULL, _("GnuPG Options" ), |
static void |
1200 |
IDS_WINPT_GPGOPT ); |
reload_keycache (struct km_info_s *kmi) |
1201 |
return TRUE; |
{ |
1202 |
|
gpg_keycache_t c; |
1203 |
case ID_KEYMISC_IMPORT: |
|
1204 |
t = get_filename_dlg (dlg, FILE_OPEN, _("Choose Name of the Key File"), NULL, NULL); |
keycache_reload (kmi->dlg); |
1205 |
if (t) |
c = keycache_get_ctx (1); |
1206 |
km_file_import (dlg, t); |
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby); |
1207 |
return TRUE; |
update_status_bar (kmi->statbar, kmi->lv); |
1208 |
|
SetForegroundWindow (kmi->dlg); |
1209 |
case ID_KEYMISC_IMPORT_HTTP: |
keyring_check_last_access (); |
1210 |
url = (struct URL_ctx_s*)get_http_file_dlg (dlg); |
} |
1211 |
if (url->cancel == 0) |
|
1212 |
km_http_import (dlg, url->url); |
|
1213 |
delete url; url=NULL; |
/* Handle all import request. */ |
1214 |
break; |
static void |
1215 |
|
km_gui_import (struct km_info_s *kmi, int cmd_id, void *param) |
1216 |
case ID_KEYMISC_EXPORT: |
{ |
1217 |
idx = listview_get_curr_pos (kmi->lv); |
int newkeys = 0, newsks = 0; |
1218 |
if (idx == -1) { |
int err = 0; |
1219 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1220 |
return TRUE; |
switch (cmd_id) { |
1221 |
} |
case ID_KEYMISC_PASTE: |
1222 |
if (listview_count_items (kmi->lv, 1) > 1) |
err = km_clip_import (kmi->dlg, &newkeys, &newsks); |
1223 |
name = m_strdup ("Exported_GPG_Keys.asc"); |
break; |
1224 |
else { |
|
1225 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
case ID_KEYMISC_IMPORT: |
1226 |
name = gen_export_filename (keyid, 0); |
err = km_file_import (kmi->dlg, NULL, &newkeys, &newsks); |
1227 |
} |
break; |
1228 |
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
|
1229 |
free_if_alloc (name); |
case WM_DROPFILES: |
1230 |
if (t == NULL) |
err = km_dropped_file_import (kmi->dlg, (HDROP)param, |
1231 |
return TRUE; |
&newkeys, &newsks); |
1232 |
km_file_export (dlg, kmi->lv, t); |
break; |
1233 |
return TRUE; |
|
1234 |
|
default: |
1235 |
case ID_KEYMISC_EXPORT_PRIVKEY: |
err = 1; |
1236 |
idx = listview_get_curr_pos( kmi->lv ); |
break; |
1237 |
if( idx == -1 ) { |
} |
1238 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1239 |
return TRUE; |
if (!err && !newsks && (newkeys > 0 && newkeys < KM_PRELOAD_KEYS)) |
1240 |
} |
refresh_keylist (kmi); |
1241 |
if( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
else if (!err) /* avoid to spawn too much processes. */ |
1242 |
msg_box( dlg, _("There is no corresponding secret key for this key."), |
reload_keycache (kmi); |
1243 |
_("Key Manager"), MB_ERR ); |
SetForegroundWindow (kmi->dlg); |
1244 |
return TRUE; |
} |
1245 |
} |
|
1246 |
if( listview_count_items( kmi->lv, 1 ) > 1 ) { |
|
1247 |
msg_box( dlg, _("You can only export one secret key."), _("Key Manager"), MB_ERR ); |
/* Copy the requested key information (@what) to the clipboard. |
1248 |
return TRUE; |
If multiple items were selected, each key info is copied to |
1249 |
} |
the clipboard. The data is separated by \r\n. */ |
1250 |
idx = msg_box( dlg, |
static void |
1251 |
_("This operation will export your *SECRET* key!\n\n" |
copy_key_info (int what, struct km_info_s *kmi) |
1252 |
"Never send this key to ANYONE, it should be available\n" |
{ |
1253 |
"ONLY on your machine and you may use this function\n" |
gpgme_data_t out; |
1254 |
"to copy the key to a safe place.\n\n" |
gpgme_key_t key; |
1255 |
"Do you really want to export the key?"), |
struct keycache_s *kci = NULL; |
1256 |
_("WARNING"), MB_INFO|MB_YESNO ); |
size_t n=0; |
1257 |
if( idx == IDYES ) { |
char *p, tmp[256]; |
1258 |
idx = listview_get_curr_pos( kmi->lv ); |
int i=0, end = listview_count_items (kmi->lv, 0); |
1259 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof (keyid)-8 ); |
bool single = false; |
1260 |
name = gen_export_filename (keyid, 1); |
|
1261 |
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
/* Do not iterate over the entire list if just one item is selected. */ |
1262 |
if (t != NULL) |
n = listview_count_items (kmi->lv, 1); |
1263 |
km_privkey_export (dlg, kmi->lv, t); |
if (n == 1) { |
1264 |
} |
i = kmi->lv_idx; |
1265 |
break; |
end = i+1; |
1266 |
|
single = true; |
1267 |
case ID_KEYMISC_INFO: |
} |
1268 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, glob_hwnd, |
|
1269 |
about_winpt_dlg_proc, NULL, _("About WinPT"), |
gpgme_data_new (&out); |
1270 |
IDS_WINPT_ABOUT ); |
for (; i < end; i++) { |
1271 |
break; |
if (!listview_get_item_state (kmi->lv, i)) |
1272 |
|
continue; |
1273 |
case ID_KEYMISC_HELP: |
switch (what) { |
1274 |
ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW); |
|
1275 |
break; |
case ID_KEYCTX_EMAIL_COPY: |
1276 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1277 |
case ID_KEYMISC_OT: |
gpgme_data_write (out, key->uids->email, strlen (key->uids->email)); |
1278 |
dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_OWNERTRUST, glob_hwnd, |
if (!single) gpgme_data_write (out, "\r\n", 2); |
1279 |
ownertrust_dlg_proc, NULL, |
break; |
1280 |
_("Ownertrust"), IDS_WINPT_OWNERTRUST ); |
|
1281 |
break; |
case ID_KEYCTX_UID_COPY: |
1282 |
|
key = km_get_key_ptr (kmi->lv, i, &kci); |
1283 |
case ID_KEYMISC_EDITKEY: |
gpgme_data_write (out, kci->uids->uid, strlen (kci->uids->uid)); |
1284 |
idx = listview_get_curr_pos (kmi->lv); |
if (!single) gpgme_data_write (out, "\r\n", 2); |
1285 |
if (idx == -1) |
break; |
1286 |
break; |
|
1287 |
listview_get_item_text (kmi->lv, idx, 1, keyid, sizeof (keyid)-1); |
case ID_KEYCTX_KEYID_COPY: |
1288 |
/* XXX: pub/crd = secret key does not work */ |
key = km_get_key_ptr (kmi->lv, i, NULL); |
1289 |
memset (&k, 0, sizeof (k)); |
gpgme_data_write (out, "0x", 2); |
1290 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
gpgme_data_write (out, key->subkeys->keyid+8, 8); |
1291 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
if (!single) gpgme_data_write (out, "\r\n", 2); |
1292 |
k.keyid = keyid; |
break; |
1293 |
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
|
1294 |
k.flags = km_get_key_status (kmi->lv, idx); |
case ID_KEYCTX_FPR_COPY: |
1295 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT, dlg, |
key = km_get_key_ptr (kmi->lv, i, NULL); |
1296 |
keyedit_main_dlg_proc, (LPARAM)&k, |
gpgme_data_write (out, key->subkeys->fpr, strlen (key->subkeys->fpr)); |
1297 |
_("Key Edit"), IDS_KEYCTX_EDIT); |
if (!single) gpgme_data_write (out, "\r\n", 2); |
1298 |
if (k.update) |
break; |
1299 |
update_key (kmi->lv, idx, keyid, 1); |
|
1300 |
break; |
case ID_KEYCTX_KINFO_COPY: |
1301 |
|
key = km_get_key_ptr (kmi->lv, i, NULL); |
1302 |
case ID_KEYMISC_COPY: |
key_get_clip_info (key->subkeys->keyid+8, tmp, sizeof (tmp)-1); |
1303 |
km_index = listview_get_curr_pos (kmi->lv); |
gpgme_data_write (out, tmp, strlen (tmp)); |
1304 |
km_clip_export (dlg, kmi->lv); |
if (!single) gpgme_data_write (out, "\r\n", 2); |
1305 |
break; |
break; |
1306 |
|
} |
1307 |
case ID_KEYMISC_SELALL: |
} |
1308 |
listview_select_all (kmi->lv); |
gpgme_data_write (out, "\0", 1); |
1309 |
break; |
p = gpgme_data_release_and_get_mem (out, &n); |
1310 |
|
set_clip_text (NULL, p, n); |
1311 |
case ID_KEYMISC_PASTE: |
gpgme_free (p); |
1312 |
km_index = -1; |
} |
1313 |
km_clip_import (dlg); |
|
1314 |
break; |
|
1315 |
|
/* Dialog box procedure for the Key Manager. */ |
1316 |
case ID_KEYCTX_SETPREFKS: |
BOOL CALLBACK |
1317 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM(keyid)-1); |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
1318 |
memset (&k, 0, sizeof (k)); |
{ |
1319 |
k.keyid = keyid; |
HWND kl; |
1320 |
keyedit_set_pref_keyserver (&k, dlg); |
HMENU hm; |
1321 |
break; |
RECT r; |
1322 |
|
gpg_keycache_t c; |
1323 |
case ID_KEYMISC_REFRESH_KEYS: |
gpgme_key_t key; |
1324 |
if (listview_count_items (kmi->lv, 1) == 0) { |
km_info_t kmi = NULL; |
1325 |
msg_box (dlg, _("No key was selected, select all by default."), _("Key Manager"), MB_INFO); |
struct genkey_s genkey; |
1326 |
listview_select_all (kmi->lv); |
struct winpt_key_s k = {0}; |
1327 |
} |
struct URL_ctx_s *url; |
1328 |
km_refresh_from_keyserver (kmi->lv, dlg); |
char type[32], *name; |
1329 |
break; |
const char *t, *host; |
1330 |
|
WORD port = 0; |
1331 |
/** Context menu **/ |
int l_idx = 0, i=0, rc; |
1332 |
case ID_KEYCTX_EDIT: |
|
1333 |
send_cmd_id( dlg, ID_KEYMISC_EDITKEY ); |
if ((msg != WM_INITDIALOG) |
1334 |
break; |
&& ((kmi = (km_info_t)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
1335 |
|
return FALSE; |
1336 |
case ID_KEYCTX_PROPS: |
|
1337 |
send_cmd_id( dlg, ID_KEYMISC_PROPS ); |
/* handle dynamic popup items in the keyserver menu. */ |
1338 |
break; |
if (msg == WM_COMMAND && LOWORD (wparam) >= WM_APP && |
1339 |
|
LOWORD (wparam) <= WM_APP+MAX_KEYSERVERS) { |
1340 |
case ID_KEYCTX_UIDS: |
l_idx = LOWORD (wparam)-WM_APP; |
1341 |
send_cmd_id( dlg, ID_KEYMISC_UID ); |
if (l_idx < 0) |
1342 |
break; |
return TRUE; |
1343 |
|
host = kserver_get_hostname (l_idx, 0, &port); |
1344 |
case ID_KEYCTX_SIGN: |
if (host != NULL) |
1345 |
send_cmd_id( dlg, ID_KEYMISC_SIGN ); |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
1346 |
break; |
return TRUE; |
1347 |
|
} |
1348 |
case ID_KEYCTX_DEL: |
|
1349 |
send_cmd_id (dlg, ID_KEYMISC_DELETE); |
switch (msg) { |
1350 |
break; |
case WM_INITDIALOG: |
1351 |
|
kmi = new struct km_info_s; |
1352 |
case ID_KEYCTX_REV: |
memset (kmi, 0, sizeof (struct km_info_s)); |
1353 |
send_cmd_id( dlg, ID_KEYMISC_REVCERT ); |
kmi->lv_idx = -1; |
1354 |
break; |
kmi->hwnd_sep = regist_sep_wnd (dlg, kmi); |
1355 |
|
imagelist_load (dlg); |
1356 |
case ID_KEYCTX_SENDMAIL: |
translate_menu_strings (dlg); |
1357 |
km_send_to_mail_recipient (kmi->lv, dlg); |
SetWindowText (dlg, _("Key Manager")); |
1358 |
break; |
|
1359 |
|
c = keycache_get_ctx (KEYCACHE_PUB); |
1360 |
case ID_KEYCTX_KS_DEFAULT: |
kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST); |
1361 |
host = kserver_get_hostname (0, -1, &port); |
kmi->keylist_sortby = KEY_SORT_USERID; |
1362 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
Header_SetImageList(ListView_GetHeader (kl), glob_imagelist); |
1363 |
break; |
kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c, |
1364 |
|
NULL, KEYLIST_LIST, kmi->keylist_sortby); |
1365 |
case ID_KEYCTX_ADDKEY: |
if (check_ultimate_trusted_key (keycache_get_ctx (0))) { |
1366 |
idx = listview_get_curr_pos (kmi->lv); |
msg_box (dlg, _("No ultimately trusted key found.\n" |
1367 |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
"Please set at least one secret key to ultimate trust."), |
1368 |
memset (&k, 0, sizeof (k)); |
_("Key Manager"), MB_WARN); |
1369 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
} |
1370 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
/* init subclassing for the listview */ |
1371 |
k.keyid = keyid; |
keylist_proc.opaque = kmi; |
1372 |
keyedit_add_subkey (&k, dlg, NULL); |
keylist_proc.dlg = dlg; |
1373 |
if (k.update) |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
1374 |
update_key (kmi->lv, idx, keyid, 1); |
keylist_proc.old = (WNDPROC)GetWindowLong(kl, GWL_WNDPROC); |
1375 |
break; |
if (keylist_proc.old) { |
1376 |
|
if (!SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) { |
1377 |
case ID_KEYCTX_ADDUID: |
msg_box (dlg, "Could not set keylist window procedure.", |
1378 |
idx = listview_get_curr_pos (kmi->lv); |
_("Key Manager"), MB_ERR); |
1379 |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
BUG (NULL); |
1380 |
memset (&k, 0, sizeof (k)); |
} |
1381 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
} |
1382 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
1383 |
k.keyid = keyid; |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
1384 |
keyedit_add_userid (&k, dlg, NULL); |
kmi->toolbar = create_toolbar (dlg, kmi); |
1385 |
if (k.update) |
kmi->dlg = dlg; |
1386 |
update_key (kmi->lv, idx, keyid, 1); |
|
1387 |
break; |
do_center_window (dlg, kmi); |
1388 |
|
do_resize_window (dlg, kmi); |
1389 |
case ID_KEYCTX_ADDREV: |
restore_window_size (dlg, kmi); |
1390 |
idx = listview_get_curr_pos (kmi->lv); |
update_ui_items (dlg, kmi->lv); |
1391 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
restore_column_info (kmi); |
1392 |
memset (&k, 0, sizeof (k)); |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1393 |
k.keyid = keyid; |
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1394 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
|
1395 |
k.key_pair = km_check_for_seckey( kmi->lv, idx, NULL ); |
SendMessage (dlg, WM_SETICON, (WPARAM)ICON_SMALL, |
1396 |
keyedit_add_revoker (&k, dlg); |
(LPARAM)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT)); |
1397 |
if (k.update) |
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups")); |
1398 |
update_key (kmi->lv, idx, keyid, 1); |
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show")); |
1399 |
break; |
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New...")); |
1400 |
|
SetForegroundWindow (dlg); |
1401 |
case ID_KEYCTX_ADDPHOTO: |
kmi->magic = SetTimer (dlg, 1, 1000, NULL); |
1402 |
idx = listview_get_curr_pos (kmi->lv); |
return TRUE; |
1403 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
|
1404 |
memset (&k, 0, sizeof (k)); |
|
1405 |
k.keyid = keyid; |
case WM_TIMER: |
1406 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
KillTimer (dlg, kmi->magic); |
1407 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
SetForegroundWindow (dlg); |
1408 |
keyedit_add_photo (&k, dlg); |
break; |
1409 |
if (k.update) |
|
1410 |
update_key (kmi->lv, idx, keyid, 1); |
case WM_DESTROY: |
1411 |
break; |
save_column_info (kmi); |
1412 |
|
if (kmi->lv) { |
1413 |
case ID_KEYCTX_KS_NL: |
keylist_delete (kmi->lv); |
1414 |
case ID_KEYCTX_KS_PL: |
kmi->lv = NULL; |
1415 |
case ID_KEYCTX_KS_AT: |
} |
1416 |
case ID_KEYCTX_KS_DE: |
imagelist_destroy (); |
1417 |
case ID_KEYCTX_KS_DK: |
|
1418 |
case ID_KEYCTX_KS_CZ: |
ltoa (kmi->pos_x, type, 10); |
1419 |
case ID_KEYCTX_KS_ES: |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type); |
1420 |
case ID_KEYCTX_KS_UK: |
ltoa (kmi->pos_y, type, 10); |
1421 |
host = kserver_get_hostname (LOWORD (wparam) - 40107, 0, &port); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type); |
1422 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
|
1423 |
break; |
GetWindowRect (dlg, &r); |
1424 |
|
sprintf (type, "%d", (int)(r.bottom-r.top)); |
1425 |
case ID_KEYCTX_RECVFROM: |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Width", |
1426 |
km_refresh_from_keyserver (kmi->lv, dlg); |
type); |
1427 |
break; |
sprintf (type, "%d", (int)(r.right-r.left)); |
1428 |
|
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Size_Height", |
1429 |
case ID_KEYCTX_UID_COPY: |
type); |
1430 |
/* XXX: add generic function to support multiple selection |
|
1431 |
with a callback */ |
/* Remove runtime information. |
1432 |
idx = listview_get_curr_pos( kmi->lv ); |
This should be the last action taken here. */ |
1433 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid-1 ); |
delete kmi; |
1434 |
set_clip_text( NULL, uid, strlen( uid ) ); |
kmi = NULL; |
1435 |
break; |
SetWindowLong (dlg, GWL_USERDATA, 0); |
1436 |
|
return FALSE; |
1437 |
case ID_KEYCTX_KEYID_COPY: |
|
1438 |
idx = listview_get_curr_pos( kmi->lv ); |
case WM_MOVE: |
1439 |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
GetWindowRect (dlg, &r); |
1440 |
set_clip_text( NULL, uid, strlen( uid ) ); |
kmi->pos_x = r.left; |
1441 |
break; |
kmi->pos_y = r.top; |
1442 |
|
break; |
1443 |
case ID_KEYCTX_FPR_COPY: |
|
1444 |
idx = listview_get_curr_pos( kmi->lv ); |
|
1445 |
key = (gpgme_key_t) listview_get_item2 (kmi->lv, idx); |
case WM_RBUTTONUP: |
1446 |
if (key) { |
do_create_minpopup (dlg); |
1447 |
const char * s = get_key_fpr (key); |
break; |
1448 |
set_clip_text (NULL, s? s : "", s? strlen (s): 0); |
|
1449 |
} |
case WM_NOTIFY: |
1450 |
break; |
NMHDR *notify; |
1451 |
|
POINT p; |
1452 |
case ID_KEYCTX_KINFO_COPY: |
HMENU popup; |
1453 |
idx = listview_get_curr_pos( kmi->lv ); |
|
1454 |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
notify = (NMHDR *)lparam; |
1455 |
km_set_clip_info( uid ); |
if (!notify) |
1456 |
break; |
break; |
1457 |
|
switch (notify->code) { |
1458 |
case ID_KEYCTX_COPY: |
case TBN_QUERYDELETE: |
1459 |
km_index = listview_get_curr_pos (kmi->lv); |
SetWindowLong (dlg, DWL_MSGRESULT, TRUE); |
1460 |
km_clip_export (dlg, kmi->lv); |
return TRUE; |
1461 |
break; |
|
1462 |
|
case TBN_QUERYINSERT: |
1463 |
case ID_KEYCTX_PASTE: |
SetWindowLong (dlg, DWL_MSGRESULT, TRUE); |
1464 |
km_index = -1; |
return TRUE; |
1465 |
km_clip_import (dlg); |
|
1466 |
break; |
case TBN_GETBUTTONINFO: |
1467 |
|
LPTBNOTIFY lpTbNotify; |
1468 |
case ID_KEYCTX_DISABLE: |
lpTbNotify = (LPTBNOTIFY)lparam; |
1469 |
idx = listview_get_curr_pos (kmi->lv); |
if (lpTbNotify->iItem < (sizeof(tbb) / sizeof(tb_button_s))) { |
1470 |
km_enable_disable_key (kmi->lv, dlg, idx, 0); |
lpTbNotify->tbButton.iBitmap = imagelist_getindex (tbb[lpTbNotify->iItem].icon); |
1471 |
break; |
lpTbNotify->tbButton.idCommand = tbb[lpTbNotify->iItem].command; |
1472 |
|
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
1473 |
case ID_KEYCTX_ENABLE: |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
1474 |
idx = listview_get_curr_pos (kmi->lv); |
lpTbNotify->tbButton.iString = 0; |
1475 |
km_enable_disable_key (kmi->lv, dlg, idx, 1); |
strncpy (lpTbNotify->pszText, tbb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
1476 |
break; |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
1477 |
|
} |
1478 |
case ID_KEYCTX_LISTSIGS: |
return TRUE; |
1479 |
send_cmd_id (dlg, ID_KEYMISC_CHECKSIGS); |
|
1480 |
break; |
case TBN_RESET: /* Restore last saved toolbar status */ |
1481 |
|
TBSAVEPARAMS tbsp; |
1482 |
case ID_KEYCTX_MAXTRUST: |
|
1483 |
idx = listview_get_curr_pos (kmi->lv); |
tbsp.hkr = HKEY_CURRENT_USER; |
1484 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
tbsp.pszSubKey = "Software\\WinPT"; |
1485 |
rc = km_set_implicit_trust (dlg, kmi->lv, idx); |
tbsp.pszValueName = "KM_toolbar"; |
1486 |
if (!rc) |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp); |
1487 |
update_key (kmi->lv, idx, keyid, 0); |
break; |
1488 |
break; |
|
1489 |
|
case TBN_BEGINADJUST: /* User is about to change the toolbar. Save it */ |
1490 |
case ID_KEYCTX_SETDEFKEY: |
tbsp.hkr = HKEY_CURRENT_USER; |
1491 |
idx = listview_get_curr_pos (kmi->lv); |
tbsp.pszSubKey = "Software\\WinPT"; |
1492 |
if (!km_check_key_status (kmi->lv, idx)) { |
tbsp.pszValueName = "KM_toolbar"; |
1493 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
1494 |
rc = set_gnupg_default_key (keyid); |
break; |
1495 |
if (rc) |
|
1496 |
msg_box( dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR); |
case TBN_ENDADJUST: /* User has finished customizing the toolbar. Save it. */ |
1497 |
km_update_default_key_str (kmi->statbar); |
tbsp.hkr = HKEY_CURRENT_USER; |
1498 |
} |
tbsp.pszSubKey = "Software\\WinPT"; |
1499 |
break; |
tbsp.pszValueName = "KM_toolbar"; |
1500 |
|
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
1501 |
#if 0 /* XXX */ |
break; |
1502 |
case ID_GROUP_NEW: |
|
1503 |
memset (&gcb, 0, sizeof (gcb)); |
case TTN_GETDISPINFO: |
1504 |
gcb.gc = gc; |
LPTOOLTIPTEXT lpttt; |
1505 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GROUP, glob_hwnd, |
lpttt = (LPTOOLTIPTEXT)lparam; |
1506 |
group_manager_dlg_proc, (LPARAM)&gcb, _("New Group"), |
|
1507 |
IDS_WINPT_GROUP); |
lpttt->hinst = NULL; |
1508 |
if( gcb.use_name ) |
switch (lpttt->hdr.idFrom) { |
1509 |
treeview_add_item( GetDlgItem(dlg, IDC_KEYMISC_GROUP), NULL, gcb.name ); |
case ID_KEYMISC_KEYWIZARD: |
1510 |
return TRUE; |
lpttt->lpszText = (char*)_("Generate new key pair"); |
1511 |
|
break; |
1512 |
case ID_GROUP_PASTE: |
|
1513 |
km_groups_add (gc, kmi->lv, km_index); |
case ID_KEYMISC_SENDRECV: |
1514 |
break; |
lpttt->lpszText = (char*)_("Search for a specific key"); |
1515 |
|
break; |
1516 |
case ID_GROUP_DELETE: |
|
1517 |
km_groups_del (gc); |
case ID_KEYMISC_DELETE: |
1518 |
break; |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
1519 |
#endif |
break; |
1520 |
} |
|
1521 |
|
case ID_KEYMISC_PROPS: |
1522 |
break; |
lpttt->lpszText = (char *)_("Show key properties"); |
1523 |
} |
break; |
1524 |
|
|
1525 |
return FALSE; |
case ID_KEYMISC_SIGN: |
1526 |
} |
lpttt->lpszText = (char *)_("Sign key"); |
1527 |
|
break; |
1528 |
|
|
1529 |
|
case ID_KEYCTX_COPY: |
1530 |
|
lpttt->lpszText = (char *)_("Copy key to clipboard"); |
1531 |
|
break; |
1532 |
|
|
1533 |
|
case ID_KEYCTX_PASTE: |
1534 |
|
lpttt->lpszText = (char*)_("Paste key from clipboard"); |
1535 |
|
break; |
1536 |
|
|
1537 |
|
case ID_KEYMISC_IMPORT: |
1538 |
|
lpttt->lpszText = (char *)_("Import key to keyring"); |
1539 |
|
break; |
1540 |
|
|
1541 |
|
case ID_KEYMISC_EXPORT: |
1542 |
|
lpttt->lpszText = (char *)_("Export key to a file"); |
1543 |
|
break; |
1544 |
|
} |
1545 |
|
return TRUE; |
1546 |
|
|
1547 |
|
case LVN_ITEMCHANGED: |
1548 |
|
if (((LPNMLISTVIEW)lparam)->uNewState) { /* item selected? */ |
1549 |
|
kmi->lv_idx = listview_get_curr_pos (kmi->lv); |
1550 |
|
update_ui_items (dlg, kmi->lv); |
1551 |
|
return TRUE; |
1552 |
|
} |
1553 |
|
break; |
1554 |
|
|
1555 |
|
case NM_RCLICK: |
1556 |
|
if (!wait_for_progress_cb (0)) |
1557 |
|
break; |
1558 |
|
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1559 |
|
l_idx =listview_get_curr_pos (kmi->lv); |
1560 |
|
if (l_idx == -1) |
1561 |
|
return TRUE; /* Popup only when a item was selected */ |
1562 |
|
GetCursorPos (&p); |
1563 |
|
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYMISC_CTX)); |
1564 |
|
popup = GetSubMenu (hm, 0); |
1565 |
|
translate_popupmenu_strings (popup); |
1566 |
|
|
1567 |
|
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); |
1570 |
|
if (i == 0) |
1571 |
|
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
1572 |
|
if (!km_check_for_seckey (kmi->lv, l_idx, NULL) || |
1573 |
|
(km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED)) { |
1574 |
|
set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED); |
1575 |
|
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
1576 |
|
set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED); |
1577 |
|
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED); |
1578 |
|
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED ); |
1579 |
|
set_menu_state (popup, ID_KEYCTX_SETPREFKS, MF_DISABLED|MF_GRAYED); |
1580 |
|
} |
1581 |
|
else if (km_check_for_seckey (kmi->lv, l_idx, NULL) && |
1582 |
|
km_key_is_v3 (kmi->lv, l_idx)) { |
1583 |
|
/* PGP 2 keys, version 3 have no no support for photo-id's, |
1584 |
|
designated revokers and secondary keys. */ |
1585 |
|
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
1586 |
|
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED); |
1587 |
|
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED); |
1588 |
|
} |
1589 |
|
if (km_get_key_status( kmi->lv, l_idx ) & KM_FLAG_DISABLED) |
1590 |
|
set_menu_state (popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED); |
1591 |
|
else |
1592 |
|
set_menu_state (popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED); |
1593 |
|
if (km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED || |
1594 |
|
km_get_key_status (kmi->lv, l_idx) & KM_FLAG_EXPIRED) |
1595 |
|
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
1596 |
|
if (!clip_contains_pgpkey ()) |
1597 |
|
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED); |
1598 |
|
if (mapi_init ()) |
1599 |
|
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. */ |
1604 |
|
host = kserver_get_hostname (0, -1, &port); |
1605 |
|
if (!host) |
1606 |
|
host = DEF_HKP_KEYSERVER; |
1607 |
|
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host); |
1608 |
|
{ |
1609 |
|
HMENU ks = GetSubMenu (popup, 19); |
1610 |
|
for (i=0; server[i].name != NULL; i++) |
1611 |
|
insert_menu_item (ks, i+2, WM_APP+i, server[i].name); |
1612 |
|
} |
1613 |
|
popup_gpg_readonly (dlg, popup); |
1614 |
|
if (listview_count_items (kmi->lv, 1) > 1) |
1615 |
|
popup_multiple (dlg, popup); |
1616 |
|
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
1617 |
|
DestroyMenu (popup); |
1618 |
|
DestroyMenu (hm); |
1619 |
|
return TRUE; |
1620 |
|
} |
1621 |
|
break; |
1622 |
|
|
1623 |
|
case LVN_COLUMNCLICK: |
1624 |
|
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
1625 |
|
NMLISTVIEW *nft = (LPNMLISTVIEW) lparam; |
1626 |
|
int sortby = 0; |
1627 |
|
|
1628 |
|
if (!wait_for_progress_cb (0)) |
1629 |
|
break; |
1630 |
|
switch (nft->iSubItem) { |
1631 |
|
case 0: sortby = KEY_SORT_USERID; break; |
1632 |
|
case 1: sortby = KEY_SORT_KEYID; break; |
1633 |
|
case 2: sortby = KEY_SORT_IS_SECRET; break; |
1634 |
|
case 3: sortby = KEY_SORT_LEN; break; |
1635 |
|
case 5: sortby = KEY_SORT_VALIDITY; break; |
1636 |
|
case 6: sortby = KEY_SORT_OTRUST; break; |
1637 |
|
case 7: sortby = KEY_SORT_CREATED; break; |
1638 |
|
case 8: sortby = KEY_SORT_ALGO; break; |
1639 |
|
default: return TRUE; /*sortby userid.*/ |
1640 |
|
} |
1641 |
|
|
1642 |
|
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
1643 |
|
kmi->keylist_sortby ^= KEYLIST_SORT_DESC; |
1644 |
|
else |
1645 |
|
kmi->keylist_sortby = sortby; |
1646 |
|
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1647 |
|
km_gui_adjust_column_images (kmi->lv, kmi->keylist_sortby); |
1648 |
|
|
1649 |
|
return TRUE; |
1650 |
|
} |
1651 |
|
break; |
1652 |
|
} |
1653 |
|
break; |
1654 |
|
|
1655 |
|
case WM_WINDOWPOSCHANGING: |
1656 |
|
if (((WINDOWPOS*)lparam)->cx < 400) |
1657 |
|
((WINDOWPOS*)lparam)->cx = 400; |
1658 |
|
if (((WINDOWPOS*)lparam)->cy < 200) |
1659 |
|
((WINDOWPOS*)lparam)->cy = 200; |
1660 |
|
return TRUE; |
1661 |
|
|
1662 |
|
case WM_SIZE: |
1663 |
|
do_resize_window (dlg, kmi); |
1664 |
|
return TRUE; |
1665 |
|
|
1666 |
|
case WM_SYSCOMMAND: |
1667 |
|
if (LOWORD (wparam) == SC_CLOSE) |
1668 |
|
EndDialog (dlg, TRUE); |
1669 |
|
return FALSE; |
1670 |
|
|
1671 |
|
case WM_MENUSELECT: |
1672 |
|
change_edit_menu (kmi->lv, (HMENU)lparam, LOWORD (wparam)); |
1673 |
|
change_key_menu ((HMENU)lparam, LOWORD (wparam)); |
1674 |
|
break; |
1675 |
|
|
1676 |
|
case WM_INITMENUPOPUP: |
1677 |
|
hm = (HMENU)wparam; |
1678 |
|
if ((UINT)LOWORD (lparam) == 3) |
1679 |
|
set_menu_text_bypos (hm, 0, _("New")); |
1680 |
|
else if ((UINT)LOWORD (lparam) == 1) |
1681 |
|
set_menu_text_bypos (hm, 8, _("Preferences...")); |
1682 |
|
return FALSE; |
1683 |
|
|
1684 |
|
case WM_COMMAND: |
1685 |
|
/* Allow at least 'Exit' in such a case. */ |
1686 |
|
if (gnupg_access_keyring (1) && LOWORD (wparam) != ID_KEYMISC_QUIT) { |
1687 |
|
msg_box (dlg, _("Could not access public keyring"), |
1688 |
|
_("Key Manager"), MB_ERR); |
1689 |
|
return FALSE; |
1690 |
|
} |
1691 |
|
|
1692 |
|
/*wait_for_progress_cb ();*/ |
1693 |
|
switch (LOWORD (wparam)) { |
1694 |
|
case ID_KEYMISC_QUIT: |
1695 |
|
EndDialog (dlg, TRUE); |
1696 |
|
return TRUE; |
1697 |
|
|
1698 |
|
case ID_KEYMISC_FIND: |
1699 |
|
km_find_key (dlg, kmi->lv); |
1700 |
|
break; |
1701 |
|
|
1702 |
|
case ID_KEYMISC_DELETE: |
1703 |
|
case ID_KEYMISC_DELETE2: |
1704 |
|
if (!km_delete_keys (kmi->lv, dlg)) |
1705 |
|
update_status_bar (kmi->statbar, kmi->lv); |
1706 |
|
return TRUE; |
1707 |
|
|
1708 |
|
case ID_KEYMISC_SIGN: |
1709 |
|
if (kmi->lv_idx == -1) { |
1710 |
|
msg_box (dlg, _("Please select a key."), |
1711 |
|
_("Key Manager"), MB_ERR); |
1712 |
|
return TRUE; |
1713 |
|
} |
1714 |
|
if (km_check_key_status (kmi->lv, kmi->lv_idx)) |
1715 |
|
return TRUE; |
1716 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
1717 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIGN, dlg, |
1718 |
|
keysign_dlg_proc, (LPARAM)&k, |
1719 |
|
_("Key Signing"), IDS_WINPT_KEYSIGN); |
1720 |
|
if (k.update) |
1721 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
1722 |
|
return TRUE; |
1723 |
|
|
1724 |
|
case ID_KEYMISC_REVCERT: |
1725 |
|
if (kmi->lv_idx == -1) { |
1726 |
|
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
1727 |
|
return TRUE; |
1728 |
|
} |
1729 |
|
|
1730 |
|
{ |
1731 |
|
char state[64]; |
1732 |
|
listview_get_item_text (kmi->lv, kmi->lv_idx, 5, |
1733 |
|
state, sizeof (state) -1); |
1734 |
|
if (strchr (state, 'R' )) { |
1735 |
|
msg_box (dlg, _("Key already revoked!"), |
1736 |
|
_("Key Manager"), MB_INFO); |
1737 |
|
return TRUE; |
1738 |
|
} |
1739 |
|
} |
1740 |
|
|
1741 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
1742 |
|
if (!k.key_pair) { |
1743 |
|
msg_box (dlg, _("There is no secret key available!"), |
1744 |
|
_("Key Manager"), MB_ERR); |
1745 |
|
return TRUE; |
1746 |
|
} |
1747 |
|
dialog_box_param(glob_hinst, (LPCSTR)IDD_WINPT_KEYREVOKE, dlg, |
1748 |
|
key_revoke_dlg_proc, (LPARAM)&k, |
1749 |
|
_("Key Revocation Cert"), IDS_WINPT_KEYREVOKE); |
1750 |
|
return TRUE; |
1751 |
|
|
1752 |
|
case ID_KEYMISC_TRUSTPATH: |
1753 |
|
if (kmi->lv_idx == -1) { |
1754 |
|
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
1755 |
|
return TRUE; |
1756 |
|
} |
1757 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
1758 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
1759 |
|
keytrust_dlg_proc, (LPARAM)&k, |
1760 |
|
_("List Trust Path"), IDS_WINPT_KEYTRUST); |
1761 |
|
return TRUE; |
1762 |
|
|
1763 |
|
case ID_KEYMISC_CHECKSIGS: |
1764 |
|
if (kmi->lv_idx == -1) { |
1765 |
|
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
1766 |
|
return TRUE; |
1767 |
|
} |
1768 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
1769 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIG_TREE, dlg, |
1770 |
|
sigtree_dlg_proc, (LPARAM)&k, |
1771 |
|
_("Key Signature List"), IDS_WINPT_KEYSIG); |
1772 |
|
if (k.update) |
1773 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
1774 |
|
if (updated_keys_avail ()) |
1775 |
|
refresh_keylist (kmi); |
1776 |
|
return TRUE; |
1777 |
|
|
1778 |
|
case ID_KEYMISC_PROPS: |
1779 |
|
if (kmi->lv_idx == -1) { |
1780 |
|
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
1781 |
|
return TRUE; |
1782 |
|
} |
1783 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
1784 |
|
k.callback.ctl = kmi->lv; |
1785 |
|
k.callback.idx = kmi->lv_idx; |
1786 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYPROPS, dlg, |
1787 |
|
keyprops_dlg_proc, (LPARAM)&k, |
1788 |
|
_("Key Properties"), IDS_WINPT_KEYPROPS); |
1789 |
|
if (k.update) |
1790 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, k.key_pair); |
1791 |
|
return TRUE; |
1792 |
|
|
1793 |
|
case ID_KEYMISC_RECACHE: |
1794 |
|
if (updated_keys_avail ()) |
1795 |
|
l_idx = IDYES; |
1796 |
|
else { |
1797 |
|
l_idx = log_box (_("Key Manager"), MB_YESNO, |
1798 |
|
_("This is only useful when the keyring has been " |
1799 |
|
"modified (sign a key...).\n" |
1800 |
|
"Do you really want to reload the keycache?")); |
1801 |
|
} |
1802 |
|
if (l_idx == IDYES) |
1803 |
|
reload_keycache (kmi); |
1804 |
|
return TRUE; |
1805 |
|
|
1806 |
|
case ID_KEYMISC_REBUILD: |
1807 |
|
name = NULL; |
1808 |
|
gpg_rebuild_cache (&name); |
1809 |
|
if (name != NULL) { |
1810 |
|
char *line = strchr (name, '\n'); |
1811 |
|
show_msg (dlg, 2000, line? name + (line-name)+1 : name); |
1812 |
|
safe_free (name); |
1813 |
|
} |
1814 |
|
SetForegroundWindow (dlg); |
1815 |
|
return TRUE; |
1816 |
|
|
1817 |
|
case ID_KEYMISC_NEWKEY: |
1818 |
|
memset (&genkey, 0, sizeof (genkey)); |
1819 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYGEN, dlg, |
1820 |
|
keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"), |
1821 |
|
IDS_WINPT_KEYGEN); |
1822 |
|
if (genkey.cancel == 0) |
1823 |
|
refresh_keylist (kmi); |
1824 |
|
return TRUE; |
1825 |
|
|
1826 |
|
case ID_KEYMISC_CARDNEW: |
1827 |
|
if (!scard_support) { |
1828 |
|
msg_box (dlg, _("Smart Card support is not available."), |
1829 |
|
_("Key Manager"), MB_INFO); |
1830 |
|
return TRUE; |
1831 |
|
} |
1832 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg, |
1833 |
|
card_keygen_dlg_proc, 0, _("Card Key Generation"), |
1834 |
|
IDS_WINPT_CARD_KEYGEN); |
1835 |
|
if (updated_keys_avail ()) |
1836 |
|
send_cmd_id (dlg, ID_KEYMISC_RECACHE); |
1837 |
|
return TRUE; |
1838 |
|
|
1839 |
|
case ID_KEYMISC_KEYWIZARD: |
1840 |
|
memset (&genkey, 0, sizeof (genkey)); |
1841 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, dlg, |
1842 |
|
keygen_wizard_dlg_proc, (LPARAM)&genkey, |
1843 |
|
_("Key Generation Wizard"), |
1844 |
|
IDS_WINPT_KEYWIZARD); |
1845 |
|
if (genkey.cancel == 0) |
1846 |
|
refresh_keylist (kmi); |
1847 |
|
return TRUE; |
1848 |
|
|
1849 |
|
case ID_KEYMISC_SENDRECV: |
1850 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
1851 |
|
keyserver_dlg_proc, 0, _("Keyserver Access"), |
1852 |
|
IDS_WINPT_KEYSERVER); |
1853 |
|
refresh_keylist (kmi); |
1854 |
|
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: |
1863 |
|
rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, |
1864 |
|
dlg, gpgprefs_dlg_proc, 0, |
1865 |
|
_("GnuPG Preferences"), IDS_WINPT_GPGPREFS); |
1866 |
|
if (rc == TRUE) { |
1867 |
|
reload_keycache (kmi); |
1868 |
|
update_default_key_str (kmi->statbar); |
1869 |
|
} |
1870 |
|
return TRUE; |
1871 |
|
|
1872 |
|
case ID_KEYMISC_GPGOPT: |
1873 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGOPT, dlg, |
1874 |
|
gpgopt_dlg_proc, 0, _("GnuPG Options"), |
1875 |
|
IDS_WINPT_GPGOPT); |
1876 |
|
return TRUE; |
1877 |
|
|
1878 |
|
case ID_KEYMISC_IMPORT: |
1879 |
|
km_gui_import (kmi, LOWORD (wparam), NULL); |
1880 |
|
return TRUE; |
1881 |
|
|
1882 |
|
case ID_KEYMISC_IMPORT_HTTP: |
1883 |
|
url = (struct URL_ctx_s*)get_http_file_dlg (dlg); |
1884 |
|
if (url && url->cancel == 0) { |
1885 |
|
km_http_import (dlg, url->url); |
1886 |
|
refresh_keylist (kmi); |
1887 |
|
} |
1888 |
|
free_if_alloc (url); |
1889 |
|
break; |
1890 |
|
|
1891 |
|
case ID_KEYMISC_EXPORT: |
1892 |
|
if (kmi->lv_idx == -1) { |
1893 |
|
msg_box (dlg, _("Please select a key."), |
1894 |
|
_("Key Manager"), MB_ERR); |
1895 |
|
return TRUE; |
1896 |
|
} |
1897 |
|
if (listview_count_items (kmi->lv, 1) > 1) |
1898 |
|
name = m_strdup ("Exported_GPG_Keys.asc"); |
1899 |
|
else { |
1900 |
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
1901 |
|
name = km_gen_export_filename (key->subkeys->keyid+8, 0); |
1902 |
|
} |
1903 |
|
t = get_filesave_dlg (dlg, _("Choose Name for Key File"), NULL, name); |
1904 |
|
free_if_alloc (name); |
1905 |
|
if (t == NULL) |
1906 |
|
return TRUE; |
1907 |
|
km_file_export (dlg, kmi->lv, t); |
1908 |
|
return TRUE; |
1909 |
|
|
1910 |
|
case ID_KEYMISC_EXPORT_PRIVKEY: |
1911 |
|
if (kmi->lv_idx == -1) { |
1912 |
|
msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR); |
1913 |
|
return TRUE; |
1914 |
|
} |
1915 |
|
if( !km_check_for_seckey( kmi->lv, kmi->lv_idx, NULL ) ) { |
1916 |
|
msg_box (dlg, _("There is no corresponding secret key for this key."), |
1917 |
|
_("Key Manager"), MB_ERR); |
1918 |
|
return TRUE; |
1919 |
|
} |
1920 |
|
if (listview_count_items (kmi->lv, 1) > 1) { |
1921 |
|
msg_box (dlg, _("You can only export one secret key."), |
1922 |
|
_("Key Manager"), MB_ERR); |
1923 |
|
return TRUE; |
1924 |
|
} |
1925 |
|
i = msg_box (dlg, |
1926 |
|
_("This operation will export your *SECRET* key!\n\n" |
1927 |
|
"Never send this key to ANYONE, it should be available\n" |
1928 |
|
"ONLY on your machine and you may use this function\n" |
1929 |
|
"to copy the key to a safe place.\n\n" |
1930 |
|
"Do you really want to export the key?"), |
1931 |
|
_("WARNING"), MB_INFO|MB_YESNO); |
1932 |
|
if (i == IDYES) { |
1933 |
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
1934 |
|
name = km_gen_export_filename (key->subkeys->keyid+8, 1); |
1935 |
|
t = get_filesave_dlg (dlg, _("Choose Name for Key File"), NULL, name); |
1936 |
|
if (t != NULL) |
1937 |
|
km_privkey_export (dlg, kmi->lv, t); |
1938 |
|
} |
1939 |
|
return TRUE; |
1940 |
|
|
1941 |
|
case ID_KEYMISC_INFO: |
1942 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, dlg, |
1943 |
|
about_winpt_dlg_proc, 0, _("About WinPT"), |
1944 |
|
IDS_WINPT_ABOUT); |
1945 |
|
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: |
1953 |
|
ShellExecute (dlg, "open", "http://www.stud.uni-hannover.de/~twoaday/winpt.html", |
1954 |
|
NULL, NULL, SW_SHOW); |
1955 |
|
break; |
1956 |
|
|
1957 |
|
case ID_KEYMISC_HELP: |
1958 |
|
start_help (dlg, 0); |
1959 |
|
break; |
1960 |
|
|
1961 |
|
case ID_KEYMISC_OT: |
1962 |
|
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_OWNERTRUST, |
1963 |
|
dlg, ownertrust_dlg_proc, 0, |
1964 |
|
_("Ownertrust"), IDS_WINPT_OWNERTRUST); |
1965 |
|
break; |
1966 |
|
|
1967 |
|
case ID_KEYMISC_EDITKEY: |
1968 |
|
if (km_get_key (kmi->lv, kmi->lv_idx, &k)) |
1969 |
|
break; |
1970 |
|
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT, dlg, |
1971 |
|
keyedit_main_dlg_proc, (LPARAM)&k, |
1972 |
|
_("Key Edit"), IDS_KEYCTX_EDIT); |
1973 |
|
if (k.update) |
1974 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1); |
1975 |
|
break; |
1976 |
|
|
1977 |
|
case ID_KEYMISC_COPY: |
1978 |
|
km_clip_export (dlg, kmi->lv); |
1979 |
|
break; |
1980 |
|
|
1981 |
|
case ID_KEYMISC_SELALL: |
1982 |
|
listview_select_all (kmi->lv); |
1983 |
|
break; |
1984 |
|
|
1985 |
|
case ID_KEYMISC_PASTE: |
1986 |
|
km_gui_import (kmi, LOWORD (wparam), NULL); |
1987 |
|
break; |
1988 |
|
|
1989 |
|
case ID_KEYCTX_SETPREFKS: |
1990 |
|
if (km_get_key (kmi->lv, kmi->lv_idx, &k)) |
1991 |
|
break; |
1992 |
|
keyedit_set_pref_keyserver (&k, dlg); |
1993 |
|
break; |
1994 |
|
|
1995 |
|
case ID_KEYMISC_REFRESH_KEYS: |
1996 |
|
if (listview_count_items (kmi->lv, 1) == 0) { |
1997 |
|
msg_box (dlg, _("No key was selected, select all by default."), |
1998 |
|
_("Key Manager"), MB_INFO); |
1999 |
|
listview_select_all (kmi->lv); |
2000 |
|
} |
2001 |
|
if (!km_refresh_from_keyserver (kmi->lv, dlg)) |
2002 |
|
msg_box (dlg, _("Keyserver refresh finished."), |
2003 |
|
_("Key Manager"), MB_OK); |
2004 |
|
break; |
2005 |
|
|
2006 |
|
/** Context menu **/ |
2007 |
|
case ID_KEYCTX_EDIT: |
2008 |
|
send_cmd_id( dlg, ID_KEYMISC_EDITKEY ); |
2009 |
|
break; |
2010 |
|
|
2011 |
|
case ID_KEYCTX_PROPS: |
2012 |
|
send_cmd_id( dlg, ID_KEYMISC_PROPS ); |
2013 |
|
break; |
2014 |
|
|
2015 |
|
case ID_KEYCTX_UIDS: |
2016 |
|
send_cmd_id( dlg, ID_KEYMISC_UID ); |
2017 |
|
break; |
2018 |
|
|
2019 |
|
case ID_KEYCTX_SIGN: |
2020 |
|
send_cmd_id( dlg, ID_KEYMISC_SIGN ); |
2021 |
|
break; |
2022 |
|
|
2023 |
|
case ID_KEYCTX_DEL: |
2024 |
|
send_cmd_id (dlg, ID_KEYMISC_DELETE); |
2025 |
|
break; |
2026 |
|
|
2027 |
|
case ID_KEYCTX_REV: |
2028 |
|
send_cmd_id( dlg, ID_KEYMISC_REVCERT ); |
2029 |
|
break; |
2030 |
|
|
2031 |
|
case ID_KEYCTX_SENDMAIL: |
2032 |
|
km_send_to_mail_recipient (kmi->lv, dlg); |
2033 |
|
break; |
2034 |
|
|
2035 |
|
case ID_KEYCTX_KS_DEFAULT: |
2036 |
|
host = kserver_get_hostname (0, -1, &port); |
2037 |
|
km_send_to_keyserver (kmi->lv, dlg, host, port); |
2038 |
|
break; |
2039 |
|
|
2040 |
|
case ID_KEYCTX_ADDKEY: |
2041 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
2042 |
|
keyedit_add_subkey (&k, dlg, NULL); |
2043 |
|
if (k.update) |
2044 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1); |
2045 |
|
break; |
2046 |
|
|
2047 |
|
case ID_KEYCTX_ADDUID: |
2048 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
2049 |
|
keyedit_add_userid (&k, dlg, NULL); |
2050 |
|
if (k.update) |
2051 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1); |
2052 |
|
break; |
2053 |
|
|
2054 |
|
case ID_KEYCTX_ADDREV: |
2055 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
2056 |
|
keyedit_add_revoker (&k, dlg); |
2057 |
|
if (k.update) |
2058 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1); |
2059 |
|
break; |
2060 |
|
|
2061 |
|
case ID_KEYCTX_ADDPHOTO: |
2062 |
|
km_get_key (kmi->lv, kmi->lv_idx, &k); |
2063 |
|
keyedit_add_photo (&k, dlg); |
2064 |
|
if (k.update) |
2065 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1); |
2066 |
|
break; |
2067 |
|
|
2068 |
|
case ID_KEYCTX_RECVFROM: |
2069 |
|
km_refresh_from_keyserver (kmi->lv, dlg); |
2070 |
|
if (updated_keys_avail ()) |
2071 |
|
refresh_keylist (kmi); |
2072 |
|
break; |
2073 |
|
|
2074 |
|
case ID_KEYCTX_UID_COPY: |
2075 |
|
case ID_KEYCTX_KEYID_COPY: |
2076 |
|
case ID_KEYCTX_FPR_COPY: |
2077 |
|
case ID_KEYCTX_KINFO_COPY: |
2078 |
|
case ID_KEYCTX_EMAIL_COPY: |
2079 |
|
copy_key_info (LOWORD (wparam), kmi); |
2080 |
|
break; |
2081 |
|
|
2082 |
|
case ID_KEYCTX_COPY: |
2083 |
|
send_cmd_id (dlg, ID_KEYMISC_COPY); |
2084 |
|
break; |
2085 |
|
|
2086 |
|
case ID_KEYCTX_PASTE: |
2087 |
|
send_cmd_id (dlg, ID_KEYMISC_PASTE); |
2088 |
|
break; |
2089 |
|
|
2090 |
|
case ID_KEYCTX_DISABLE: |
2091 |
|
case ID_KEYCTX_ENABLE: |
2092 |
|
i = LOWORD (wparam) == ID_KEYCTX_ENABLE? 1 : 0; |
2093 |
|
if (km_get_key (kmi->lv, kmi->lv_idx, &k)) |
2094 |
|
break; |
2095 |
|
rc = km_enable_disable_key (kmi->lv, dlg, kmi->lv_idx, i); |
2096 |
|
if (!rc) |
2097 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
2098 |
|
break; |
2099 |
|
|
2100 |
|
case ID_KEYCTX_LISTSIGS: |
2101 |
|
send_cmd_id (dlg, ID_KEYMISC_CHECKSIGS); |
2102 |
|
break; |
2103 |
|
|
2104 |
|
case ID_KEYCTX_MAXTRUST: |
2105 |
|
if (km_get_key (kmi->lv, kmi->lv_idx, &k)) |
2106 |
|
break; |
2107 |
|
rc = km_set_implicit_trust (dlg, kmi->lv, kmi->lv_idx); |
2108 |
|
if (!rc) |
2109 |
|
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 0); |
2110 |
|
break; |
2111 |
|
|
2112 |
|
case ID_KEYCTX_SETDEFKEY: |
2113 |
|
if (!km_check_key_status (kmi->lv, kmi->lv_idx)) { |
2114 |
|
key = km_get_key_ptr (kmi->lv, kmi->lv_idx, NULL); |
2115 |
|
rc = set_gnupg_default_key (key->subkeys->keyid+8); |
2116 |
|
if (rc) |
2117 |
|
msg_box (dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR); |
2118 |
|
update_default_key_str (kmi->statbar); |
2119 |
|
} |
2120 |
|
break; |
2121 |
|
|
2122 |
|
case ID_KEYMISC_VIEWKEYID: |
2123 |
|
case ID_KEYMISC_VIEWCIPHER: |
2124 |
|
case ID_KEYMISC_VIEWTYPE: |
2125 |
|
case ID_KEYMISC_VIEWCREAT: |
2126 |
|
case ID_KEYMISC_VIEWDESC: |
2127 |
|
hm = GetMenu (dlg); |
2128 |
|
i = get_menu_state (hm, LOWORD (wparam)); |
2129 |
|
set_menu_state (hm, LOWORD (wparam), |
2130 |
|
i & MFS_CHECKED? MFS_UNCHECKED : MFS_CHECKED); |
2131 |
|
modify_listview_columns (kmi, LOWORD (wparam), !(i & MFS_CHECKED)); |
2132 |
|
break; |
2133 |
|
|
2134 |
|
case ID_GROUP_NEW: |
2135 |
|
case ID_GROUP_PASTE: |
2136 |
|
case ID_GROUP_DELETE: |
2137 |
|
case ID_GROUP_SHOW: |
2138 |
|
/* XXX: Implement group manager. */ |
2139 |
|
return TRUE; |
2140 |
|
} |
2141 |
|
|
2142 |
|
break; |
2143 |
|
} |
2144 |
|
|
2145 |
|
return FALSE; |
2146 |
|
} |