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

Annotation of /trunk/Src/wptMDSumDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations)
Mon Oct 24 08:03:48 2005 UTC (19 years, 4 months ago) by twoaday
File size: 3713 byte(s)
2005-10-23  Timo Schulz  <twoaday@g10code.com>
 
        * wptFileManager.cpp (fm_get_file_type): Detect detached sigs.
        * wptKeyList.cpp (keylist_cmp_cb): Take care of expired/revoked keys.
        (get_ext_validity): New.
        * wptFileVerifyDlg.cpp (file_verify_dlg_proc): Several cleanups.
        * wptClipEditDlg.cpp (load_clipboard): Factored out some code into
        this function.
        (load_clipboard_from_file): Likewise.
        (save_clipboard_to_file): New.
        * wptKeyManagerDlg.cpp (keyprops_dlg_proc): Fix stack overflow.

For complete details, see the ChangeLog files.

1 twoaday 2 /* wptMDSumDlg.cpp
2 twoaday 22 * Copyright (C) 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 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    
22     #include <windows.h>
23     #include <stdio.h>
24     #include "../resource.h"
25    
26     #include "wptTypes.h"
27     #include "wptW32API.h"
28     #include "wptGPG.h"
29     #include "wptCommonCtl.h"
30     #include "wptContext.h"
31     #include "wptNLS.h"
32     #include "wptErrors.h"
33    
34    
35 twoaday 32 /* Return a printable digest of the buffer @mdbuf. */
36     static const char*
37     printable_digest (byte *mdbuf, size_t n)
38 twoaday 2 {
39     static char mdasc[64];
40     size_t i;
41 twoaday 32 for (i = 0; i < n; i++)
42     sprintf (mdasc+2*i, "%02X", mdbuf[i]);
43 twoaday 2 return mdasc;
44 twoaday 32 }
45 twoaday 2
46    
47 twoaday 32 /* Dialog box procedure to show and calculate file digests. */
48 twoaday 2 BOOL CALLBACK
49 twoaday 22 mdsum_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
50 twoaday 2 {
51     static listview_ctrl_t lv;
52     static struct md_file_s * md;
53     struct listview_column_s cols[] = {
54     {0, 264, (char *)_("Digest")},
55     {1, 128, (char *)_("Name")},
56     {0, 0, 0}
57     };
58     gpgme_data_t sumlist;
59 twoaday 22 char fname[300], mdasc[64];
60 twoaday 2 byte mdbuf[20];
61     int i;
62     size_t n;
63    
64     switch( msg ) {
65     case WM_INITDIALOG:
66     md = (md_file_s *)lparam;
67     if( !md )
68     BUG( NULL );
69     if( listview_new( &lv ) )
70     BUG( NULL );
71     lv->ctrl = GetDlgItem( dlg, IDC_MDSUM_LIST );
72     for( i = 0; i < cols[i].width; i++ )
73     listview_add_column( lv, &cols[i] );
74     for( i = 0; i < listview_count_items( md->lv, 0 ); i++ ) {
75     if( listview_get_item_state( md->lv, i ) ) {
76 twoaday 23 listview_get_item_text( md->lv, i, 1, fname, sizeof (fname)-1 );
77 twoaday 2 if( !gpg_md_hash_file( md->mdalgo, fname, mdbuf, &n ) ) {
78     listview_add_item( lv, "" );
79     listview_add_sub_item( lv, 0, 0, printable_digest( mdbuf, n ) );
80     listview_add_sub_item( lv, 0, 1, fname );
81     }
82     }
83     }
84     SetForegroundWindow( dlg );
85     break;
86    
87     case WM_DESTROY:
88     if( lv ) {
89     listview_release( lv );
90     lv = NULL;
91     }
92     break;
93    
94     case WM_COMMAND:
95 twoaday 23 switch (LOWORD (wparam)) {
96 twoaday 2 case IDOK:
97 twoaday 23 EndDialog (dlg, TRUE);
98 twoaday 2 break;
99    
100     case IDC_MDSUM_COPY:
101 twoaday 22 if (gpgme_data_new (&sumlist))
102     BUG(0);
103     if (md->mdalgo == 3) {/* rmd160 */
104     const char *s = "# warning rmd160sum is not yet available\r\n";
105     gpgme_data_write (sumlist, s, strlen (s));
106     }
107     for (i = 0; i < listview_count_items (lv, 0); i++) {
108     listview_get_item_text (lv, i, 0, mdasc, DIM (mdasc)-1);
109     listview_get_item_text (lv, i, 1, fname, DIM (fname)-1);
110 twoaday 2
111 twoaday 22 gpgme_data_write (sumlist, mdasc, strlen (mdasc));
112     gpgme_data_write (sumlist, " ", 1);
113     gpgme_data_write (sumlist, fname, strlen (fname));
114     gpgme_data_write (sumlist, "\r\n", 2);
115 twoaday 2 }
116 twoaday 22 const char *name = get_filename_dlg (dlg, 1, _("Select file to save checksums"), NULL, NULL);
117     if (name && *name) {
118 twoaday 23 gpg_data_release_and_set_file (sumlist, name);
119     log_box (_("File Manager"), MB_OK, "Checksums successfully saved in '%s'", name);
120 twoaday 22 }
121     else
122     gpgme_data_release (sumlist);
123 twoaday 2 break;
124     }
125     break;
126     }
127     return FALSE;
128 twoaday 32 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26