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

Diff of /trunk/Src/wptKeysignDlg.cpp

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

revision 224 by twoaday, Tue May 9 10:29:07 2006 UTC revision 225 by twoaday, Tue Jun 6 13:37:59 2006 UTC
# Line 45  Line 45 
45  static const char*  static const char*
46  get_printable_fpr (const char *fpr)  get_printable_fpr (const char *fpr)
47  {  {
48      static char pfpr[64];          static char pfpr[64];
49      int pos = 0;      int pos = 0;
50      size_t i;      size_t i;
51    
# Line 61  get_printable_fpr (const char *fpr) Line 61  get_printable_fpr (const char *fpr)
61    
62    
63  /* Return human friendly information about the key @key. */  /* Return human friendly information about the key @key. */
64  static const char*  const char*
65  get_keyinfo (gpgme_key_t key)  get_keyinfo (gpgme_key_t key)
66  {  {
67      static char buf[64+16];      static char buf[64+16];
68      struct winpt_key_s k;      struct winpt_key_s k;
69    
70      memset (&k, 0, sizeof (k));      memset (&k, 0, sizeof (k));
71      winpt_get_seckey (key->subkeys->keyid, &k);      if (winpt_get_seckey (key->subkeys->keyid, &k))
72      _snprintf (buf, DIM (buf)-1-16, _("%d-bit %s key, ID 0x%s"),          BUG (0);
73          key->subkeys->length,      _snprintf (buf, DIM (buf)-1-16, _("%d-bit %s key, ID 0x%s"),
74          get_key_pubalgo (key->subkeys->pubkey_algo),                 key->subkeys->length,
75          key->subkeys->keyid+8);                 get_key_pubalgo (key->subkeys->pubkey_algo),
76                   key->subkeys->keyid+8);
77      if (k.ext->gloflags.divert_to_card)      if (k.ext->gloflags.divert_to_card)
78          strcat (buf, " (Card)");          strcat (buf, " (Card)");
79      return buf;      return buf;
# Line 87  do_fill_seckeylist (HWND dlg, const char Line 88  do_fill_seckeylist (HWND dlg, const char
88  {  {
89      gpg_keycache_t sec;      gpg_keycache_t sec;
90      gpgme_key_t pk, defkey;      gpgme_key_t pk, defkey;
91      const char *s;      const char *s, *inf;
92      char *uid, *p;      char *uid, *p;
93      int i = 0, n = 0, curr_sel = 0;      int i = 0, n = 0, curr_sel = 0;
94        int len = 0;
95    
96      sec = keycache_get_ctx (0);      sec = keycache_get_ctx (0);
     if (!sec)  
         BUG (0);  
97      gpg_keycache_get_default_key (sec, &defkey);      gpg_keycache_get_default_key (sec, &defkey);
98      gpg_keycache_rewind (sec);      gpg_keycache_rewind (sec);
99      while (!gpg_keycache_next_key (sec, 1, &pk)) {      while (!gpg_keycache_next_key (sec, 1, &pk)) {
# Line 114  do_fill_seckeylist (HWND dlg, const char Line 114  do_fill_seckeylist (HWND dlg, const char
114          if (defkey && !strcmp (defkey->subkeys->keyid, pk->subkeys->keyid))          if (defkey && !strcmp (defkey->subkeys->keyid, pk->subkeys->keyid))
115              curr_sel = i;              curr_sel = i;
116          uid = utf8_to_native (s);          uid = utf8_to_native (s);
117          p = new char[strlen (uid) + 64];          inf = get_keyinfo (pk);
118            len = strlen (uid) + strlen (inf) + 8;
119            p = new char[len+1];
120          if (!p)          if (!p)
121              BUG (NULL);              BUG (NULL);
122          _snprintf (p, strlen (uid) + 63, "%s (%s)", uid, get_keyinfo (pk));          _snprintf (p, len, "%s (%s)", uid, inf);
123          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
124                              CB_ADDSTRING, i, (LPARAM)(char *)p);                              CB_ADDSTRING, i, (LPARAM)(char *)p);
125          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
126                              CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);                              CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);
127          free_if_alloc (p);          free_if_alloc (p);
128          free (uid);          safe_free (uid);
129          n++;          n++;
130      }      }
131      SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,      SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
# Line 147  do_check_protection (HWND dlg) Line 149  do_check_protection (HWND dlg)
149      key = (gpgme_key_t)SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,      key = (gpgme_key_t)SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
150                                             CB_GETITEMDATA, (WPARAM)idx, 0);                                             CB_GETITEMDATA, (WPARAM)idx, 0);
151      if (key) {      if (key) {
152          winpt_get_seckey (key->subkeys->keyid, &k);          if (winpt_get_seckey (key->subkeys->keyid, &k))
153                BUG (0);
154          protec = k.is_protected;          protec = k.is_protected;
155          if (!protec)          if (!protec)
156              protec = k.ext->gloflags.divert_to_card;              protec = k.ext->gloflags.divert_to_card;
# Line 165  sig_class_dlg_proc (HWND dlg, UINT msg, Line 168  sig_class_dlg_proc (HWND dlg, UINT msg,
168      switch (msg) {      switch (msg) {
169      case WM_INITDIALOG:      case WM_INITDIALOG:
170          SetWindowText (dlg, _("Choose Signature Class"));          SetWindowText (dlg, _("Choose Signature Class"));
171          SetDlgItemText (dlg, IDC_SIGCLASS_TITLEINF, _("How carefully have you verified the key you are about to sign actually belongs to the person? If you don't know what to anwser, use \"0\"."));          SetDlgItemText (dlg, IDC_SIGCLASS_TITLEINF,
172          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0, _("(0) I will not answer (default)"));                          _("How carefully have you verified the key you are about to sign actually belongs to the person? If you don't know what to anwser, use \"0\"."));
173          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1, _("(1) I have not checked at all."));          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0,
174          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2, _("(2) I have done causal checking."));                          _("(0) I will not answer (default)"));
175          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3, _("(3) I have done very careful checkings."));          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1,
176                            _("(1) I have not checked at all."));
177            SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2,
178                            _("(2) I have done causal checking."));
179            SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3,
180                            _("(3) I have done very careful checkings."));
181          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);
182          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
183          center_window (dlg, NULL);          center_window (dlg, NULL);
# Line 212  get_expire_date (gpgme_key_t key) Line 220  get_expire_date (gpgme_key_t key)
220      return get_key_expire_date (u);      return get_key_expire_date (u);
221  }  }
222    
223    
224  /* Display photo of key @key in a separate window. */  /* Display photo of key @key in a separate window. */
225  static void  static void
226  show_photo (winpt_key_t key)  show_photo (winpt_key_t key)
# Line 254  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 263  keysign_dlg_proc (HWND dlg, UINT msg, WP
263            
264      switch (msg)  {      switch (msg)  {
265      case WM_INITDIALOG:      case WM_INITDIALOG:
         if (lparam == 0)  
             dlg_fatal_error (dlg, "could not get dialog param.");  
         SetWindowText (dlg, _("Key Signing"));  
266          key = (winpt_key_t) lparam;          key = (winpt_key_t) lparam;
267            if (!key)
268                BUG (0);
269          _snprintf (keymsg, sizeof keymsg -1,          _snprintf (keymsg, sizeof keymsg -1,
270                     _("pub %d/%s  created: %s    expires: %s\n\n"                     _("pub %d/%s  created: %s    expires: %s\n\n"
271                       "Primary key fingerprint: %s\n\n"                       "Primary key fingerprint: %s\n\n"
# Line 273  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 281  keysign_dlg_proc (HWND dlg, UINT msg, WP
281          if (do_fill_seckeylist (dlg, s)) {          if (do_fill_seckeylist (dlg, s)) {
282              msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);              msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);
283              EndDialog (dlg, FALSE);              EndDialog (dlg, FALSE);
284              break;              return TRUE;
285          }          }
286          do_check_protection (dlg);          do_check_protection (dlg);
287          SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);          SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);
# Line 285  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 293  keysign_dlg_proc (HWND dlg, UINT msg, WP
293          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
294          SetDlgItemText (dlg, IDC_KEYSIGN_SHOWIMG, _("&Show photo"));          SetDlgItemText (dlg, IDC_KEYSIGN_SHOWIMG, _("&Show photo"));
295          SetDlgItemText (dlg, IDC_KEYSIGN_HIDE, _("&Hide Typing"));          SetDlgItemText (dlg, IDC_KEYSIGN_HIDE, _("&Hide Typing"));
296            SetWindowText (dlg, _("Key Signing"));
297          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);
298          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);
299          CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);
# Line 302  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 311  keysign_dlg_proc (HWND dlg, UINT msg, WP
311          h = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);          h = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);
312          SetFocus (h);          SetFocus (h);
313          return FALSE;          return FALSE;
   
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE) {  
             SetDlgItemText (dlg, IDC_KEYSIGN_PASSPHRASE, "");  
             EndDialog (dlg, TRUE);  
         }  
         return FALSE;  
314                    
315      case WM_COMMAND:      case WM_COMMAND:
316          if (HIWORD (wparam) == CBN_SELCHANGE) {          if (HIWORD (wparam) == CBN_SELCHANGE) {
# Line 318  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 320  keysign_dlg_proc (HWND dlg, UINT msg, WP
320          if (HIWORD (wparam) == BN_CLICKED &&          if (HIWORD (wparam) == BN_CLICKED &&
321              LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {              LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {
322              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);
323    
324              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);
325          }          }
326          if (HIWORD (wparam) == BN_CLICKED &&          if (HIWORD (wparam) == BN_CLICKED &&
327              LOWORD (wparam) == IDC_KEYSIGN_HIDE) {              LOWORD (wparam) == IDC_KEYSIGN_HIDE) {
328              HWND hwnd = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);              HWND hwnd = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);
329              int hide = IsDlgButtonChecked (dlg, IDC_KEYSIGN_HIDE);              int hide = IsDlgButtonChecked (dlg, IDC_KEYSIGN_HIDE);
330    
331              SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);              SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
332              SetFocus (hwnd);              SetFocus (hwnd);
333          }          }
# Line 331  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 335  keysign_dlg_proc (HWND dlg, UINT msg, WP
335          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
336          case IDOK:          case IDOK:
337              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))
338                  sig_class = dialog_box_param (glob_hinst,                  sig_class = dialog_box_param (glob_hinst,
339                                                (LPCSTR)IDD_WINPT_SIGCLASS, dlg,                                                (LPCSTR)IDD_WINPT_SIGCLASS, dlg,
340                                                sig_class_dlg_proc, (LPARAM)NULL,                                                sig_class_dlg_proc, (LPARAM)NULL,
341                                                _("Choose Signature Class"),                                                _("Choose Signature Class"),
# Line 363  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 367  keysign_dlg_proc (HWND dlg, UINT msg, WP
367                      if an advanced button is checked and offer to add it to the config                      if an advanced button is checked and offer to add it to the config
368                      file. */                      file. */
369    
370              GetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, pwd, DIM (pwd)-1);              GetDlgItemText (dlg, IDC_KEYSIGN_PASSPHRASE, pwd, DIM (pwd)-1);
371              keyid = key->ctx->subkeys->keyid;              keyid = key->ctx->subkeys->keyid;
372              if( !keyid ) {              if (!keyid) {
373                  msg_box( dlg, _("Could not get Key ID from key."), _("Key Signing"), MB_ERR );                  wipememory (pwd, sizeof (pwd));
374                    msg_box (dlg, _("Could not get Key ID from key."), _("Key Signing"), MB_ERR);
375                  return TRUE;                  return TRUE;
376              }              }
377              ke = new GpgKeyEdit (keyid);              ke = new GpgKeyEdit (keyid);
# Line 386  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 391  keysign_dlg_proc (HWND dlg, UINT msg, WP
391                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);
392                  return TRUE;                  return TRUE;
393              }              }
394              if (ke->getResult () != 0)              if (ke->getResult () != 0) {
395                  msg_box (dlg, _("This key is already signed by your key"),                  msg_box (dlg, _("This key is already signed by your key"),
396                           _("Key Signing"), MB_INFO);                           _("Key Signing"), MB_INFO);
397                    delete ke;
398                    return TRUE;
399                }
400              else {              else {
401                  status_box (dlg, _("Key successfully signed."), _("Key Signing"));                  status_box (dlg, _("Key successfully signed."), _("Key Signing"));
402                  key->update = 1;                  key->update = 1;
# Line 410  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 418  keysign_dlg_proc (HWND dlg, UINT msg, WP
418            
419      return FALSE;      return FALSE;
420  }  }
   

Legend:
Removed from v.224  
changed lines
  Added in v.225

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26