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

Annotation of /trunk/Src/wptSigTreeDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 205 - (hide annotations)
Thu Apr 27 12:46:03 2006 UTC (18 years, 10 months ago) by twoaday
File size: 5079 byte(s)
2006-04-27  Timo Schulz  <ts@g10code.de>
                                                                                
        * wptKeyManager.cpp (km_get_key_ptr): New.
        * wptListview.cpp (listview_get_item_text): Drop utf8 support.
        * wptKeyCache.cpp (keycache_decode_uids): New.
        (free_native_uids): New.
        * wptKeyEdit.cpp (uid_inf_colon_handler): Do utf8 decodig here.
                                                                                
2006-04-26  Timo Schulz  <ts@g10code.de>
                                                                                
        * wptKeylist.cpp (get_keyid_from_fpr): New.
        * wptDecryptClipDlg.cpp (clip_decrypt_dlg): Use it here.
        * wptVerifyList.cpp (verlist_add_sig): Likewise.


1 twoaday 176 /* wptSigTreeDlg.cpp - List signatures in a tree view
2 twoaday 175 * Copyright (C) 2006 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 "wptGPG.h"
26     #include "wptNLS.h"
27 twoaday 176 #include "wptVersion.h"
28     #include "wptTypes.h"
29     #include "wptCommonCtl.h"
30     #include "wptContext.h"
31 twoaday 188 #include "wptUTF8.h"
32 twoaday 193 #include "wptW32API.h"
33 twoaday 175
34 twoaday 180
35     /* ID to display signature properties. */
36     #define _ID_SIGCTX_PROPS 65000
37    
38    
39 twoaday 176 BOOL CALLBACK sigprops_dlg_proc (HWND dlg, UINT msg,
40     WPARAM wparam, LPARAM lparam);
41 twoaday 188 BOOL CALLBACK keysig_dlg_proc (HWND dlg, UINT msg,
42     WPARAM wparam, LPARAM lparam);
43 twoaday 176
44 twoaday 175 /* Initialize the signature tree based on the given key @key. */
45     static void
46     sigtree_load (HWND dlg, gpgme_key_t key)
47     {
48     TVITEM tvi;
49     TVINSERTSTRUCT ctx;
50     HTREEITEM uid;
51     gpgme_user_id_t u;
52     gpgme_key_sig_t s;
53     gpgme_key_t signer;
54 twoaday 188 char *p;
55 twoaday 175
56     memset (&tvi, 0, sizeof (tvi));
57     memset (&ctx, 0, sizeof (ctx));
58     for (u=key->uids; u; u = u->next) {
59 twoaday 176 if (u->revoked)
60     continue;
61 twoaday 190 p = utf8_to_native (u->uid);
62     tvi.pszText = p;
63 twoaday 175 tvi.state = TVIS_BOLD;
64 twoaday 176 tvi.mask = TVIF_TEXT;
65     tvi.iImage = 0;
66     tvi.iSelectedImage = 0;
67 twoaday 175 ctx.hParent = TVI_ROOT;
68     ctx.item = tvi;
69     uid = TreeView_InsertItem (dlg, &ctx);
70 twoaday 190 safe_free (p);
71 twoaday 175 for (s = u->signatures; s; s=s->next) {
72     if (get_pubkey (s->keyid+8, &signer))
73     continue;
74 twoaday 188 p = utf8_to_native (signer->uids->uid);
75     tvi.pszText = p;
76 twoaday 176 tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
77     tvi.iImage = 1;
78     tvi.iSelectedImage = 1;
79     tvi.lParam = (LPARAM)s;
80 twoaday 175 ctx.hParent = uid;
81     ctx.item = tvi;
82     TreeView_InsertItem (dlg, &ctx);
83 twoaday 188 safe_free (p);
84 twoaday 175 }
85     }
86     }
87    
88    
89 twoaday 176 /* Associate a signature list based on the icons @ico with
90     the treeview control @tree. */
91     HIMAGELIST
92     treeview_set_image_list (HWND tree, HICON *ico, DWORD nicons)
93     {
94     HIMAGELIST hil;
95     DWORD i;
96    
97     hil = ImageList_Create (16, 16, ILC_COLOR8|ILC_MASK, nicons, 1);
98     ImageList_SetBkColor (hil, CLR_NONE);
99     for (i=0; i < nicons; i++)
100     ImageList_AddIcon (hil, ico[i]);
101     TreeView_SetImageList (tree, hil, TVSIL_NORMAL);
102     return hil;
103     }
104    
105    
106 twoaday 180 static void
107     create_popup (HWND dlg)
108     {
109     HMENU hm;
110     POINT p;
111    
112     hm = CreatePopupMenu ();
113     if (!hm)
114 twoaday 193 BUG (0);
115     insert_menu_item (hm, 0, _ID_SIGCTX_PROPS, _("Signature &Properties"));
116 twoaday 180 GetCursorPos (&p);
117     TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL);
118     DestroyMenu (hm);
119     }
120    
121    
122     static void
123     show_sigprops (HWND dlg)
124     {
125     HWND tree;
126     HTREEITEM hti;
127     TVITEM tvi;
128    
129     memset (&tvi, 0, sizeof (tvi));
130     tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
131     hti = TreeView_GetSelection (tree);
132     tvi.mask = TVIF_PARAM;
133     tvi.hItem = hti;
134     TreeView_GetItem (tree, &tvi);
135     if (tvi.lParam != 0)
136     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
137     sigprops_dlg_proc, tvi.lParam);
138     }
139    
140    
141 twoaday 175 /* Dialog box procedure for the tree based signature listing. */
142     BOOL CALLBACK
143     sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
144     {
145 twoaday 176 static winpt_key_t key;
146 twoaday 175 static HWND tree;
147 twoaday 176 static HIMAGELIST hil;
148     HICON ico[2];
149     NMHDR *nft;
150 twoaday 205 char inf[300], *p;
151 twoaday 175
152     switch (msg) {
153     case WM_INITDIALOG:
154 twoaday 176 key = (winpt_key_t)lparam;
155 twoaday 175 if (!key)
156 twoaday 176 BUG (0);
157     ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_USERID);
158     ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEY_SIG);
159 twoaday 175 tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
160 twoaday 176 hil = treeview_set_image_list (tree, ico, 2);
161     sigtree_load (tree, key->ctx);
162 twoaday 205 p = utf8_to_native (key->ctx->uids->uid);
163 twoaday 193 _snprintf (inf, sizeof (inf)-1,
164     _("Signature Tree for \"%s\" (0x%s)"),
165 twoaday 205 p, key->ctx->subkeys->keyid+8);
166 twoaday 179 SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit..."));
167 twoaday 205 SetWindowText (dlg, inf);
168 twoaday 175 SetForegroundWindow (dlg);
169 twoaday 205 safe_free (p);
170 twoaday 175 break;
171    
172 twoaday 176 case WM_DESTROY:
173     ImageList_Destroy (hil);
174     break;
175    
176     case WM_NOTIFY:
177     nft = (NMHDR*)lparam;
178 twoaday 180 if (nft->code == NM_DBLCLK)
179     show_sigprops (dlg);
180     else if (nft->code == NM_RCLICK)
181     create_popup (dlg);
182 twoaday 176 break;
183    
184 twoaday 175 case WM_COMMAND:
185     switch (LOWORD (wparam)) {
186 twoaday 180 case _ID_SIGCTX_PROPS:
187     show_sigprops (dlg);
188     break;
189    
190 twoaday 175 case IDOK:
191     EndDialog (dlg, 1);
192     break;
193    
194     case IDCANCEL:
195     EndDialog (dlg, 0);
196     break;
197 twoaday 176
198     case IDC_VKEYSIG_EDIT:
199     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSIG, dlg,
200     keysig_dlg_proc, (LPARAM)key);
201 twoaday 175 }
202     break;
203     }
204    
205     return FALSE;
206     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26