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

Annotation of /trunk/Src/wptVerifyList.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (hide annotations)
Fri May 20 08:39:15 2005 UTC (19 years, 9 months ago) by twoaday
File size: 6236 byte(s)
2005-05-09 Timo Schulz  <twoaday@freakmail.de>
                                                                                  
        * wptCommonDlg.cpp (http_file_dlg_proc): Renamed to..
        (http_dlg_proc): ..this.
        (get_keyserver_URL_dlg): New.
        (check_URL): New.
        * wptKeyEditDlgs.cpp (keyedit_set_pref_keyserver): New.
        (keyedit_main_dlg_proc): Avoid massive keycache reloads, just reload
        the single key.
        * wptKeyRevokersDlg.cpp (key_revokers_dlg_proc): Show the key properties
        of the selected desig. revoker.
        * wptVerifyList.cpp (verlist_build): Increase the column size of 'keyid'.
        * wptGPGME.cpp (keycache_update): New.
        * wptKeySigDlg.cpp (keysig_dlg_proc): Update the key if a signature
        was deleted.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Zeroing the key struct
        before we set any values.
                                                                                  

1 twoaday 2 /* wptVerifyList.cpp - Listview for verifying signatures
2 twoaday 19 * Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
3 twoaday 2 *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (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 GNU
14     * 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     /* x-todo-status: OK */
21    
22     #include <windows.h>
23     #include <time.h>
24    
25     #include "wptTypes.h"
26     #include "wptGPG.h"
27     #include "wptCommonCtl.h"
28     #include "wptKeylist.h"
29     #include "wptNLS.h"
30     #include "wptErrors.h"
31     #include "wptUTF8.h"
32     #include "wptW32API.h"
33    
34    
35     static char *
36     extract_filename( const char * path )
37     {
38     char * fname, * p;
39     int n, len = 0;
40    
41     p = strrchr( path, '\\' );
42     if( !p )
43     return m_strdup( path );
44     n = p - path;
45     len = strlen( path ) - n;
46     fname = new char[len+1];
47     if( !fname )
48     BUG( NULL );
49     memcpy( fname, path+n+1, len );
50     fname[len] = '\0';
51     return fname;
52     } /* extract_filename */
53    
54    
55     const char *
56     strtimestamp( long timestamp )
57     {
58     static char timebuf[64] = {0};
59     struct tm * warp;
60    
61     warp = localtime( &timestamp );
62     _snprintf( timebuf, sizeof timebuf - 1, "%04d-%02d-%02d %02d:%02d:%02d",
63     warp->tm_year+1900, warp->tm_mon+1, warp->tm_mday,
64     warp->tm_hour, warp->tm_min, warp->tm_sec );
65     return timebuf;
66     } /* strtimestamp */
67    
68    
69     int
70 twoaday 19 verlist_build (listview_ctrl_t * lv, HWND ctrl, int fm_mode)
71 twoaday 2 {
72     int j, rc = 0;
73     struct listview_ctrl_s * c;
74     struct listview_column_s fm_verlist[] = {
75     {0, 100, (char *)_("Name") },
76     {1, 120, (char *)_("Status") },
77     {2, 115, (char *)_("Signed") },
78     {3, 58, (char *)_("Trust") },
79     {4, 160, (char *)_("User ID") },
80     {5, 0, NULL }
81    
82     };
83     struct listview_column_s verlist[] = {
84     {0, 140, (char *)_("Status") },
85     {1, 120, (char *)_("Signed") },
86     {2, 58, (char *)_("Trust") },
87 twoaday 19 {3, 80, (char *)_("Key ID" )},
88 twoaday 2 {4, 160, (char *)_("User ID") },
89     {5, 0, NULL }
90     };
91    
92     rc = listview_new( &c );
93     if( rc )
94     return rc;
95    
96     c->ctrl = ctrl;
97     if( fm_mode ) {
98     for( j = 0; fm_verlist[j].fieldname; j++ )
99     listview_add_column( c, &fm_verlist[j] );
100     }
101     else {
102     for( j = 0; verlist[j].fieldname; j++ )
103     listview_add_column( c, &verlist[ j ] );
104     }
105     listview_set_ext_style( c );
106     *lv = c;
107     return 0;
108     } /* verlist_build */
109    
110    
111     void
112     verlist_delete( listview_ctrl_t lv )
113     {
114     if( lv ) {
115     listview_release( lv );
116     }
117     } /* verlist_delete */
118    
119    
120     int
121     verlist_add_sig( listview_ctrl_t lv, gpgme_sig_t sig )
122     {
123     gpgme_key_t key;
124     const char * attr;
125     u32 key_attr, t;
126     char keyid[32+1];
127     char * uid = NULL;
128    
129     if( listview_add_item( lv, " " ) )
130     return WPTERR_GENERAL;
131    
132     if( !gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_TYPE ) )
133     return WPTERR_GENERAL; /* No key was stored */
134    
135     t = gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_VALIDITY );
136     attr = gpg_sigstat[t % SIGSTAT_MASK];
137     if( attr )
138     listview_add_sub_item( lv, 0, 0, (char *)attr );
139    
140     t = gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_CREATED );
141     attr = strtimestamp( t );
142     if( attr )
143     listview_add_sub_item( lv, 0, 1, (char *)attr );
144    
145     t = gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_TYPE );
146     key = (gpgme_key_t)t;
147     key_attr = gpgme_key_get_ulong_attr( key, GPGME_ATTR_VALIDITY, NULL, 0 );
148     attr = gpgme_key_expand_attr( GPGME_ATTR_VALIDITY, key_attr );
149     if( attr )
150     listview_add_sub_item( lv, 0, 2, (char *)attr );
151    
152     attr = gpgme_key_get_string_attr( key, GPGME_ATTR_KEYID, NULL, 0 );
153     if ( !attr || strlen( attr ) < 8 )
154     attr = "DEADBEEFDEADBEEF";
155     _snprintf( keyid, sizeof keyid -1, "0x%s", attr + 8 );
156     listview_add_sub_item( lv, 0, 3, keyid );
157    
158     attr = gpgme_key_get_string_attr( key, GPGME_ATTR_NAME, NULL, 0 );
159     if( !attr ) {
160     attr = _("Invalid User ID");
161     listview_add_sub_item( lv, 0, 4, (char *)attr );
162     }
163     else {
164     uid = utf8_to_wincp (attr, strlen (attr));
165     if ( uid ) {
166     listview_add_sub_item( lv, 0, 4, (char *)uid );
167     free( uid );
168     }
169     }
170    
171     return 0;
172     } /* verlist_add_sig */
173    
174    
175     int
176     verlist_add_sig_log( listview_ctrl_t lv, siglog_context_t log )
177     {
178     gpgme_sig_t sig = log->sig;
179     const char * attr;
180     char t[64], * name;
181     u32 i_attr;
182    
183     if( listview_add_item( lv, "" ) )
184     return WPTERR_GENERAL;
185    
186     name = extract_filename( log->file );
187     if( name )
188     listview_add_sub_item( lv, 0, 0, name );
189     free_if_alloc( name );
190    
191     i_attr = gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_VALIDITY );
192     attr = gpg_sigstat[i_attr % SIGSTAT_MASK];
193     if( attr )
194     listview_add_sub_item( lv, 0, 1, attr );
195    
196     attr = strtimestamp( gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_CREATED ) );
197     if( attr )
198     listview_add_sub_item( lv, 0, 2, attr );
199    
200     attr = gpgme_key_expand_attr( GPGME_ATTR_VALIDITY,
201     gpgme_sig_get_ulong_attr( sig, 0, GPGME_ATTR_OTRUST ) );
202     if( attr )
203     listview_add_sub_item( lv, 0, 3, attr );
204    
205     attr = gpgme_sig_get_string_attr( sig, GPGME_ATTR_KEYID );
206     if( !log->use_uid && strlen( attr ) == 16 ) {
207     _snprintf( t, sizeof t-1, "0x%s", attr + 8 );
208     listview_add_sub_item( lv, 0, 4, t );
209     }
210     else if( !log->use_uid && strlen( attr ) == 8 ) {
211     _snprintf( t, sizeof t-1, "0x%s", attr );
212     listview_add_sub_item( lv, 0, 4, t );
213     }
214     else if( log->user_id ) {
215     char * p = utf8_to_wincp (log->user_id, strlen (log->user_id));
216     if( p ) {
217     listview_add_sub_item( lv, 0, 4, p );
218     free( p );
219     }
220     }
221     return 0;
222     } /* verlist_add_sig_log */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26