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

Annotation of /trunk/Src/wptKeyRevokersDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 204 - (hide annotations)
Wed Apr 26 06:37:23 2006 UTC (18 years, 10 months ago) by twoaday
File size: 5344 byte(s)
2006-04-25  Timo Schulz  <ts@g10code.de>
                                                                                
        * wptFileManagerDlg.cpp (file_manager_dlg_proc): Handle IDCANCEL.
        * wptMDSumDlg.cpp (hash_selected_files): New.
        (mdsum_dlg_proc): Cleanups.
        * wptKeysignDlg.cpp (keysign_dlg_proc): Fix segv.
                                                                                
2006-04-23  Timo Schulz  <ts@g10code.de>
                                                                                
        * wptW32API.cpp (SetDlgItemText_utf8): New.
        (SetWindowText_utf8): New.
        (GetDlgItemText_utf8): New.
        * wptListView.cpp (listview_add_sub_item): Internal
        utf8 support.


1 werner 36 /* wptKeyRevokersDlg.cpp - Designated Revoker Keys
2     * Copyright (C) 2002, 2003, 2005 Timo Schulz
3     * Copyright (C) 2005 g10 Code GmbH
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     #ifdef HAVE_CONFIG_H
22     #include <config.h>
23     #endif
24    
25     #include <windows.h>
26     #include <commctrl.h>
27    
28 werner 47 #include "resource.h"
29 werner 36 #include "wptCommonCtl.h"
30     #include "wptNLS.h"
31     #include "wptTypes.h"
32     #include "wptGPG.h"
33     #include "wptCommonCtl.h"
34     #include "wptContext.h"
35     #include "wptDlgs.h"
36     #include "wptErrors.h"
37     #include "wptKeyserver.h"
38 werner 47 #include "wptW32API.h"
39 werner 36 #include "wptVersion.h"
40     #include "wptKeyEdit.h"
41 werner 47 #include "wptKeylist.h"
42 twoaday 129 #include "wptUTF8.h"
43 werner 36
44    
45 twoaday 129 enum revoke_col_t {
46     REV_COL_NAME = 0,
47     REV_COL_KEYID = 1,
48     REV_COL_ALGO = 2
49     };
50    
51 werner 36 /* Initialize the listview given in @ctrl and return it in @r_lv. */
52     static int
53     revokelist_build (listview_ctrl_t *r_lv, HWND ctrl)
54     {
55     listview_ctrl_t lv;
56     struct listview_column_s rlist[] = {
57 twoaday 129 {0, 160, (char *)_("Name") },
58     {1, 80, (char *)_("Key ID")},
59     {2, 55, (char *)_("Algorithm")},
60 werner 36 {0}
61     };
62     int i, rc;
63    
64     rc = listview_new (&lv);
65     if (rc)
66     return rc;
67     lv->ctrl = ctrl;
68     lv->items = DIM( rlist )-1;
69     for (i = 0; i < lv->items; i++)
70     listview_add_column (lv, &rlist[i]);
71     listview_set_ext_style (lv);
72     *r_lv = lv;
73     return 0;
74     }
75    
76    
77     /* Initialize the listview @ctrl with all designated revokers of the
78     key @key. @ctx is used to retrieve the rev key from the cache to
79     show the user-id.
80     Return value: the initialized listview or NULL on error. */
81     static listview_ctrl_t
82     revokelist_init (HWND ctrl, gpgme_key_t key, gpg_keycache_t ctx)
83     {
84     gpgme_error_t err;
85 twoaday 129 gpgme_key_t revkey;
86     GpgKeyEdit *ke;
87 werner 36 gpg_desig_rev_t rev=NULL, r;
88 twoaday 129 listview_ctrl_t lv;
89     const char *alg;
90 twoaday 204 const char *uid = NULL;
91 twoaday 193 char keyid[32];
92 werner 36
93     ke = new GpgKeyEdit (key);
94     if (!ke)
95     BUG (NULL);
96     err = ke->getDesignatedRevoker (&rev);
97     if (err) {
98     delete ke;
99 twoaday 129 msg_box (NULL, gpgme_strerror (err),
100     _("Designated Key Revokers"), MB_ERR);
101 werner 36 return NULL;
102     }
103    
104     if (revokelist_build (&lv, ctrl))
105     BUG (0);
106     for (r = rev; r; r = r->next) {
107     if (get_pubkey (r->fpr+32, &revkey))
108 twoaday 204 uid = _("user ID not found");
109 werner 36 else
110 twoaday 204 uid = revkey->uids->name;
111 twoaday 193 _snprintf (keyid, sizeof (keyid)-1, "0x%s", r->fpr+32);
112 werner 36 listview_add_item (lv, "");
113 twoaday 129 alg = get_key_pubalgo (r->pubkey_algo);
114     listview_add_sub_item (lv, 0, REV_COL_ALGO, alg);
115 twoaday 193 listview_add_sub_item (lv, 0, REV_COL_KEYID, keyid);
116 twoaday 129 listview_add_sub_item (lv, 0, REV_COL_NAME, uid);
117 werner 36 }
118 twoaday 129
119 werner 36 delete ke;
120     gpg_desig_rev_release (rev);
121     return lv;
122     }
123    
124    
125     /* Dialog box procedure to show designated revokers. */
126     BOOL CALLBACK
127     key_revokers_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
128     {
129     static listview_ctrl_t lv;
130 twoaday 161 static int key_update = 0;
131 werner 36 gpgme_key_t key;
132     char buf[128], keyid[32];
133     int rc;
134    
135     switch( msg ) {
136     case WM_INITDIALOG:
137     gpg_keycache_t ctx;
138     key = (gpgme_key_t)lparam;
139     if (!key)
140     dlg_fatal_error( dlg, "Could not get dilaog param" );
141     ctx = keycache_get_ctx (1);
142     if (!ctx)
143     BUG (dlg);
144 twoaday 88 lv = revokelist_init (GetDlgItem (dlg, IDC_KEYREVOKERS_LIST), key, ctx);
145    
146     SetDlgItemText (dlg, IDC_KEYREVOKERS_INF, _("Designated Revoker Keys"));
147     SetWindowText (dlg, _("Key Revokers"));
148     SetForegroundWindow (dlg);
149 werner 36 return TRUE;
150    
151     case WM_NOTIFY:
152     NMHDR *notify;
153     notify = (NMHDR *)lparam;
154     if (notify && notify->code == NM_DBLCLK &&
155     notify->idFrom == IDC_KEYREVOKERS_LIST) {
156     int idx = listview_get_curr_pos (lv);
157 twoaday 129 listview_get_item_text (lv, idx, REV_COL_KEYID, keyid, DIM (keyid)-1);
158     listview_get_item_text (lv, idx, REV_COL_NAME, buf, sizeof (buf)-1);
159     if (!strcmp (buf, _("user ID not found"))) {
160 werner 36 int id = log_box (_("Designated Key Revokers"), MB_YESNO|MB_INFO,
161     _("Do you want to retrieve 0x%s via the default keyserver?"), keyid);
162     if (id == IDNO)
163     break;
164     rc = hkp_recv_key (dlg, default_keyserver,
165 twoaday 129 default_keyserver_port, keyid, 0, 0);
166     if (!rc) {
167 twoaday 161 keycache_update (0, keyid);
168     key_update = 1;
169 werner 36 if (get_pubkey (keyid, &key))
170     BUG (NULL);
171 twoaday 204 if (key->uids && key->uids->name)
172     listview_add_sub_item (lv, idx, REV_COL_NAME, key->uids->name);
173 werner 36 }
174     }
175     else {
176     struct winpt_key_s k;
177     memset (&k, 0, sizeof k);
178     k.keyid = keyid;
179     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
180     keyprops_dlg_proc, (LPARAM)&k);
181     }
182     }
183     break;
184    
185     case WM_DESTROY:
186     if (lv) {
187     listview_release (lv);
188     lv = NULL;
189     }
190     return FALSE;
191    
192     case WM_COMMAND:
193     switch (LOWORD (wparam)) {
194     case IDOK:
195 twoaday 161 EndDialog (dlg, key_update);
196 werner 36 break;
197     }
198     break;
199     }
200    
201     return FALSE;
202     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26