1 |
/* wptKeyManagerDlg.cpp - WinPT Key Manager |
/* wptKeyManagerDlg.cpp - WinPT Key Manager |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2005 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 |
|
|
22 |
#include <windows.h> |
#ifdef HAVE_CONFIG_H |
23 |
#include <commctrl.h> |
#include <config.h> |
24 |
|
#endif |
25 |
#include "../resource.h" |
|
26 |
#include "wptTypes.h" |
#include <windows.h> |
27 |
#include "wptGPG.h" |
#include <commctrl.h> |
28 |
#include "wptCommonCtl.h" |
|
29 |
#include "wptContext.h" /* for passphrase_s */ |
#include "resource.h" |
30 |
#include "wptDlgs.h" |
#include "wptTypes.h" |
31 |
#include "wptW32API.h" |
#include "wptGPG.h" |
32 |
#include "wptVersion.h" |
#include "wptCommonCtl.h" |
33 |
#include "wptKeylist.h" |
#include "wptContext.h" /* for passphrase_s */ |
34 |
#include "wptNLS.h" |
#include "wptDlgs.h" |
35 |
#include "wptErrors.h" |
#include "wptW32API.h" |
36 |
#include "wptHotkey.h" |
#include "wptVersion.h" |
37 |
#include "wptKeyManager.h" |
#include "wptKeylist.h" |
38 |
#include "wptKeyserver.h" |
#include "wptNLS.h" |
39 |
#include "wptKeyEdit.h" |
#include "wptErrors.h" |
40 |
#include "wptRegistry.h" |
#include "wptHotkey.h" |
41 |
|
#include "wptKeyManager.h" |
42 |
|
#include "wptKeyserver.h" |
43 |
#define WINDOWCLASS_SEPARATOR_CHILD "WINPT_SEP_CHILD" |
#include "wptKeyEdit.h" |
44 |
#define SEPARATOR_HEIGHT 5 |
#include "wptRegistry.h" |
45 |
|
|
46 |
void km_dump_key (gpgme_key_t key); |
#define KM_SEPARATOR_ID 10000 |
47 |
|
#define WINDOWCLASS_SEPARATOR_CHILD "WINPT_SEP_CHILD" |
48 |
//int treeview_add_item (HWND tree, HTREEITEM parent, const char * text); |
//#define KM_SEPARATOR_HEIGHT 5 |
49 |
|
|
50 |
static subclass_s keylist_proc; |
|
51 |
static int km_index = -1; |
static subclass_s keylist_proc; |
52 |
|
static int km_index = -1; |
53 |
HIMAGELIST glob_imagelist; |
|
54 |
|
HIMAGELIST glob_imagelist; |
55 |
struct km_info { |
|
56 |
/* Window positions */ |
struct km_info { |
57 |
int pos_x, pos_y; |
/* Window positions */ |
58 |
int ypos_sep; |
int pos_x, pos_y; |
59 |
int ypercent_sep; |
int ypos_sep; |
60 |
|
int ypercent_sep; |
61 |
HWND hwnd_sep; |
|
62 |
HWND toolbar; |
HWND hwnd_sep; |
63 |
HWND statbar; |
HWND toolbar; |
64 |
|
HWND statbar; |
65 |
listview_ctrl_t lv; |
|
66 |
int keylist_sortby; |
listview_ctrl_t lv; |
67 |
}; |
int keylist_sortby; |
68 |
|
}; |
69 |
struct mybuttons { |
|
70 |
long icon; |
struct mybuttons { |
71 |
long command; |
long icon; |
72 |
char *text; |
long command; |
73 |
}; |
char *text; |
74 |
|
}; |
75 |
struct mybuttons myb[] = { |
|
76 |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
struct mybuttons myb[] = { |
77 |
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
{IMI_KEY_DELETE, ID_KEYMISC_DELETE, "Delete"}, |
78 |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
{IMI_KEY_PROPS, ID_KEYMISC_PROPS, "Properties"}, |
79 |
{IMI_KEY_IMPORT, ID_KEYMISC_IMPORT, "Import"}, |
{IMI_KEY_SIGN, ID_KEYMISC_SIGN, "Sign"}, |
80 |
{IMI_KEY_EXPORT, ID_KEYMISC_EXPORT, "Export"}, |
{IMI_KEY_IMPORT, ID_KEYMISC_IMPORT, "Import"}, |
81 |
}; |
{IMI_KEY_EXPORT, ID_KEYMISC_EXPORT, "Export"}, |
82 |
|
}; |
83 |
|
|
84 |
#ifndef VK_F |
|
85 |
#define VK_F 70 |
#ifndef VK_F |
86 |
#endif |
#define VK_F 70 |
87 |
#ifndef VK_A |
#endif |
88 |
#define VK_A 65 |
#ifndef VK_A |
89 |
#endif |
#define VK_A 65 |
90 |
#ifndef VK_C |
#endif |
91 |
#define VK_C 67 |
#ifndef VK_C |
92 |
#endif |
#define VK_C 67 |
93 |
#ifndef VK_P |
#endif |
94 |
#define VK_P 80 |
#ifndef VK_P |
95 |
#endif |
#define VK_P 80 |
96 |
|
#endif |
97 |
static BOOL CALLBACK |
|
98 |
keylist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
static BOOL CALLBACK |
99 |
{ |
keylist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
100 |
struct listview_ctrl_s lv; |
{ |
101 |
|
struct listview_ctrl_s lv; |
102 |
switch (msg) { |
|
103 |
case WM_LBUTTONDBLCLK: |
switch (msg) { |
104 |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS); |
case WM_LBUTTONDBLCLK: |
105 |
break; |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS); |
106 |
|
break; |
107 |
case WM_KEYUP: |
|
108 |
int virt_key = (int)wparam; |
case WM_KEYUP: |
109 |
switch (virt_key) { |
int virt_key = (int)wparam; |
110 |
case VK_SPACE: |
switch (virt_key) { |
111 |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_PROPS ); |
case VK_SPACE: |
112 |
break; |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_PROPS ); |
113 |
|
break; |
114 |
case VK_DELETE: |
|
115 |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_DELETE ); |
case VK_DELETE: |
116 |
break; |
send_cmd_id( keylist_proc.dlg, ID_KEYMISC_DELETE ); |
117 |
|
break; |
118 |
case VK_INSERT: |
|
119 |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PASTE); |
case VK_INSERT: |
120 |
break; |
send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PASTE); |
121 |
|
break; |
122 |
case VK_A: |
|
123 |
if (GetAsyncKeyState (VK_CONTROL)) { |
case VK_A: |
124 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
if (GetAsyncKeyState (VK_CONTROL)) { |
125 |
listview_select_all (&lv); |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
126 |
} |
listview_select_all (&lv); |
127 |
break; |
} |
128 |
|
break; |
129 |
case VK_C: |
|
130 |
if (GetAsyncKeyState (VK_CONTROL)) { |
case VK_C: |
131 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
if (GetAsyncKeyState (VK_CONTROL)) { |
132 |
km_index = listview_get_curr_pos (&lv); |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
133 |
km_clip_export (keylist_proc.dlg, &lv); |
km_index = listview_get_curr_pos (&lv); |
134 |
} |
km_clip_export (keylist_proc.dlg, &lv); |
135 |
break; |
} |
136 |
|
break; |
137 |
case VK_P: |
|
138 |
if (GetAsyncKeyState (VK_CONTROL)) { |
case VK_P: |
139 |
km_index = -1; |
if (GetAsyncKeyState (VK_CONTROL)) { |
140 |
km_clip_import (keylist_proc.dlg); |
km_index = -1; |
141 |
} |
km_clip_import (keylist_proc.dlg); |
142 |
break; |
} |
143 |
|
break; |
144 |
case VK_F: |
|
145 |
if (GetAsyncKeyState (VK_CONTROL)) { |
case VK_F: |
146 |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
if (GetAsyncKeyState (VK_CONTROL)) { |
147 |
km_find_key (dlg, &lv); |
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST); |
148 |
} |
km_find_key (dlg, &lv); |
149 |
break; |
} |
150 |
} |
break; |
151 |
break; |
} |
152 |
} |
break; |
153 |
|
} |
154 |
return CallWindowProc( keylist_proc.old, dlg, msg, wparam, lparam ); |
|
155 |
} /* keylist_subclass_proc */ |
return CallWindowProc( keylist_proc.old, dlg, msg, wparam, lparam ); |
156 |
|
} /* keylist_subclass_proc */ |
157 |
|
|
158 |
static HWND |
|
159 |
load_toolbar (HWND dlg, struct km_info * kmi) |
static HWND |
160 |
{ |
load_toolbar (HWND dlg, struct km_info * kmi) |
161 |
HWND tbwnd; |
{ |
162 |
TBSAVEPARAMS tbsp; |
HWND tbwnd; |
163 |
TBBUTTON tb_buttons[] = { |
TBSAVEPARAMS tbsp; |
164 |
/*{imagelist_getindex(IMI_EXIT), ID_KEYMISC_QUIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0L, 0},*/ |
TBBUTTON tb_buttons[] = { |
165 |
{imagelist_getindex(IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
/*{imagelist_getindex(IMI_EXIT), ID_KEYMISC_QUIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0L, 0},*/ |
166 |
{imagelist_getindex(IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{imagelist_getindex(IMI_KEY_DELETE), ID_KEYMISC_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
167 |
{imagelist_getindex(IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{imagelist_getindex(IMI_KEY_PROPS), ID_KEYMISC_PROPS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
168 |
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
{imagelist_getindex(IMI_KEY_SIGN), ID_KEYMISC_SIGN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
169 |
{imagelist_getindex(IMI_KEY_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{0, 0, 0, TBSTYLE_SEP, {0}, 0L, 0}, |
170 |
{imagelist_getindex(IMI_KEY_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
{imagelist_getindex(IMI_KEY_IMPORT), ID_KEYMISC_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
171 |
}; |
{imagelist_getindex(IMI_KEY_EXPORT), ID_KEYMISC_EXPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0L, 0}, |
172 |
|
}; |
173 |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
|
174 |
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
tbwnd = CreateWindowEx (0, TOOLBARCLASSNAME, NULL, |
175 |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE, |
176 |
if (tbwnd) { |
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL); |
177 |
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
if (tbwnd) { |
178 |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); |
179 |
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist); |
180 |
ShowWindow (tbwnd, SW_SHOW); |
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0); |
181 |
|
ShowWindow (tbwnd, SW_SHOW); |
182 |
/* Restore toolbar */ |
|
183 |
tbsp.hkr = HKEY_CURRENT_USER; |
/* Restore toolbar */ |
184 |
tbsp.pszSubKey = "Software\\WinPT"; |
tbsp.hkr = HKEY_CURRENT_USER; |
185 |
tbsp.pszValueName = "KM_toolbar"; |
tbsp.pszSubKey = "Software\\WinPT"; |
186 |
if (SendMessage(tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp ) == 0) |
tbsp.pszValueName = "KM_toolbar"; |
187 |
SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]), (LONG)&tb_buttons[0]); |
if (SendMessage(tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp ) == 0) |
188 |
} |
SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]), (LONG)&tb_buttons[0]); |
189 |
return tbwnd; |
} |
190 |
} /* load_toolbar */ |
return tbwnd; |
191 |
|
} /* load_toolbar */ |
192 |
|
|
193 |
static void |
|
194 |
do_center_window (HWND dlg, struct km_info * kmi) |
static void |
195 |
{ |
do_center_window (HWND dlg, struct km_info * kmi) |
196 |
RECT rect; |
{ |
197 |
char * p; |
RECT rect; |
198 |
int pos_x = 0, pos_y = 0; |
char * p; |
199 |
|
int pos_x = 0, pos_y = 0; |
200 |
/* Find bottom of keylist */ |
|
201 |
GetWindowRect (GetDlgItem(dlg, IDC_KEYMISC_KEYLIST), &rect); |
/* Find bottom of keylist */ |
202 |
MapWindowPoints (NULL, dlg, (POINT*)&rect, 2); |
GetWindowRect (GetDlgItem(dlg, IDC_KEYMISC_KEYLIST), &rect); |
203 |
|
MapWindowPoints (NULL, dlg, (POINT*)&rect, 2); |
204 |
kmi->ypos_sep = rect.bottom; |
|
205 |
|
kmi->ypos_sep = rect.bottom; |
206 |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X" ); |
|
207 |
if( p && !strcmp( p, " " ) ) { |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X" ); |
208 |
free_if_alloc( p ); |
if( p && !strcmp( p, " " ) ) { |
209 |
center_window( dlg, NULL ); |
free_if_alloc( p ); |
210 |
return; |
center_window( dlg, NULL ); |
211 |
} |
return; |
212 |
else if( p ) |
} |
213 |
pos_x = atol( p ); |
else if( p ) |
214 |
|
pos_x = atol( p ); |
215 |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y" ); |
|
216 |
if( p && !strcmp( p, " " ) ) { |
p = get_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y" ); |
217 |
free_if_alloc( p ); |
if( p && !strcmp( p, " " ) ) { |
218 |
center_window( dlg, NULL ); |
free_if_alloc( p ); |
219 |
return; |
center_window( dlg, NULL ); |
220 |
} |
return; |
221 |
else if( p ) |
} |
222 |
pos_y = atol( p ); |
else if( p ) |
223 |
|
pos_y = atol( p ); |
224 |
if( !pos_y && !pos_x ) { |
|
225 |
center_window( dlg, NULL ); |
if( !pos_y && !pos_x ) { |
226 |
return; |
center_window( dlg, NULL ); |
227 |
} |
return; |
228 |
|
} |
229 |
if( pos_x > GetSystemMetrics( SM_CXSCREEN ) |
|
230 |
|| pos_y > GetSystemMetrics( SM_CYSCREEN ) ) { |
if( pos_x > GetSystemMetrics( SM_CXSCREEN ) |
231 |
pos_x = pos_y = 0; |
|| pos_y > GetSystemMetrics( SM_CYSCREEN ) ) { |
232 |
} |
pos_x = pos_y = 0; |
233 |
GetClientRect( dlg, &rect ); |
} |
234 |
MoveWindow( dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE ); |
GetClientRect( dlg, &rect ); |
235 |
} |
MoveWindow( dlg, pos_x, pos_y, rect.right, rect.bottom, TRUE ); |
236 |
|
} |
237 |
|
|
238 |
static void |
|
239 |
do_resize_window( HWND dlg, struct km_info *kmi) |
static void |
240 |
{ |
do_resize_window( HWND dlg, struct km_info *kmi) |
241 |
HWND h; |
{ |
242 |
RECT rclient, rect; |
HWND h; |
243 |
BOOL bRepaint = FALSE; |
RECT rclient, rect; |
244 |
|
BOOL bRepaint = FALSE; |
245 |
/* Get rect of client area and make life easier */ |
|
246 |
GetClientRect( dlg, &rclient ); |
/* Get rect of client area and make life easier */ |
247 |
|
GetClientRect( dlg, &rclient ); |
248 |
/* Move toolbar to the top of the window */ |
|
249 |
if (kmi->toolbar) { |
/* Move toolbar to the top of the window */ |
250 |
GetWindowRect(kmi->toolbar, &rect); |
if (kmi->toolbar) { |
251 |
ScreenToClient(dlg, (POINT*)&rect); |
GetWindowRect(kmi->toolbar, &rect); |
252 |
ScreenToClient(dlg, (POINT*)&(rect.right)); |
ScreenToClient(dlg, (POINT*)&rect); |
253 |
|
ScreenToClient(dlg, (POINT*)&(rect.right)); |
254 |
rclient.top += rect.bottom - rect.top; |
|
255 |
MoveWindow (kmi->toolbar, 0, 0, rclient.right - rclient.left, |
rclient.top += rect.bottom - rect.top; |
256 |
rect.bottom - rect.top, bRepaint); |
MoveWindow (kmi->toolbar, 0, 0, rclient.right - rclient.left, |
257 |
} |
rect.bottom - rect.top, bRepaint); |
258 |
|
} |
259 |
/* Move statusbar to the bottom of the window */ |
|
260 |
if (kmi->statbar) { |
/* Move statusbar to the bottom of the window */ |
261 |
GetWindowRect( kmi->statbar, &rect ); |
if (kmi->statbar) { |
262 |
ScreenToClient(dlg, (POINT*)&rect); |
GetWindowRect( kmi->statbar, &rect ); |
263 |
ScreenToClient(dlg, (POINT*)&(rect.right)); |
ScreenToClient(dlg, (POINT*)&rect); |
264 |
|
ScreenToClient(dlg, (POINT*)&(rect.right)); |
265 |
rclient.bottom -= rect.bottom - rect.top; |
|
266 |
MoveWindow (kmi->statbar, 0, rclient.bottom, rclient.right - rclient.left, |
rclient.bottom -= rect.bottom - rect.top; |
267 |
rect.bottom - rect.top, bRepaint); |
MoveWindow (kmi->statbar, 0, rclient.bottom, rclient.right - rclient.left, |
268 |
} |
rect.bottom - rect.top, bRepaint); |
269 |
|
} |
270 |
// Obtain separator information and move it to the desired posistion |
|
271 |
if (kmi->ypercent_sep) |
// Obtain separator information and move it to the desired posistion |
272 |
kmi->ypos_sep = (rclient.bottom - rclient.top) * kmi->ypercent_sep / 100; |
if (kmi->ypercent_sep) |
273 |
else |
kmi->ypos_sep = (rclient.bottom - rclient.top) * kmi->ypercent_sep / 100; |
274 |
kmi->ypercent_sep = kmi->ypos_sep * 100 / (rclient.bottom - rclient.top); |
else |
275 |
|
kmi->ypercent_sep = kmi->ypos_sep * 100 / (rclient.bottom - rclient.top); |
276 |
// Don't move away |
|
277 |
if (kmi->ypos_sep+5 > rclient.bottom) |
// Don't move away |
278 |
kmi->ypos_sep = rclient.bottom - 5; |
if (kmi->ypos_sep+5 > rclient.bottom) |
279 |
if (kmi->ypos_sep < rclient.top) |
kmi->ypos_sep = rclient.bottom - 5; |
280 |
kmi->ypos_sep = rclient.top; |
if (kmi->ypos_sep < rclient.top) |
281 |
MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep, (rclient.right - rclient.left), 5, bRepaint); |
kmi->ypos_sep = rclient.top; |
282 |
|
MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep, (rclient.right - rclient.left), 5, bRepaint); |
283 |
// Place the keylist above the separator |
|
284 |
h = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
// Place the keylist above the separator |
285 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
h = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
286 |
kmi->ypos_sep - rclient.top, bRepaint); |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
287 |
rclient.top = kmi->ypos_sep + 5 + 8; |
kmi->ypos_sep - rclient.top, bRepaint); |
288 |
|
rclient.top = kmi->ypos_sep + 5 + 8; |
289 |
/* Place the group text and the group box below the separator */ |
|
290 |
h = GetDlgItem( dlg, IDC_KEYMISC_GTEXT ); |
/* Place the group text and the group box below the separator */ |
291 |
MoveWindow( h, rclient.left, rclient.top, 100, 14, bRepaint); |
h = GetDlgItem( dlg, IDC_KEYMISC_GTEXT ); |
292 |
rclient.top += 18; |
MoveWindow( h, rclient.left, rclient.top, 100, 14, bRepaint); |
293 |
|
rclient.top += 18; |
294 |
h = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
|
295 |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
h = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
296 |
(rclient.bottom < rclient.top) ? 0 : rclient.bottom - rclient.top, bRepaint); |
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left, |
297 |
|
(rclient.bottom < rclient.top) ? 0 : rclient.bottom - rclient.top, bRepaint); |
298 |
/* Repaint the whole thing */ |
|
299 |
InvalidateRect (dlg, NULL, TRUE); |
/* Repaint the whole thing */ |
300 |
} /* do_resize_window */ |
InvalidateRect (dlg, NULL, TRUE); |
301 |
|
} /* do_resize_window */ |
302 |
|
|
303 |
static void |
|
304 |
do_create_minpopup (HWND dlg) |
static void |
305 |
{ |
do_create_minpopup (HWND dlg) |
306 |
HMENU hm; |
{ |
307 |
MENUITEMINFO mi; |
HMENU hm; |
308 |
char * s; |
MENUITEMINFO mi; |
309 |
POINT p; |
char * s; |
310 |
|
POINT p; |
311 |
if (gpg_read_only) |
|
312 |
return; |
if (gpg_read_only) |
313 |
hm = CreatePopupMenu (); |
return; |
314 |
if (!hm) |
hm = CreatePopupMenu (); |
315 |
BUG( NULL ); |
if (!hm) |
316 |
memset (&mi, 0, sizeof mi); |
BUG( NULL ); |
317 |
mi.cbSize = sizeof mi; |
memset (&mi, 0, sizeof mi); |
318 |
s = (char *)_("Paste Key from Clipboard"); |
mi.cbSize = sizeof mi; |
319 |
mi.fType = MF_STRING; |
s = (char *)_("Paste Key from Clipboard"); |
320 |
mi.dwTypeData = s; |
mi.fType = MF_STRING; |
321 |
mi.cch = strlen (s); |
mi.dwTypeData = s; |
322 |
mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; |
mi.cch = strlen (s); |
323 |
mi.wID = ID_KEYCTX_PASTE; |
mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; |
324 |
InsertMenuItem (hm, 0, FALSE, &mi); |
mi.wID = ID_KEYCTX_PASTE; |
325 |
GetCursorPos (&p); |
InsertMenuItem (hm, 0, FALSE, &mi); |
326 |
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL); |
GetCursorPos (&p); |
327 |
DestroyMenu (hm); |
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL); |
328 |
} /* do_create_minpopup */ |
DestroyMenu (hm); |
329 |
|
} /* do_create_minpopup */ |
330 |
|
|
331 |
static void |
|
332 |
do_check_cache( listview_ctrl_t lv, HWND dlg, HWND sb ) |
static void |
333 |
{ |
do_check_cache (listview_ctrl_t lv, HWND dlg, HWND sb) |
334 |
gpgme_keycache_t cache; |
{ |
335 |
|
gpg_keycache_t cache; |
336 |
if( keycache_get_reload( ) ) { |
|
337 |
keycache_reload( dlg ); |
if( keycache_get_reload( ) ) { |
338 |
keycache_set_reload( 0 ); |
keycache_reload( dlg ); |
339 |
cache = keycache_get_ctx( 1 ); |
keycache_set_reload( 0 ); |
340 |
if( !cache ) |
cache = keycache_get_ctx( 1 ); |
341 |
BUG( dlg ); |
if( !cache ) |
342 |
keylist_reload( lv, cache, KEYLIST_LIST, KEY_SORT_USERID ); |
BUG( dlg ); |
343 |
km_complete_status_bar (sb, lv); |
keylist_reload( lv, cache, KEYLIST_LIST, KEY_SORT_USERID ); |
344 |
} |
km_complete_status_bar (sb, lv); |
345 |
} /* do_check_cache */ |
} |
346 |
|
} /* do_check_cache */ |
347 |
|
|
348 |
long CALLBACK |
|
349 |
separator_wnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) |
long CALLBACK |
350 |
{ |
separator_wnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) |
351 |
static POINT last_mouse_pos; |
{ |
352 |
|
static POINT last_mouse_pos; |
353 |
if (msg == WM_CREATE) |
|
354 |
SetWindowLong (hwnd, GWL_USERDATA, (long)(((CREATESTRUCT*)lparam)->lpCreateParams)); |
if (msg == WM_CREATE) |
355 |
|
SetWindowLong (hwnd, GWL_USERDATA, (long)(((CREATESTRUCT*)lparam)->lpCreateParams)); |
356 |
switch (msg) { |
|
357 |
case WM_PAINT: |
switch (msg) { |
358 |
PAINTSTRUCT ps; |
case WM_PAINT: |
359 |
RECT rect; |
PAINTSTRUCT ps; |
360 |
HPEN hpen; |
RECT rect; |
361 |
|
HPEN hpen; |
362 |
GetClientRect (hwnd, &rect); |
|
363 |
BeginPaint (hwnd, &ps); |
GetClientRect (hwnd, &rect); |
364 |
|
BeginPaint (hwnd, &ps); |
365 |
// Background |
|
366 |
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
// Background |
367 |
|
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1)); |
368 |
// The lines from the light into the dark |
|
369 |
MoveToEx(ps.hdc, 0,0, NULL); |
// The lines from the light into the dark |
370 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) { |
MoveToEx(ps.hdc, 0,0, NULL); |
371 |
SelectObject(ps.hdc, (LPVOID)hpen); |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) { |
372 |
LineTo(ps.hdc, rect.right, 0); |
SelectObject(ps.hdc, (LPVOID)hpen); |
373 |
DeleteObject(hpen); |
LineTo(ps.hdc, rect.right, 0); |
374 |
} |
DeleteObject(hpen); |
375 |
MoveToEx(ps.hdc, 0, 1, NULL); |
} |
376 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) { |
MoveToEx(ps.hdc, 0, 1, NULL); |
377 |
SelectObject(ps.hdc, (LPVOID)hpen); |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) { |
378 |
LineTo(ps.hdc, rect.right, rect.bottom); |
SelectObject(ps.hdc, (LPVOID)hpen); |
379 |
DeleteObject(hpen); |
LineTo(ps.hdc, rect.right, rect.bottom); |
380 |
} |
DeleteObject(hpen); |
381 |
|
} |
382 |
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL); |
|
383 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) { |
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL); |
384 |
SelectObject(ps.hdc, (LPVOID)hpen); |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) { |
385 |
LineTo(ps.hdc, rect.right, rect.bottom-1); |
SelectObject(ps.hdc, (LPVOID)hpen); |
386 |
DeleteObject(hpen); |
LineTo(ps.hdc, rect.right, rect.bottom-1); |
387 |
} |
DeleteObject(hpen); |
388 |
MoveToEx(ps.hdc, 0, rect.bottom, NULL); |
} |
389 |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) { |
MoveToEx(ps.hdc, 0, rect.bottom, NULL); |
390 |
SelectObject(ps.hdc, (LPVOID)hpen); |
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) { |
391 |
LineTo(ps.hdc, rect.right, rect.bottom); |
SelectObject(ps.hdc, (LPVOID)hpen); |
392 |
DeleteObject(hpen); |
LineTo(ps.hdc, rect.right, rect.bottom); |
393 |
} |
DeleteObject(hpen); |
394 |
|
} |
395 |
EndPaint (hwnd, &ps); |
|
396 |
return 0; |
EndPaint (hwnd, &ps); |
397 |
|
return 0; |
398 |
case WM_LBUTTONDOWN: |
|
399 |
last_mouse_pos.x = LOWORD(lparam); |
case WM_LBUTTONDOWN: |
400 |
last_mouse_pos.y = HIWORD(lparam); |
last_mouse_pos.x = LOWORD(lparam); |
401 |
ClientToScreen (hwnd, &last_mouse_pos); |
last_mouse_pos.y = HIWORD(lparam); |
402 |
SetCapture (hwnd); |
ClientToScreen (hwnd, &last_mouse_pos); |
403 |
return 0; |
SetCapture (hwnd); |
404 |
|
return 0; |
405 |
case WM_LBUTTONUP: |
|
406 |
ReleaseCapture (); |
case WM_LBUTTONUP: |
407 |
return 0; |
ReleaseCapture (); |
408 |
|
return 0; |
409 |
case WM_MOUSEMOVE: |
|
410 |
if (wparam == MK_LBUTTON) { |
case WM_MOUSEMOVE: |
411 |
struct km_info *kmi; |
if (wparam == MK_LBUTTON) { |
412 |
POINT p; |
struct km_info *kmi; |
413 |
RECT rect; |
POINT p; |
414 |
|
RECT rect; |
415 |
if ((kmi = (struct km_info *)GetWindowLong (hwnd, GWL_USERDATA)) == NULL) |
|
416 |
break; |
if ((kmi = (struct km_info *)GetWindowLong (hwnd, GWL_USERDATA)) == NULL) |
417 |
|
break; |
418 |
// Calculate mouse movement |
|
419 |
p.x = LOWORD(lparam); |
// Calculate mouse movement |
420 |
p.y = HIWORD(lparam); |
p.x = LOWORD(lparam); |
421 |
ClientToScreen (hwnd, &p); |
p.y = HIWORD(lparam); |
422 |
|
ClientToScreen (hwnd, &p); |
423 |
GetWindowRect (hwnd, &rect); |
|
424 |
rect.top += (short)(p.y - last_mouse_pos.y); |
GetWindowRect (hwnd, &rect); |
425 |
rect.bottom += (short)(p.y - last_mouse_pos.y); |
rect.top += (short)(p.y - last_mouse_pos.y); |
426 |
|
rect.bottom += (short)(p.y - last_mouse_pos.y); |
427 |
last_mouse_pos.y = p.y; |
|
428 |
|
last_mouse_pos.y = p.y; |
429 |
// Apply mouse movement to window. Beware the MoveWindow is relaive |
|
430 |
// to parent NOT screen |
// Apply mouse movement to window. Beware the MoveWindow is relaive |
431 |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
// to parent NOT screen |
432 |
kmi->ypos_sep = rect.top; |
MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2); |
433 |
kmi->ypercent_sep = 0; // This forces do_resize_window to use abs. position |
kmi->ypos_sep = rect.top; |
434 |
do_resize_window (GetParent(hwnd), kmi); |
kmi->ypercent_sep = 0; // This forces do_resize_window to use abs. position |
435 |
return 0; |
do_resize_window (GetParent(hwnd), kmi); |
436 |
} |
return 0; |
437 |
} |
} |
438 |
|
} |
439 |
return DefWindowProc (hwnd, msg, wparam, lparam); |
|
440 |
} |
return DefWindowProc (hwnd, msg, wparam, lparam); |
441 |
|
} |
442 |
|
|
443 |
static HWND |
|
444 |
regist_sep_wnd (HWND dlg, struct km_info * kmi) |
static HWND |
445 |
{ |
regist_sep_wnd (HWND dlg, struct km_info * kmi) |
446 |
WNDCLASS wndclass; |
{ |
447 |
HWND h; |
WNDCLASS wndclass; |
448 |
|
HWND h; |
449 |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
|
450 |
wndclass.lpfnWndProc = separator_wnd_proc; |
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; |
451 |
wndclass.cbClsExtra = 0; |
wndclass.lpfnWndProc = separator_wnd_proc; |
452 |
wndclass.cbWndExtra = sizeof (long); |
wndclass.cbClsExtra = 0; |
453 |
wndclass.hInstance = glob_hinst; |
wndclass.cbWndExtra = sizeof (long); |
454 |
wndclass.hIcon = NULL; |
wndclass.hInstance = glob_hinst; |
455 |
wndclass.hCursor = LoadCursor (NULL, IDC_SIZENS); |
wndclass.hIcon = NULL; |
456 |
wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); |
wndclass.hCursor = LoadCursor (NULL, IDC_SIZENS); |
457 |
wndclass.lpszMenuName = 0; |
wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); |
458 |
wndclass.lpszClassName = WINDOWCLASS_SEPARATOR_CHILD; |
wndclass.lpszMenuName = 0; |
459 |
RegisterClass (&wndclass); |
wndclass.lpszClassName = WINDOWCLASS_SEPARATOR_CHILD; |
460 |
|
RegisterClass (&wndclass); |
461 |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
|
462 |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
h = CreateWindowEx (WS_EX_WINDOWEDGE, WINDOWCLASS_SEPARATOR_CHILD, NULL, |
463 |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, |
464 |
ShowWindow (h, SW_SHOW); |
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi); |
465 |
return h; |
ShowWindow (h, SW_SHOW); |
466 |
} /* regist_sep_wnd */ |
return h; |
467 |
|
} /* regist_sep_wnd */ |
468 |
|
|
469 |
|
|
470 |
#define enable_button(hwnd, cid) \ |
|
471 |
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG (key_selected, 0)) |
#define enable_button(hwnd, cid) \ |
472 |
|
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG (key_selected, 0)) |
473 |
void |
|
474 |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
|
475 |
{ |
/* Interactive modification of the dialog item which depend if an item |
476 |
int key_selected = 0, key_has_sec = 0; |
is selected or not and what kind of item. @lv is the list view with |
477 |
int i, key_inv = 0; |
the items. */ |
478 |
HWND hwnd_child; |
void |
479 |
HMENU hmenu; |
update_ui_items (HWND hwnd, listview_ctrl_t lv) |
480 |
|
{ |
481 |
/* Get some states */ |
int key_selected = 0, key_has_sec = 0; |
482 |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
int i, key_inv = 0; |
483 |
LVM_GETSELECTEDCOUNT, 0, 0) |
HWND hwnd_child; |
484 |
? TRUE : FALSE; |
HMENU hmenu; |
485 |
key_has_sec = FALSE; |
|
486 |
if (key_selected) { |
/* Get some states */ |
487 |
i = listview_get_curr_pos (lv); |
key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), |
488 |
key_has_sec = km_check_for_seckey( lv, i, NULL ) ? TRUE : FALSE; |
LVM_GETSELECTEDCOUNT, 0, 0) |
489 |
key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED; |
? TRUE : FALSE; |
490 |
} |
key_has_sec = FALSE; |
491 |
|
if (key_selected) { |
492 |
/* Enable / disable toolbar buttons */ |
i = listview_get_curr_pos (lv); |
493 |
hwnd_child = GetDlgItem(hwnd, IDR_WINPT_KMTB); |
key_has_sec = km_check_for_seckey (lv, i, NULL) ? TRUE : FALSE; |
494 |
enable_button (hwnd_child, ID_KEYMISC_DELETE); |
key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED; |
495 |
enable_button (hwnd_child, ID_KEYMISC_PROPS); |
} |
496 |
enable_button (hwnd_child, ID_KEYMISC_SIGN); |
|
497 |
enable_button (hwnd_child, ID_KEYMISC_EXPORT); |
/* Enable / disable toolbar buttons */ |
498 |
|
hwnd_child = GetDlgItem (hwnd, IDR_WINPT_KMTB); |
499 |
/* Enable / disable menu items */ |
enable_button (hwnd_child, ID_KEYMISC_DELETE); |
500 |
hmenu = GetMenu (hwnd); |
enable_button (hwnd_child, ID_KEYMISC_PROPS); |
501 |
set_menu_state (hmenu, ID_KEYMISC_EXPORT, key_selected ? MF_ENABLED : MF_GRAYED); |
enable_button (hwnd_child, ID_KEYMISC_SIGN); |
502 |
set_menu_state (hmenu, ID_KEYMISC_EXPORT_PRIVKEY, key_has_sec ? MF_ENABLED : MF_GRAYED); |
enable_button (hwnd_child, ID_KEYMISC_EXPORT); |
503 |
set_menu_state (hmenu, ID_KEYMISC_REVCERT, key_has_sec ? MF_ENABLED : MF_GRAYED); |
|
504 |
set_menu_state (hmenu, ID_KEYMISC_DELETE, key_selected ? MF_ENABLED : MF_GRAYED); |
/* Enable / disable menu items */ |
505 |
set_menu_state (hmenu, ID_KEYMISC_PROPS, key_selected ? MF_ENABLED : MF_GRAYED); |
hmenu = GetMenu (hwnd); |
506 |
set_menu_state (hmenu, ID_KEYMISC_SIGN, key_selected && !key_inv ? MF_ENABLED : MF_GRAYED); |
set_menu_state (hmenu, ID_KEYMISC_EXPORT, key_selected ? MF_ENABLED : MF_GRAYED); |
507 |
} /* update_ui_items */ |
set_menu_state (hmenu, ID_KEYMISC_EXPORT_PRIVKEY, key_has_sec ? MF_ENABLED : MF_GRAYED); |
508 |
|
set_menu_state (hmenu, ID_KEYMISC_REVCERT, key_has_sec ? MF_ENABLED : MF_GRAYED); |
509 |
|
set_menu_state (hmenu, ID_KEYMISC_DELETE, key_selected ? MF_ENABLED : MF_GRAYED); |
510 |
static void |
set_menu_state (hmenu, ID_KEYMISC_PROPS, key_selected ? MF_ENABLED : MF_GRAYED); |
511 |
popup_gpg_readonly (HWND dlg, HMENU hm) |
set_menu_state (hmenu, ID_KEYMISC_SIGN, key_selected && !key_inv ? MF_ENABLED : MF_GRAYED); |
512 |
{ |
set_menu_state (hmenu, ID_KEYMISC_EDITKEY, key_selected? MF_ENABLED : MF_GRAYED); |
513 |
int resids[] = { |
set_menu_state (hmenu, ID_KEYMISC_CHECKSIGS, key_selected? MF_ENABLED : MF_GRAYED); |
514 |
ID_KEYCTX_PASTE, |
} |
515 |
ID_KEYCTX_EDIT, |
|
516 |
ID_KEYCTX_SIGN, |
|
517 |
ID_KEYCTX_REV, |
/* The items which are shown when GPG is in read-only mode. */ |
518 |
ID_KEYCTX_DEL, |
static void |
519 |
ID_KEYCTX_ENABLE, |
popup_gpg_readonly (HWND dlg, HMENU hm) |
520 |
ID_KEYCTX_DISABLE, |
{ |
521 |
ID_KEYCTX_RECVFROM, |
int resids[] = { |
522 |
ID_KEYCTX_ADDKEY, |
ID_KEYCTX_PASTE, |
523 |
ID_KEYCTX_ADDPHOTO, |
ID_KEYCTX_EDIT, |
524 |
ID_KEYCTX_ADDUID, |
ID_KEYCTX_SIGN, |
525 |
ID_KEYCTX_ADDREV, |
ID_KEYCTX_REV, |
526 |
0 |
ID_KEYCTX_DEL, |
527 |
}; |
ID_KEYCTX_ENABLE, |
528 |
int i; |
ID_KEYCTX_DISABLE, |
529 |
|
ID_KEYCTX_RECVFROM, |
530 |
if (gpg_read_only == 0) |
ID_KEYCTX_ADDKEY, |
531 |
return; |
ID_KEYCTX_ADDPHOTO, |
532 |
for (i=0; resids[i] != 0; i++) |
ID_KEYCTX_ADDUID, |
533 |
set_menu_state (hm, resids[i], MF_GRAYED); |
ID_KEYCTX_ADDREV, |
534 |
} |
0 |
535 |
|
}; |
536 |
|
int i; |
537 |
static void |
|
538 |
menu_gpg_readonly (HWND dlg, HMENU hm, int id) |
if (gpg_read_only == 0) |
539 |
{ |
return; |
540 |
int key_resids[] = { |
for (i=0; resids[i] != 0; i++) |
541 |
ID_KEYMISC_SIGN, |
set_menu_state (hm, resids[i], MF_GRAYED); |
542 |
ID_KEYMISC_DELETE, |
} |
543 |
ID_KEYMISC_REVCERT, |
|
544 |
ID_KEYMISC_IMPORT_HTTP, |
|
545 |
ID_KEYMISC_IMPORT, |
static void |
546 |
ID_KEYMISC_REFRESH_KEYS, |
menu_gpg_readonly (HWND dlg, HMENU hm, int id) |
547 |
ID_KEYMISC_REBUILD, |
{ |
548 |
ID_KEYMISC_KEYWIZARD, |
int key_resids[] = { |
549 |
ID_KEYMISC_CARDNEW, |
ID_KEYMISC_SIGN, |
550 |
ID_KEYMISC_NEWKEY, |
ID_KEYMISC_DELETE, |
551 |
0, |
ID_KEYMISC_REVCERT, |
552 |
}; |
ID_KEYMISC_IMPORT_HTTP, |
553 |
int edit_resids[] = { |
ID_KEYMISC_IMPORT, |
554 |
ID_KEYMISC_PASTE, |
ID_KEYMISC_REFRESH_KEYS, |
555 |
ID_KEYMISC_OT, |
ID_KEYMISC_REBUILD, |
556 |
ID_KEYMISC_EDITKEY, |
ID_KEYMISC_KEYWIZARD, |
557 |
0 |
ID_KEYMISC_CARDNEW, |
558 |
}; |
ID_KEYMISC_NEWKEY, |
559 |
int * resids; |
0, |
560 |
int i; |
}; |
561 |
|
int edit_resids[] = { |
562 |
|
ID_KEYMISC_PASTE, |
563 |
if (gpg_read_only == 0) |
ID_KEYMISC_OT, |
564 |
return; |
ID_KEYMISC_EDITKEY, |
565 |
switch (id) { |
0 |
566 |
case 0: return; |
}; |
567 |
case 3: resids = key_resids; break; |
int * resids; |
568 |
case 1: resids = edit_resids;break; |
int i; |
569 |
} |
|
570 |
|
|
571 |
for (i=0; resids[i] != 0; i++) |
if (gpg_read_only == 0) |
572 |
set_menu_state (hm, resids[i], MF_GRAYED); |
return; |
573 |
} |
switch (id) { |
574 |
|
case 0: return; |
575 |
|
case 3: resids = key_resids; break; |
576 |
static char* |
case 1: resids = edit_resids;break; |
577 |
gen_export_filename (const char *keyid) |
} |
578 |
{ |
|
579 |
gpgme_key_t key; |
for (i=0; resids[i] != 0; i++) |
580 |
const char *s; |
set_menu_state (hm, resids[i], MF_GRAYED); |
581 |
char *p; |
} |
582 |
|
|
583 |
if (get_pubkey (keyid, &key)) |
|
584 |
return m_strdup (keyid); |
static char* |
585 |
s = key->uids->name; |
gen_export_filename (const char *keyid, int is_secret) |
586 |
if (!s) |
{ |
587 |
return m_strdup (keyid); |
gpgme_key_t key; |
588 |
p = new char[strlen (s) + 8]; |
const char *s; |
589 |
if (!p) |
char *p; |
590 |
BUG (0); |
|
591 |
sprintf (p, "%s.asc", s); |
if (get_pubkey (keyid, &key)) |
592 |
for (size_t i=0; i < strlen (p); i++) { |
return m_strdup (keyid); |
593 |
if (p[i] == ' ' || p[i] == ':' || p[i] == '?' || p[i] == '|') |
s = key->uids->name; |
594 |
p[i] = '_'; |
if (!s) |
595 |
} |
return m_strdup (keyid); |
596 |
return p; |
p = new char[strlen (s) + 8 + 16]; |
597 |
} |
if (!p) |
598 |
|
BUG (0); |
599 |
|
sprintf (p, "%s%s.asc", s, is_secret? "_sec" : ""); |
600 |
static void |
for (size_t i=0; i < strlen (p); i++) { |
601 |
update_key (listview_ctrl_t lv, int pos, const char *keyid, int keypair) |
if (p[i] == ' ' || p[i] == ':' || p[i] == '?' || p[i] == '|') |
602 |
{ |
p[i] = '_'; |
603 |
gpgme_key_t key; |
} |
604 |
|
return p; |
605 |
keycache_update (0, keyid); |
} |
606 |
if (keypair) |
|
607 |
keycache_update (1, keyid); |
|
608 |
|
static void |
609 |
/* because we replaced the key item, we need to update the |
update_key (listview_ctrl_t lv, int pos, const char *keyid, int keypair) |
610 |
address of the pointer in the ListView control. */ |
{ |
611 |
get_pubkey (keyid, &key); |
gpgme_key_t key; |
612 |
keylist_upd_key (lv, pos, key); |
|
613 |
} |
keycache_update (0, keyid); |
614 |
|
if (keypair) |
615 |
|
keycache_update (1, keyid); |
616 |
|
|
617 |
BOOL CALLBACK |
/* because we replaced the key item, we need to update the |
618 |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
address of the pointer in the ListView control. */ |
619 |
{ |
get_pubkey (keyid, &key); |
620 |
struct km_info *kmi; |
keylist_upd_key (lv, pos, key); |
621 |
static km_group_s *gc = NULL; |
} |
622 |
static HMENU menu = NULL; |
|
623 |
static int refresh_keys = 0; |
|
624 |
INITCOMMONCONTROLSEX icex; |
/* Setup status bar for the main window @dlg. */ |
625 |
HWND kl; |
static HWND |
626 |
HMENU hm; |
setup_status_bar (HWND dlg, listview_ctrl_t lv) |
627 |
gpgme_keycache_t c; |
{ |
628 |
gpgme_key_t key; |
HWND statbar; |
629 |
/*km_group_cb_s gcb; XXX */ |
RECT r; |
630 |
struct genkey_s genkey; |
int partpos[3]; |
631 |
struct winpt_key_s k = {0}; |
int i; |
632 |
struct URL_ctx_s *url; |
|
633 |
refresh_cache_s rcs = {0}; |
GetClientRect (dlg, &r); |
634 |
char keyid[48], uid[128], type[32], * name; |
for (i=1; i <= 3; i++) |
635 |
const char *t, * host; |
partpos[i-1] = r.right/3*i; |
636 |
u16 port = 0; |
statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
637 |
int idx = 0, i=0, rc; |
"status bar", dlg, KM_SEPARATOR_ID); |
638 |
size_t size = 0; |
|
639 |
|
ShowWindow (statbar, SW_SHOW); |
640 |
if ((msg != WM_INITDIALOG) |
SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
641 |
&& ((kmi = (struct km_info*)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
|
642 |
return FALSE; |
km_update_default_key_str (statbar); |
643 |
|
km_complete_status_bar (statbar, lv); |
644 |
switch (msg) { |
|
645 |
case WM_INITDIALOG: |
return statbar; |
646 |
kmi = new struct km_info; |
} |
647 |
memset (kmi, 0, sizeof (struct km_info)); |
|
648 |
icex.dwSize = sizeof (INITCOMMONCONTROLSEX); |
|
649 |
icex.dwICC = ICC_BAR_CLASSES; |
BOOL CALLBACK |
650 |
InitCommonControlsEx (&icex); |
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
651 |
kmi->hwnd_sep = regist_sep_wnd (dlg, kmi); |
{ |
652 |
imagelist_load (dlg); |
struct km_info *kmi; |
653 |
|
static km_group_s *gc = NULL; |
654 |
#ifndef LANG_DE |
static HMENU menu = NULL; |
655 |
SetWindowText( dlg, _("Key Manager") ); |
static int refresh_keys = 0; |
656 |
#endif |
INITCOMMONCONTROLSEX icex; |
657 |
menu = LoadMenu( glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC ); |
HWND kl; |
658 |
#ifndef LANG_DE |
HMENU hm; |
659 |
set_menu_text( menu, ID_KEYMISC_QUIT, _("&Quit") ); |
gpg_keycache_t c; |
660 |
set_menu_text( menu, ID_KEYMISC_UID, _("User ID") ); |
gpgme_key_t key; |
661 |
set_menu_text( menu, ID_KEYMISC_NEWKEY, _("&Expert") ); |
/*km_group_cb_s gcb; XXX */ |
662 |
set_menu_text( menu, ID_KEYMISC_KEYWIZARD, _("&Normal") ); |
struct genkey_s genkey; |
663 |
set_menu_text( menu, ID_KEYMISC_EDIT, _("Edit") ); |
struct winpt_key_s k = {0}; |
664 |
set_menu_text( menu, ID_KEYMISC_SIGN, _("&Sign") ); |
struct URL_ctx_s *url; |
665 |
set_menu_text( menu, ID_KEYMISC_DELETE, _("&Delete") ); |
refresh_cache_s rcs = {0}; |
666 |
set_menu_text( menu, ID_KEYMISC_REVCERT, _("&Revoke") ); |
char keyid[48], uid[128], type[32], *name; |
667 |
set_menu_text( menu, ID_KEYMISC_CHECKSIGS, _("&List Signatures") ); |
const char *t, * host; |
668 |
set_menu_text( menu, ID_KEYMISC_TRUSTPATH, _("List Trust Path") ); |
u16 port = 0; |
669 |
set_menu_text( menu, ID_KEYMISC_PROPS, _("&Properties") ); |
int idx = 0, i=0, rc; |
670 |
set_menu_text( menu, ID_KEYMISC_GPGOPT, _("Options") ); |
size_t size = 0; |
671 |
set_menu_text( menu, ID_KEYMISC_GPGPREFS, _("Preferences") ); |
|
672 |
set_menu_text( menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
if ((msg != WM_INITDIALOG) |
673 |
set_menu_text( menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache") ); |
&& ((kmi = (struct km_info*)GetWindowLong (dlg, GWL_USERDATA)) == NULL)) |
674 |
set_menu_text( menu, ID_KEYMISC_REBUILD, _("R&everify Signatures") ); |
return FALSE; |
675 |
set_menu_text( menu, ID_KEYMISC_INFO, _("Info") ); |
|
676 |
set_menu_text (menu, ID_KEYMISC_HELP, _("Help")); |
switch (msg) { |
677 |
#endif |
case WM_INITDIALOG: |
678 |
SetMenu( dlg, menu ); |
kmi = new struct km_info; |
679 |
if( keyring_check_last_access() ) |
memset (kmi, 0, sizeof (struct km_info)); |
680 |
keycache_set_reload( 1 ); |
icex.dwSize = sizeof (INITCOMMONCONTROLSEX); |
681 |
if( keycache_get_reload( ) ) |
icex.dwICC = ICC_BAR_CLASSES; |
682 |
keycache_reload( dlg ); |
InitCommonControlsEx (&icex); |
683 |
c = keycache_get_ctx( KEYCACHE_PUB ); |
kmi->hwnd_sep = regist_sep_wnd (dlg, kmi); |
684 |
if( !c ) |
imagelist_load (dlg); |
685 |
BUG( NULL ); |
|
686 |
kmi->keylist_sortby = KEY_SORT_USERID; |
#ifndef LANG_DE |
687 |
Header_SetImageList(ListView_GetHeader(GetDlgItem( dlg, IDC_KEYMISC_KEYLIST )), |
SetWindowText( dlg, _("Key Manager") ); |
688 |
glob_imagelist); |
#endif |
689 |
kmi->lv = keylist_load( GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ), c, |
menu = LoadMenu( glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC ); |
690 |
NULL, KEYLIST_LIST, kmi->keylist_sortby ); |
#ifndef LANG_DE |
691 |
/* init subclassing for the listview */ |
set_menu_text (menu, ID_KEYMISC_MAIL, _("Send Mail...")); |
692 |
kl = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
set_menu_text (menu, ID_KEYMISC_OT, _("Ownertrust")); /* XXX */ |
693 |
keylist_proc.dlg = dlg; |
set_menu_text (menu, ID_KEYMISC_COPY, _("&Copy\tCtrl+C")); |
694 |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
set_menu_text (menu, ID_KEYMISC_PASTE, _("&Paste\tCtrl+V")); |
695 |
keylist_proc.old = (WNDPROC)GetWindowLong( kl, GWL_WNDPROC ); |
set_menu_text (menu, ID_KEYMISC_FIND, _("Search...\tCtrl+F")); |
696 |
if( keylist_proc.old ) { |
set_menu_text (menu, ID_KEYMISC_SELALL, _("Select All\tCtrl+A")); |
697 |
if( !SetWindowLong( kl, GWL_WNDPROC, (LONG)keylist_proc.current) ) { |
set_menu_text (menu, ID_KEYMISC_QUIT, _("&Quit")); |
698 |
msg_box( dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR ); |
set_menu_text (menu, ID_KEYMISC_UID, _("User ID")); |
699 |
BUG( NULL ); |
set_menu_text (menu, ID_KEYMISC_NEWKEY, _("&Expert")); |
700 |
} |
set_menu_text (menu, ID_KEYMISC_KEYWIZARD, _("&Normal")); |
701 |
} |
set_menu_text (menu, ID_KEYMISC_EDIT, _("Edit")); |
702 |
#if 0 |
set_menu_text (menu, ID_KEYMISC_SIGN, _("&Sign")); |
703 |
km_groups_new( &gc, GetDlgItem( dlg, IDC_KEYMISC_GROUP ) ); |
set_menu_text (menu, ID_KEYMISC_DELETE, _("&Delete")); |
704 |
km_groups_load( gc ); |
set_menu_text (menu, ID_KEYMISC_REVCERT, _("&Revoke")); |
705 |
#endif |
set_menu_text (menu, ID_KEYMISC_CHECKSIGS, _("&List Signatures")); |
706 |
SetForegroundWindow( dlg ); |
set_menu_text (menu, ID_KEYMISC_TRUSTPATH, _("List Trust Path")); |
707 |
|
set_menu_text (menu, ID_KEYMISC_EXPORT, _("&Export...")); |
708 |
int partpos[3]; |
set_menu_text (menu, ID_KEYMISC_IMPORT, _("&Import...")); |
709 |
RECT r; |
set_menu_text (menu, ID_KEYMISC_PROPS, _("&Properties")); |
710 |
|
set_menu_text (menu, ID_KEYMISC_GPGOPT, _("Options")); |
711 |
GetClientRect (dlg, &r); |
set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("Preferences")); |
712 |
for (i=1; i <= 3; i++) |
set_menu_text (menu, ID_KEYMISC_SENDRECV, _("Keyserver") ); |
713 |
partpos[i-1] = r.right/3*i; |
set_menu_text (menu, ID_KEYMISC_EXPORT_PRIVKEY, _("E&xport Secret Key")); |
714 |
kmi->statbar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | CCS_BOTTOM, |
set_menu_text (menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache")); |
715 |
"status bar", dlg, 100000); |
set_menu_text (menu, ID_KEYMISC_REBUILD, _("R&everify Signatures")); |
716 |
ShowWindow (kmi->statbar, SW_SHOW); |
set_menu_text (menu, ID_KEYMISC_REFRESH_KEYS, _("Refresh &Keys (Keyserver)")); |
717 |
SendMessage (kmi->statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos); |
set_menu_text (menu, ID_KEYMISC_INFO, _("Info") ); |
718 |
|
set_menu_text (menu, ID_KEYMISC_HELP, _("&Help")); |
719 |
km_update_default_key_str (kmi->statbar); |
|
720 |
km_complete_status_bar( kmi->statbar, kmi->lv); |
#endif |
721 |
|
SetMenu (dlg, menu); |
722 |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
if( keyring_check_last_access() ) |
723 |
kmi->toolbar = load_toolbar (dlg, kmi); |
keycache_set_reload( 1 ); |
724 |
|
if( keycache_get_reload( ) ) |
725 |
do_center_window( dlg, kmi ); |
keycache_reload( dlg ); |
726 |
do_resize_window( dlg, kmi ); |
c = keycache_get_ctx( KEYCACHE_PUB ); |
727 |
update_ui_items (dlg, kmi->lv); |
if( !c ) |
728 |
return TRUE; |
BUG( NULL ); |
729 |
|
kmi->keylist_sortby = KEY_SORT_USERID; |
730 |
case WM_DESTROY: |
Header_SetImageList(ListView_GetHeader(GetDlgItem( dlg, IDC_KEYMISC_KEYLIST )), |
731 |
if (kmi->lv) { |
glob_imagelist); |
732 |
keylist_delete (kmi->lv); |
kmi->lv = keylist_load( GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ), c, |
733 |
kmi->lv = NULL; |
NULL, KEYLIST_LIST, kmi->keylist_sortby ); |
734 |
|
/* init subclassing for the listview */ |
735 |
/* |
kl = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ); |
736 |
if (gc) { |
keylist_proc.dlg = dlg; |
737 |
km_groups_release (gc); |
keylist_proc.current = (WNDPROC)keylist_subclass_proc; |
738 |
gc = NULL; |
keylist_proc.old = (WNDPROC)GetWindowLong( kl, GWL_WNDPROC ); |
739 |
}*/ |
if( keylist_proc.old ) { |
740 |
imagelist_destroy (); |
if( !SetWindowLong( kl, GWL_WNDPROC, (LONG)keylist_proc.current) ) { |
741 |
|
msg_box( dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR ); |
742 |
char buf[32]; |
BUG( NULL ); |
743 |
ltoa (kmi->pos_x, buf, 10); |
} |
744 |
set_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", buf ); |
} |
745 |
ltoa (kmi->pos_y, buf, 10); |
#if 0 |
746 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", buf); |
km_groups_new( &gc, GetDlgItem( dlg, IDC_KEYMISC_GROUP ) ); |
747 |
/* Remove runtime information. This should be the last action taken here. */ |
km_groups_load( gc ); |
748 |
delete kmi; kmi = NULL; |
#endif |
749 |
SetWindowLong (dlg, GWL_USERDATA, NULL); |
SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT)); |
750 |
keycache_set_reload (refresh_keys); |
SetForegroundWindow (dlg); |
751 |
return FALSE; |
|
752 |
|
kmi->statbar = setup_status_bar (dlg, kmi->lv); |
753 |
case WM_MOVE: |
|
754 |
/* kmi->pos_x = (int)(short)LOWORD(lparam); |
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi); |
755 |
kmi->pos_y = (int)(short)HIWORD(lparam); */ |
kmi->toolbar = load_toolbar (dlg, kmi); |
756 |
RECT r; |
|
757 |
GetWindowRect (dlg, &r); |
do_center_window (dlg, kmi); |
758 |
kmi->pos_x = r.left; |
do_resize_window (dlg, kmi); |
759 |
kmi->pos_y = r.top; |
update_ui_items (dlg, kmi->lv); |
760 |
break; |
return TRUE; |
761 |
|
|
762 |
|
case WM_DESTROY: |
763 |
case WM_RBUTTONUP: |
if (kmi->lv) { |
764 |
do_create_minpopup (dlg); |
keylist_delete (kmi->lv); |
765 |
break; |
kmi->lv = NULL; |
766 |
|
|
767 |
case WM_NOTIFY: |
/* |
768 |
NMHDR * notify; |
if (gc) { |
769 |
POINT p; |
km_groups_release (gc); |
770 |
HMENU popup; |
gc = NULL; |
771 |
|
}*/ |
772 |
notify = (NMHDR *)lparam; |
imagelist_destroy (); |
773 |
if (notify == NULL) |
|
774 |
break; |
char buf[32]; |
775 |
switch (notify->code) |
ltoa (kmi->pos_x, buf, 10); |
776 |
{ |
set_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", buf ); |
777 |
case TBN_QUERYDELETE: |
ltoa (kmi->pos_y, buf, 10); |
778 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", buf); |
779 |
return TRUE; |
/* Remove runtime information. This should be the last action taken here. */ |
780 |
|
delete kmi; kmi = NULL; |
781 |
case TBN_QUERYINSERT: |
SetWindowLong (dlg, GWL_USERDATA, NULL); |
782 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
keycache_set_reload (refresh_keys); |
783 |
return TRUE; |
return FALSE; |
784 |
|
|
785 |
case TBN_GETBUTTONINFO: |
case WM_MOVE: |
786 |
LPTBNOTIFY lpTbNotify; |
/* kmi->pos_x = (int)(short)LOWORD(lparam); |
787 |
lpTbNotify = (LPTBNOTIFY)lparam; |
kmi->pos_y = (int)(short)HIWORD(lparam); */ |
788 |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
RECT r; |
789 |
lpTbNotify->tbButton.iBitmap = imagelist_getindex(myb[lpTbNotify->iItem].icon); |
GetWindowRect (dlg, &r); |
790 |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
kmi->pos_x = r.left; |
791 |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
kmi->pos_y = r.top; |
792 |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
break; |
793 |
lpTbNotify->tbButton.iString = 0; |
|
794 |
strncpy (lpTbNotify->pszText, myb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
|
795 |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
case WM_RBUTTONUP: |
796 |
} |
do_create_minpopup (dlg); |
797 |
return TRUE; |
break; |
798 |
|
|
799 |
case TBN_RESET: /* Restore last saved toolbar status */ |
case WM_NOTIFY: |
800 |
TBSAVEPARAMS tbsp; |
NMHDR * notify; |
801 |
|
POINT p; |
802 |
tbsp.hkr = HKEY_CURRENT_USER; |
HMENU popup; |
803 |
tbsp.pszSubKey = "Software\\WinPT"; |
|
804 |
tbsp.pszValueName = "KM_toolbar"; |
notify = (NMHDR *)lparam; |
805 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp); |
if (notify == NULL) |
806 |
break; |
break; |
807 |
|
switch (notify->code) |
808 |
case TBN_BEGINADJUST: /* User is about to change the toolbar. Save it */ |
{ |
809 |
tbsp.hkr = HKEY_CURRENT_USER; |
case TBN_QUERYDELETE: |
810 |
tbsp.pszSubKey = "Software\\WinPT"; |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
811 |
tbsp.pszValueName = "KM_toolbar"; |
return TRUE; |
812 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
|
813 |
break; |
case TBN_QUERYINSERT: |
814 |
|
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
815 |
case TBN_ENDADJUST: /* User has finished customizing the toolbar. Save it. */ |
return TRUE; |
816 |
tbsp.hkr = HKEY_CURRENT_USER; |
|
817 |
tbsp.pszSubKey = "Software\\WinPT"; |
case TBN_GETBUTTONINFO: |
818 |
tbsp.pszValueName = "KM_toolbar"; |
LPTBNOTIFY lpTbNotify; |
819 |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
lpTbNotify = (LPTBNOTIFY)lparam; |
820 |
break; |
if (lpTbNotify->iItem < (sizeof(myb) / sizeof(mybuttons))) { |
821 |
|
lpTbNotify->tbButton.iBitmap = imagelist_getindex(myb[lpTbNotify->iItem].icon); |
822 |
case TTN_GETDISPINFO: |
lpTbNotify->tbButton.idCommand = myb[lpTbNotify->iItem].command; |
823 |
LPTOOLTIPTEXT lpttt; |
lpTbNotify->tbButton.fsState = TBSTATE_ENABLED; |
824 |
lpttt = (LPTOOLTIPTEXT)lparam; |
lpTbNotify->tbButton.fsStyle = TBSTYLE_BUTTON; |
825 |
|
lpTbNotify->tbButton.iString = 0; |
826 |
lpttt->hinst = NULL; |
strncpy (lpTbNotify->pszText, myb[lpTbNotify->iItem].text, lpTbNotify->cchText); |
827 |
switch (lpttt->hdr.idFrom) { |
SetWindowLong(dlg, DWL_MSGRESULT, TRUE); |
828 |
case ID_KEYMISC_DELETE: |
} |
829 |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
return TRUE; |
830 |
break; |
|
831 |
|
case TBN_RESET: /* Restore last saved toolbar status */ |
832 |
case ID_KEYMISC_PROPS: |
TBSAVEPARAMS tbsp; |
833 |
lpttt->lpszText = (char *)_("Show key properties"); |
|
834 |
break; |
tbsp.hkr = HKEY_CURRENT_USER; |
835 |
|
tbsp.pszSubKey = "Software\\WinPT"; |
836 |
case ID_KEYMISC_SIGN: |
tbsp.pszValueName = "KM_toolbar"; |
837 |
lpttt->lpszText = (char *)_("Sign key"); |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp); |
838 |
break; |
break; |
839 |
|
|
840 |
case ID_KEYMISC_IMPORT: |
case TBN_BEGINADJUST: /* User is about to change the toolbar. Save it */ |
841 |
lpttt->lpszText = (char *)_("Import key to keyring"); |
tbsp.hkr = HKEY_CURRENT_USER; |
842 |
break; |
tbsp.pszSubKey = "Software\\WinPT"; |
843 |
|
tbsp.pszValueName = "KM_toolbar"; |
844 |
case ID_KEYMISC_EXPORT: |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
845 |
lpttt->lpszText = (char *)_("Export key to a file"); |
break; |
846 |
break; |
|
847 |
} |
case TBN_ENDADJUST: /* User has finished customizing the toolbar. Save it. */ |
848 |
return TRUE; |
tbsp.hkr = HKEY_CURRENT_USER; |
849 |
|
tbsp.pszSubKey = "Software\\WinPT"; |
850 |
case LVN_ITEMCHANGED: |
tbsp.pszValueName = "KM_toolbar"; |
851 |
if (((LPNMLISTVIEW)lparam)->uNewState) /* item selected? */ |
SendMessage (notify->hwndFrom, TB_SAVERESTORE, TRUE, (LPARAM)&tbsp); |
852 |
{ |
break; |
853 |
update_ui_items (dlg, kmi->lv); |
|
854 |
return TRUE; |
case TTN_GETDISPINFO: |
855 |
} |
LPTOOLTIPTEXT lpttt; |
856 |
break; |
lpttt = (LPTOOLTIPTEXT)lparam; |
857 |
|
|
858 |
case NM_RCLICK: |
lpttt->hinst = NULL; |
859 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
switch (lpttt->hdr.idFrom) { |
860 |
if (listview_get_curr_pos (kmi->lv) == -1) |
case ID_KEYMISC_DELETE: |
861 |
return TRUE; /* Popup only when a item was selected */ |
lpttt->lpszText = (char *)_("Delete key from keyring"); |
862 |
do_check_cache (kmi->lv, dlg, kmi->statbar); |
break; |
863 |
GetCursorPos (&p); |
|
864 |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYMISC_CTX)); |
case ID_KEYMISC_PROPS: |
865 |
popup = GetSubMenu (hm, 0); |
lpttt->lpszText = (char *)_("Show key properties"); |
866 |
#ifndef LANG_DE |
break; |
867 |
set_menu_text( popup, ID_KEYCTX_UID_COPY, _("Copy User ID to Clipboard") ); |
|
868 |
set_menu_text( popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard") ); |
case ID_KEYMISC_SIGN: |
869 |
set_menu_text( popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard") ); |
lpttt->lpszText = (char *)_("Sign key"); |
870 |
set_menu_text( popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver") ); |
break; |
871 |
#endif |
|
872 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYMISC_IMPORT: |
873 |
if (km_check_for_seckey (kmi->lv, idx, &i)) |
lpttt->lpszText = (char *)_("Import key to keyring"); |
874 |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
break; |
875 |
if (i == 0) |
|
876 |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
case ID_KEYMISC_EXPORT: |
877 |
if (!km_check_for_seckey (kmi->lv, idx, NULL)) { |
lpttt->lpszText = (char *)_("Export key to a file"); |
878 |
set_menu_state( popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED ); |
break; |
879 |
set_menu_state( popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED ); |
} |
880 |
set_menu_state( popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED ); |
return TRUE; |
881 |
set_menu_state( popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED ); |
|
882 |
set_menu_state( popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED ); |
case LVN_ITEMCHANGED: |
883 |
set_menu_state (popup, ID_KEYCTX_SETPREFKS, MF_DISABLED|MF_GRAYED); |
if (((LPNMLISTVIEW)lparam)->uNewState) /* item selected? */ |
884 |
} |
{ |
885 |
else if( km_check_for_seckey( kmi->lv, idx, NULL ) |
update_ui_items (dlg, kmi->lv); |
886 |
&& km_key_is_v3( kmi->lv, idx ) ) |
return TRUE; |
887 |
{ |
} |
888 |
/* PGP 2 keys, version 3 have no no support for photo-id's, |
break; |
889 |
designated revokers and secondary keys. */ |
|
890 |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
case NM_RCLICK: |
891 |
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED); |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
892 |
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED); |
if (listview_get_curr_pos (kmi->lv) == -1) |
893 |
} |
return TRUE; /* Popup only when a item was selected */ |
894 |
if( km_get_key_status( kmi->lv, idx ) & KM_FLAG_DISABLED ) |
do_check_cache (kmi->lv, dlg, kmi->statbar); |
895 |
set_menu_state( popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED ); |
GetCursorPos (&p); |
896 |
else |
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYMISC_CTX)); |
897 |
set_menu_state( popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED ); |
popup = GetSubMenu (hm, 0); |
898 |
if (km_get_key_status (kmi->lv, idx) & KM_FLAG_REVOKED) |
#ifndef LANG_DE |
899 |
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
set_menu_text (popup, ID_KEYCTX_UID_COPY, _("Copy User ID to Clipboard")); |
900 |
if (mapi_init()) |
set_menu_text (popup, ID_KEYCTX_KEYID_COPY, _("Copy Key ID to Clipboard")); |
901 |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
set_menu_text (popup, ID_KEYCTX_FPR_COPY, _("Copy Fingerprint to Clipboard")); |
902 |
/* Override 'Default Keyserver' with the actual name. */ |
set_menu_text (popup, ID_KEYCTX_KINFO_COPY, _("Copy Key Info to Clipboard")); |
903 |
host = kserver_get_hostname (0, -1, &port); |
set_menu_text (popup, ID_KEYCTX_COPY, _("Copy Key to Clipboard")); |
904 |
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host); |
set_menu_text (popup, ID_KEYCTX_PASTE, _("Paste Key from Clipboard")); |
905 |
popup_gpg_readonly (dlg, popup); |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Refresh from Keyserver")); |
906 |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
set_menu_text (popup, ID_KEYCTX_MAXTRUST, _("Set Implicit &Trust")); |
907 |
DestroyMenu (popup); |
set_menu_text (popup, ID_KEYCTX_LISTSIGS, _("&List Signatures")); |
908 |
DestroyMenu (hm); |
set_menu_text (popup, ID_KEYCTX_PROPS, _("&Key Properties")); |
909 |
return TRUE; |
set_menu_text (popup, ID_KEYCTX_EDIT, _("Key Edit")); |
910 |
} |
set_menu_text (popup, ID_KEYCTX_DEL, _("&Delete")); |
911 |
#if 0 /* XXX */ |
set_menu_text (popup, ID_KEYCTX_REV, _("&Revoke")); |
912 |
if( notify->idFrom == IDC_KEYMISC_GROUP ) { |
set_menu_text (popup, ID_KEYCTX_SIGN, _("&Sign")); |
913 |
HWND tree = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
set_menu_text (popup, ID_KEYCTX_ENABLE, _("&Enable")); |
914 |
if( TreeView_GetSelection( tree ) ) { |
set_menu_text (popup, ID_KEYCTX_DISABLE, _("&Disable")); |
915 |
GetCursorPos( &p ); |
set_menu_text (popup, ID_KEYCTX_RECVFROM, _("Re&fresh from Keyserver")); |
916 |
hm = LoadMenu( glob_hinst, MAKEINTRESOURCE(IDR_WINPT_GROUP_CTX) ); |
set_menu_text (popup, ID_KEYCTX_SETPREFKS, _("Set preferred Keyserver URL")); |
917 |
popup = GetSubMenu( hm, 0 ); |
set_menu_text (popup, ID_KEYCTX_SENDMAIL, _("Send Key to Mail Recipient")); |
918 |
if( km_index == -1 ) |
set_menu_text (popup, ID_KEYCTX_SETDEFKEY, _("Set as Default Key")); |
919 |
set_menu_state( popup, ID_GROUP_PASTE, MF_DISABLED|MF_GRAYED ); |
/* change popup texts */ |
920 |
set_menu_text( popup, ID_GROUP_PASTE, _("Paste into this group") ); |
set_menu_text_bypos (popup, 0, _("Key Attributes")); |
921 |
set_menu_text( popup, ID_GROUP_DELETE, _("Delete") ); |
set_menu_text_bypos (popup, 6, _("Add")); |
922 |
TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL ); |
set_menu_text_bypos (popup, 19, _("Send to Keyserver")); |
923 |
DestroyMenu( popup ); |
#endif |
924 |
DestroyMenu( hm ); |
idx = listview_get_curr_pos (kmi->lv); |
925 |
return TRUE; |
if (km_check_for_seckey (kmi->lv, idx, &i)) |
926 |
} |
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED); |
927 |
} |
if (i == 0) |
928 |
#endif |
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED); |
929 |
break; |
if (!km_check_for_seckey (kmi->lv, idx, NULL)) { |
930 |
|
set_menu_state( popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED ); |
931 |
case LVN_COLUMNCLICK: |
set_menu_state( popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED ); |
932 |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
set_menu_state( popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED ); |
933 |
NMLISTVIEW * p = (LPNMLISTVIEW) lparam; |
set_menu_state( popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED ); |
934 |
int sortby = 0; |
set_menu_state( popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED ); |
935 |
switch (p->iSubItem) { |
set_menu_state (popup, ID_KEYCTX_SETPREFKS, MF_DISABLED|MF_GRAYED); |
936 |
case 0: sortby = KEY_SORT_USERID; break; |
} |
937 |
case 1: sortby = KEY_SORT_KEYID; break; |
else if( km_check_for_seckey (kmi->lv, idx, NULL) |
938 |
case 2: sortby = KEY_SORT_IS_SECRET; break; |
&& km_key_is_v3 (kmi->lv, idx)) { |
939 |
case 3: sortby = KEY_SORT_LEN; break; |
/* PGP 2 keys, version 3 have no no support for photo-id's, |
940 |
case 5: sortby = KEY_SORT_VALIDITY; break; |
designated revokers and secondary keys. */ |
941 |
case 6: sortby = KEY_SORT_OTRUST; break; |
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED); |
942 |
case 7: sortby = KEY_SORT_CREATED; break; |
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED); |
943 |
case 8: sortby = KEY_SORT_ALGO; break; |
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED); |
944 |
default: return TRUE; //sortby = KEY_SORT_USERID; break; |
} |
945 |
} |
if( km_get_key_status( kmi->lv, idx ) & KM_FLAG_DISABLED ) |
946 |
|
set_menu_state( popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED ); |
947 |
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
else |
948 |
kmi->keylist_sortby ^= KEYLIST_SORT_DESC; |
set_menu_state( popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED ); |
949 |
else |
if (km_get_key_status (kmi->lv, idx) & KM_FLAG_REVOKED) |
950 |
kmi->keylist_sortby = sortby; |
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED); |
951 |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
if (mapi_init()) |
952 |
return TRUE; |
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED); |
953 |
} |
/* Override 'Default Keyserver' with the actual name. */ |
954 |
break; |
host = kserver_get_hostname (0, -1, &port); |
955 |
} |
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host); |
956 |
break; |
popup_gpg_readonly (dlg, popup); |
957 |
} |
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL); |
958 |
|
DestroyMenu (popup); |
959 |
case WM_WINDOWPOSCHANGING: |
DestroyMenu (hm); |
960 |
if (((WINDOWPOS*)lparam)->cx < 400) |
return TRUE; |
961 |
((WINDOWPOS*)lparam)->cx = 400; |
} |
962 |
if (((WINDOWPOS*)lparam)->cy < 200) |
#if 0 /* XXX */ |
963 |
((WINDOWPOS*)lparam)->cy = 200; |
if( notify->idFrom == IDC_KEYMISC_GROUP ) { |
964 |
return TRUE; |
HWND tree = GetDlgItem( dlg, IDC_KEYMISC_GROUP ); |
965 |
|
if( TreeView_GetSelection( tree ) ) { |
966 |
case WM_SIZE: |
GetCursorPos( &p ); |
967 |
do_resize_window (dlg, kmi); |
hm = LoadMenu( glob_hinst, MAKEINTRESOURCE(IDR_WINPT_GROUP_CTX) ); |
968 |
return TRUE; |
popup = GetSubMenu( hm, 0 ); |
969 |
|
if( km_index == -1 ) |
970 |
case WM_SYSCOMMAND: |
set_menu_state( popup, ID_GROUP_PASTE, MF_DISABLED|MF_GRAYED ); |
971 |
if( LOWORD (wparam) == SC_CLOSE ) |
set_menu_text( popup, ID_GROUP_PASTE, _("Paste into this group") ); |
972 |
EndDialog( dlg, TRUE ); |
set_menu_text( popup, ID_GROUP_DELETE, _("Delete") ); |
973 |
return FALSE; |
TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL ); |
974 |
|
DestroyMenu( popup ); |
975 |
case WM_MENUSELECT: |
DestroyMenu( hm ); |
976 |
menu_gpg_readonly (dlg, (HMENU)lparam, LOWORD (wparam)); |
return TRUE; |
977 |
break; |
} |
978 |
|
} |
979 |
case WM_COMMAND: |
#endif |
980 |
if( gnupg_access_keyring( 1 ) ) { |
break; |
981 |
msg_box( dlg, _("Could not access public keyring"), _("Key Manager"), MB_ERR ); |
|
982 |
return FALSE; |
case LVN_COLUMNCLICK: |
983 |
} |
if (notify->idFrom == IDC_KEYMISC_KEYLIST) { |
984 |
do_check_cache( kmi->lv, dlg, kmi->statbar ); |
NMLISTVIEW * p = (LPNMLISTVIEW) lparam; |
985 |
switch( LOWORD( wparam ) ) { |
int sortby = 0; |
986 |
case ID_KEYMISC_QUIT: |
switch (p->iSubItem) { |
987 |
EndDialog( dlg, TRUE ); |
case 0: sortby = KEY_SORT_USERID; break; |
988 |
return TRUE; |
case 1: sortby = KEY_SORT_KEYID; break; |
989 |
|
case 2: sortby = KEY_SORT_IS_SECRET; break; |
990 |
case ID_KEYMISC_MAIL: |
case 3: sortby = KEY_SORT_LEN; break; |
991 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_MAIL, GetDesktopWindow (), |
case 5: sortby = KEY_SORT_VALIDITY; break; |
992 |
winpt_mail_proc, NULL); |
case 6: sortby = KEY_SORT_OTRUST; break; |
993 |
break; |
case 7: sortby = KEY_SORT_CREATED; break; |
994 |
|
case 8: sortby = KEY_SORT_ALGO; break; |
995 |
case ID_KEYMISC_FIND: |
default: return TRUE; //sortby = KEY_SORT_USERID; break; |
996 |
km_find_key (dlg, kmi->lv); |
} |
997 |
break; |
|
998 |
|
if ((kmi->keylist_sortby & ~KEYLIST_SORT_DESC) == sortby) |
999 |
case ID_KEYMISC_DELETE: |
kmi->keylist_sortby ^= KEYLIST_SORT_DESC; |
1000 |
if (km_delete_keys (kmi->lv, dlg)) |
else |
1001 |
return FALSE; |
kmi->keylist_sortby = sortby; |
1002 |
return TRUE; |
keylist_sort (kmi->lv, kmi->keylist_sortby); |
1003 |
|
return TRUE; |
1004 |
case ID_KEYMISC_SIGN: |
} |
1005 |
if ( (idx = listview_get_curr_pos( kmi->lv )) == -1 ) { |
break; |
1006 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), |
} |
1007 |
MB_ERR ); |
break; |
1008 |
return FALSE; |
} |
1009 |
} |
|
1010 |
if (km_check_key_status (kmi->lv, idx)) |
case WM_WINDOWPOSCHANGING: |
1011 |
return FALSE; |
if (((WINDOWPOS*)lparam)->cx < 400) |
1012 |
key = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
((WINDOWPOS*)lparam)->cx = 400; |
1013 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
if (((WINDOWPOS*)lparam)->cy < 200) |
1014 |
memset (&k, 0, sizeof (k)); |
((WINDOWPOS*)lparam)->cy = 200; |
1015 |
k.ctx = key; |
return TRUE; |
1016 |
k.keyid = keyid; |
|
1017 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIGN, dlg, |
case WM_SIZE: |
1018 |
keysign_dlg_proc, (LPARAM)&k, |
do_resize_window (dlg, kmi); |
1019 |
_("Key Signing"), IDS_WINPT_KEYSIGN); |
return TRUE; |
1020 |
if (k.update) |
|
1021 |
update_key (kmi->lv, idx, k.keyid, 0); |
case WM_SYSCOMMAND: |
1022 |
return TRUE; |
if( LOWORD (wparam) == SC_CLOSE ) |
1023 |
|
EndDialog( dlg, TRUE ); |
1024 |
case ID_KEYMISC_REVCERT: |
return FALSE; |
1025 |
idx = listview_get_curr_pos( kmi->lv ); |
|
1026 |
if( idx == -1 ) { |
case WM_MENUSELECT: |
1027 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
menu_gpg_readonly (dlg, (HMENU)lparam, LOWORD (wparam)); |
1028 |
return FALSE; |
break; |
1029 |
} |
|
1030 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
case WM_INITMENUPOPUP: |
1031 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid-1 ); |
if ((UINT)LOWORD (lparam) == 3) { |
1032 |
if ( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
HMENU hm = (HMENU)wparam; |
1033 |
msg_box( dlg, _("There is no secret key available!"), _("Key Manager"), MB_ERR ); |
set_menu_text_bypos (hm, 0, _("New")); |
1034 |
return FALSE; |
} |
1035 |
} |
return FALSE; |
1036 |
|
|
1037 |
{ |
case WM_COMMAND: |
1038 |
char t[128]; |
if( gnupg_access_keyring( 1 ) ) { |
1039 |
listview_get_item_text( kmi->lv, idx, 5, t, sizeof t -1 ); |
msg_box( dlg, _("Could not access public keyring"), _("Key Manager"), MB_ERR ); |
1040 |
if( strchr( t, 'R' ) ) { |
return FALSE; |
1041 |
msg_box( dlg, _("Key already revoked!"), _("Key Manager"), MB_INFO ); |
} |
1042 |
return FALSE; |
do_check_cache( kmi->lv, dlg, kmi->statbar ); |
1043 |
} |
switch( LOWORD( wparam ) ) { |
1044 |
} |
case ID_KEYMISC_QUIT: |
1045 |
|
EndDialog( dlg, TRUE ); |
1046 |
name = km_quote_uid (uid); |
return TRUE; |
1047 |
memset (&k, 0, sizeof (k)); |
|
1048 |
k.key_pair = 1; |
case ID_KEYMISC_MAIL: |
1049 |
k.keyid = keyid; |
/* XXX |
1050 |
k.uid = name; |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_MAIL, GetDesktopWindow (), |
1051 |
k.is_protected = km_check_if_protected( kmi->lv, idx ); |
winpt_mail_proc, NULL);*/ |
1052 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYREVOKE, dlg, |
break; |
1053 |
key_revoke_dlg_proc, (LPARAM)&k, |
|
1054 |
_("Key Revocation"), IDS_WINPT_KEYREVOKE ); |
case ID_KEYMISC_FIND: |
1055 |
free_if_alloc (name); |
km_find_key (dlg, kmi->lv); |
1056 |
return TRUE; |
break; |
1057 |
|
|
1058 |
case ID_KEYMISC_TRUSTPATH: |
case ID_KEYMISC_DELETE: |
1059 |
idx = listview_get_curr_pos( kmi->lv ); |
km_delete_keys (kmi->lv, dlg); |
1060 |
if( idx == -1 ) { |
return TRUE; |
1061 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1062 |
return FALSE; |
case ID_KEYMISC_SIGN: |
1063 |
} |
if ( (idx = listview_get_curr_pos( kmi->lv )) == -1 ) { |
1064 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), |
1065 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid -1 ); |
MB_ERR ); |
1066 |
if( km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
return TRUE;; |
1067 |
msg_box( dlg, _("It does not make any sense with a key pair!"), _("Key Manager"), MB_OK ); |
} |
1068 |
return FALSE; |
if (km_check_key_status (kmi->lv, idx)) |
1069 |
} |
return TRUE; |
1070 |
memset (&k, 0, sizeof (k)); |
key = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
1071 |
k.keyid = keyid; |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1072 |
k.uid = uid; |
memset (&k, 0, sizeof (k)); |
1073 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
k.ctx = key; |
1074 |
keytrust_dlg_proc, (LPARAM)&k, |
k.keyid = keyid; |
1075 |
_("List Trust Path"), IDS_WINPT_KEYTRUST ); |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIGN, dlg, |
1076 |
return TRUE; |
keysign_dlg_proc, (LPARAM)&k, |
1077 |
|
_("Key Signing"), IDS_WINPT_KEYSIGN); |
1078 |
case ID_KEYMISC_CHECKSIGS: |
if (k.update) |
1079 |
idx = listview_get_curr_pos (kmi->lv); |
update_key (kmi->lv, idx, k.keyid, 0); |
1080 |
if( idx == -1 ) { |
return TRUE; |
1081 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1082 |
return FALSE; |
case ID_KEYMISC_REVCERT: |
1083 |
} |
idx = listview_get_curr_pos( kmi->lv ); |
1084 |
listview_get_item_text (kmi->lv, idx, 0, uid, DIM (uid)-1); |
if( idx == -1 ) { |
1085 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1086 |
memset (&k, 0, sizeof (k)); |
return TRUE; |
1087 |
k.keyid = keyid; |
} |
1088 |
k.uid = uid; |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
1089 |
k.ctx = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid-1 ); |
1090 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIG, dlg, |
if ( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
1091 |
keysig_dlg_proc, (LPARAM)&k, |
msg_box( dlg, _("There is no secret key available!"), _("Key Manager"), MB_ERR ); |
1092 |
_("Key Signature List" ), IDS_WINPT_KEYSIG); |
return TRUE; |
1093 |
return TRUE; |
} |
1094 |
|
|
1095 |
case ID_KEYMISC_PROPS: |
{ |
1096 |
idx = listview_get_curr_pos( kmi->lv ); |
char t[128]; |
1097 |
if( idx == -1 ) { |
listview_get_item_text( kmi->lv, idx, 5, t, sizeof t -1 ); |
1098 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
if( strchr( t, 'R' ) ) { |
1099 |
return FALSE; |
msg_box( dlg, _("Key already revoked!"), _("Key Manager"), MB_INFO ); |
1100 |
} |
return TRUE; |
1101 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
} |
1102 |
listview_get_item_text (kmi->lv, idx, 2, type, DIM (type)-1); |
} |
1103 |
memset (&k, 0, sizeof (k)); |
|
1104 |
k.key_pair = 0; |
memset (&k, 0, sizeof (k)); |
1105 |
k.keyid = keyid; |
k.key_pair = 1; |
1106 |
if( !strcmp( type, "pub/sec" ) || !strcmp( type, "pub/crd" ) ) |
k.keyid = keyid; |
1107 |
k.key_pair = 1; |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1108 |
k.callback.ctl = kmi->lv; |
dialog_box_param(glob_hinst, (LPCSTR)IDD_WINPT_KEYREVOKE, dlg, |
1109 |
k.callback.idx = idx; |
key_revoke_dlg_proc, (LPARAM)&k, |
1110 |
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
_("Key Revocation"), IDS_WINPT_KEYREVOKE); |
1111 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYPROPS, dlg, |
return TRUE; |
1112 |
keyprops_dlg_proc, (LPARAM)&k, |
|
1113 |
_("Key Properties"), IDS_WINPT_KEYPROPS ); |
case ID_KEYMISC_TRUSTPATH: |
1114 |
if (k.callback.new_val != 0) { |
idx = listview_get_curr_pos( kmi->lv ); |
1115 |
t = get_key_trust_str (k.callback.new_val); |
if( idx == -1 ) { |
1116 |
listview_add_sub_item (kmi->lv, idx, 6, t); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1117 |
} |
return TRUE; |
1118 |
return TRUE; |
} |
1119 |
|
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 ); |
1120 |
case ID_KEYMISC_RECACHE: |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid -1 ); |
1121 |
/* If there is already a reload request, don't bother the user with a message. */ |
if( km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
1122 |
if( keycache_get_reload() == 1 ) |
msg_box( dlg, _("It does not make any sense with a key pair!"), _("Key Manager"), MB_OK ); |
1123 |
idx = IDYES; |
return FALSE; |
1124 |
else { |
} |
1125 |
char t[256]; |
memset (&k, 0, sizeof (k)); |
1126 |
_snprintf( t, sizeof t -1, |
k.keyid = keyid; |
1127 |
_("This is only useful when the keyring has been " |
k.uid = uid; |
1128 |
"modified (sign a key...).\n" |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYTRUST, dlg, |
1129 |
"Do you really want to reload the keycache?") ); |
keytrust_dlg_proc, (LPARAM)&k, |
1130 |
idx = msg_box( dlg, t, _("Key Manager"), MB_YESNO ); |
_("List Trust Path"), IDS_WINPT_KEYTRUST ); |
1131 |
} |
return TRUE; |
1132 |
if( idx == IDYES ) { |
|
1133 |
rcs.kr_reload = rcs.kr_update = 1; |
case ID_KEYMISC_CHECKSIGS: |
1134 |
rcs.tr_update = 0; |
idx = listview_get_curr_pos (kmi->lv); |
1135 |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
if( idx == -1 ) { |
1136 |
keycache_dlg_proc, (LPARAM)&rcs ); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1137 |
c = keycache_get_ctx( 1 ); |
return FALSE; |
1138 |
if( !c ) |
} |
1139 |
BUG( dlg ); |
listview_get_item_text (kmi->lv, idx, 0, uid, DIM (uid)-1); |
1140 |
keylist_reload( kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID ); |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1141 |
refresh_keys = 0; |
memset (&k, 0, sizeof (k)); |
1142 |
} |
k.keyid = keyid; |
1143 |
return TRUE; |
k.uid = uid; |
1144 |
|
k.ctx = (gpgme_key_t)listview_get_item2 (kmi->lv, idx); |
1145 |
case ID_KEYMISC_REBUILD: |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIG, dlg, |
1146 |
rcs.kr_reload = rcs.kr_update = 0; |
keysig_dlg_proc, (LPARAM)&k, |
1147 |
rcs.tr_update = 1; |
_("Key Signature List" ), IDS_WINPT_KEYSIG); |
1148 |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
return TRUE; |
1149 |
keycache_dlg_proc, (LPARAM)&rcs ); |
|
1150 |
c = keycache_get_ctx( 1 ); |
case ID_KEYMISC_PROPS: |
1151 |
if( !c ) |
idx = listview_get_curr_pos( kmi->lv ); |
1152 |
BUG( dlg ); |
if( idx == -1 ) { |
1153 |
keylist_reload( kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID ); |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1154 |
return TRUE; |
return FALSE; |
1155 |
|
} |
1156 |
case ID_KEYMISC_NEWKEY: |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1157 |
memset (&genkey, 0, sizeof (genkey)); |
listview_get_item_text (kmi->lv, idx, 2, type, DIM (type)-1); |
1158 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYGEN, dlg, |
memset (&k, 0, sizeof (k)); |
1159 |
keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"), |
k.key_pair = 0; |
1160 |
IDS_WINPT_KEYGEN); |
k.keyid = keyid; |
1161 |
if (genkey.newkey != NULL) |
if( !strcmp( type, "pub/sec" ) || !strcmp( type, "pub/crd" ) ) |
1162 |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
k.key_pair = 1; |
1163 |
return TRUE; |
k.callback.ctl = kmi->lv; |
1164 |
|
k.callback.idx = idx; |
1165 |
case ID_KEYMISC_CARDNEW: |
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
1166 |
if( !scard_support ) { |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYPROPS, dlg, |
1167 |
msg_box( dlg, _("Smart Card support is not available."), _("Key Manager"), MB_INFO ); |
keyprops_dlg_proc, (LPARAM)&k, |
1168 |
return FALSE; |
_("Key Properties"), IDS_WINPT_KEYPROPS ); |
1169 |
} |
if (k.callback.new_val != 0) { |
1170 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg, |
t = get_key_trust_str (k.callback.new_val); |
1171 |
card_keygen_dlg_proc, NULL, _("Card Key Generation"), |
listview_add_sub_item (kmi->lv, idx, 6, t); |
1172 |
IDS_WINPT_CARD_KEYGEN ); |
} |
1173 |
/* XXX: use new code */ |
return TRUE; |
1174 |
if( keycache_get_reload() ) |
|
1175 |
send_cmd_id( dlg, ID_KEYMISC_RECACHE ); |
case ID_KEYMISC_RECACHE: |
1176 |
return TRUE; |
/* If there is already a reload request, don't bother the user with a message. */ |
1177 |
|
if( keycache_get_reload() == 1 ) |
1178 |
case ID_KEYMISC_KEYWIZARD: |
idx = IDYES; |
1179 |
memset (&genkey, 0, sizeof (genkey)); |
else { |
1180 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, dlg, |
char t[256]; |
1181 |
keygen_wizard_dlg_proc, (LPARAM)&genkey, _("Key Generation Wizard"), |
_snprintf( t, sizeof t -1, |
1182 |
IDS_WINPT_KEYWIZARD); |
_("This is only useful when the keyring has been " |
1183 |
if (genkey.newkey != NULL) |
"modified (sign a key...).\n" |
1184 |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
"Do you really want to reload the keycache?") ); |
1185 |
return TRUE; |
idx = msg_box( dlg, t, _("Key Manager"), MB_YESNO ); |
1186 |
|
} |
1187 |
case ID_KEYMISC_SENDRECV: |
if( idx == IDYES ) { |
1188 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
rcs.kr_reload = rcs.kr_update = 1; |
1189 |
keyserver_dlg_proc, NULL, _("Keyserver Access"), |
rcs.tr_update = 0; |
1190 |
IDS_WINPT_KEYSERVER ); |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
1191 |
return TRUE; |
keycache_dlg_proc, (LPARAM)&rcs ); |
1192 |
|
c = keycache_get_ctx( 1 ); |
1193 |
case ID_KEYMISC_GPGPREFS: |
if( !c ) |
1194 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, dlg, |
BUG( dlg ); |
1195 |
gpgprefs_dlg_proc, NULL, _("GnuPG Preferences"), |
keylist_reload( kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID ); |
1196 |
IDS_WINPT_GPGPREFS ); |
refresh_keys = 0; |
1197 |
return TRUE; |
} |
1198 |
|
return TRUE; |
1199 |
case ID_KEYMISC_GPGOPT: |
|
1200 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGOPT, dlg, |
case ID_KEYMISC_REBUILD: |
1201 |
gpgopt_dlg_proc, NULL, _("GnuPG Options" ), |
name=NULL; |
1202 |
IDS_WINPT_GPGOPT ); |
gpg_rebuild_cache (&name); |
1203 |
return TRUE; |
if (name) { |
1204 |
|
char *p = strchr (name, '\n'); |
1205 |
case ID_KEYMISC_IMPORT: |
show_msg (dlg, 2000, p? name + (p-name)+1 : name); |
1206 |
t = get_filename_dlg (dlg, FILE_OPEN, _("Choose Name of the Key File"), NULL, NULL); |
free (name); |
1207 |
if (t) |
} |
1208 |
km_file_import (dlg, t); |
return TRUE; |
1209 |
return TRUE; |
|
1210 |
|
case ID_KEYMISC_NEWKEY: |
1211 |
case ID_KEYMISC_IMPORT_HTTP: |
memset (&genkey, 0, sizeof (genkey)); |
1212 |
url = (struct URL_ctx_s*)get_http_file_dlg (dlg); |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYGEN, dlg, |
1213 |
if (url->cancel == 0) |
keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"), |
1214 |
km_http_import (dlg, url->url); |
IDS_WINPT_KEYGEN); |
1215 |
delete url; url=NULL; |
if (genkey.newkey != NULL) |
1216 |
break; |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
1217 |
|
return TRUE; |
1218 |
case ID_KEYMISC_EXPORT: |
|
1219 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYMISC_CARDNEW: |
1220 |
if (idx == -1) { |
if( !scard_support ) { |
1221 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
msg_box( dlg, _("Smart Card support is not available."), _("Key Manager"), MB_INFO ); |
1222 |
return FALSE; |
return TRUE; |
1223 |
} |
} |
1224 |
if (listview_count_items (kmi->lv, 1) > 1) |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg, |
1225 |
name = m_strdup ("Exported_GPG_Keys.asc"); |
card_keygen_dlg_proc, NULL, _("Card Key Generation"), |
1226 |
else { |
IDS_WINPT_CARD_KEYGEN ); |
1227 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
/* XXX: use new code */ |
1228 |
name = gen_export_filename (keyid); |
if( keycache_get_reload() ) |
1229 |
} |
send_cmd_id( dlg, ID_KEYMISC_RECACHE ); |
1230 |
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
return TRUE; |
1231 |
free_if_alloc (name); |
|
1232 |
if (t != NULL) |
case ID_KEYMISC_KEYWIZARD: |
1233 |
return FALSE; |
memset (&genkey, 0, sizeof (genkey)); |
1234 |
km_file_export (dlg, kmi->lv, t); |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, dlg, |
1235 |
return TRUE; |
keygen_wizard_dlg_proc, (LPARAM)&genkey, _("Key Generation Wizard"), |
1236 |
|
IDS_WINPT_KEYWIZARD); |
1237 |
case ID_KEYMISC_EXPORT_PRIVKEY: |
if (genkey.newkey != NULL) |
1238 |
idx = listview_get_curr_pos( kmi->lv ); |
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey); |
1239 |
if( idx == -1 ) { |
return TRUE; |
1240 |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
|
1241 |
return FALSE; |
case ID_KEYMISC_SENDRECV: |
1242 |
} |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg, |
1243 |
if( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
keyserver_dlg_proc, NULL, _("Keyserver Access"), |
1244 |
msg_box( dlg, _("There is no corresponding secret key for this key."), |
IDS_WINPT_KEYSERVER ); |
1245 |
_("Key Manager"), MB_ERR ); |
return TRUE; |
1246 |
return FALSE; |
|
1247 |
} |
case ID_KEYMISC_GPGPREFS: |
1248 |
if( listview_count_items( kmi->lv, 1 ) > 1 ) { |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, dlg, |
1249 |
msg_box( dlg, _("You can only export one secret key."), _("Key Manager"), MB_ERR ); |
gpgprefs_dlg_proc, NULL, _("GnuPG Preferences"), |
1250 |
return FALSE; |
IDS_WINPT_GPGPREFS ); |
1251 |
} |
return TRUE; |
1252 |
idx = msg_box( dlg, |
|
1253 |
_("This operation will export your *SECRET* key!\n\n" |
case ID_KEYMISC_GPGOPT: |
1254 |
"Never send this key to ANYONE, it should be available\n" |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_GPGOPT, dlg, |
1255 |
"ONLY on your machine and you may use this function\n" |
gpgopt_dlg_proc, NULL, _("GnuPG Options" ), |
1256 |
"to copy the key to a safe place.\n\n" |
IDS_WINPT_GPGOPT ); |
1257 |
"Do you really want to export the key?"), |
return TRUE; |
1258 |
_("WARNING"), MB_INFO|MB_YESNO ); |
|
1259 |
if( idx == IDYES ) { |
case ID_KEYMISC_IMPORT: |
1260 |
idx = listview_get_curr_pos( kmi->lv ); |
t = get_filename_dlg (dlg, FILE_OPEN, _("Choose Name of the Key File"), NULL, NULL); |
1261 |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof (keyid)-8 ); |
if (t) |
1262 |
name = gen_export_filename (keyid); |
km_file_import (dlg, t); |
1263 |
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
return TRUE; |
1264 |
if (t != NULL) |
|
1265 |
km_privkey_export (dlg, kmi->lv, t); |
case ID_KEYMISC_IMPORT_HTTP: |
1266 |
} |
url = (struct URL_ctx_s*)get_http_file_dlg (dlg); |
1267 |
break; |
if (url->cancel == 0) |
1268 |
|
km_http_import (dlg, url->url); |
1269 |
case ID_KEYMISC_INFO: |
delete url; url=NULL; |
1270 |
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, glob_hwnd, |
break; |
1271 |
about_winpt_dlg_proc, NULL, _("About WinPT"), |
|
1272 |
IDS_WINPT_ABOUT ); |
case ID_KEYMISC_EXPORT: |
1273 |
break; |
idx = listview_get_curr_pos (kmi->lv); |
1274 |
|
if (idx == -1) { |
1275 |
case ID_KEYMISC_HELP: |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1276 |
ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW); |
return TRUE; |
1277 |
break; |
} |
1278 |
|
if (listview_count_items (kmi->lv, 1) > 1) |
1279 |
case ID_KEYMISC_OT: |
name = m_strdup ("Exported_GPG_Keys.asc"); |
1280 |
dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_OWNERTRUST, glob_hwnd, |
else { |
1281 |
ownertrust_dlg_proc, NULL, |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1282 |
_("Ownertrust"), IDS_WINPT_OWNERTRUST ); |
name = gen_export_filename (keyid, 0); |
1283 |
break; |
} |
1284 |
|
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
1285 |
case ID_KEYMISC_EDITKEY: |
free_if_alloc (name); |
1286 |
idx = listview_get_curr_pos (kmi->lv); |
if (t == NULL) |
1287 |
if (idx == -1) |
return TRUE; |
1288 |
break; |
km_file_export (dlg, kmi->lv, t); |
1289 |
listview_get_item_text (kmi->lv, idx, 1, keyid, sizeof (keyid)-1); |
return TRUE; |
1290 |
/* XXX: pub/crd = secret key does not work */ |
|
1291 |
memset (&k, 0, sizeof (k)); |
case ID_KEYMISC_EXPORT_PRIVKEY: |
1292 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
idx = listview_get_curr_pos( kmi->lv ); |
1293 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
if( idx == -1 ) { |
1294 |
k.keyid = keyid; |
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR ); |
1295 |
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
return TRUE; |
1296 |
k.flags = km_get_key_status (kmi->lv, idx); |
} |
1297 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT, dlg, |
if( !km_check_for_seckey( kmi->lv, idx, NULL ) ) { |
1298 |
keyedit_main_dlg_proc, (LPARAM)&k, |
msg_box( dlg, _("There is no corresponding secret key for this key."), |
1299 |
_("Key Edit"), IDS_KEYCTX_EDIT); |
_("Key Manager"), MB_ERR ); |
1300 |
if (k.update) |
return TRUE; |
1301 |
update_key (kmi->lv, idx, keyid, 1); |
} |
1302 |
break; |
if( listview_count_items( kmi->lv, 1 ) > 1 ) { |
1303 |
|
msg_box( dlg, _("You can only export one secret key."), _("Key Manager"), MB_ERR ); |
1304 |
case ID_KEYMISC_COPY: |
return TRUE; |
1305 |
km_index = listview_get_curr_pos (kmi->lv); |
} |
1306 |
km_clip_export (dlg, kmi->lv); |
idx = msg_box( dlg, |
1307 |
break; |
_("This operation will export your *SECRET* key!\n\n" |
1308 |
|
"Never send this key to ANYONE, it should be available\n" |
1309 |
case ID_KEYMISC_SELALL: |
"ONLY on your machine and you may use this function\n" |
1310 |
listview_select_all (kmi->lv); |
"to copy the key to a safe place.\n\n" |
1311 |
break; |
"Do you really want to export the key?"), |
1312 |
|
_("WARNING"), MB_INFO|MB_YESNO ); |
1313 |
case ID_KEYMISC_PASTE: |
if( idx == IDYES ) { |
1314 |
km_index = -1; |
idx = listview_get_curr_pos( kmi->lv ); |
1315 |
km_clip_import (dlg); |
listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof (keyid)-8 ); |
1316 |
break; |
name = gen_export_filename (keyid, 1); |
1317 |
|
t = get_filename_dlg (dlg, FILE_SAVE, _("Choose Name for Key File"), NULL, name); |
1318 |
case ID_KEYCTX_SETPREFKS: |
if (t != NULL) |
1319 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM(keyid)-1); |
km_privkey_export (dlg, kmi->lv, t); |
1320 |
memset (&k, 0, sizeof (k)); |
} |
1321 |
k.keyid = keyid; |
break; |
1322 |
keyedit_set_pref_keyserver (&k, dlg); |
|
1323 |
break; |
case ID_KEYMISC_INFO: |
1324 |
|
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, glob_hwnd, |
1325 |
case ID_KEYMISC_REFRESH_KEYS: |
about_winpt_dlg_proc, NULL, _("About WinPT"), |
1326 |
if (listview_count_items (kmi->lv, 1) == 0) { |
IDS_WINPT_ABOUT ); |
1327 |
msg_box (dlg, _("No key was selected, select all by default."), _("Key Manager"), MB_INFO); |
break; |
1328 |
listview_select_all (kmi->lv); |
|
1329 |
} |
case ID_KEYMISC_HELP: |
1330 |
km_refresh_from_keyserver (kmi->lv, dlg); |
ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW); |
1331 |
break; |
break; |
1332 |
|
|
1333 |
/** Context menu **/ |
case ID_KEYMISC_OT: |
1334 |
case ID_KEYCTX_EDIT: |
dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_OWNERTRUST, glob_hwnd, |
1335 |
send_cmd_id( dlg, ID_KEYMISC_EDITKEY ); |
ownertrust_dlg_proc, NULL, |
1336 |
break; |
_("Ownertrust"), IDS_WINPT_OWNERTRUST ); |
1337 |
|
break; |
1338 |
case ID_KEYCTX_PROPS: |
|
1339 |
send_cmd_id( dlg, ID_KEYMISC_PROPS ); |
case ID_KEYMISC_EDITKEY: |
1340 |
break; |
idx = listview_get_curr_pos (kmi->lv); |
1341 |
|
if (idx == -1) |
1342 |
case ID_KEYCTX_UIDS: |
break; |
1343 |
send_cmd_id( dlg, ID_KEYMISC_UID ); |
listview_get_item_text (kmi->lv, idx, 1, keyid, sizeof (keyid)-1); |
1344 |
break; |
/* XXX: pub/crd = secret key does not work */ |
1345 |
|
memset (&k, 0, sizeof (k)); |
1346 |
case ID_KEYCTX_SIGN: |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1347 |
send_cmd_id( dlg, ID_KEYMISC_SIGN ); |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
1348 |
break; |
k.keyid = keyid; |
1349 |
|
k.is_v3 = km_key_is_v3 (kmi->lv, idx); |
1350 |
case ID_KEYCTX_DEL: |
k.flags = km_get_key_status (kmi->lv, idx); |
1351 |
send_cmd_id (dlg, ID_KEYMISC_DELETE); |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT, dlg, |
1352 |
break; |
keyedit_main_dlg_proc, (LPARAM)&k, |
1353 |
|
_("Key Edit"), IDS_KEYCTX_EDIT); |
1354 |
case ID_KEYCTX_REV: |
if (k.update) |
1355 |
send_cmd_id( dlg, ID_KEYMISC_REVCERT ); |
update_key (kmi->lv, idx, keyid, 1); |
1356 |
break; |
break; |
1357 |
|
|
1358 |
case ID_KEYCTX_SENDMAIL: |
case ID_KEYMISC_COPY: |
1359 |
km_send_to_mail_recipient (kmi->lv, dlg); |
km_index = listview_get_curr_pos (kmi->lv); |
1360 |
break; |
km_clip_export (dlg, kmi->lv); |
1361 |
|
break; |
1362 |
case ID_KEYCTX_KS_DEFAULT: |
|
1363 |
host = kserver_get_hostname (0, -1, &port); |
case ID_KEYMISC_SELALL: |
1364 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
listview_select_all (kmi->lv); |
1365 |
break; |
break; |
1366 |
|
|
1367 |
case ID_KEYCTX_ADDKEY: |
case ID_KEYMISC_PASTE: |
1368 |
idx = listview_get_curr_pos (kmi->lv); |
km_index = -1; |
1369 |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
km_clip_import (dlg); |
1370 |
memset (&k, 0, sizeof (k)); |
break; |
1371 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
|
1372 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
case ID_KEYCTX_SETPREFKS: |
1373 |
k.keyid = keyid; |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM(keyid)-1); |
1374 |
keyedit_add_subkey (&k, dlg, NULL); |
memset (&k, 0, sizeof (k)); |
1375 |
if (k.update) |
k.keyid = keyid; |
1376 |
update_key (kmi->lv, idx, keyid, 1); |
keyedit_set_pref_keyserver (&k, dlg); |
1377 |
break; |
break; |
1378 |
|
|
1379 |
case ID_KEYCTX_ADDUID: |
case ID_KEYMISC_REFRESH_KEYS: |
1380 |
idx = listview_get_curr_pos (kmi->lv); |
if (listview_count_items (kmi->lv, 1) == 0) { |
1381 |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
msg_box (dlg, _("No key was selected, select all by default."), _("Key Manager"), MB_INFO); |
1382 |
memset (&k, 0, sizeof (k)); |
listview_select_all (kmi->lv); |
1383 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
} |
1384 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
km_refresh_from_keyserver (kmi->lv, dlg); |
1385 |
k.keyid = keyid; |
break; |
1386 |
keyedit_add_userid (&k, dlg, NULL); |
|
1387 |
if (k.update) |
/** Context menu **/ |
1388 |
update_key (kmi->lv, idx, keyid, 1); |
case ID_KEYCTX_EDIT: |
1389 |
break; |
send_cmd_id( dlg, ID_KEYMISC_EDITKEY ); |
1390 |
|
break; |
1391 |
case ID_KEYCTX_ADDREV: |
|
1392 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_PROPS: |
1393 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
send_cmd_id( dlg, ID_KEYMISC_PROPS ); |
1394 |
memset (&k, 0, sizeof (k)); |
break; |
1395 |
k.keyid = keyid; |
|
1396 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
case ID_KEYCTX_UIDS: |
1397 |
k.key_pair = km_check_for_seckey( kmi->lv, idx, NULL ); |
send_cmd_id( dlg, ID_KEYMISC_UID ); |
1398 |
keyedit_add_revoker (&k, dlg); |
break; |
1399 |
if (k.update) |
|
1400 |
update_key (kmi->lv, idx, keyid, 1); |
case ID_KEYCTX_SIGN: |
1401 |
break; |
send_cmd_id( dlg, ID_KEYMISC_SIGN ); |
1402 |
|
break; |
1403 |
case ID_KEYCTX_ADDPHOTO: |
|
1404 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_DEL: |
1405 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
send_cmd_id (dlg, ID_KEYMISC_DELETE); |
1406 |
memset (&k, 0, sizeof (k)); |
break; |
1407 |
k.keyid = keyid; |
|
1408 |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
case ID_KEYCTX_REV: |
1409 |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
send_cmd_id( dlg, ID_KEYMISC_REVCERT ); |
1410 |
keyedit_add_photo (&k, dlg); |
break; |
1411 |
if (k.update) |
|
1412 |
update_key (kmi->lv, idx, keyid, 1); |
case ID_KEYCTX_SENDMAIL: |
1413 |
break; |
km_send_to_mail_recipient (kmi->lv, dlg); |
1414 |
|
break; |
1415 |
case ID_KEYCTX_KS_NL: |
|
1416 |
case ID_KEYCTX_KS_PL: |
case ID_KEYCTX_KS_DEFAULT: |
1417 |
case ID_KEYCTX_KS_AT: |
host = kserver_get_hostname (0, -1, &port); |
1418 |
case ID_KEYCTX_KS_DE: |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
1419 |
case ID_KEYCTX_KS_DK: |
break; |
1420 |
case ID_KEYCTX_KS_CZ: |
|
1421 |
case ID_KEYCTX_KS_ES: |
case ID_KEYCTX_ADDKEY: |
1422 |
case ID_KEYCTX_KS_UK: |
idx = listview_get_curr_pos (kmi->lv); |
1423 |
host = kserver_get_hostname (LOWORD (wparam) - 40107, 0, &port); |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1424 |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
memset (&k, 0, sizeof (k)); |
1425 |
break; |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
1426 |
|
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1427 |
case ID_KEYCTX_RECVFROM: |
k.keyid = keyid; |
1428 |
km_refresh_from_keyserver (kmi->lv, dlg); |
keyedit_add_subkey (&k, dlg, NULL); |
1429 |
break; |
if (k.update) |
1430 |
|
update_key (kmi->lv, idx, keyid, 1); |
1431 |
case ID_KEYCTX_UID_COPY: |
break; |
1432 |
/* XXX: add generic function to support multiple selection |
|
1433 |
with a callback */ |
case ID_KEYCTX_ADDUID: |
1434 |
idx = listview_get_curr_pos( kmi->lv ); |
idx = listview_get_curr_pos (kmi->lv); |
1435 |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid-1 ); |
listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1436 |
set_clip_text( NULL, uid, strlen( uid ) ); |
memset (&k, 0, sizeof (k)); |
1437 |
break; |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
1438 |
|
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1439 |
case ID_KEYCTX_KEYID_COPY: |
k.keyid = keyid; |
1440 |
idx = listview_get_curr_pos( kmi->lv ); |
keyedit_add_userid (&k, dlg, NULL); |
1441 |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
if (k.update) |
1442 |
set_clip_text( NULL, uid, strlen( uid ) ); |
update_key (kmi->lv, idx, keyid, 1); |
1443 |
break; |
break; |
1444 |
|
|
1445 |
case ID_KEYCTX_FPR_COPY: |
case ID_KEYCTX_ADDREV: |
1446 |
idx = listview_get_curr_pos( kmi->lv ); |
idx = listview_get_curr_pos (kmi->lv); |
1447 |
key = (gpgme_key_t) listview_get_item2 (kmi->lv, idx); |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1448 |
if (key) { |
memset (&k, 0, sizeof (k)); |
1449 |
const char * s = get_key_fpr (key); |
k.keyid = keyid; |
1450 |
set_clip_text (NULL, s? s : "", s? strlen (s): 0); |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1451 |
} |
k.key_pair = km_check_for_seckey( kmi->lv, idx, NULL ); |
1452 |
break; |
keyedit_add_revoker (&k, dlg); |
1453 |
|
if (k.update) |
1454 |
case ID_KEYCTX_KINFO_COPY: |
update_key (kmi->lv, idx, keyid, 1); |
1455 |
idx = listview_get_curr_pos( kmi->lv ); |
break; |
1456 |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
|
1457 |
km_set_clip_info( uid ); |
case ID_KEYCTX_ADDPHOTO: |
1458 |
break; |
idx = listview_get_curr_pos (kmi->lv); |
1459 |
|
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1460 |
case ID_KEYCTX_COPY: |
memset (&k, 0, sizeof (k)); |
1461 |
km_index = listview_get_curr_pos (kmi->lv); |
k.keyid = keyid; |
1462 |
km_clip_export (dlg, kmi->lv); |
k.is_protected = km_check_if_protected (kmi->lv, idx); |
1463 |
break; |
k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL); |
1464 |
|
keyedit_add_photo (&k, dlg); |
1465 |
case ID_KEYCTX_PASTE: |
if (k.update) |
1466 |
km_index = -1; |
update_key (kmi->lv, idx, keyid, 1); |
1467 |
km_clip_import (dlg); |
break; |
1468 |
break; |
|
1469 |
|
case ID_KEYCTX_KS_NL: |
1470 |
case ID_KEYCTX_DISABLE: |
case ID_KEYCTX_KS_PL: |
1471 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_KS_AT: |
1472 |
km_enable_disable_key (kmi->lv, dlg, idx, 0); |
case ID_KEYCTX_KS_DE: |
1473 |
break; |
case ID_KEYCTX_KS_DK: |
1474 |
|
case ID_KEYCTX_KS_CZ: |
1475 |
case ID_KEYCTX_ENABLE: |
case ID_KEYCTX_KS_ES: |
1476 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_KS_UK: |
1477 |
km_enable_disable_key (kmi->lv, dlg, idx, 1); |
host = kserver_get_hostname (LOWORD (wparam) - 40107, 0, &port); |
1478 |
break; |
km_send_to_keyserver (kmi->lv, dlg, host, port); |
1479 |
|
break; |
1480 |
case ID_KEYCTX_LISTSIGS: |
|
1481 |
send_cmd_id (dlg, ID_KEYMISC_CHECKSIGS); |
case ID_KEYCTX_RECVFROM: |
1482 |
break; |
km_refresh_from_keyserver (kmi->lv, dlg); |
1483 |
|
break; |
1484 |
case ID_KEYCTX_MAXTRUST: |
|
1485 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_UID_COPY: |
1486 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
/* XXX: add generic function to support multiple selection |
1487 |
rc = km_set_implicit_trust (dlg, kmi->lv, idx); |
with a callback */ |
1488 |
if (!rc) |
idx = listview_get_curr_pos( kmi->lv ); |
1489 |
update_key (kmi->lv, idx, keyid, 0); |
listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid-1 ); |
1490 |
break; |
set_clip_text( NULL, uid, strlen( uid ) ); |
1491 |
|
break; |
1492 |
case ID_KEYCTX_SETDEFKEY: |
|
1493 |
idx = listview_get_curr_pos (kmi->lv); |
case ID_KEYCTX_KEYID_COPY: |
1494 |
if (!km_check_key_status (kmi->lv, idx)) { |
idx = listview_get_curr_pos( kmi->lv ); |
1495 |
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
1496 |
rc = set_gnupg_default_key (keyid); |
set_clip_text( NULL, uid, strlen( uid ) ); |
1497 |
if (rc) |
break; |
1498 |
msg_box( dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR); |
|
1499 |
km_update_default_key_str (kmi->statbar); |
case ID_KEYCTX_FPR_COPY: |
1500 |
} |
idx = listview_get_curr_pos( kmi->lv ); |
1501 |
break; |
key = (gpgme_key_t) listview_get_item2 (kmi->lv, idx); |
1502 |
|
if (key) { |
1503 |
#if 0 /* XXX */ |
const char * s = get_key_fpr (key); |
1504 |
case ID_GROUP_NEW: |
set_clip_text (NULL, s? s : "", s? strlen (s): 0); |
1505 |
memset (&gcb, 0, sizeof (gcb)); |
} |
1506 |
gcb.gc = gc; |
break; |
1507 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GROUP, glob_hwnd, |
|
1508 |
group_manager_dlg_proc, (LPARAM)&gcb, _("New Group"), |
case ID_KEYCTX_KINFO_COPY: |
1509 |
IDS_WINPT_GROUP); |
idx = listview_get_curr_pos( kmi->lv ); |
1510 |
if( gcb.use_name ) |
listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 ); |
1511 |
treeview_add_item( GetDlgItem(dlg, IDC_KEYMISC_GROUP), NULL, gcb.name ); |
km_set_clip_info( uid ); |
1512 |
return TRUE; |
break; |
1513 |
|
|
1514 |
case ID_GROUP_PASTE: |
case ID_KEYCTX_COPY: |
1515 |
km_groups_add (gc, kmi->lv, km_index); |
km_index = listview_get_curr_pos (kmi->lv); |
1516 |
break; |
km_clip_export (dlg, kmi->lv); |
1517 |
|
break; |
1518 |
case ID_GROUP_DELETE: |
|
1519 |
km_groups_del (gc); |
case ID_KEYCTX_PASTE: |
1520 |
break; |
km_index = -1; |
1521 |
#endif |
km_clip_import (dlg); |
1522 |
} |
break; |
1523 |
|
|
1524 |
break; |
case ID_KEYCTX_DISABLE: |
1525 |
} |
idx = listview_get_curr_pos (kmi->lv); |
1526 |
|
km_enable_disable_key (kmi->lv, dlg, idx, 0); |
1527 |
return FALSE; |
break; |
1528 |
} /* keymanager_dlg_proc */ |
|
1529 |
|
case ID_KEYCTX_ENABLE: |
1530 |
|
idx = listview_get_curr_pos (kmi->lv); |
1531 |
|
km_enable_disable_key (kmi->lv, dlg, idx, 1); |
1532 |
|
break; |
1533 |
|
|
1534 |
|
case ID_KEYCTX_LISTSIGS: |
1535 |
|
send_cmd_id (dlg, ID_KEYMISC_CHECKSIGS); |
1536 |
|
break; |
1537 |
|
|
1538 |
|
case ID_KEYCTX_MAXTRUST: |
1539 |
|
idx = listview_get_curr_pos (kmi->lv); |
1540 |
|
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1541 |
|
rc = km_set_implicit_trust (dlg, kmi->lv, idx); |
1542 |
|
if (!rc) |
1543 |
|
update_key (kmi->lv, idx, keyid, 0); |
1544 |
|
break; |
1545 |
|
|
1546 |
|
case ID_KEYCTX_SETDEFKEY: |
1547 |
|
idx = listview_get_curr_pos (kmi->lv); |
1548 |
|
if (!km_check_key_status (kmi->lv, idx)) { |
1549 |
|
listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1); |
1550 |
|
rc = set_gnupg_default_key (keyid); |
1551 |
|
if (rc) |
1552 |
|
msg_box( dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR); |
1553 |
|
km_update_default_key_str (kmi->statbar); |
1554 |
|
} |
1555 |
|
break; |
1556 |
|
|
1557 |
|
#if 0 /* XXX */ |
1558 |
|
case ID_GROUP_NEW: |
1559 |
|
memset (&gcb, 0, sizeof (gcb)); |
1560 |
|
gcb.gc = gc; |
1561 |
|
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GROUP, glob_hwnd, |
1562 |
|
group_manager_dlg_proc, (LPARAM)&gcb, _("New Group"), |
1563 |
|
IDS_WINPT_GROUP); |
1564 |
|
if( gcb.use_name ) |
1565 |
|
treeview_add_item( GetDlgItem(dlg, IDC_KEYMISC_GROUP), NULL, gcb.name ); |
1566 |
|
return TRUE; |
1567 |
|
|
1568 |
|
case ID_GROUP_PASTE: |
1569 |
|
km_groups_add (gc, kmi->lv, km_index); |
1570 |
|
break; |
1571 |
|
|
1572 |
|
case ID_GROUP_DELETE: |
1573 |
|
km_groups_del (gc); |
1574 |
|
break; |
1575 |
|
#endif |
1576 |
|
} |
1577 |
|
|
1578 |
|
break; |
1579 |
|
} |
1580 |
|
|
1581 |
|
return FALSE; |
1582 |
|
} |
1583 |
|
|
1584 |
|
|
1585 |
|
|