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

Annotation of /trunk/Src/wptKeyRevokersDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 4849 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26