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

Contents of /trunk/Src/wptSigTreeDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 180 - (show annotations)
Mon Mar 6 14:41:58 2006 UTC (18 years, 11 months ago) by twoaday
File size: 5092 byte(s)
2006-02-27  Timo Schulz  <twoaday@freakmail.de>
 
        * wptSOCKS.cpp (socks_handshake): New.
        * wptMainProc.cpp (winpt_main_proc): A dbl-click forces
        the key manager in teh foreground if possible.
        * wptHotkey.cpp (hotkey_unregister): Unregister all hotkeys.
        * wptRegistry.cpp (get_reg_proxy_prefs,
        set_reg_proxy_prefs): Use directly the proxy context.
        Changed all callers.
        * wptProxySettingsDlg.cpp (init_proxy_protocols): New.
        (keyserver_proxy_dlg_proc): Use directly the proxy context.
        * wptKeyserver.cpp (kserver_connect): Better proxy support.
        (kserver_send_request, kserver_recvkey_request): Likewise.
        * wptKeyserverDlg.cpp (name_from_proto): New.
        (set_proxy): Adjusted for the new code.


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26