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

Annotation of /trunk/Src/wptKeyRevokersDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88 - (hide annotations)
Mon Nov 21 12:06:59 2005 UTC (19 years, 3 months ago) by twoaday
File size: 4990 byte(s)
2005-11-21  Timo Schulz  <ts@g10code.com>
 
        * WinPT.cpp (WinMain): Implement --stop switch.
        * wptClipEditDlg.cpp (clip_edit_dlg_proc): Localize
        missing string.
        * wptPreferencesDlg.cpp (prefs_dlg_proc): Likewise.
        * wptKeygenDlg.cpp (keygen_dlg_proc): Verify valid context
        first. Thanks to Ralf.
        * wptFileManagerDlg.cpp (update_ui_items): New.
        * wptFileManager.cpp (fm_set_status): New sigmode param.
        Changed all callers.


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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26