/[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 187 by twoaday, Wed Mar 22 11:04:20 2006 UTC revision 204 by twoaday, Wed Apr 26 06:37:23 2006 UTC
# Line 1  Line 1 
1  /* wptPassphraseCB.cpp - GPGME Passphrase Callback  /* wptPassphraseCB.cpp - GPGME Passphrase Callback
2   *      Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz   *      Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz
3   *      Copyright (C) 2005 g10 Code GmbH   *      Copyright (C) 2005 g10 Code GmbH
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
# Line 34  Line 34 
34  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
35  #include "wptContext.h"  #include "wptContext.h"
36  #include "wptDlgs.h"  #include "wptDlgs.h"
 #include "wptUTF8.h"  
37  #include "wptErrors.h"  #include "wptErrors.h"
38  #include "wptTypes.h"  #include "wptTypes.h"
39  #include "wptKeylist.h"  #include "wptKeylist.h"
# Line 50  const char* get_symkey_algo (int algo); Line 49  const char* get_symkey_algo (int algo);
49      ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_HIDE : IDC_DECRYPT_SIGN_HIDE)      ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_HIDE : IDC_DECRYPT_SIGN_HIDE)
50    
51    
52    void ListBox_AddString_utf8 (HWND lb, const char *txt);
53    
54  /* Overwrite passphrase and free memory. */  /* Overwrite passphrase and free memory. */
55  static void  static void
56  burn_passphrase (char **pwd)  burn_passphrase (char **pwd)
# Line 116  passphrase_callback_proc (HWND dlg, UINT Line 117  passphrase_callback_proc (HWND dlg, UINT
117                  get_pubkey (r->keyid, &key);                  get_pubkey (r->keyid, &key);
118                  if (key) {                  if (key) {
119                      gpgme_user_id_t u = key->uids;                      gpgme_user_id_t u = key->uids;
                     char *uid;  
120    
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_native (id);                      n = 32+strlen (id)+1+4+strlen (r->keyid)+1;
                     n = 32+strlen (uid)+1+4+strlen (r->keyid)+1;  
125                      if (u->email)                      if (u->email)
126                          n += strlen (u->email)+1;                          n += strlen (u->email)+1;
127                      info = new char [n+1];                      info = new char [n+1];
128                      if (!info)                      if (!info)
129                          BUG (NULL);                          BUG (NULL);
130                      if (!u->email || strlen (u->email) < 1)                      if (!u->email || strlen (u->email) < 1)
131                          sprintf (info, "%s (%s, 0x%s)", uid,                          sprintf (info, "%s (%s, 0x%s)", id,
132                                   get_key_pubalgo (r->pubkey_algo), r->keyid+8);                                   get_key_pubalgo (r->pubkey_algo), r->keyid+8);
133                      else                      else
134                          sprintf (info, "%s <%s> (%s, 0x%s)", uid, u->email,                          sprintf (info, "%s <%s> (%s, 0x%s)", id, u->email,
135                                   get_key_pubalgo (r->pubkey_algo), r->keyid+8);                                   get_key_pubalgo (r->pubkey_algo), r->keyid+8);
                     free (uid);  
136                  }                  }
137                  else {                  else {
138                      info = new char [32 + strlen (r->keyid)+1 + 4];                      info = new char [32 + strlen (r->keyid)+1 + 4];
# Line 143  passphrase_callback_proc (HWND dlg, UINT Line 141  passphrase_callback_proc (HWND dlg, UINT
141                      sprintf (info, _("Unknown key ID (%s, 0x%s)"),                      sprintf (info, _("Unknown key ID (%s, 0x%s)"),
142                               get_key_pubalgo (r->pubkey_algo), r->keyid+8);                               get_key_pubalgo (r->pubkey_algo), r->keyid+8);
143                  }                  }
144                  listbox_add_string (GetDlgItem (dlg, IDC_DECRYPT_LIST), info);                  ListBox_AddString_utf8 (GetDlgItem (dlg, IDC_DECRYPT_LIST), info);
145                  free_if_alloc (info);                  free_if_alloc (info);
146              }              }
147          }          }
# Line 167  passphrase_callback_proc (HWND dlg, UINT Line 165  passphrase_callback_proc (HWND dlg, UINT
165                  free_if_alloc (info);                  free_if_alloc (info);
166              }              }
167              else              else
168                  SetDlgItemText (dlg, IDC_DECRYPT_MSG, c->info);                  SetDlgItemText_utf8 (dlg, IDC_DECRYPT_MSG, c->info);
169          }          }
170          else {          else {
171              SetFocus( GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));              SetFocus (GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));
172              SetDlgItemText (dlg, IDC_DECRYPT_SIGN_MSG, c->info);              SetDlgItemText_utf8 (dlg, IDC_DECRYPT_SIGN_MSG, c->info);
173          }          }
174          center_window (dlg, NULL);          center_window (dlg, NULL);
175          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
# Line 276  parse_gpg_description (const char *uid_h Line 274  parse_gpg_description (const char *uid_h
274      gpgme_pubkey_algo_t algo;      gpgme_pubkey_algo_t algo;
275      char usedkey[16+1];      char usedkey[16+1];
276      char mainkey[16+1];      char mainkey[16+1];
277      char *uid, *p;      char *p;
278      int n=0;      int n=0;
279    
280      algo = (gpgme_pubkey_algo_t)0;      algo = (gpgme_pubkey_algo_t)0;
# Line 297  parse_gpg_description (const char *uid_h Line 295  parse_gpg_description (const char *uid_h
295      uid_hint += 16; /* skip keyid */      uid_hint += 16; /* skip keyid */
296      uid_hint += 1;  /* space */      uid_hint += 1;  /* space */
297    
     uid = utf8_to_native (uid_hint);  
   
298      if (strcmp (usedkey, mainkey))      if (strcmp (usedkey, mainkey))
299          _snprintf (desc, size-1,          _snprintf (desc, size-1,
300                     _("You need a passphrase to unlock the secret key for\n"                     _("You need a passphrase to unlock the secret key for\n"
301                       "user: \"%s\"\n"                       "user: \"%s\"\n"
302                       "%s key, ID %s (main key ID %s)\n"),                       "%s key, ID %s (main key ID %s)\n"),
303                     uid, get_key_pubalgo (algo), usedkey+8, mainkey+8);                     uid_hint, get_key_pubalgo (algo), usedkey+8, mainkey+8);
304      else if (!strcmp (usedkey, mainkey))      else if (!strcmp (usedkey, mainkey))
305          _snprintf (desc, size-1,          _snprintf (desc, size-1,
306                     _("You need a passphrase to unlock the secret key for\n"                     _("You need a passphrase to unlock the secret key for\n"
307                       "user: \"%s\"\n"                       "user: \"%s\"\n"
308                       "%s key, ID %s\n"),                       "%s key, ID %s\n"),
309                       uid, get_key_pubalgo (algo), usedkey+8);                       uid_hint, get_key_pubalgo (algo), usedkey+8);
     free (uid);  
310      return 0;      return 0;
311  }  }
312    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26