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

Annotation of /trunk/Src/wptKeyTrustPathDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 5168 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

1 werner 36 /* wptKeyTrustPathDlg.cpp - List a trust path for a key.
2     * Copyright (C) 2001, 2002, 2003 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     #if 0
21     #ifdef HAVE_CONFIG_H
22     #include <config.h>
23     #endif
24    
25     #include <windows.h>
26     #include <commctrl.h>
27    
28 werner 47 #include "resource.h"
29 werner 36 #include "wptGPGME.h"
30     #include "wptCommonCtl.h"
31     #include "wptContext.h" /* for passphrase_s */
32     #include "wptDlgs.h"
33     #include "wptTypes.h"
34     #include "wptNLS.h"
35    
36     struct trust_path_s {
37     int level;
38     int type;
39     char otrust[2];
40     char valid[2];
41     char keyid[16+1];
42     char uid[128];
43     };
44    
45    
46     static void
47     copy_trust_item(trust_path_s *tp, GpgmeTrustItem ti)
48     {
49     const char *t;
50    
51     tp->level = gpgme_trust_item_get_int_attr( ti, GPGME_ATTR_LEVEL, NULL, 0 );
52     tp->type = gpgme_trust_item_get_int_attr( ti, GPGME_ATTR_TYPE, NULL, 0 );
53     t = gpgme_trust_item_get_string_attr( ti, GPGME_ATTR_OTRUST, NULL, 0);
54     strcpy( tp->otrust, t );
55     t = gpgme_trust_item_get_string_attr( ti, GPGME_ATTR_VALIDITY, NULL, 0 );
56     strcpy( tp->valid, t );
57     t = gpgme_trust_item_get_string_attr( ti, GPGME_ATTR_KEYID, NULL, 0 );
58     strcpy( tp->keyid, t );
59     t = gpgme_trust_item_get_string_attr( ti, GPGME_ATTR_USERID, NULL, 0 );
60     strcpy( tp->uid, t );
61     } /* copy_trust_item */
62    
63    
64     static HTREEITEM
65     treeview_insert_item( HWND tree, HTREEITEM parent, const char *text )
66     {
67     TVINSERTSTRUCT ti;
68     HTREEITEM node;
69    
70     memset( &ti, 0, sizeof ti );
71     ti.hParent = parent;
72     ti.hInsertAfter = TVI_LAST;
73     ti.item.mask = TVIF_TEXT;
74     ti.item.pszText = (char *)text;
75     node = TreeView_InsertItem( tree, &ti );
76     return node;
77     } /* treeview_insert_item */
78    
79    
80     HTREEITEM
81     treeview_create_child_item( HWND tree, trust_path_s *tp, HTREEITEM parent )
82     {
83     char info[1024];
84     HTREEITEM node;
85    
86     if( tp->type == 0 ) /* root */
87     _snprintf( info, sizeof info-1, "%s", tp->uid );
88     else if( tp->type == 1 )/* key */
89     _snprintf(info, sizeof info -1, "0x%s (otrust=%s, validity=%s)",
90     tp->keyid, tp->otrust, tp->valid );
91     else if( tp->type == 2 ) /* userid */
92     _snprintf( info, sizeof info -1, "%s (validity=%s)", tp->uid, tp->valid );
93     node = treeview_insert_item( tree, parent, info );
94     return node;
95     } /* treeview_create_child_item */
96    
97    
98     void
99     treeview_add_trustpath(HWND tree, HTREEITEM node, trust_path_s c[], int n, int level)
100     {
101     HTREEITEM _node;
102     int i;
103    
104     for( i=0; i<n; i++ ) {
105     if( c[i].level == level ) {
106     _node = treeview_create_child_item( tree, &c[i], node );
107     treeview_add_trustpath( tree, _node, c, n, i );
108     }
109     }
110     } /* treeview_add_trustpath */
111    
112    
113     BOOL CALLBACK
114     keytrust_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
115     {
116     winpt_key_t k;
117     HWND tree;
118     GpgmeTrustItem trust_item;
119     gpgme_ctx_t ctx;
120     gpgme_error_t ec;
121     trust_path_s tp[256] = {0};
122     int pos = 0;
123    
124     switch( msg ) {
125     case WM_INITDIALOG:
126     if( !lparam )
127     dlg_fatal_error( dlg, "Could not get dialog param!" );
128     k = (winpt_key_t )lparam;
129     #ifndef LANG_DE
130     SetWindowText( dlg, _("List Trust Path") );
131     #endif
132     tree = GetDlgItem( dlg, IDC_KEYTRUST_TREE );
133     ec = gpgme_new( &ctx );
134     if( ec )
135     BUG( NULL );
136     ec = gpgme_op_trustlist_start( ctx, k->keyid, 6 );
137     if( ec ) {
138     msg_box( dlg, gpgme_strerror( err ), _("Trustlist"), MB_ERR );
139     gpgme_release( ctx );
140     return FALSE;
141     }
142     memset( &tp[0], 0, sizeof tp[0] );
143     tp[0].level = -1; pos++;
144     strcpy( tp[0].uid, k->uid );
145     strcpy( tp[0].keyid, k->keyid );
146    
147     while( !gpgme_op_trustlist_next( ctx, &trust_item ) ) {
148     copy_trust_item( &tp[pos++], trust_item );
149     if( pos > 256 )
150     break;
151     gpgme_trust_item_release( trust_item );
152     }
153     gpgme_release( ctx );
154     treeview_add_trustpath( tree, NULL, tp, pos, -1 );
155     return TRUE;
156    
157     case WM_SYSCOMMAND:
158     if( LOWORD( wparam ) == SC_CLOSE )
159     EndDialog( dlg, FALSE );
160     return FALSE;
161    
162     case WM_COMMAND:
163     switch( LOWORD(wparam) ) {
164     case IDOK:
165     EndDialog( dlg, TRUE );
166     return TRUE;
167     }
168     }
169    
170     return FALSE;
171 twoaday 2 } /* keytrust_dlg_proc */
172 werner 36 #else
173     #include <windows.h>
174     BOOL CALLBACK keytrust_dlg_proc( HWND dlg, UINT msg, WPARAM wparam,
175     LPARAM lparam ) { return FALSE; }
176     /* GPG 1.2.x does not support this yet */
177     #endif

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26