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

Annotation of /trunk/Src/wptClipEncryptDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (hide annotations)
Mon Apr 4 06:59:24 2005 UTC (19 years, 10 months ago) by twoaday
File size: 5459 byte(s)
2005-03-04  Timo Schulz  <twoaday@g10code.com>
 
        * GPG asks twice for the new PIN. Thanks to Achim.
        * wptCardDlg.cpp (card_changepin_dlg_proc): Reset the 'safety' pin also.        Only check the passphrase if the backup flag is enabled. Again thanks to        Achim.
 
2005-03-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptKeySignDlg.cpp (do_fill_seckeylist): Skip secret keys without
        a public key. Noted by Kurt Fitzner.
 
2005-03-22  Timo Schulz  <twoaday@freakmail.de>
 
        * WinPT.cpp (WinMain): --debug as an alias for --enable-debug.
        (enable_mobile_mode): New.
        * wptKeyEditDlg.cpp (keyedit_addsubkey_dlg_proc): Use new
        ID's for adding subkeys.
 


1 twoaday 2 /* wptClipEncryptDlg.cpp - Clipboard encrypt dialog
2     * Copyright (C) 2000-2004 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     #include <windows.h>
22     #include <commctrl.h>
23    
24     #include "../resource.h"
25     #include "wptTypes.h"
26     #include "wptW32API.h"
27     #include "wptVersion.h"
28     #include "wptErrors.h"
29     #include "wptCommonCtl.h"
30     #include "wptGPG.h"
31     #include "wptKeylist.h"
32     #include "wptNLS.h"
33     #include "wptContext.h" /* for passphrase_s */
34     #include "wptRegistry.h"
35     #include "wptDlgs.h"
36    
37    
38     BOOL CALLBACK
39     clip_encrypt_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
40     {
41     static listview_ctrl_t lv = NULL;
42     gpgme_keycache_t kc;
43     gpgme_recipients_t rset;
44     gpgme_ctx_t ctx;
45     gpgme_error_t err;
46     refresh_cache_s rcs = {0};
47     int force_trust = 0, opt = 0;
48     int kmode = reg_prefs.keylist_mode? KEYLIST_ENCRYPT_MIN : KEYLIST_ENCRYPT;
49    
50     switch( msg ) {
51     case WM_INITDIALOG:
52     SetWindowText( dlg, _("Encryption") );
53    
54     if( keycache_get_reload() ) {
55     rcs.kr_reload = rcs.kr_update = 1;
56     rcs.tr_update = 0;
57     DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, GetDesktopWindow(),
58     keycache_dlg_proc, (LPARAM)&rcs );
59     }
60     kc = keycache_get_ctx( KEYCACHE_PUB );
61     if( !kc )
62     BUG( NULL );
63     lv = keylist_load( GetDlgItem( dlg, IDC_ENCRYPT_KEYLIST ), kc, NULL,
64     kmode, GPGME_ATTR_USERID );
65     center_window( dlg );
66     SetForegroundWindow( dlg );
67     set_active_window( dlg );
68     return TRUE;
69    
70     case WM_DESTROY:
71     reset_active_window( );
72     if( lv ) {
73     keylist_delete( lv );
74     lv = NULL;
75     }
76     return FALSE;
77    
78     case WM_NOTIFY:
79     NMHDR *notify;
80    
81     notify = (NMHDR *)lparam;
82     if( notify && notify->code == NM_DBLCLK && notify->idFrom == IDC_ENCRYPT_KEYLIST )
83     PostMessage( dlg, WM_COMMAND, MAKEWPARAM( IDOK, 0 ), NULL );
84     if( notify && notify->code == LVN_COLUMNCLICK && notify->idFrom == IDC_ENCRYPT_KEYLIST ) {
85     NMLISTVIEW *p = (LPNMLISTVIEW) lparam;
86     int sortby = 0;
87    
88     switch( p->iSubItem ) {
89     case 0: sortby = GPGME_ATTR_USERID; break;
90     case 1: sortby = GPGME_ATTR_KEYID; break;
91     case 2: sortby = GPGME_ATTR_LEN; break;
92     case 4: sortby = GPGME_ATTR_VALIDITY; break;
93     default: sortby = GPGME_ATTR_USERID; break;
94     }
95     keylist_sort( lv, sortby );
96     }
97     return TRUE;
98    
99     case WM_SYSCOMMAND:
100     if( LOWORD( wparam ) == SC_CLOSE )
101     EndDialog( dlg, TRUE );
102     return FALSE;
103    
104     case WM_COMMAND:
105     switch( LOWORD( wparam ) ) {
106     case IDOK:
107     rset = keylist_get_recipients( lv, &force_trust, NULL );
108     if( !gpgme_recipients_count( rset ) ) {
109     msg_box( dlg, _("You must select at least one key."), _("Encryption"), MB_ERR );
110     gpgme_recipients_release( rset );
111     return FALSE;
112     }
113     if( force_trust )
114     opt |= GPGME_CTRL_FORCETRUST;
115     if( reg_prefs.use_tmpfiles )
116     opt |= GPGME_CTRL_TMPFILES;
117     err = gpgme_op_clip_encrypt( rset, opt, &ctx );
118     if( err && err != GPGME_Inv_Recipients ) {
119 twoaday 6 if( err == GPGME_Internal_GPG_Problem )
120 twoaday 2 gnupg_display_error ();
121     else
122     msg_box( dlg, gpgme_strerror( err ), _("Encryption"), MB_ERR );
123     gpgme_release( ctx );
124     gpgme_recipients_release( rset );
125     return FALSE;
126     }
127     else if( err == GPGME_Inv_Recipients ) {
128     int ncount = gpgme_recperr_count_items( ctx );
129     gpgme_error_t code = GPGME_No_Error;
130    
131     while( ncount-- ) {
132     const char *s = gpgme_recperr_get( ctx, ncount, &code );
133     if( s )
134     log_box( _("Encryption"), MB_ERR,
135     _("Unusable recipient \"%s\": %s"), s,
136     gpgme_strerror( code ) );
137     }
138     }
139     else
140     show_msg( dlg, 1500, _("GnuPG Status: Finished") );
141     gpgme_recipients_release( rset );
142     gpgme_release( ctx );
143     EndDialog( dlg, TRUE );
144     return TRUE;
145    
146     case IDCANCEL:
147     EndDialog( dlg, FALSE );
148     return FALSE;
149    
150     case IDC_ENCRYPT_FNDCMD:
151     {
152     char tmpbuf[64];
153     int n;
154    
155     n = GetDlgItemText (dlg, IDC_ENCRYPT_FIND, tmpbuf, DIM (tmpbuf)-1);
156     if (!n)
157     break;
158     n = listview_find (lv, tmpbuf);
159     if (n != -1)
160     listview_select_one (lv, n);
161     else
162     log_box (_("Encryption"), MB_ERR, _("No recipient found with '%s'"), tmpbuf);
163     break;
164     }
165     }
166     break;
167     }
168    
169     return FALSE;
170     } /* clip_encrypt_dlg_proc */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26