1 |
twoaday |
175 |
/* wptSigTreeDlg.cpp |
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 |
|
|
|
28 |
|
|
/* Initialize the signature tree based on the given key @key. */ |
29 |
|
|
static void |
30 |
|
|
sigtree_load (HWND dlg, gpgme_key_t key) |
31 |
|
|
{ |
32 |
|
|
TVITEM tvi; |
33 |
|
|
TVINSERTSTRUCT ctx; |
34 |
|
|
HTREEITEM uid; |
35 |
|
|
gpgme_user_id_t u; |
36 |
|
|
gpgme_key_sig_t s; |
37 |
|
|
gpgme_key_t signer; |
38 |
|
|
|
39 |
|
|
memset (&tvi, 0, sizeof (tvi)); |
40 |
|
|
memset (&ctx, 0, sizeof (ctx)); |
41 |
|
|
for (u=key->uids; u; u = u->next) { |
42 |
|
|
tvi.pszText = u->uid; |
43 |
|
|
tvi.state = TVIS_BOLD; |
44 |
|
|
tvi.mask = TVIF_TEXT |TVIF_STATE; |
45 |
|
|
ctx.hParent = TVI_ROOT; |
46 |
|
|
ctx.item = tvi; |
47 |
|
|
uid = TreeView_InsertItem (dlg, &ctx); |
48 |
|
|
for (s = u->signatures; s; s=s->next) { |
49 |
|
|
if (get_pubkey (s->keyid+8, &signer)) |
50 |
|
|
continue; |
51 |
|
|
tvi.state = 0; |
52 |
|
|
tvi.pszText = signer->uids->uid; |
53 |
|
|
tvi.mask = TVIF_TEXT; |
54 |
|
|
ctx.hParent = uid; |
55 |
|
|
ctx.item = tvi; |
56 |
|
|
TreeView_InsertItem (dlg, &ctx); |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
/* Dialog box procedure for the tree based signature listing. */ |
63 |
|
|
BOOL CALLBACK |
64 |
|
|
sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
65 |
|
|
{ |
66 |
|
|
static gpgme_key_t key; |
67 |
|
|
static HWND tree; |
68 |
|
|
|
69 |
|
|
switch (msg) { |
70 |
|
|
case WM_INITDIALOG: |
71 |
|
|
key = (gpgme_key_t)lparam; |
72 |
|
|
if (!key) |
73 |
|
|
abort (); |
74 |
|
|
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE); |
75 |
|
|
sigtree_load (tree, key); |
76 |
|
|
SetWindowText (dlg, _("Key Signature Tree")); |
77 |
|
|
SetForegroundWindow (dlg); |
78 |
|
|
break; |
79 |
|
|
|
80 |
|
|
case WM_COMMAND: |
81 |
|
|
switch (LOWORD (wparam)) { |
82 |
|
|
|
83 |
|
|
case IDOK: |
84 |
|
|
EndDialog (dlg, 1); |
85 |
|
|
break; |
86 |
|
|
|
87 |
|
|
case IDCANCEL: |
88 |
|
|
EndDialog (dlg, 0); |
89 |
|
|
break; |
90 |
|
|
} |
91 |
|
|
break; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
return FALSE; |
95 |
|
|
} |