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

Contents of /trunk/Src/wptMDSumDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (show annotations)
Wed Aug 10 11:33:35 2005 UTC (19 years, 6 months ago) by twoaday
File size: 3643 byte(s)
2005-08-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptGPGME.cpp (keycache_update): Reload OpenPGP parts
        of the secret key.
        (keycache_init): cache name of secret keyring.
        * wptKeyList.cpp (keylist_upd_key): Do not add long keyid.
        (get_key_type): Do not assume 'ultimate' means key pair.
        * wptKeyEditDlgs.cpp (diff_time): New.
        (keyedit_addsubkey_dlg_proc): Changed design and use
        diff_time. Drop checks for invalid keylength (< 1024, > 4096)
        because the combo box automatically handles this.
        * wptKeyManager.cpp (km_set_implicit_trust): Return error code.
        * wptGPG.cpp (get_backup_name): New.
        (gnupg_backup_keyrings): Rotate backup names, from 0..3.
        * wptClipImportDialog.cpp (clip_import_dlg_proc): Free memory.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Use 0x short keyid and
        not the long keyid.


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26