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