28 |
#include "wptTypes.h" |
#include "wptTypes.h" |
29 |
#include "wptCommonCtl.h" |
#include "wptCommonCtl.h" |
30 |
#include "wptContext.h" |
#include "wptContext.h" |
31 |
|
#include "wptUTF8.h" |
32 |
|
|
33 |
|
|
34 |
|
/* ID to display signature properties. */ |
35 |
|
#define _ID_SIGCTX_PROPS 65000 |
36 |
|
|
37 |
|
|
38 |
BOOL CALLBACK sigprops_dlg_proc (HWND dlg, UINT msg, |
BOOL CALLBACK sigprops_dlg_proc (HWND dlg, UINT msg, |
39 |
WPARAM wparam, LPARAM lparam); |
WPARAM wparam, LPARAM lparam); |
40 |
BOOL CALLBACK |
BOOL CALLBACK keysig_dlg_proc (HWND dlg, UINT msg, |
41 |
keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam); |
WPARAM wparam, LPARAM lparam); |
42 |
|
|
43 |
/* Initialize the signature tree based on the given key @key. */ |
/* Initialize the signature tree based on the given key @key. */ |
44 |
static void |
static void |
50 |
gpgme_user_id_t u; |
gpgme_user_id_t u; |
51 |
gpgme_key_sig_t s; |
gpgme_key_sig_t s; |
52 |
gpgme_key_t signer; |
gpgme_key_t signer; |
53 |
|
char *p; |
54 |
|
|
55 |
memset (&tvi, 0, sizeof (tvi)); |
memset (&tvi, 0, sizeof (tvi)); |
56 |
memset (&ctx, 0, sizeof (ctx)); |
memset (&ctx, 0, sizeof (ctx)); |
57 |
for (u=key->uids; u; u = u->next) { |
for (u=key->uids; u; u = u->next) { |
58 |
if (u->revoked) |
if (u->revoked) |
59 |
continue; |
continue; |
60 |
tvi.pszText = u->uid; |
p = utf8_to_native (u->uid); |
61 |
|
tvi.pszText = p; |
62 |
tvi.state = TVIS_BOLD; |
tvi.state = TVIS_BOLD; |
63 |
tvi.mask = TVIF_TEXT; |
tvi.mask = TVIF_TEXT; |
64 |
tvi.iImage = 0; |
tvi.iImage = 0; |
66 |
ctx.hParent = TVI_ROOT; |
ctx.hParent = TVI_ROOT; |
67 |
ctx.item = tvi; |
ctx.item = tvi; |
68 |
uid = TreeView_InsertItem (dlg, &ctx); |
uid = TreeView_InsertItem (dlg, &ctx); |
69 |
|
safe_free (p); |
70 |
for (s = u->signatures; s; s=s->next) { |
for (s = u->signatures; s; s=s->next) { |
71 |
if (get_pubkey (s->keyid+8, &signer)) |
if (get_pubkey (s->keyid+8, &signer)) |
72 |
continue; |
continue; |
73 |
tvi.pszText = signer->uids->uid; |
p = utf8_to_native (signer->uids->uid); |
74 |
|
tvi.pszText = p; |
75 |
tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; |
tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; |
76 |
tvi.iImage = 1; |
tvi.iImage = 1; |
77 |
tvi.iSelectedImage = 1; |
tvi.iSelectedImage = 1; |
79 |
ctx.hParent = uid; |
ctx.hParent = uid; |
80 |
ctx.item = tvi; |
ctx.item = tvi; |
81 |
TreeView_InsertItem (dlg, &ctx); |
TreeView_InsertItem (dlg, &ctx); |
82 |
|
safe_free (p); |
83 |
} |
} |
84 |
} |
} |
85 |
} |
} |
102 |
} |
} |
103 |
|
|
104 |
|
|
105 |
|
static void |
106 |
|
create_popup (HWND dlg) |
107 |
|
{ |
108 |
|
HMENU hm; |
109 |
|
MENUITEMINFO mi; |
110 |
|
POINT p; |
111 |
|
char *s; |
112 |
|
|
113 |
|
hm = CreatePopupMenu (); |
114 |
|
if (!hm) |
115 |
|
BUG( NULL ); |
116 |
|
memset (&mi, 0, sizeof mi); |
117 |
|
mi.cbSize = sizeof mi; |
118 |
|
s = (char *)_("Signature &Properties"); |
119 |
|
mi.fType = MF_STRING; |
120 |
|
mi.dwTypeData = s; |
121 |
|
mi.cch = strlen (s); |
122 |
|
mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; |
123 |
|
mi.wID = _ID_SIGCTX_PROPS; |
124 |
|
InsertMenuItem (hm, 0, FALSE, &mi); |
125 |
|
GetCursorPos (&p); |
126 |
|
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL); |
127 |
|
DestroyMenu (hm); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
static void |
132 |
|
show_sigprops (HWND dlg) |
133 |
|
{ |
134 |
|
HWND tree; |
135 |
|
HTREEITEM hti; |
136 |
|
TVITEM tvi; |
137 |
|
|
138 |
|
memset (&tvi, 0, sizeof (tvi)); |
139 |
|
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
140 |
|
hti = TreeView_GetSelection (tree); |
141 |
|
tvi.mask = TVIF_PARAM; |
142 |
|
tvi.hItem = hti; |
143 |
|
TreeView_GetItem (tree, &tvi); |
144 |
|
if (tvi.lParam != 0) |
145 |
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
146 |
|
sigprops_dlg_proc, tvi.lParam); |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
/* Dialog box procedure for the tree based signature listing. */ |
/* Dialog box procedure for the tree based signature listing. */ |
151 |
BOOL CALLBACK |
BOOL CALLBACK |
152 |
sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
154 |
static winpt_key_t key; |
static winpt_key_t key; |
155 |
static HWND tree; |
static HWND tree; |
156 |
static HIMAGELIST hil; |
static HIMAGELIST hil; |
|
|
|
157 |
HICON ico[2]; |
HICON ico[2]; |
158 |
NMHDR *nft; |
NMHDR *nft; |
159 |
char inf[256]; |
char inf[256], *p; |
160 |
|
|
161 |
switch (msg) { |
switch (msg) { |
162 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
168 |
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
169 |
hil = treeview_set_image_list (tree, ico, 2); |
hil = treeview_set_image_list (tree, ico, 2); |
170 |
sigtree_load (tree, key->ctx); |
sigtree_load (tree, key->ctx); |
171 |
_snprintf (inf, sizeof (inf)-1, _("Signature Tree for \"%s\""), |
p = utf8_to_native (key->ctx->uids->uid); |
172 |
key->ctx->uids->uid); |
_snprintf (inf, sizeof (inf)-1, _("Signature Tree for \"%s\""), p); |
173 |
|
safe_free (p); |
174 |
SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit...")); |
SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit...")); |
175 |
SetWindowText (dlg, inf); |
SetWindowText (dlg, inf); |
176 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
182 |
|
|
183 |
case WM_NOTIFY: |
case WM_NOTIFY: |
184 |
nft = (NMHDR*)lparam; |
nft = (NMHDR*)lparam; |
185 |
if (nft->code == NM_DBLCLK) { |
if (nft->code == NM_DBLCLK) |
186 |
HTREEITEM hti; |
show_sigprops (dlg); |
187 |
TVITEM tvi; |
else if (nft->code == NM_RCLICK) |
188 |
|
create_popup (dlg); |
|
memset (&tvi, 0, sizeof (tvi)); |
|
|
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
|
|
hti = TreeView_GetSelection (tree); |
|
|
tvi.mask = TVIF_PARAM; |
|
|
tvi.hItem = hti; |
|
|
TreeView_GetItem (tree, &tvi); |
|
|
if (tvi.lParam != 0) |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg, |
|
|
sigprops_dlg_proc, tvi.lParam); |
|
|
} |
|
189 |
break; |
break; |
190 |
|
|
191 |
case WM_COMMAND: |
case WM_COMMAND: |
192 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
193 |
|
case _ID_SIGCTX_PROPS: |
194 |
|
show_sigprops (dlg); |
195 |
|
break; |
196 |
|
|
197 |
case IDOK: |
case IDOK: |
198 |
EndDialog (dlg, 1); |
EndDialog (dlg, 1); |
199 |
break; |
break; |