18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
20 |
*/ |
*/ |
21 |
|
|
22 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
23 |
#include <config.h> |
#include <config.h> |
24 |
#endif |
#endif |
38 |
#include "wptContext.h" /* for passphrase_s */ |
#include "wptContext.h" /* for passphrase_s */ |
39 |
#include "wptRegistry.h" |
#include "wptRegistry.h" |
40 |
#include "wptDlgs.h" |
#include "wptDlgs.h" |
41 |
|
#include "wptUTF8.h" |
42 |
|
|
43 |
|
|
44 |
/* Encrypt the contents of the clipboard with the keys in @rset. |
/* Encrypt the contents of the clipboard with the keys in @rset. |
65 |
goto leave; |
goto leave; |
66 |
err = gpgme_data_new (&ciph); |
err = gpgme_data_new (&ciph); |
67 |
if (err) |
if (err) |
68 |
goto leave; |
goto leave; |
69 |
err = gpgme_op_encrypt (ctx, rset, |
err = gpgme_op_encrypt (ctx, rset, |
70 |
always_trust?GPGME_ENCRYPT_ALWAYS_TRUST : (gpgme_encrypt_flags_t)0, |
always_trust?GPGME_ENCRYPT_ALWAYS_TRUST : (gpgme_encrypt_flags_t)0, |
71 |
plain, ciph); |
plain, ciph); |
95 |
gpgme_invalid_key_t k; |
gpgme_invalid_key_t k; |
96 |
gpgme_key_t key; |
gpgme_key_t key; |
97 |
size_t len=0; |
size_t len=0; |
98 |
char *p; |
char *uid, *p; |
99 |
|
|
100 |
if (!ctx) |
if (!ctx) |
101 |
return -1; |
return -1; |
104 |
return -1; |
return -1; |
105 |
|
|
106 |
for (k=res->invalid_recipients; k; k = k->next) { |
for (k=res->invalid_recipients; k; k = k->next) { |
107 |
get_pubkey (k->fpr, &key); |
if (get_pubkey (k->fpr, &key)) |
108 |
|
continue; |
109 |
len += (32 + 16 + strlen (key->uids->name) + 2) + 4; |
len += (32 + 16 + strlen (key->uids->name) + 2) + 4; |
110 |
} |
} |
111 |
|
|
114 |
BUG (NULL); |
BUG (NULL); |
115 |
strcpy (p, _("Recipients unsuable for encryption:\n")); |
strcpy (p, _("Recipients unsuable for encryption:\n")); |
116 |
for (k = res->invalid_recipients; k; k = k->next) { |
for (k = res->invalid_recipients; k; k = k->next) { |
117 |
get_pubkey (k->fpr, &key); |
if (get_pubkey (k->fpr, &key)) |
118 |
|
continue; |
119 |
|
uid = utf8_to_native (key->uids->name); |
120 |
strcat (p, key->subkeys->keyid+8); |
strcat (p, key->subkeys->keyid+8); |
121 |
strcat (p, " : "); |
strcat (p, " : "); |
122 |
strcat (p, key->uids->name); |
strcat (p, uid); |
123 |
strcat (p, "\n"); |
strcat (p, "\n"); |
124 |
|
safe_free (uid); |
125 |
} |
} |
126 |
msg_box (dlg, p, _("Encryption"), MB_ERR); |
msg_box (dlg, p, _("Encryption"), MB_ERR); |
127 |
free (p); |
free (p); |
141 |
int force_trust = 0; |
int force_trust = 0; |
142 |
int n; |
int n; |
143 |
|
|
144 |
switch( msg ) { |
switch (msg) { |
145 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
146 |
SetWindowText (dlg, _("Encryption")); |
SetWindowText (dlg, _("Encryption")); |
147 |
SetDlgItemText (dlg, IDC_ENCRYPT_FNDCMD, _("&Find")); |
SetDlgItemText (dlg, IDC_ENCRYPT_FNDCMD, _("&Find")); |
148 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
149 |
kc = keycache_get_ctx( KEYCACHE_PUB ); |
kc = keycache_get_ctx (KEYCACHE_PUB); |
150 |
if( !kc ) |
if (!kc) |
151 |
BUG( NULL ); |
BUG (NULL); |
152 |
lv = keylist_load (GetDlgItem( dlg, IDC_ENCRYPT_KEYLIST ), kc, NULL, |
lv = keylist_load (GetDlgItem (dlg, IDC_ENCRYPT_KEYLIST), kc, NULL, |
153 |
KEYLIST_ENCRYPT_MIN, KEY_SORT_USERID); |
KEYLIST_ENCRYPT_MIN, KEY_SORT_USERID); |
154 |
center_window( dlg, NULL ); |
center_window (dlg, NULL); |
155 |
SetForegroundWindow( dlg ); |
SetForegroundWindow (dlg); |
156 |
return TRUE; |
return TRUE; |
157 |
|
|
158 |
case WM_DESTROY: |
case WM_DESTROY: |
195 |
case IDOK: |
case IDOK: |
196 |
rset = keylist_get_recipients (lv, &force_trust, &n); |
rset = keylist_get_recipients (lv, &force_trust, &n); |
197 |
if (!n) { |
if (!n) { |
198 |
msg_box (dlg, _("You must select at least one key."), _("Encryption"), MB_ERR); |
msg_box (dlg, _("You must select at least one key."), |
199 |
free (rset); |
_("Encryption"), MB_ERR); |
200 |
|
safe_free (rset); |
201 |
return FALSE; |
return FALSE; |
202 |
} |
} |
203 |
err = gpg_clip_encrypt (rset, force_trust, &ctx); |
err = gpg_clip_encrypt (rset, force_trust, &ctx); |
206 |
msg_box (dlg, gpgme_strerror (err), _("Encryption"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Encryption"), MB_ERR); |
207 |
if (ctx) |
if (ctx) |
208 |
gpgme_release (ctx); |
gpgme_release (ctx); |
209 |
free (rset); |
safe_free (rset); |
210 |
return FALSE; |
return FALSE; |
211 |
} |
} |
212 |
else |
else |