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

Diff of /trunk/Src/wptPassphraseCB.cpp

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

revision 204 by twoaday, Wed Apr 26 06:37:23 2006 UTC revision 214 by twoaday, Sun May 14 18:40:36 2006 UTC
# Line 39  Line 39 
39  #include "wptKeylist.h"  #include "wptKeylist.h"
40  #include "wptAgent.h"  #include "wptAgent.h"
41  #include "wptRegistry.h"  #include "wptRegistry.h"
42    #include "wptUTF8.h"
43    
44  const char* get_symkey_algo (int algo);  const char* get_symkey_algo (int algo);
45    
# Line 90  passphrase_callback_proc (HWND dlg, UINT Line 91  passphrase_callback_proc (HWND dlg, UINT
91          if (!c)          if (!c)
92              BUG (0);              BUG (0);
93          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
         SetDlgItemText (dlg, IDC_DECRYPT_HIDE, _("&Hide Typing"));  
94          SetWindowText (dlg, c->title);          SetWindowText (dlg, c->title);
95          if (c->gpg_cmd == GPG_CMD_DECRYPT) {          if (c->gpg_cmd == GPG_CMD_DECRYPT) {
96                SetDlgItemText (dlg, IDC_DECRYPT_HIDE, _("&Hide Typing"));
97              SetDlgItemText (dlg, IDC_DECRYPT_LISTINF,              SetDlgItemText (dlg, IDC_DECRYPT_LISTINF,
98                              _("Encrypted with the following public key(s)"));                              _("Encrypted with the following public key(s)"));
99              CheckDlgButton (dlg, IDC_DECRYPT_HIDE, BST_CHECKED);              CheckDlgButton (dlg, IDC_DECRYPT_HIDE, BST_CHECKED);
# Line 165  passphrase_callback_proc (HWND dlg, UINT Line 166  passphrase_callback_proc (HWND dlg, UINT
166                  free_if_alloc (info);                  free_if_alloc (info);
167              }              }
168              else              else
169                  SetDlgItemText_utf8 (dlg, IDC_DECRYPT_MSG, c->info);                  SetDlgItemText (dlg, IDC_DECRYPT_MSG, c->info);
170          }          }
171          else {          else {
172              SetFocus (GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));              SetFocus (GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));
173              SetDlgItemText_utf8 (dlg, IDC_DECRYPT_SIGN_MSG, c->info);              SetDlgItemText (dlg, IDC_DECRYPT_SIGN_MSG, c->info);
174          }          }
175          center_window (dlg, NULL);          center_window (dlg, NULL);
176          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
# Line 274  parse_gpg_description (const char *uid_h Line 275  parse_gpg_description (const char *uid_h
275      gpgme_pubkey_algo_t algo;      gpgme_pubkey_algo_t algo;
276      char usedkey[16+1];      char usedkey[16+1];
277      char mainkey[16+1];      char mainkey[16+1];
278      char *p;      char *p, *uid;
279      int n=0;      int n=0;
280    
281      algo = (gpgme_pubkey_algo_t)0;      algo = (gpgme_pubkey_algo_t)0;
# Line 295  parse_gpg_description (const char *uid_h Line 296  parse_gpg_description (const char *uid_h
296      uid_hint += 16; /* skip keyid */      uid_hint += 16; /* skip keyid */
297      uid_hint += 1;  /* space */      uid_hint += 1;  /* space */
298    
299        uid = utf8_to_native (uid_hint);
300      if (strcmp (usedkey, mainkey))      if (strcmp (usedkey, mainkey))
301          _snprintf (desc, size-1,          _snprintf (desc, size-1,
302                     _("You need a passphrase to unlock the secret key for\n"                     _("You need a passphrase to unlock the secret key for\n"
303                       "user: \"%s\"\n"                       "user: \"%s\"\n"
304                       "%s key, ID %s (main key ID %s)\n"),                       "%s key, ID %s (main key ID %s)\n"),
305                     uid_hint, get_key_pubalgo (algo), usedkey+8, mainkey+8);                     uid, get_key_pubalgo (algo), usedkey+8, mainkey+8);
306      else if (!strcmp (usedkey, mainkey))      else if (!strcmp (usedkey, mainkey))
307          _snprintf (desc, size-1,          _snprintf (desc, size-1,
308                     _("You need a passphrase to unlock the secret key for\n"                     _("You need a passphrase to unlock the secret key for\n"
309                       "user: \"%s\"\n"                       "user: \"%s\"\n"
310                       "%s key, ID %s\n"),                       "%s key, ID %s\n"),
311                       uid_hint, get_key_pubalgo (algo), usedkey+8);                       uid, get_key_pubalgo (algo), usedkey+8);
312        safe_free (uid);
313      return 0;      return 0;
314  }  }
315    
# Line 414  passphrase_cb (void *hook, const char *u Line 417  passphrase_cb (void *hook, const char *u
417          }          }
418          c->pwd_init = 0;          c->pwd_init = 0;
419      }      }
420      if (c->cancel) {      if (c->cancel || !c->pwd) {
421          if (!WriteFile (hd, "\n", 1, &n, NULL))          if (!WriteFile (hd, "\n", 1, &n, NULL))
422              log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);              log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno);
423          return 0;          return 0;
# Line 444  set_gpg_passphrase_cb (passphrase_cb_s * Line 447  set_gpg_passphrase_cb (passphrase_cb_s *
447      cb->pwd_init = 1;      cb->pwd_init = 1;
448      free_if_alloc (cb->title);      free_if_alloc (cb->title);
449      cb->title = m_strdup (title);      cb->title = m_strdup (title);
     if (!cb->title)  
         BUG (NULL);  
450      gpgme_set_passphrase_cb (ctx, passphrase_cb, cb);      gpgme_set_passphrase_cb (ctx, passphrase_cb, cb);
451      cb->gpg = ctx;      cb->gpg = ctx;
452  }  }
453    
454    
455  /* Release a passphrase callback @ctx. */  /* Release the gpg recipient list. */
456  void  void
457  release_gpg_passphrase_cb (passphrase_cb_s *ctx)  release_gpg_recipients (gpgme_recipient_t *recipients)
458  {  {
459      gpgme_recipient_t r, n;      gpgme_recipient_t r, n;
460    
461      if (!ctx)      r = *recipients;
462          return;      while (r != NULL) {
     sfree_if_alloc (ctx->pwd);  
     free_if_alloc (ctx->title);  
     r = ctx->recipients;  
     while (r) {  
463          n = r->next;          n = r->next;
464          safe_free (r->keyid);          safe_free (r->keyid);
465          safe_free (r);          safe_free (r);
466          r = n;          r = n;
467      }      }
468        *recipients = NULL;
469    }
470    
471    
472    
473    /* Release a passphrase callback @ctx. */
474    void
475    release_gpg_passphrase_cb (passphrase_cb_s *ctx)
476    {
477        if (!ctx)
478            return;
479        sfree_if_alloc (ctx->pwd);
480        free_if_alloc (ctx->title);
481        release_gpg_recipients (&ctx->recipients);
482  }  }
483    
484    

Legend:
Removed from v.204  
changed lines
  Added in v.214

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26