/[winpt]/trunk/Src/wptKeyManagerDlg.cpp
ViewVC logotype

Annotation of /trunk/Src/wptKeyManagerDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (hide annotations)
Thu Oct 20 12:35:59 2005 UTC (19 years, 4 months ago) by twoaday
File size: 53104 byte(s)
Minor cleanups and prepare the translation.

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26