/[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 160 by twoaday, Thu Jan 19 09:22:09 2006 UTC revision 187 by twoaday, Wed Mar 22 11:04:20 2006 UTC
# Line 43  Line 43 
43    
44  const char* get_symkey_algo (int algo);  const char* get_symkey_algo (int algo);
45    
46  #define item_ctrl_id( cmd ) \  #define item_ctrl_id(cmd) \
47      ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_PWD : IDC_DECRYPT_SIGN_PWD)      ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_PWD : IDC_DECRYPT_SIGN_PWD)
48    
49  #define item_ctrl_id2(cmd) \  #define item_ctrl_id2(cmd) \
# Line 76  passphrase_callback_proc (HWND dlg, UINT Line 76  passphrase_callback_proc (HWND dlg, UINT
76      int n;      int n;
77    
78      switch (msg) {      switch (msg) {
79        case WM_ACTIVATE:
80            safe_edit_control_init (dlg, item_ctrl_id (c->gpg_cmd));
81            break;
82    
83        case WM_DESTROY:
84            safe_edit_control_free (dlg, item_ctrl_id (c->gpg_cmd));
85            break;
86    
87      case WM_INITDIALOG:      case WM_INITDIALOG:
88          c = (passphrase_cb_s *)lparam;          c = (passphrase_cb_s *)lparam;
89          if (!c)          if (!c)
# Line 92  passphrase_callback_proc (HWND dlg, UINT Line 100  passphrase_callback_proc (HWND dlg, UINT
100              SetDlgItemText (dlg, IDC_DECRYPT_SIGN_HIDE, _("&Hide Typing"));              SetDlgItemText (dlg, IDC_DECRYPT_SIGN_HIDE, _("&Hide Typing"));
101              CheckDlgButton (dlg, IDC_DECRYPT_SIGN_HIDE, BST_CHECKED);              CheckDlgButton (dlg, IDC_DECRYPT_SIGN_HIDE, BST_CHECKED);
102          }          }
103            /* Because it depends on the order the keys are stored in the
104               keyring whether res->recipients is complete or not, we also
105               support that the recipients were externally extracted and then
106               we use this list. */
107          if (c->recipients)          if (c->recipients)
108              recip = c->recipients; /* recipients were already extracted. */              recip = c->recipients; /* recipients were already extracted. */
109          else {          else {
             /* XXX: not all ENCRYPT_TO entries are listed here. */  
110              res = gpgme_op_decrypt_result (c->gpg);              res = gpgme_op_decrypt_result (c->gpg);
111              if (res && res->recipients)              if (res && res->recipients)
112                  recip = res->recipients;                  recip = res->recipients;
113          }          }
114          if (recip != NULL && c->gpg_cmd == GPG_CMD_DECRYPT) {          if (recip != NULL && c->gpg_cmd == GPG_CMD_DECRYPT) {
115              for (r = res->recipients; r; r = r->next) {              for (r = recip; r; r = r->next) {
116                  get_pubkey (r->keyid, &key);                  get_pubkey (r->keyid, &key);
117                  if (key) {                  if (key) {
118                      gpgme_user_id_t u = key->uids;                      gpgme_user_id_t u = key->uids;
# Line 110  passphrase_callback_proc (HWND dlg, UINT Line 121  passphrase_callback_proc (HWND dlg, UINT
121                      id = u->name;                      id = u->name;
122                      if (!id)                      if (!id)
123                          id = _("Invalid User ID");                          id = _("Invalid User ID");
124                      uid = utf8_to_wincp (id, strlen (id));                      uid = utf8_to_native (id);
125                      n = 32+strlen (uid)+1+4+strlen (r->keyid)+1;                      n = 32+strlen (uid)+1+4+strlen (r->keyid)+1;
126                      if (u->email)                      if (u->email)
127                          n += strlen (u->email)+1;                          n += strlen (u->email)+1;
# Line 205  passphrase_callback_proc (HWND dlg, UINT Line 216  passphrase_callback_proc (HWND dlg, UINT
216                      c->pwd = new char[n+2];                      c->pwd = new char[n+2];
217                      if (!c->pwd)                      if (!c->pwd)
218                          BUG (NULL);                          BUG (NULL);
219                      GetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), c->pwd, n+1);                      SafeGetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd),
220                                            c->pwd, n+1);
221                  }                  }
222                  res = gpgme_op_decrypt_result (c->gpg);                  res = gpgme_op_decrypt_result (c->gpg);
223                  if (!res)                  if (!res)
# Line 285  parse_gpg_description (const char *uid_h Line 297  parse_gpg_description (const char *uid_h
297      uid_hint += 16; /* skip keyid */      uid_hint += 16; /* skip keyid */
298      uid_hint += 1;  /* space */      uid_hint += 1;  /* space */
299    
300      uid = utf8_to_wincp (uid_hint, strlen (uid_hint));      uid = utf8_to_native (uid_hint);
301    
302      if (strcmp (usedkey, mainkey))      if (strcmp (usedkey, mainkey))
303          _snprintf (desc, size-1,          _snprintf (desc, size-1,
# Line 389  passphrase_cb (void *hook, const char *u Line 401  passphrase_cb (void *hook, const char *u
401          }          }
402          else if (uid_hint)          else if (uid_hint)
403              parse_gpg_description (uid_hint, passphrase_info,              parse_gpg_description (uid_hint, passphrase_info,
404                                     c->info, sizeof c->info - 1);                                     c->info, sizeof (c->info) - 1);
405          if (c->gpg_cmd == GPG_CMD_DECRYPT) {          if (c->gpg_cmd == GPG_CMD_DECRYPT) {
406              rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_DECRYPT,              rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_DECRYPT,
407                                   (HWND)c->hwnd, passphrase_callback_proc,                                   (HWND)c->hwnd, passphrase_callback_proc,

Legend:
Removed from v.160  
changed lines
  Added in v.187

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26