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

Annotation of /trunk/Src/wptKeyRevokersDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20 - (hide annotations)
Wed Jul 27 11:17:22 2005 UTC (19 years, 7 months ago) by twoaday
File size: 4649 byte(s)
2005-07-22  Timo Schulz  <twoaday@freakmail.de>
 
        * wptMainProc.cpp (winpt_main_proc): Take care for shutdown
        messages and make sure WinPT make a keyring backup in this case.
        * wptGPGME.cpp (keycache_reload): Do not rebuild the signature
        cache each time. Just do it on startup.
        * wptKeyManager.cpp (km_key_is_v3): Use new ATTR_VERSION.
        * wptKeyEditDlgs.cpp (keyedit_main_dlg_proc): Assume the v3 flag
        was set by the calling function.
        * wptKeyGenDlg.cpp (keygen_wizard_dlg_proc): Ask for backups.
        (keygen_dlg_proc): Only add the generated key to the keycache
        and do not reload the entire cache.
        * wptKeyManager.cpp (km_delete_keys): Store the number of keys
        because in each loop iteration it will be new calculated.
        * wptListView.cpp (listview_del_items): Likewise.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Directly add the
        generated key to the list instead of reloading the entire cache.
        * wptKeyEditDlgs.cpp (parse_preflist): Support fpr SHAnnn.


1 twoaday 2 /* wptKeyRevokersDlg.cpp - Designated Revoker Keys
2     * Copyright (C) 2002, 2003, 2005 Timo Schulz
3     *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * WinPT is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with WinPT; if not, write to the Free Software Foundation,
18     * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19     */
20    
21     #include <windows.h>
22     #include <commctrl.h>
23    
24     #include "../resource.h"
25     #include "wptCommonCtl.h"
26     #include "wptNLS.h"
27     #include "wptTypes.h"
28     #include "wptGPG.h"
29     #include "wptCommonCtl.h"
30     #include "wptContext.h"
31     #include "wptDlgs.h"
32     #include "wptErrors.h"
33     #include "wptKeyserver.h"
34 twoaday 20 #include "wptW32Api.h"
35     #include "wptVersion.h"
36 twoaday 2
37    
38     static int
39 twoaday 20 revokelist_build (listview_ctrl_t *r_lv, HWND ctrl)
40 twoaday 2 {
41     listview_ctrl_t lv;
42     struct listview_column_s rlist[] = {
43     { 0, 55, (char *)_("Algorithm") },
44     { 1, 80, (char *)_("Key ID") },
45     { 2, 160, (char *)_("Name") },
46     {0}
47     };
48     int i, rc;
49    
50     rc = listview_new( &lv );
51     if( rc )
52     return rc;
53     lv->ctrl = ctrl;
54     lv->items = DIM( rlist )-1;
55     for( i = 0; i < lv->items; i++ )
56     listview_add_column( lv, &rlist[i] );
57     listview_set_ext_style( lv );
58     *r_lv = lv;
59     return 0;
60     } /* revokelist_build */
61    
62    
63     static listview_ctrl_t
64     revokelist_init (HWND ctrl, gpgme_key_t key, gpgme_keycache_t ctx)
65     {
66     const char *keyid, *alg, *id;
67     int i, nkeys;
68     gpgme_key_t revkey;
69     listview_ctrl_t lv;
70    
71     if (revokelist_build (&lv, ctrl))
72     BUG (0);
73    
74     nkeys = gpgme_key_count_items (key, GPGME_ATTR_REVKEY_FPR);
75     for (i = 0; i < nkeys; i++) {
76     int algo = gpgme_key_get_ulong_attr (key, GPGME_ATTR_REVKEY_ALGO, NULL, i);
77     alg = gpgme_key_expand_attr (GPGME_ATTR_ALGO, algo);
78     keyid = gpgme_key_get_string_attr (key, GPGME_ATTR_REVKEY_FPR, NULL, i);
79     if (!keyid)
80     continue;
81     keyid += 32;
82     if (get_pubkey (keyid, &revkey))
83     id = _("User ID was not found");
84     else
85     id = gpgme_key_get_string_attr (revkey, GPGME_ATTR_NAME, NULL, 0);
86     listview_add_item (lv, "");
87     listview_add_sub_item (lv, 0, 0, alg);
88     listview_add_sub_item (lv, 0, 1, keyid);
89     listview_add_sub_item (lv, 0, 2, id);
90     }
91     return lv;
92     } /* revokelist_init */
93    
94    
95     BOOL CALLBACK
96 twoaday 20 key_revokers_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
97 twoaday 2 {
98     static listview_ctrl_t lv;
99     gpgme_key_t key;
100     char buf[128], keyid[32];
101     int rc;
102    
103     switch( msg ) {
104     case WM_INITDIALOG:
105     gpgme_keycache_t ctx;
106     key = (gpgme_key_t)lparam;
107     if( !key )
108     dlg_fatal_error( dlg, "Could not get dilaog param" );
109     ctx = keycache_get_ctx( 1 );
110     if( !ctx )
111     BUG( dlg );
112     lv = revokelist_init( GetDlgItem( dlg, IDC_KEYREVOKERS_LIST ), key, ctx );
113     return TRUE;
114    
115     case WM_NOTIFY:
116     NMHDR *notify;
117     notify = (NMHDR *)lparam;
118 twoaday 20 if (notify && notify->code == NM_DBLCLK && notify->idFrom == IDC_KEYREVOKERS_LIST) {
119     int idx = listview_get_curr_pos (lv);
120     listview_get_item_text (lv, idx, 1, keyid, DIM (keyid)-1);
121     listview_get_item_text (lv, idx, 2, buf, DIM (buf)-1);
122     if (!strcmp( buf, _("User ID was not found"))) {
123     int id = log_box (_("Designated Key Revokers"), MB_YESNO|MB_INFO,
124     _("Do you want to retrieve 0x%s via the default keyserver?"), keyid);
125     if (id == IDNO)
126 twoaday 2 break;
127 twoaday 20 rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, buf, 0, 0);
128 twoaday 2 if( !rc ) {
129     const char * s;
130 twoaday 20 keycache_reload (dlg);
131     if (get_pubkey (keyid, &key))
132 twoaday 2 BUG( NULL );
133     s = gpgme_key_get_string_attr( key, GPGME_ATTR_NAME, NULL, 0 );
134     if( s )
135     listview_add_sub_item( lv, idx, 2, s );
136     }
137     }
138 twoaday 20 else {
139     struct winpt_key_s k;
140     memset (&k, 0, sizeof k);
141     k.keyid = keyid;
142     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
143     keyprops_dlg_proc, (LPARAM)&k);
144     }
145 twoaday 2 }
146     break;
147    
148     case WM_DESTROY:
149     if( lv ) {
150     listview_release( lv );
151     lv = NULL;
152     }
153     return FALSE;
154    
155     case WM_COMMAND:
156     switch( LOWORD( wparam ) ) {
157     case IDOK:
158     EndDialog( dlg, TRUE );
159     break;
160     }
161     break;
162     }
163    
164     return FALSE;
165     } /* key_revokers_dlg_proc */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26