1 |
/* wptFileManager.cpp - File Manager routines |
/* wptFileManager.cpp - File Manager routines |
2 |
* Copyright (C) 2001-2005 Timo Schulz |
* Copyright (C) 2001-2005 Timo Schulz |
3 |
|
* Copyright (C) 2005 g10 Code GmbH |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
6 |
* |
* |
698 |
return n; |
return n; |
699 |
} |
} |
700 |
|
|
|
|
|
701 |
int |
int |
702 |
fm_parse_files (listview_ctrl_t lv, HWND dlg, int cmd) |
fm_parse_files (listview_ctrl_t lv, HWND dlg, int cmd) |
703 |
{ |
{ |
836 |
progress_cleanup (&pfx2); |
progress_cleanup (&pfx2); |
837 |
} |
} |
838 |
if (ctx->cache_cb) { |
if (ctx->cache_cb) { |
839 |
memset (ctx->pass_cb.pwd, 0, sizeof (ctx->pass_cb)); |
release_gpg_passphrase_cb (&ctx->pass_cb); |
840 |
ctx->cache_cb = 0; /* make sure it's only used for this session! */ |
ctx->cache_cb = 0; /* make sure it's only used for this session! */ |
841 |
} |
} |
842 |
|
|
893 |
if (!s) |
if (!s) |
894 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
895 |
|
|
896 |
free_if_alloc (*dst); |
if (dst != NULL) |
897 |
|
free_if_alloc (*dst); |
898 |
free_if_alloc (c->output); |
free_if_alloc (c->output); |
899 |
c->output = m_strdup (s); |
c->output = m_strdup (s); |
900 |
if (!c->output) |
if (!c->output) |
915 |
char * keyid = NULL, ext[5]; |
char * keyid = NULL, ext[5]; |
916 |
int no_compr = 0; |
int no_compr = 0; |
917 |
int rc = 0; |
int rc = 0; |
918 |
|
|
|
|
|
919 |
c->output = new char[strlen (name) + 5 + 1]; |
c->output = new char[strlen (name) + 5 + 1]; |
920 |
if (!c->output) |
if (!c->output) |
921 |
BUG (0); |
BUG (0); |
929 |
goto leave; |
goto leave; |
930 |
} |
} |
931 |
|
|
932 |
err = gpg_file_data_new (name, &in, 1); |
err = gpg_file_data_new (name, 1, &in); |
933 |
if (err) |
if (err) |
934 |
goto leave; |
goto leave; |
935 |
err = gpg_file_data_new (c->output, &out, 0); |
err = gpg_file_data_new (c->output, 0, &out); |
936 |
if (err) |
if (err) |
937 |
goto leave; |
goto leave; |
938 |
|
|
970 |
err = gpgme_op_encrypt_sign (ctx, c->recp, GPGME_ENCRYPT_ALWAYS_TRUST, |
err = gpgme_op_encrypt_sign (ctx, c->recp, GPGME_ENCRYPT_ALWAYS_TRUST, |
971 |
in->dat, out->dat); |
in->dat, out->dat); |
972 |
if (!c->cache_cb) |
if (!c->cache_cb) |
973 |
memset (c->pass_cb.pwd, 0, sizeof (c->pass_cb.pwd)); |
release_gpg_passphrase_cb (&c->pass_cb); |
974 |
if (c->pass_cb.cancel) { |
if (c->pass_cb.cancel) { |
975 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
976 |
goto leave; |
goto leave; |
1035 |
|
|
1036 |
gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass); |
gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass); |
1037 |
|
|
1038 |
err = gpg_file_data_new (name, &in, 1); |
err = gpg_file_data_new (name, 1, &in); |
1039 |
if (err) |
if (err) |
1040 |
goto leave; |
goto leave; |
1041 |
err = gpg_file_data_new (c->output, &out, 0); |
err = gpg_file_data_new (c->output, 0, &out); |
1042 |
if (err) |
if (err) |
1043 |
goto leave; |
goto leave; |
1044 |
|
|
1108 |
|
|
1109 |
remove_crit_file_attrs (c->output, 0); |
remove_crit_file_attrs (c->output, 0); |
1110 |
|
|
1111 |
err = gpg_file_data_new (name, &in, 1); |
err = gpg_file_data_new (name, 1, &in); |
1112 |
if (err) |
if (err) |
1113 |
goto leave; |
goto leave; |
1114 |
err = gpg_file_data_new (c->output, &out, 0); |
err = gpg_file_data_new (c->output, 0, &out); |
1115 |
if (err) |
if (err) |
1116 |
goto leave; |
goto leave; |
1117 |
|
|
1118 |
err = gpgme_op_decrypt_verify (ctx, in->dat, out->dat); |
err = gpgme_op_decrypt_verify (ctx, in->dat, out->dat); |
1119 |
if (!c->cache_cb) |
if (!c->cache_cb) |
1120 |
memset (c->pass_cb.pwd, 0, sizeof (c->pass_cb.pwd)); |
release_gpg_passphrase_cb (&c->pass_cb); |
1121 |
if (c->pass_cb.cancel) { |
if (c->pass_cb.cancel) { |
1122 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
1123 |
goto leave; |
goto leave; |
1124 |
} |
} |
1125 |
|
|
1126 |
res = gpgme_op_decrypt_result (ctx); |
res = gpgme_op_decrypt_result (ctx); |
1127 |
if (res && err == gpg_error (GPG_ERR_NO_SECKEY)) { |
if (res && gpgme_err_code (err) == GPG_ERR_NO_SECKEY) { |
1128 |
char *p = get_key_userid (keyid+8); |
char *p = get_key_userid (keyid+8); |
1129 |
gpgme_pubkey_algo_t pkalgo = (gpgme_pubkey_algo_t)0; |
gpgme_pubkey_algo_t pkalgo = (gpgme_pubkey_algo_t)0; |
1130 |
|
|
1139 |
goto leave; |
goto leave; |
1140 |
} |
} |
1141 |
else if (err) { |
else if (err) { |
1142 |
msg_box( c->dlg, gpgme_strerror( err ), _("Decrypt"), MB_ERR ); |
msg_box (c->dlg, gpgme_strerror (err), _("Decrypt"), MB_ERR); |
1143 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
1144 |
goto leave; |
goto leave; |
1145 |
} |
} |
1146 |
if( file_exist_check( c->output ) ) { |
if (file_exist_check (c->output)) { |
1147 |
msg_box( c->dlg, _("Decryption failed"), _("Decrypt"), MB_ERR ); |
//msg_box( c->dlg, _("Decryption failed"), _("Decrypt"), MB_ERR ); |
1148 |
|
log_box ("Decrypt", MB_ERR, _("Decryption failed.\n%s: does not exist."), c->output); |
1149 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
1150 |
} |
} |
1151 |
|
|
1152 |
sigres = gpgme_op_verify_result (ctx); |
sigres = gpgme_op_verify_result (ctx); |
1153 |
if (sigres) { |
if (sigres && sigres->signatures) { |
1154 |
sig = sigres->signatures; |
sig = sigres->signatures; |
1155 |
sigok = sig->summary & GPGME_SIGSUM_GREEN; |
sigok = sig->summary & GPGME_SIGSUM_GREEN; |
1156 |
const char *s = sigok? _("Good signature") : _("BAD signature"); |
const char *s = sigok? _("Good signature") : _("BAD signature"); |
1208 |
} |
} |
1209 |
remove_crit_file_attrs( c->output, 0 ); |
remove_crit_file_attrs( c->output, 0 ); |
1210 |
|
|
1211 |
err = gpg_file_data_new (name, &in, 1); |
err = gpg_file_data_new (name, 1, &in); |
1212 |
if (err) |
if (err) |
1213 |
goto leave; |
goto leave; |
1214 |
err = gpg_file_data_new (c->output, &out, 0); |
err = gpg_file_data_new (c->output, 0, &out); |
1215 |
if (err) |
if (err) |
1216 |
goto leave; |
goto leave; |
1217 |
|
|
1218 |
err = gpgme_op_sign (ctx, in->dat, out->dat, c->sigmode); |
err = gpgme_op_sign (ctx, in->dat, out->dat, c->sigmode); |
1219 |
if( !c->cache_cb ) |
if( !c->cache_cb ) |
1220 |
memset( c->pass_cb.pwd, 0, sizeof (c->pass_cb.pwd) ); |
release_gpg_passphrase_cb (&c->pass_cb); |
1221 |
if( c->pass_cb.cancel ) { |
if( c->pass_cb.cancel ) { |
1222 |
rc = WPTERR_GENERAL; |
rc = WPTERR_GENERAL; |
1223 |
goto leave; |
goto leave; |
1375 |
strcpy (log.file, name); /* XXX: check bounds */ |
strcpy (log.file, name); /* XXX: check bounds */ |
1376 |
file_verify_create_dlg (); |
file_verify_create_dlg (); |
1377 |
|
|
1378 |
err = gpg_file_data_new (name, &in, 1); |
err = gpg_file_data_new (name, 1, &in); |
1379 |
if (err) |
if (err) |
1380 |
goto leave; |
goto leave; |
1381 |
err = gpg_file_data_new (c->output, &out, 0); |
err = gpg_file_data_new (c->output, 0, &out); |
1382 |
if (err) |
if (err) |
1383 |
goto leave; |
goto leave; |
1384 |
|
|
1431 |
if (!c->output) |
if (!c->output) |
1432 |
BUG (NULL); |
BUG (NULL); |
1433 |
|
|
1434 |
err = gpg_file_data_new (name, &keydata, 1); |
err = gpg_file_data_new (name, 1, &keydata); |
1435 |
if (err) |
if (err) |
1436 |
goto leave; |
goto leave; |
1437 |
|
|
1494 |
|
|
1495 |
patt = gpg_keylist_to_pattern (rset); |
patt = gpg_keylist_to_pattern (rset); |
1496 |
|
|
1497 |
err = gpg_file_data_new (name, &keydata, 0); |
err = gpg_file_data_new (name, 0, &keydata); |
1498 |
if (err) |
if (err) |
1499 |
goto leave; |
goto leave; |
1500 |
|
|
1693 |
rc = listview_get_item_text (lv, -1, 1, buf, sizeof (buf)-1); |
rc = listview_get_item_text (lv, -1, 1, buf, sizeof (buf)-1); |
1694 |
if (rc == -1) |
if (rc == -1) |
1695 |
return 0; |
return 0; |
1696 |
mapi_send_ascfile (buf); |
/*mapi_send_ascfile (buf); XXX */ |
1697 |
return 0; |
return 0; |
1698 |
} |
} |