/[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 277 by twoaday, Sun Nov 5 08:57:45 2006 UTC revision 278 by twoaday, Mon Jan 15 22:02:04 2007 UTC
# Line 13  Line 13 
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * General Public License for more details.   * General Public License for more details.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
16   */   */
   
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
18  #include <config.h>  #include <config.h>
19  #endif  #endif
# Line 40  Line 35 
35  #include "wptAgent.h"  #include "wptAgent.h"
36  #include "wptRegistry.h"  #include "wptRegistry.h"
37  #include "wptUTF8.h"  #include "wptUTF8.h"
38    #include "StringBuffer.h"
39    
40    
41  /* Return the control ID dependent on the mode (sign or decrypt). */  /* Return the control ID dependent on the mode (sign or decrypt). */
# Line 75  passphrase_callback_proc (HWND dlg, UINT Line 71  passphrase_callback_proc (HWND dlg, UINT
71      gpgme_recipient_t recip=NULL, r;      gpgme_recipient_t recip=NULL, r;
72      winpt_key_s key;      winpt_key_s key;
73      void *item;      void *item;
     const char *id;  
     char *info;  
74      int n;      int n;
75    
76      switch (msg) {      switch (msg) {
# Line 116  passphrase_callback_proc (HWND dlg, UINT Line 110  passphrase_callback_proc (HWND dlg, UINT
110                  recip = res->recipients;                  recip = res->recipients;
111          }          }
112          if (recip != NULL && c->gpg_cmd == GPG_CMD_DECRYPT) {          if (recip != NULL && c->gpg_cmd == GPG_CMD_DECRYPT) {
113                StringBuffer inf;
114    
115              for (r = recip; r; r = r->next) {              for (r = recip; r; r = r->next) {
116                  memset (&key, 0, sizeof (key));                  memset (&key, 0, sizeof (key));
117                  if (!winpt_get_pubkey (r->keyid, &key)) {                  if (!winpt_get_pubkey (r->keyid, &key)) {
118                      gpgme_user_id_t u = key.ctx->uids;                      gpgme_user_id_t u = key.ctx->uids;
119                        
120                      id = u->name;                      inf = (u->name? u->name : _("Invalid User ID"));
121                      if (!id)                      if (u->email != NULL && strlen (u->email) > 1)
122                          id = _("Invalid User ID");                          inf = inf + " <" + u->email + ">";
123                      n = 32+strlen (id)+1+4+strlen (r->keyid)+1;                      inf = inf + " (" + get_key_pubalgo (r->pubkey_algo);
124                      if (u->email)                      inf = inf + ", 0x" + (r->keyid+8) + ")";
                         n += strlen (u->email)+1;  
                     info = new char [n+1];  
                     if (!info)  
                         BUG (NULL);  
                     if (!u->email || strlen (u->email) < 1)  
                         sprintf (info, "%s (%s, 0x%s)", id,  
                                  get_key_pubalgo (r->pubkey_algo), r->keyid+8);  
                     else  
                         sprintf (info, "%s <%s> (%s, 0x%s)", id, u->email,  
                                  get_key_pubalgo (r->pubkey_algo), r->keyid+8);  
125                  }                  }
126                  else {                  else {
127                      info = new char [32 + strlen (r->keyid)+1 + 4];                      inf = _("Unknown key ID");
128                      if (!info)                      inf = inf + " (" + get_key_pubalgo (r->pubkey_algo);
129                          BUG (NULL);                      inf = inf + ", 0x" + (r->keyid+8) + ")";
                     sprintf (info, _("Unknown key ID (%s, 0x%s)"),  
                              get_key_pubalgo (r->pubkey_algo), r->keyid+8);  
130                  }                  }
131                  ListBox_AddString_utf8 (GetDlgItem (dlg, IDC_DECRYPT_LIST), info);                  ListBox_AddString_utf8 (GetDlgItem (dlg, IDC_DECRYPT_LIST),
132                  free_if_alloc (info);                                          inf.getBuffer ());
133                  winpt_release_pubkey (&key);                  winpt_release_pubkey (&key);
134              }              }
135          }          }
# Line 158  passphrase_callback_proc (HWND dlg, UINT Line 142  passphrase_callback_proc (HWND dlg, UINT
142          if (c->gpg_cmd == GPG_CMD_DECRYPT) {          if (c->gpg_cmd == GPG_CMD_DECRYPT) {
143              SetFocus (GetDlgItem (dlg, IDC_DECRYPT_PWD));              SetFocus (GetDlgItem (dlg, IDC_DECRYPT_PWD));
144              if (res && !res->recipients) {              if (res && !res->recipients) {
145                  const char *s = _("Symmetric encryption.\n"                  StringBuffer sinf;
146                                    "%s encrypted data.");  
147                  const char *alg = get_symkey_algo (c->sym.sym_algo);                  sinf = _("Symmetric encryption.");
148                  info = new char[strlen (s) + strlen (alg) + 2];                  sinf = sinf + "\n" + get_symkey_algo (c->sym.sym_algo);
149                  if (!info)                  sinf = sinf + " " + _("encrypted data.");
150                      BUG (NULL);                  SetDlgItemText (dlg, IDC_DECRYPT_MSG, sinf.getBuffer ());
                 sprintf (info, s, alg);  
                 SetDlgItemText (dlg, IDC_DECRYPT_MSG, info);  
                 free_if_alloc (info);  
151              }              }
152              else              else
153                  SetDlgItemText (dlg, IDC_DECRYPT_MSG, c->info);                  SetDlgItemText (dlg, IDC_DECRYPT_MSG, c->info);
# Line 391  passphrase_cb (void *hook, const char *u Line 372  passphrase_cb (void *hook, const char *u
372              const char *s=passphrase_info;              const char *s=passphrase_info;
373              while (s && *s && *s != 'D')              while (s && *s && *s != 'D')
374                  s++;                  s++;
375              _snprintf (c->info, sizeof c->info-1,              _snprintf (c->info, sizeof (c->info)-1,
376                         _("Please enter the PIN to unlock your secret card key\n"                         _("Please enter the PIN to unlock your secret card key\n"
377                           "Card: %s"), extract_serial_no (s));                           "Card: %s"), extract_serial_no (s));
378              c->is_card = 1;              c->is_card = 1;

Legend:
Removed from v.277  
changed lines
  Added in v.278

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26