17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
20 |
|
#ifdef HAVE_CONFIG_H |
21 |
|
#include <config.h> |
22 |
|
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
25 |
#include <commctrl.h> |
#include <commctrl.h> |
46 |
|
|
47 |
/* Initialize the signature tree based on the given key @key. */ |
/* Initialize the signature tree based on the given key @key. */ |
48 |
static void |
static void |
49 |
sigtree_load (HWND dlg, gpgme_key_t key) |
sigtree_load (HWND dlg, winpt_key_t key) |
50 |
{ |
{ |
51 |
TVITEM tvi; |
TVITEM tvi; |
52 |
TVINSERTSTRUCT ctx; |
TVINSERTSTRUCT ctx; |
53 |
HTREEITEM uid; |
HTREEITEM uid; |
|
gpgme_user_id_t u; |
|
54 |
gpgme_key_sig_t s; |
gpgme_key_sig_t s; |
55 |
gpgme_key_t signer; |
winpt_key_s signer; |
56 |
char *p; |
struct native_uid_s *u; |
57 |
|
|
58 |
memset (&tvi, 0, sizeof (tvi)); |
memset (&tvi, 0, sizeof (tvi)); |
59 |
memset (&ctx, 0, sizeof (ctx)); |
memset (&ctx, 0, sizeof (ctx)); |
60 |
for (u=key->uids; u; u = u->next) { |
for (u=key->ext->uids; u; u = u->next) { |
61 |
if (u->revoked) |
if (u->revoked) |
62 |
continue; |
continue; |
63 |
p = utf8_to_native (u->uid); |
tvi.pszText = u->uid; |
|
tvi.pszText = p; |
|
64 |
tvi.state = TVIS_BOLD; |
tvi.state = TVIS_BOLD; |
65 |
tvi.mask = TVIF_TEXT; |
tvi.mask = TVIF_TEXT; |
66 |
tvi.iImage = 0; |
tvi.iImage = 0; |
68 |
ctx.hParent = TVI_ROOT; |
ctx.hParent = TVI_ROOT; |
69 |
ctx.item = tvi; |
ctx.item = tvi; |
70 |
uid = TreeView_InsertItem (dlg, &ctx); |
uid = TreeView_InsertItem (dlg, &ctx); |
|
safe_free (p); |
|
71 |
for (s = u->signatures; s; s=s->next) { |
for (s = u->signatures; s; s=s->next) { |
72 |
if (get_pubkey (s->keyid+8, &signer)) |
memset (&signer, 0, sizeof (signer)); |
73 |
|
if (winpt_get_pubkey (s->keyid+8, &signer)) |
74 |
continue; |
continue; |
75 |
p = utf8_to_native (signer->uids->uid); |
tvi.pszText = signer.ext->uids->uid; |
|
tvi.pszText = p; |
|
76 |
tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; |
tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; |
77 |
tvi.iImage = 1; |
tvi.iImage = 1; |
78 |
tvi.iSelectedImage = 1; |
tvi.iSelectedImage = 1; |
79 |
tvi.lParam = (LPARAM)s; |
tvi.lParam = (LPARAM)s; |
80 |
ctx.hParent = uid; |
ctx.hParent = uid; |
81 |
ctx.item = tvi; |
ctx.item = tvi; |
82 |
|
/* XXX: mark non exportable sigs */ |
83 |
TreeView_InsertItem (dlg, &ctx); |
TreeView_InsertItem (dlg, &ctx); |
|
safe_free (p); |
|
84 |
} |
} |
85 |
} |
} |
86 |
} |
} |
104 |
|
|
105 |
|
|
106 |
static void |
static void |
107 |
create_popup (HWND dlg) |
show_popup (HWND dlg) |
108 |
{ |
{ |
109 |
HMENU hm; |
HMENU hm; |
110 |
POINT p; |
POINT p; |
119 |
} |
} |
120 |
|
|
121 |
|
|
122 |
|
/* Get the signature properties for the selected item. */ |
123 |
static void |
static void |
124 |
show_sigprops (HWND dlg) |
show_sigprops (HWND dlg) |
125 |
{ |
{ |
143 |
BOOL CALLBACK |
BOOL CALLBACK |
144 |
sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
145 |
{ |
{ |
146 |
static winpt_key_t key; |
static winpt_key_t key; |
|
static HWND tree; |
|
147 |
static HIMAGELIST hil; |
static HIMAGELIST hil; |
148 |
|
HWND tree; |
149 |
HICON ico[2]; |
HICON ico[2]; |
150 |
NMHDR *nft; |
NMHDR *nft; |
151 |
char inf[300], *p; |
char inf[300]; |
152 |
|
|
153 |
switch (msg) { |
switch (msg) { |
154 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
159 |
ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEY_SIG); |
ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEY_SIG); |
160 |
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
161 |
hil = treeview_set_image_list (tree, ico, 2); |
hil = treeview_set_image_list (tree, ico, 2); |
162 |
sigtree_load (tree, key->ctx); |
sigtree_load (tree, key); |
163 |
p = utf8_to_native (key->ctx->uids->name); |
_snprintf (inf, DIM (inf)-1, |
|
_snprintf (inf, sizeof (inf)-1, |
|
164 |
_("Signature Tree for \"%s\" (0x%s)"), |
_("Signature Tree for \"%s\" (0x%s)"), |
165 |
p, key->ctx->subkeys->keyid+8); |
key->ext->uids->name, key->ctx->subkeys->keyid+8); |
|
safe_free (p); |
|
166 |
SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit...")); |
SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit...")); |
167 |
SetWindowText (dlg, inf); |
SetWindowText (dlg, inf); |
168 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
177 |
if (nft->code == NM_DBLCLK) |
if (nft->code == NM_DBLCLK) |
178 |
show_sigprops (dlg); |
show_sigprops (dlg); |
179 |
else if (nft->code == NM_RCLICK) |
else if (nft->code == NM_RCLICK) |
180 |
create_popup (dlg); |
show_popup (dlg); |
181 |
break; |
break; |
182 |
|
|
183 |
case WM_COMMAND: |
case WM_COMMAND: |