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

Contents of /trunk/Src/wptMDSumDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (show annotations)
Mon Nov 14 15:01:01 2005 UTC (19 years, 3 months ago) by twoaday
File size: 3651 byte(s)
2005-11-12  Timo Schulz  <ts@g10code.com>
 
        Fix more GCC warnings.
 
2005-11-10  Timo Schulz  <ts@g10code.com>
 
        * wptClipSignDlg.cpp (one_key_proc): Use
        release_gpg_passphrase_cb() to free the context.
        * wptListView.cpp (listview_deselect_all): New.
        * wptMAPI.cpp (mapi_send_pubkey): Works again.
        * wptFileManagerDlg.cpp (file_manager_dlg_proc): Support encrypt &
        zip.
        * wptPassphraseCB.cpp (passphrase_callback_proc): Fix passphrase
        caching for signing operations.
        * wptKeyManager.cpp (km_send_to_mail_recipient): Works again.
        * wptFileManager.cpp (fm_send_file): Likewise.
        (fm_encrypt_into_zip): New.
         

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

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26