353 |
gpgme_ctx_t gctx; |
gpgme_ctx_t gctx; |
354 |
gpgme_data_t in, out; |
gpgme_data_t in, out; |
355 |
pass_cb_t cb_val; |
pass_cb_t cb_val; |
356 |
|
int cancel; |
357 |
|
|
358 |
cb_val = new_pass_cb (ctx->main_wnd); |
cb_val = new_pass_cb (ctx->main_wnd); |
359 |
|
|
367 |
err = gpgme_op_sign (gctx, in, out, GPGME_SIG_MODE_CLEAR); |
err = gpgme_op_sign (gctx, in, out, GPGME_SIG_MODE_CLEAR); |
368 |
} |
} |
369 |
|
|
370 |
|
cancel = pass_cb_cancelled (cb_val); |
371 |
|
|
372 |
gpgme_release (gctx); |
gpgme_release (gctx); |
373 |
gpgme_data_release (in); |
gpgme_data_release (in); |
374 |
free_pass_cb (cb_val); |
free_pass_cb (cb_val); |
375 |
|
|
376 |
if (err) |
if (err || cancel) |
377 |
gpgme_data_release (out); |
gpgme_data_release (out); |
378 |
else |
else |
379 |
map_gpgme_data (out, r_msg); |
map_gpgme_data (out, r_msg); |
380 |
|
|
381 |
return err; |
return cancel? 0 : err; |
382 |
} |
} |
383 |
|
|
384 |
|
|
392 |
gpgme_key_t *keys; |
gpgme_key_t *keys; |
393 |
pass_cb_t cb_val; |
pass_cb_t cb_val; |
394 |
recip_list_t list = NULL; |
recip_list_t list = NULL; |
395 |
|
int cancel; |
396 |
|
|
397 |
err = get_keys (ctx, &list, &keys); |
err = get_keys (ctx, &list, &keys); |
398 |
if (err) |
if (err) |
413 |
in, out); |
in, out); |
414 |
} |
} |
415 |
|
|
416 |
|
cancel = pass_cb_cancelled (cb_val); |
417 |
|
|
418 |
gpgme_release (gctx); |
gpgme_release (gctx); |
419 |
gpgme_data_release (in); |
gpgme_data_release (in); |
420 |
release_recipient (list); |
release_recipient (list); |
421 |
free_if_alloc (keys); |
free_if_alloc (keys); |
422 |
free_pass_cb (cb_val); |
free_pass_cb (cb_val); |
423 |
|
|
424 |
if (err) |
if (err || cancel) |
425 |
gpgme_data_release (out); |
gpgme_data_release (out); |
426 |
else |
else |
427 |
map_gpgme_data (out, r_msg); |
map_gpgme_data (out, r_msg); |
428 |
return err; |
return cancel? 0 : err; |
429 |
} |
} |
430 |
|
|
431 |
|
|
510 |
gpgme_data_t in = NULL, out = NULL; |
gpgme_data_t in = NULL, out = NULL; |
511 |
gpgme_error_t err; |
gpgme_error_t err; |
512 |
pass_cb_t cb_val; |
pass_cb_t cb_val; |
513 |
|
int cancel; |
514 |
char *msg = *r_msg; |
char *msg = *r_msg; |
515 |
|
|
516 |
cb_val = new_pass_cb (main_wnd); |
cb_val = new_pass_cb (main_wnd); |
524 |
err = gpgme_op_decrypt (gctx, in, out); |
err = gpgme_op_decrypt (gctx, in, out); |
525 |
} |
} |
526 |
|
|
527 |
|
cancel = pass_cb_cancelled (cb_val); |
528 |
|
|
529 |
gpgme_release (gctx); |
gpgme_release (gctx); |
530 |
gpgme_data_release (in); |
gpgme_data_release (in); |
531 |
free_pass_cb (cb_val); |
free_pass_cb (cb_val); |
532 |
|
|
533 |
if (err) |
if (err || cancel) |
534 |
gpgme_data_release (out); |
gpgme_data_release (out); |
535 |
else |
else |
536 |
map_gpgme_data (out, r_msg); |
map_gpgme_data (out, r_msg); |
537 |
|
|
538 |
return err; |
return cancel? 0 : err; |
539 |
} |
} |
540 |
|
|
541 |
|
|
542 |
/* Decrypt the message @r_msg. If the type @type is actually a signature, |
/* Decrypt the message @r_msg. If the type @type is actually a signature, |
543 |
the verify function is called instead of decryption. */ |
the verify function is called instead of decryption. */ |
544 |
static gpgme_error_t |
static gpgme_error_t |
545 |
decrypt_msg (plugin_ctx_t ctx, char **r_msg, int type) |
decrypt_msg (plugin_ctx_t ctx, char **r_msg, int type, int *r_cancel) |
546 |
{ |
{ |
547 |
gpgme_ctx_t gctx = NULL; |
gpgme_ctx_t gctx = NULL; |
548 |
gpgme_data_t in = NULL, out = NULL; |
gpgme_data_t in = NULL, out = NULL; |
569 |
DialogBoxParam (mod_hinst_dll, (LPCTSTR)IDD_VERIFY, ctx->main_wnd, |
DialogBoxParam (mod_hinst_dll, (LPCTSTR)IDD_VERIFY, ctx->main_wnd, |
570 |
verify_dlg_proc, (LPARAM)res->signatures); |
verify_dlg_proc, (LPARAM)res->signatures); |
571 |
} |
} |
572 |
if (err) { |
*r_cancel = pass_cb_cancelled (cb_val); |
573 |
|
|
574 |
|
if (!*r_cancel && err) { |
575 |
gpgme_decrypt_result_t r = gpgme_op_decrypt_result (gctx); |
gpgme_decrypt_result_t r = gpgme_op_decrypt_result (gctx); |
576 |
store_decrypt_info (ctx->errbuf, sizeof (ctx->errbuf)-1, r); |
store_decrypt_info (ctx->errbuf, sizeof (ctx->errbuf)-1, r); |
577 |
} |
} |
580 |
gpgme_data_release (in); |
gpgme_data_release (in); |
581 |
free_pass_cb (cb_val); |
free_pass_cb (cb_val); |
582 |
|
|
583 |
if (err) |
if (err || *r_cancel) |
584 |
gpgme_data_release (out); |
gpgme_data_release (out); |
585 |
else |
else |
586 |
map_gpgme_data (out, r_msg); |
map_gpgme_data (out, r_msg); |
587 |
|
|
588 |
return err; |
return *r_cancel? 0 : err; |
589 |
} |
} |
590 |
|
|
591 |
|
|
657 |
gpgme_error_t rc = 0; |
gpgme_error_t rc = 0; |
658 |
char *msg; |
char *msg; |
659 |
int msg_type = 0; |
int msg_type = 0; |
660 |
|
int cancel; |
661 |
|
|
662 |
assert (ctx); |
assert (ctx); |
663 |
|
|
686 |
_("GPG Plug-in Info"), MB_ICONINFORMATION|MB_OK); |
_("GPG Plug-in Info"), MB_ICONINFORMATION|MB_OK); |
687 |
} |
} |
688 |
else if (msg_type) { |
else if (msg_type) { |
689 |
rc = decrypt_msg (ctx, &msg, msg_type); |
rc = decrypt_msg (ctx, &msg, msg_type, &cancel); |
690 |
SendMessage (ctx->msg_wnd, WM_CLEAR, 0, 0); |
SendMessage (ctx->msg_wnd, WM_CLEAR, 0, 0); |
691 |
SendMessage (ctx->msg_wnd, WM_UNDO, 0, 0); |
SendMessage (ctx->msg_wnd, WM_UNDO, 0, 0); |
692 |
if (!rc && (msg_type & PGP_MESSAGE) && msg && strlen (msg) > 0) { |
if (!cancel && !rc && (msg_type & PGP_MESSAGE) |
693 |
|
&& msg && strlen (msg) > 0) { |
694 |
struct viewer_ctx_s viewer; |
struct viewer_ctx_s viewer; |
695 |
viewer.msg = msg; |
viewer.msg = msg; |
696 |
viewer.main_wnd = ctx->main_wnd; |
viewer.main_wnd = ctx->main_wnd; |