/[gpgoe]/trunk/src/OECrypto.c
ViewVC logotype

Diff of /trunk/src/OECrypto.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 17 by twoaday, Tue Apr 11 06:56:23 2006 UTC revision 18 by twoaday, Thu Apr 13 07:41:30 2006 UTC
# Line 353  sign_msg (plugin_ctx_t ctx, char **r_msg Line 353  sign_msg (plugin_ctx_t ctx, char **r_msg
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    
# Line 366  sign_msg (plugin_ctx_t ctx, char **r_msg Line 367  sign_msg (plugin_ctx_t ctx, char **r_msg
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    
# Line 389  sign_encrypt_msg (plugin_ctx_t ctx, char Line 392  sign_encrypt_msg (plugin_ctx_t ctx, char
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)
# Line 409  sign_encrypt_msg (plugin_ctx_t ctx, char Line 413  sign_encrypt_msg (plugin_ctx_t ctx, char
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    
# Line 504  oe_decrypt_msg (HWND main_wnd, char **r_ Line 510  oe_decrypt_msg (HWND main_wnd, char **r_
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);
# Line 517  oe_decrypt_msg (HWND main_wnd, char **r_ Line 524  oe_decrypt_msg (HWND main_wnd, char **r_
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;
# Line 560  decrypt_msg (plugin_ctx_t ctx, char **r_ Line 569  decrypt_msg (plugin_ctx_t ctx, char **r_
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      }      }
# Line 569  decrypt_msg (plugin_ctx_t ctx, char **r_ Line 580  decrypt_msg (plugin_ctx_t ctx, char **r_
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    
# Line 646  oe_handle_mail (plugin_ctx_t ctx) Line 657  oe_handle_mail (plugin_ctx_t ctx)
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    
# Line 674  oe_handle_mail (plugin_ctx_t ctx) Line 686  oe_handle_mail (plugin_ctx_t ctx)
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;

Legend:
Removed from v.17  
changed lines
  Added in v.18

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26