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

Diff of /trunk/Src/wptKeyEditDlgs.cpp

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

revision 211 by twoaday, Sun May 7 12:36:48 2006 UTC revision 231 by twoaday, Tue Jun 20 09:18:44 2006 UTC
# Line 120  enum uid_col_t { Line 120  enum uid_col_t {
120    
121  /* Key edit callback context. */  /* Key edit callback context. */
122  struct keyedit_cb_s {  struct keyedit_cb_s {
123      const char     *keyid;      HWND            parent; /* parent window handle. */
124      const char     *pass;      const char     *keyid;  /* key ID of the key. */
125        const char     *pass;   /* pointer to the passphrase. */
126      listview_ctrl_t lv;      listview_ctrl_t lv;
127      int             lv_pos;      int             lv_pos;
128      void           *opaque;      void           *opaque;
# Line 150  static subclass_s keyedit_subkey_proc; Line 151  static subclass_s keyedit_subkey_proc;
151  static subclass_s keyedit_uid_proc;  static subclass_s keyedit_uid_proc;
152    
153  int keygen_check_date (SYSTEMTIME *st);  int keygen_check_date (SYSTEMTIME *st);
154  void get_userid_preflist (char **r_prefs, int * r_flags);  void get_userid_preflist (char **r_prefs, int *r_flags);
155  char* get_subkey_keyid (const char *keyid);  char* get_subkey_keyid (const char *keyid);
   
156  void ComboBox_AddString_utf8 (HWND cb, const char *txt);  void ComboBox_AddString_utf8 (HWND cb, const char *txt);
157    
158    
159    /* Safe wrapper for allocation. */
160  static GpgKeyEdit*  static GpgKeyEdit*
161  create_GpgKeyEdit (const char *keyid)  create_GpgKeyEdit (const char *keyid)
162  {  {
# Line 178  do_init_keylist (HWND dlg, const char *k Line 180  do_init_keylist (HWND dlg, const char *k
180      int i, n;      int i, n;
181    
182      pub = keycache_get_ctx (1);      pub = keycache_get_ctx (1);
     if (!pub)  
         BUG (0);  
   
183      gpg_keycache_rewind (pub);      gpg_keycache_rewind (pub);
184      while( !gpg_keycache_next_key (pub, 0, &key)) {      while (!gpg_keycache_next_key (pub, 0, &key)) {
185          if (key->expired || key->revoked ||          if (key->expired || key->revoked ||
186              key->disabled || key->invalid)              key->disabled || key->invalid)
187              continue;              continue;
# Line 209  do_add_new_userid (listview_ctrl_t lv, Line 208  do_add_new_userid (listview_ctrl_t lv,
208                     const char *utf8_name, const char *email,                     const char *utf8_name, const char *email,
209                     const char *utf8_comment)                     const char *utf8_comment)
210  {  {
211      char *p;      char *p, *native;
212      size_t n;      size_t n;
213            
214      n = strlen (utf8_name) + strlen (email) + 16;      n = strlen (utf8_name) + strlen (email) + 16;
# Line 218  do_add_new_userid (listview_ctrl_t lv, Line 217  do_add_new_userid (listview_ctrl_t lv,
217      p = new char[n+1];      p = new char[n+1];
218      if (!p)      if (!p)
219          BUG (NULL);          BUG (NULL);
220      if (utf8_comment) {      if (utf8_comment)
221          sprintf (p, "%s (%s)", utf8_name, utf8_comment);          sprintf (p, "%s (%s)", utf8_name, utf8_comment);
     }  
222      else      else
223          sprintf (p, "%s", utf8_name);          sprintf (p, "%s", utf8_name);
224        native = utf8_to_native (p);
225        free_if_alloc (p);
226    
227      listview_add_item (lv, "");      listview_add_item (lv, "");
228      listview_add_sub_item (lv, 0, 0, _("Ultimate" ));      listview_add_sub_item (lv, 0, UID_COL_VALID, _("Ultimate" ));
229      listview_add_sub_item (lv, 0, 1, p);      listview_add_sub_item (lv, 0, UID_COL_NAME, native);
230      listview_add_sub_item (lv, 0, 2, email && *email? email : "");      listview_add_sub_item (lv, 0, UID_COL_EMAIL, email && *email? email : "");
231      listview_add_sub_item (lv, 0, 3, get_key_created (time (NULL)));      listview_add_sub_item (lv, 0, UID_COL_CREATION, get_key_created (time (NULL)));
232      free_if_alloc (p);      free_if_alloc (native);
233  }  }
234    
235    
# Line 241  do_add_new_subkey (listview_ctrl_t lv, k Line 241  do_add_new_subkey (listview_ctrl_t lv, k
241      int n;      int n;
242            
243      expdate = keygen->expire? get_key_expire_date (keygen->expire) : _("Never");      expdate = keygen->expire? get_key_expire_date (keygen->expire) : _("Never");
244      _snprintf (info, sizeof info-1, "%d-bit %s",      _snprintf (info, sizeof (info)-1, "%d-bit %s",
245                 keygen->bits,                 keygen->bits,
246                 get_key_pubalgo ((gpgme_pubkey_algo_t)keygen->algo));                 get_key_pubalgo ((gpgme_pubkey_algo_t)keygen->algo));
247      _snprintf (keyid, sizeof keyid-1, "0x%s", keygen->fpr+8);      _snprintf (keyid, sizeof (keyid)-1, "0x%s", keygen->fpr+8);
248      s = get_key_created (time (NULL));      s = get_key_created (time (NULL));
249      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
250      listview_add_item_pos (lv, n);      listview_add_item_pos (lv, n);
# Line 280  do_find_userid (const char *keyid, const Line 280  do_find_userid (const char *keyid, const
280      delete ke;      delete ke;
281      if (err) {      if (err) {
282          log_box (_("user ID"), MB_ERR,          log_box (_("user ID"), MB_ERR,
283                  _("Could not get key information for: \"%s\":\n%s"),                   _("Could not get key information for: \"%s\":\n%s"),
284                  name, gpgme_strerror (err));                   name, gpgme_strerror (err));
285          return -1;          return -1;
286      }      }
287    
# Line 360  keyedit_addphoto_dlg_proc (HWND dlg, UIN Line 360  keyedit_addphoto_dlg_proc (HWND dlg, UIN
360          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
361          break;          break;
362    
     case WM_DESTROY:  
         break;  
   
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, TRUE);  
         break;  
   
363      case WM_COMMAND:      case WM_COMMAND:
364          switch( LOWORD (wparam)) {          switch( LOWORD (wparam)) {
365          case IDC_ADDPHOTO_SELFILE:          case IDC_ADDPHOTO_SELFILE:
# Line 385  keyedit_addphoto_dlg_proc (HWND dlg, UIN Line 377  keyedit_addphoto_dlg_proc (HWND dlg, UIN
377    
378          case IDOK:          case IDOK:
379              if (!GetDlgItemText (dlg, IDC_ADDPHOTO_FILE, file, sizeof (file)-1)){              if (!GetDlgItemText (dlg, IDC_ADDPHOTO_FILE, file, sizeof (file)-1)){
380                  msg_box( dlg, _("Please enter a file name."), _("Add Photo"), MB_ERR);                  msg_box (dlg, _("Please enter a file name."),
381                             _("Add Photo"), MB_ERR);
382                  return FALSE;                  return FALSE;
383              }              }
384              if (get_file_size (file) == 0 || get_file_size (file) > 6144 ) {              if (get_file_size (file) == 0 || get_file_size (file) > 6144) {
385                  id = msg_box (dlg, _("The JPEG is really large.\n"                  id = msg_box (dlg, _("The JPEG is really large.\n"
386                                       "Are you sure you want to use it?"),                                       "Are you sure you want to use it?"),
387                                       _("Add Photo"), MB_YESNO|MB_INFO);                                       _("Add Photo"), MB_YESNO|MB_INFO);
# Line 446  keyedit_addrevoker_dlg_proc (HWND dlg, U Line 439  keyedit_addrevoker_dlg_proc (HWND dlg, U
439          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
440          SetWindowText (dlg, _("Add Revoker"));          SetWindowText (dlg, _("Add Revoker"));
441          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
442          break;          center_window (dlg, cb->parent);
   
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, FALSE);  
443          break;          break;
444    
445      case WM_COMMAND:      case WM_COMMAND:
# Line 515  keyedit_adduid_dlg_proc (HWND dlg, UINT Line 504  keyedit_adduid_dlg_proc (HWND dlg, UINT
504          SetDlgItemText (dlg, IDC_ADDUID_INFCOMMENT, _("&Comment"));          SetDlgItemText (dlg, IDC_ADDUID_INFCOMMENT, _("&Comment"));
505          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
506          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
507          return FALSE;          center_window (dlg, ctx->parent);
           
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog(dlg, TRUE);  
508          return FALSE;          return FALSE;
509                    
510      case WM_COMMAND:      case WM_COMMAND:
# Line 536  keyedit_adduid_dlg_proc (HWND dlg, UINT Line 521  keyedit_adduid_dlg_proc (HWND dlg, UINT
521              if (strchr (utf8_name, '@')) {              if (strchr (utf8_name, '@')) {
522                  msg_box (dlg, _("Please enter the email address in the email field and not in the name field"),                  msg_box (dlg, _("Please enter the email address in the email field and not in the name field"),
523                           _("UserID"), MB_INFO);                           _("UserID"), MB_INFO);
524                    free_if_alloc (utf8_name);
525                  return FALSE;                  return FALSE;
526              }              }
527    
528              if( !GetDlgItemText (dlg, IDC_ADDUID_EMAIL, email, sizeof (email) -1)) {              if( !GetDlgItemText (dlg, IDC_ADDUID_EMAIL, email, sizeof (email) -1)) {
529                  msg_box( dlg, _("Please enter an email address."), _("UserID"), MB_ERR );                  msg_box (dlg, _("Please enter an email address."), _("UserID"), MB_ERR);
530                    free_if_alloc (utf8_name);
531                  return FALSE;                  return FALSE;
532              }              }
533              if (check_email_address (email)) {              if (check_email_address (email)) {
534                  msg_box (dlg, _("Invalid email address."), _("UserID"), MB_ERR);                  msg_box (dlg, _("Invalid email address."), _("UserID"), MB_ERR);
535                    free_if_alloc (utf8_name);
536                  return FALSE;                  return FALSE;
537              }              }
538                            
# Line 561  keyedit_adduid_dlg_proc (HWND dlg, UINT Line 549  keyedit_adduid_dlg_proc (HWND dlg, UINT
549              else {              else {
550                  msg_box (dlg, _("user ID successfully added."), _("GnuPG Status"), MB_OK);                  msg_box (dlg, _("user ID successfully added."), _("GnuPG Status"), MB_OK);
551                  ctx->finished = 1;                  ctx->finished = 1;
552                    /* The caller releases this items later. */
553                  keygen->name = utf8_name;                  keygen->name = utf8_name;
554                  keygen->comment = utf8_comment;                  keygen->comment = utf8_comment;
555                  keygen->email = m_strdup (email);                  keygen->email = m_strdup (email);
# Line 580  keyedit_adduid_dlg_proc (HWND dlg, UINT Line 569  keyedit_adduid_dlg_proc (HWND dlg, UINT
569  }  }
570    
571    
572    /* Initalize a combo box with default key sizes (1024-4096). */
573  static void  static void
574  init_keysize_box (HWND dlg, int ctlid)  init_keysize_box (HWND dlg, int ctlid)
575  {  {
# Line 640  keyedit_addsubkey_dlg_proc (HWND dlg, UI Line 630  keyedit_addsubkey_dlg_proc (HWND dlg, UI
630      switch (msg) {      switch (msg) {
631      case WM_INITDIALOG:      case WM_INITDIALOG:
632          ctx = (keyedit_cb_t)lparam;          ctx = (keyedit_cb_t)lparam;
633          if (!ctx)          if (!ctx)
634              dlg_fatal_error (dlg, "Could not get dialog param!");              BUG (0);
   
635          SetWindowText (dlg, _("Add new Subkey"));          SetWindowText (dlg, _("Add new Subkey"));
636          SetDlgItemText (dlg, IDC_ADDSUBKEY_INFALGO, _("Key type"));          SetDlgItemText (dlg, IDC_ADDSUBKEY_INFALGO, _("Key type"));
637          SetDlgItemText (dlg, IDC_ADDSUBKEY_INFSIZE, _("Size in bits"));          SetDlgItemText (dlg, IDC_ADDSUBKEY_INFSIZE, _("Size in bits"));
# Line 659  keyedit_addsubkey_dlg_proc (HWND dlg, UI Line 648  keyedit_addsubkey_dlg_proc (HWND dlg, UI
648          EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE), FALSE);          EnableWindow (GetDlgItem (dlg, IDC_ADDSUBKEY_EXPDATE), FALSE);
649          init_keysize_box (dlg, IDC_ADDSUBKEY_SIZE);          init_keysize_box (dlg, IDC_ADDSUBKEY_SIZE);
650          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
651          return FALSE;          center_window (dlg, ctx->parent);
           
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, TRUE);  
652          return FALSE;          return FALSE;
653                    
654      case WM_COMMAND:      case WM_COMMAND:
# Line 766  keyedit_add_userid (winpt_key_t k, HWND Line 751  keyedit_add_userid (winpt_key_t k, HWND
751      }      }
752    
753      if (k->is_protected) {      if (k->is_protected) {
754          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
755          if (cancel)          if (cancel)
756              return FALSE;              return FALSE;
757      }      }
758    
759      memset (&keygen, 0, sizeof (keygen));      memset (&keygen, 0, sizeof (keygen));
760      memset (&cb, 0, sizeof cb);      memset (&cb, 0, sizeof cb);
761        cb.parent = dlg;
762      cb.opaque = &keygen;      cb.opaque = &keygen;
763      cb.is_protected = k->is_protected;      cb.is_protected = k->is_protected;
764      cb.pass = pass;      cb.pass = pass;
# Line 833  keyedit_add_subkey (winpt_key_t k, HWND Line 819  keyedit_add_subkey (winpt_key_t k, HWND
819          return FALSE;          return FALSE;
820      }      }
821      if (k->is_protected) {      if (k->is_protected) {
822          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
823          if (cancel)          if (cancel)
824              return FALSE;              return FALSE;
825      }      }
# Line 859  keyedit_add_subkey (winpt_key_t k, HWND Line 845  keyedit_add_subkey (winpt_key_t k, HWND
845  }  }
846    
847    
848    /* Set the preferred keyserver of the given key @k. */
849  BOOL  BOOL
850  keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg)  keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg)
851  {  {
# Line 873  keyedit_set_pref_keyserver (winpt_key_t Line 860  keyedit_set_pref_keyserver (winpt_key_t
860          return FALSE;          return FALSE;
861      }      }
862    
863      pass = request_passphrase (_("Key Edit"), 1, &url->cancel);      pass = request_key_passphrase (k->ctx, _("Key Edit"), &url->cancel);
864      if (url->cancel) {      if (url->cancel) {
865          delete url;          delete url;
866          return FALSE;          return FALSE;
# Line 914  keyedit_add_photo (winpt_key_t k, HWND d Line 901  keyedit_add_photo (winpt_key_t k, HWND d
901    
902      memset (&cb, 0, sizeof (cb));      memset (&cb, 0, sizeof (cb));
903      if (k->is_protected) {      if (k->is_protected) {
904          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
905          if (cancel)          if (cancel)
906              return FALSE;              return FALSE;
907      }      }
908        cb.parent = dlg;
909      cb.pass = pass;      cb.pass = pass;
910      cb.keyid = k->keyid;      cb.keyid = k->keyid;
   
911      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT_ADDPHOTO, dlg,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT_ADDPHOTO, dlg,
912                      keyedit_addphoto_dlg_proc, (LPARAM)&cb);                      keyedit_addphoto_dlg_proc, (LPARAM)&cb);
913    
# Line 944  keyedit_add_revoker (winpt_key_t k, HWND Line 931  keyedit_add_revoker (winpt_key_t k, HWND
931      }      }
932    
933      if (k->is_protected) {      if (k->is_protected) {
934          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
935          if (cancel)          if (cancel)
936              return FALSE;              return FALSE;
937      }      }
938    
939      memset (&cb, 0, sizeof (cb));      memset (&cb, 0, sizeof (cb));
940        cb.parent = dlg;
941      cb.is_protected = k->is_protected;      cb.is_protected = k->is_protected;
942      cb.keyid = k->keyid;      cb.keyid = k->keyid;
943      cb.pass = pass;      cb.pass = pass;
# Line 995  is_idea_protect_algo (const char *keyid) Line 983  is_idea_protect_algo (const char *keyid)
983      memset (&k, 0, sizeof (k));      memset (&k, 0, sizeof (k));
984      if (winpt_get_pubkey (keyid, &k))      if (winpt_get_pubkey (keyid, &k))
985          BUG (0);          BUG (0);
     sym_prefs = k.ext->sym_prefs;  
986      if (!k.is_v3)      if (!k.is_v3)
987          return 0;          return 0;
988        sym_prefs = k.ext->sym_prefs;
989      if (!sym_prefs)      if (!sym_prefs)
990          return 1; /* assume that only v3 keys have no symmetric cipher preferences          return 1; /* assume that only v3 keys have no symmetric cipher preferences
991                       and thus IDEA is explicit. */                       and thus IDEA is explicit. */
# Line 1032  keyedit_change_passwd (winpt_key_t k, HW Line 1020  keyedit_change_passwd (winpt_key_t k, HW
1020      }      }
1021    
1022      if (k->is_protected) {      if (k->is_protected) {
1023          old_pass = request_passphrase (_("Current (old) Passphrase"), 1, &cancel);          old_pass = request_passphrase (_("Current (old) Passphrase"),
1024                                           PASSDLG_INIT, &cancel);
1025          if (cancel)          if (cancel)
1026              return FALSE;              return FALSE;
1027      }      }
1028      new_pass = request_passphrase2 (_("New Passphrase" ), 1, &cancel);      new_pass = request_passphrase2 (_("New Passphrase" ),
1029                                        PASSDLG_INIT|PASSDLG_WARN_UTF8, &cancel);
1030      if (cancel) {      if (cancel) {
1031          free_if_alloc (old_pass);          sfree_if_alloc (old_pass);
1032          return FALSE;          return FALSE;
1033      }      }
1034    
1035      if (is_8bit_string (new_pass)) {      if (strlen (new_pass) == 0) {
1036          msg_box (dlg, _("The passphrase contains 8-bit characters.\n"          cancel = msg_box (dlg, _("Are you sure that you really don't want a passphrase?\n"
1037                           "It is not suggested to use charset specific characters."),                                   "This is propably a bad idea, still proceed?"),
1038                           _("Key Edit"), MB_ERR);                              _("Key Edit"), MB_WARN_ASK);
1039          free_if_alloc (old_pass);          if (cancel != IDYES) {
1040          free_if_alloc (new_pass);              sfree_if_alloc (old_pass);
1041          return FALSE;              sfree_if_alloc (new_pass);
1042                return FALSE;
1043            }
1044      }      }
1045    
1046      ke = create_GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
1047      ke->setPassphrase (k->is_protected? old_pass : NULL);      ke->setPassphrase (k->is_protected? old_pass : NULL);
1048      err = ke->changePassphrase (new_pass, 0);      if (!k->is_protected)
1049            ke->setNoPassphrase (true);
1050        err = ke->changePassphrase (new_pass, 1);
1051      if (err)      if (err)
1052          msg_box (dlg, gpgme_strerror (err), _("Change Passwd"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Change Passwd"), MB_ERR);
1053      else      else
# Line 1090  subkey_list_init (HWND dlg, winpt_key_t Line 1084  subkey_list_init (HWND dlg, winpt_key_t
1084      int nkeys = 0, i, bits;      int nkeys = 0, i, bits;
1085    
1086      nkeys = count_subkeys (k->ctx);      nkeys = count_subkeys (k->ctx);
1087      if( !nkeys ) {      if (!nkeys)
1088          msg_box (dlg, _("No subkey(s) found."), _("Key Edit"), MB_ERR);          BUG (0); /* should never happen. */
         return NULL;  
     }  
1089                    
1090      listview_new (&lv, GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST));      listview_new (&lv, GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST));
1091      for (i = 0; cols[i].fieldname != NULL; i++)      for (i = 0; cols[i].fieldname != NULL; i++)
1092          listview_add_column (lv, &cols[i]);          listview_add_column (lv, &cols[i]);
1093                    
1094      for( i = 0; i < nkeys; i++ ) {      for (i = 0; i < nkeys; i++) {
1095          listview_add_item( lv, "" );          listview_add_item (lv, "");
1096          listview_add_sub_item( lv, 0, 1, "" );          listview_add_sub_item (lv, 0, 1, "");
1097          memset( &lvi, 0, sizeof lvi );          memset (&lvi, 0, sizeof (lvi));
1098          lvi.mask = LVIF_PARAM;            lvi.mask = LVIF_PARAM;  
1099          lvi.lParam = (LPARAM)k->ctx;          lvi.lParam = (LPARAM)k->ext;
1100          if( ListView_SetItem( lv->ctrl, &lvi ) == FALSE )          if (ListView_SetItem (lv->ctrl, &lvi) == FALSE)
1101              return NULL;              BUG (0);
1102      }      }
1103                    
1104      listview_set_ext_style( lv );      listview_set_ext_style( lv );
# Line 1177  userid_list_init (HWND dlg, winpt_key_t Line 1169  userid_list_init (HWND dlg, winpt_key_t
1169      const char *attr;      const char *attr;
1170            
1171      nuids = count_userids (k->ctx);      nuids = count_userids (k->ctx);
1172      if (!nuids) {      if (!nuids)
1173          msg_box (dlg, _("No user ID(s) found."), _("Key Edit"), MB_ERR);          BUG (0); /* should never happen. */
         return NULL;  
     }  
1174                    
1175      listview_new (&lv, GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST));      listview_new (&lv, GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST));
1176      for( j = 0; cols[j].fieldname != NULL; j++ )      for (j = 0; cols[j].fieldname != NULL; j++)
1177          listview_add_column (lv, &cols[j]);          listview_add_column (lv, &cols[j]);
1178                    
1179      for (j = 0; j < nuids; j++) {      for (j = 0; j < nuids; j++) {
# Line 1211  userid_list_init (HWND dlg, winpt_key_t Line 1201  userid_list_init (HWND dlg, winpt_key_t
1201              listview_add_sub_item (lv, j, UID_COL_CREATION,              listview_add_sub_item (lv, j, UID_COL_CREATION,
1202                                     get_key_created (ks->timestamp));                                     get_key_created (ks->timestamp));
1203      }      }
1204      if( !k->key_pair ) {      if (!k->key_pair) {
1205          CheckDlgButton (dlg, IDC_KEYUID_ADD, BST_INDETERMINATE);          CheckDlgButton (dlg, IDC_KEYUID_ADD, BST_INDETERMINATE);
1206          CheckDlgButton (dlg, IDC_KEYUID_REVOKE, BST_INDETERMINATE);          CheckDlgButton (dlg, IDC_KEYUID_REVOKE, BST_INDETERMINATE);
1207      }      }
# Line 1291  do_editkey_delkey (winpt_key_t k, HWND d Line 1281  do_editkey_delkey (winpt_key_t k, HWND d
1281  {  {
1282      gpgme_error_t err;      gpgme_error_t err;
1283      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1284      int j, id;      int pos, id;
1285      char tmp[64];      char tmp[64];
1286    
1287      if (!k->key_pair)      if (!k->key_pair)
1288          return FALSE; /* XXX: shall we allow to modify non-secret keys?? */          return FALSE;
1289    
1290      if( listview_count_items( lv, 0 ) == 1 ) {      if (listview_count_items (lv, 0) == 1) {
1291          msg_box( dlg, _("Primary key can not be deleted!"), _("Key Edit"), MB_ERR);          msg_box (dlg, _("Primary key can not be deleted!"), _("Key Edit"), MB_ERR);
1292          return FALSE;          return FALSE;
1293      }      }
1294      if( (j = listview_get_curr_pos( lv )) == -1 ) {      pos = listview_get_curr_pos (lv);
1295          msg_box( dlg, _("Please select a key."), _("Key Edit"), MB_ERR );      if (pos == -1) {
1296            msg_box (dlg, _("Please select a key."), _("Key Edit"), MB_ERR);
1297          return FALSE;          return FALSE;
1298      }      }
1299      if( j == 0 ) {      if (pos == 0) {
1300          msg_box( dlg, _("Primary subkey can not be deleted!"), _("Key Edit"), MB_ERR );          msg_box (dlg, _("Primary key can not be deleted!"), _("Key Edit"), MB_ERR);
1301          return FALSE;          return FALSE;
1302      }      }
1303            
1304      /* XXX: change the warning to make clear that verification won't work      /* XXX: change the warning to make clear that verification won't work
1305              any longer if this is a sign-only key. */              any longer if this is a sign-only key. */
1306      listview_get_item_text (lv, j, 0, tmp, sizeof (tmp) -1);      listview_get_item_text (lv, pos, 0, tmp, sizeof (tmp) -1);
1307      id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING,      id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING,
1308                      _("\"Subkey %s.\"\n\n"                      _("\"Subkey %s.\"\n\n"
1309                        "Anything encrypted to the selected subkey will no longer\n"                        "Anything encrypted to the selected subkey will no longer\n"
# Line 1321  do_editkey_delkey (winpt_key_t k, HWND d Line 1312  do_editkey_delkey (winpt_key_t k, HWND d
1312      if (id == IDNO)      if (id == IDNO)
1313          return FALSE;          return FALSE;
1314    
1315      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
1316      if (!ke)      err = ke->delKey (pos);
         BUG (NULL);  
     err = ke->delKey (j);  
1317      if (err)      if (err)
1318          msg_box (dlg, gpgme_strerror (err), _("Delete Subkey"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Delete Subkey"), MB_ERR);
1319      else {      else {
1320          listview_del_item (lv, j);          listview_del_item (lv, pos);
1321          k->update = 1;          k->update = 1;
1322          status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status"));          status_box (dlg, _("Subkey successfully deleted."), _("GnuPG status"));
1323      }      }
# Line 1346  do_editkey_expire (winpt_key_t k, HWND d Line 1335  do_editkey_expire (winpt_key_t k, HWND d
1335      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1336      date_s udd = {0};      date_s udd = {0};
1337      char buf[256], * pass = NULL;      char buf[256], * pass = NULL;
1338      int j, cancel = 0;      time_t exp;
1339        int pos, cancel = 0;
1340    
1341      if (!k->key_pair) {      if (!k->key_pair) {
1342          msg_box (dlg, _("There is no secret key available!"), _("Key Edit"), MB_ERR);          msg_box (dlg, _("There is no secret key available!"), _("Key Edit"), MB_ERR);
1343          return FALSE;          return FALSE;
1344      }      }
1345      if ((j = listview_get_curr_pos (lv)) == -1) {      pos = listview_get_curr_pos (lv);
1346          msg_box( dlg, _("Please select a key."), _("Key Edit"), MB_ERR );      if (pos == -1) {
1347            msg_box (dlg, _("Please select a key."), _("Key Edit"), MB_ERR);
1348          return FALSE;          return FALSE;
1349      }      }
1350    
1351      /* If a key already expired, it is possible the user wants to      /* If a key already expired, it is possible the user wants to
1352         set a new expiration date.. */           set a new expiration date.. */
1353      listview_get_item_text (lv, j, SUBK_COL_STATUS, buf, sizeof buf -1);      listview_get_item_text (lv, pos, SUBK_COL_STATUS, buf, sizeof (buf)-1);
1354      if (!strcmp (buf, _("Expired"))) {      if (!strcmp (buf, _("Expired"))) {
1355          cancel = msg_box (dlg, _("Key already expired.\n\n"          cancel = msg_box (dlg, _("Key already expired.\n\n"
1356                            "Do you want to change the expiration date?"),                            "Do you want to change the expiration date?"),
# Line 1381  do_editkey_expire (winpt_key_t k, HWND d Line 1372  do_editkey_expire (winpt_key_t k, HWND d
1372                   _("Key Edit"), MB_ERR);                   _("Key Edit"), MB_ERR);
1373          return FALSE;          return FALSE;
1374      }      }
1375      if( k->is_protected ) {      if (k->is_protected) {
1376          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
1377          if (cancel)          if (cancel)
1378              return FALSE;              return FALSE;
1379      }      }
1380        exp = w32_mktime (&udd.st);
1381      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
     if (!ke)  
         BUG (NULL);  
1382      if (k->is_protected)      if (k->is_protected)
1383          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1384      else      else
1385          ke->setNoPassphrase (true);          ke->setNoPassphrase (true);
1386      err = ke->setKeyExpireDate (j, w32_mktime (&udd.st), false);      err = ke->setKeyExpireDate (pos, exp, false);
1387      if (err)      if (err)
1388          msg_box (dlg, gpgme_strerror (err), _("Expire Subkey"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Expire Subkey"), MB_ERR);
1389      else {      else {
1390          _snprintf (buf, sizeof buf - 1, "%04d-%02d-%02d",                _snprintf (buf, sizeof (buf)-1, "%s", get_key_created (exp));
1391                     udd.st.wYear, udd.st.wMonth, udd.st.wDay);          listview_add_sub_item (lv, pos, SUBK_COL_EXPIRES, buf);
         listview_add_sub_item (lv, j, SUBK_COL_EXPIRES, buf);  
1392          k->update = 1;          k->update = 1;
1393          msg_box (dlg, _("Subkey expire date successfully set."),          msg_box (dlg, _("Subkey expire date successfully set."),
1394                   _("GnuPG status"), MB_OK);                   _("GnuPG status"), MB_OK);
# Line 1447  do_editkey_revoke (winpt_key_t k, HWND d Line 1435  do_editkey_revoke (winpt_key_t k, HWND d
1435      }      }
1436            
1437      if (k->is_protected) {      if (k->is_protected) {
1438          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
1439          if (cancel)          if (cancel)
1440              return FALSE;                        return FALSE;          
1441      }      }
1442    
1443      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
     if (!ke)  
         BUG (NULL);  
1444      if (k->is_protected)      if (k->is_protected)
1445          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1446      else      else
# Line 1514  do_editkey_revuid (winpt_key_t k, HWND d Line 1500  do_editkey_revuid (winpt_key_t k, HWND d
1500      if (msg_box (dlg, inf, _("Key Edit"), MB_WARN_ASK) == IDNO)      if (msg_box (dlg, inf, _("Key Edit"), MB_WARN_ASK) == IDNO)
1501          return FALSE;          return FALSE;
1502      if (k->is_protected) {      if (k->is_protected) {
1503          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
1504          if (cancel)          if (cancel)
1505              return FALSE;                        return FALSE;          
1506      }      }
# Line 1524  do_editkey_revuid (winpt_key_t k, HWND d Line 1510  do_editkey_revuid (winpt_key_t k, HWND d
1510      if (id == -1)      if (id == -1)
1511          BUG (NULL);          BUG (NULL);
1512    
1513      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
     if (!ke)  
         BUG (NULL);  
1514      if (k->is_protected)      if (k->is_protected)
1515          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1516      else      else
# Line 1560  do_editkey_setpref (winpt_key_t k, HWND Line 1544  do_editkey_setpref (winpt_key_t k, HWND
1544      listview_get_item_text (lv, j, 2, buf, sizeof buf-1);      listview_get_item_text (lv, j, 2, buf, sizeof buf-1);
1545      id = do_find_userid (k->keyid, buf, NULL, NULL);      id = do_find_userid (k->keyid, buf, NULL, NULL);
1546      if (id == -1)      if (id == -1)
1547          BUG (dlg);          BUG (NULL);
1548      if (k->is_protected) {      if (k->is_protected) {
1549          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
1550          if (cancel)          if (cancel)
1551              return FALSE;              return FALSE;
1552      }      }
1553    
1554      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
     if (!ke)  
         BUG (NULL);  
1555      if (k->is_protected)      if (k->is_protected)
1556          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1557      else      else
# Line 1594  do_editkey_primary (winpt_key_t k, HWND Line 1576  do_editkey_primary (winpt_key_t k, HWND
1576      gpgme_error_t err;      gpgme_error_t err;
1577      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1578      int j, id, cancel=0;      int j, id, cancel=0;
1579        char valid[32];
1580      char buf[256], *pass = NULL;      char buf[256], *pass = NULL;
1581    
1582      if (listview_count_items (lv, 0) == 1)      if (listview_count_items (lv, 0) == 1)
1583          return TRUE;          return TRUE;
1584      if ((j = listview_get_curr_pos (lv)) == -1) {      if ((j = listview_get_curr_pos (lv)) == -1) {
1585          msg_box( dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR );          msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR);
1586          return FALSE;          return FALSE;
1587      }      }
1588      listview_get_item_text (lv, j, 2, buf, sizeof buf-1);      listview_get_item_text (lv, j, UID_COL_VALID, valid, sizeof (valid)-1);
1589        if (!strcmp (valid, _("Revoked")))
1590            return FALSE;
1591        listview_get_item_text (lv, j, UID_COL_EMAIL, buf, sizeof (buf)-1);
1592      id = do_find_userid (k->keyid, buf, NULL, NULL);      id = do_find_userid (k->keyid, buf, NULL, NULL);
1593      if (id == -1)      if (id == -1)
1594          BUG (0);          BUG (0);
1595      if (k->is_protected) {      if (k->is_protected) {
1596          pass = request_passphrase (_("Key Edit"), 1, &cancel);          pass = request_key_passphrase (k->ctx, _("Key Edit"), &cancel);
1597          if (cancel)          if (cancel)
1598              return FALSE;              return FALSE;
1599      }      }
1600    
1601      ke = new GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
1602      if (k->is_protected)      if (k->is_protected)
1603          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1604      else      else
# Line 1725  showpref_dlg_proc (HWND dlg, UINT msg, W Line 1711  showpref_dlg_proc (HWND dlg, UINT msg, W
1711          SetDlgItemText (dlg, IDC_SHOWPREF_UIDHINT, _("user ID:"));          SetDlgItemText (dlg, IDC_SHOWPREF_UIDHINT, _("user ID:"));
1712          SetWindowText (dlg, _("Key Preferences"));          SetWindowText (dlg, _("Key Preferences"));
1713          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
1714            center_window (dlg, cb->parent);
1715          break;          break;
1716    
1717      case WM_COMMAND:      case WM_COMMAND:
# Line 1757  do_editkey_showpref (winpt_key_t k, HWND Line 1744  do_editkey_showpref (winpt_key_t k, HWND
1744          return FALSE;          return FALSE;
1745      }      }
1746      memset (&cb, 0, sizeof (cb));      memset (&cb, 0, sizeof (cb));
1747        cb.parent = dlg;
1748      cb.opaque = k->ctx;      cb.opaque = k->ctx;
1749      cb.keyid = k->keyid;      cb.keyid = k->keyid;
1750      cb.lv = lv;      cb.lv = lv;
# Line 1780  do_editkey_deluid (winpt_key_t k, HWND d Line 1768  do_editkey_deluid (winpt_key_t k, HWND d
1768      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1769      char email[128], name[128];      char email[128], name[128];
1770      char inf[384];      char inf[384];
1771      int j, id = 0;      int pos, id = 0;
1772    
1773      if (!k->key_pair)      if (!k->key_pair)
1774          return FALSE; /* XXX: see do_editkey_delsubkey */          return FALSE;
1775    
1776      if (listview_count_items (lv, 0) == 1) {      if (listview_count_items (lv, 0) == 1) {
1777          msg_box (dlg, _("Primary user ID can not be deleted!"),          msg_box (dlg, _("Primary user ID can not be deleted!"),
1778                   _("Key Edit"), MB_ERR);                   _("Key Edit"), MB_ERR);
1779          return FALSE;          return FALSE;
1780      }      }
1781      if ((j = listview_get_curr_pos (lv)) == -1) {      pos = listview_get_curr_pos (lv);
1782        if (pos == -1) {
1783          msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR);          msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR);
1784          return FALSE;          return FALSE;
1785      }      }
1786            
1787      /* XXX: add a hint that also all signatures will be deleted? */      listview_get_item_text (lv, pos, UID_COL_NAME, name, DIM(name) -1);
     listview_get_item_text (lv, j, UID_COL_NAME, name, DIM(name) -1);  
1788      _snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n"      _snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n"
1789                                     "All signatures on this user ID will be also deleted."                                     "All signatures on this user ID will be also deleted."
1790                                     "\n\n"                                     "\n\n"
# Line 1805  do_editkey_deluid (winpt_key_t k, HWND d Line 1793  do_editkey_deluid (winpt_key_t k, HWND d
1793      if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO)      if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO)
1794          return FALSE;          return FALSE;
1795            
1796      listview_get_item_text (lv, j, UID_COL_EMAIL, email, DIM (email)-1);      listview_get_item_text (lv, pos, UID_COL_EMAIL, email, DIM (email)-1);
1797      listview_get_item_text (lv, j, UID_COL_NAME, name, DIM (name)-1);      listview_get_item_text (lv, pos, UID_COL_NAME, name, DIM (name)-1);
1798      id = do_find_userid (k->keyid, email, name, NULL);      id = do_find_userid (k->keyid, email, name, NULL);
1799      if (id == -1)      if (id == -1)
1800          BUG (dlg);          BUG (0);
   
     ke = new GpgKeyEdit (k->keyid);  
     if (!ke)  
         BUG (NULL);  
1801    
1802        ke = create_GpgKeyEdit (k->keyid);
1803      err = ke->delUserid (id);      err = ke->delUserid (id);
1804      if (err)      if (err)
1805          msg_box (dlg, gpgme_strerror (err), _("Delete user ID"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Delete User ID"), MB_ERR);
1806      else {      else {
1807          listview_del_item (lv, j);          listview_del_item (lv, pos);
1808          k->update = 1;          k->update = 1;
1809          status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status"));          status_box (dlg, _("User ID successfully deleted"), _("GnuPG Status"));
1810      }      }
# Line 1901  do_editkey_enable_disable (winpt_key_t k Line 1886  do_editkey_enable_disable (winpt_key_t k
1886  }  }
1887    
1888    
 /* Return default secret key. */  
 static gpgme_key_t  
 get_default_key (void)  
 {  
     gpgme_key_t def_sk;  
     char *keyid = get_gnupg_default_key ();  
   
     get_seckey (keyid, &def_sk);  
     free_if_alloc (keyid);  
     return def_sk;  
 }  
   
   
   
1889  static void  static void
1890  do_editkey_minimize (winpt_key_t k, HWND dlg)  do_editkey_minimize (winpt_key_t k, HWND dlg)
1891  {  {
# Line 1969  static int Line 1940  static int
1940  do_editkey_sign_userid (winpt_key_t k, HWND dlg, listview_ctrl_t lv, int mode)  do_editkey_sign_userid (winpt_key_t k, HWND dlg, listview_ctrl_t lv, int mode)
1941  {  {
1942      gpgme_error_t err;      gpgme_error_t err;
1943        winpt_key_s signer;
1944      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1945      char *pass = NULL;      char *pass = NULL;
1946      char email[64], name[128];      char *defkey;
1947        char email[64], name[128], valid[32];
1948      int uid_index;      int uid_index;
1949      int cancel = 0;      int cancel = 0;
1950    
# Line 1980  do_editkey_sign_userid (winpt_key_t k, H Line 1953  do_editkey_sign_userid (winpt_key_t k, H
1953          msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR);          msg_box (dlg, _("Please select a user ID."), _("Key Edit"), MB_ERR);
1954          return FALSE;          return FALSE;
1955      }      }
1956        listview_get_item_text (lv, uid_index, UID_COL_VALID, valid, sizeof (valid)-1);
1957        if (!strcmp (valid, _("Revoked")))
1958            return TRUE;
1959      if (mode == CMD_SIGN) {      if (mode == CMD_SIGN) {
1960          cancel = msg_box (dlg, _("Do you really want to make this sig exportable?"),          cancel = msg_box (dlg, _("Do you really want to make this sig exportable?"),
1961                            _("Key Edit"), MB_QUEST_ASK);                            _("Key Edit"), MB_QUEST_ASK);
1962          if (cancel == IDNO)          if (cancel == IDNO)
1963              return FALSE;              return FALSE;
1964      }      }
   
1965      listview_get_item_text (lv, uid_index, UID_COL_EMAIL, email, sizeof (email)-1);      listview_get_item_text (lv, uid_index, UID_COL_EMAIL, email, sizeof (email)-1);
1966      listview_get_item_text (lv, uid_index, UID_COL_NAME, name, sizeof (name)-1);      listview_get_item_text (lv, uid_index, UID_COL_NAME, name, sizeof (name)-1);
1967      uid_index = do_find_userid (k->keyid, email, name, NULL);      uid_index = do_find_userid (k->keyid, email, name, NULL);
1968      if (k->is_protected) {  
1969          pass = request_passphrase (_("Key Edit"), 1, &cancel);      defkey = get_gnupg_default_key ();
1970        memset (&signer, 0, sizeof (signer));
1971        if (winpt_get_seckey (defkey, &signer)) {
1972            log_debug ("do_editkey_sign_userid: no default secret key.\r\n");
1973            free_if_alloc (defkey);
1974            return FALSE;
1975        }
1976        if (signer.is_protected) {
1977            pass = request_key_passphrase (signer.ctx, _("Key Edit"), &cancel);
1978          if (cancel)          if (cancel)
1979              return FALSE;              return FALSE;
1980      }      }
1981      ke = create_GpgKeyEdit (k->keyid);      ke = create_GpgKeyEdit (k->keyid);
1982      if (k->is_protected)      if (signer.is_protected)
1983          ke->setPassphrase (pass);          ke->setPassphrase (pass);
1984      else      else
1985          ke->setNoPassphrase (true);          ke->setNoPassphrase (true);
1986      ke->setLocalUser (get_default_key ());      ke->setLocalUser (signer.ctx);
1987      err = ke->signUserid (uid_index,      err = ke->signUserid (uid_index,
1988                            mode == CMD_SIGN? GPG_EDITKEY_SIGN : GPG_EDITKEY_LSIGN,                            mode == CMD_SIGN? GPG_EDITKEY_SIGN : GPG_EDITKEY_LSIGN,
1989                            0, NULL);                            0, NULL);
# Line 2068  gen_desig_revoke_cert (winpt_key_t key, Line 2051  gen_desig_revoke_cert (winpt_key_t key,
2051      int id;      int id;
2052    
2053      inf = km_key_get_info (key, 0);      inf = km_key_get_info (key, 0);
2054      warn = _("Your keys is listed as a designated revoker for the key\n\n"      warn = _("Your key is listed as a designated revoker for the key\n\n"
2055               "%s\n\n"               "%s\n\n"
2056               "Are you sure you want to create a revocation certificate\n"               "Are you sure you want to create a revocation certificate\n"
2057               "which allow to revoke the key listed above?");               "which allow to revoke the key listed above?");
# Line 2103  keyedit_main_dlg_proc (HWND dlg, UINT ms Line 2086  keyedit_main_dlg_proc (HWND dlg, UINT ms
2086              BUG (NULL);              BUG (NULL);
2087          do_init_cmdlist (dlg, k->key_pair);          do_init_cmdlist (dlg, k->key_pair);
2088          lvsub = subkey_list_init (dlg, k);          lvsub = subkey_list_init (dlg, k);
         if (!lvsub)  
             BUG (0);  
2089          lvuid = userid_list_init (dlg, k);          lvuid = userid_list_init (dlg, k);
         if (!lvuid)  
             BUG (0);  
2090          item = GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST);          item = GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST);
2091          keyedit_subkey_proc.opaque = (void*)k;          keyedit_subkey_proc.opaque = (void*)k;
2092          keyedit_subkey_proc.dlg = dlg;          keyedit_subkey_proc.dlg = dlg;
# Line 2163  keyedit_main_dlg_proc (HWND dlg, UINT ms Line 2142  keyedit_main_dlg_proc (HWND dlg, UINT ms
2142      case WM_NOTIFY:      case WM_NOTIFY:
2143          NMHDR * notify;          NMHDR * notify;
2144          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
2145          if (notify && notify->code == NM_DBLCLK &&          if (!notify || notify->idFrom != IDC_KEYEDIT_UIDLIST)
2146              notify->idFrom == IDC_KEYEDIT_UIDLIST)              break;
2147            if (notify->code == NM_DBLCLK)
2148              do_editkey_showpref (k, dlg, lvuid);              do_editkey_showpref (k, dlg, lvuid);
2149            if (notify->code == NM_RCLICK && k->key_pair) {
2150                HMENU hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYEDIT));
2151                HMENU popup = GetSubMenu (hm, 0);
2152                POINT p;
2153    
2154                GetCursorPos (&p);
2155                TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
2156                DestroyMenu (hm);
2157                DestroyMenu (popup);
2158            }
2159          break;          break;
2160    
2161      case WM_COMMAND:      case WM_COMMAND:
2162          switch( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
2163          case IDOK:          case IDOK:
2164              cmd = lookup_cmd (dlg);              cmd = lookup_cmd (dlg);
2165              if (cmd == LB_ERR) {              if (cmd == LB_ERR) {
# Line 2203  keyedit_main_dlg_proc (HWND dlg, UINT ms Line 2193  keyedit_main_dlg_proc (HWND dlg, UINT ms
2193              case CMD_LSIGN: do_editkey_sign_userid (k, dlg,              case CMD_LSIGN: do_editkey_sign_userid (k, dlg,
2194                                                      lvuid, cmd);                                                      lvuid, cmd);
2195                              break;                              break;
2196              case CMD_CLEAN: do_editkey_clean (k, dlg);              case CMD_CLEAN: do_editkey_clean (k, dlg); break;
2197              case CMD_MINIMIZE: do_editkey_minimize (k, dlg);              case CMD_MINIMIZE: do_editkey_minimize (k, dlg); break;
2198              }              }
2199              break;              break;          
2200                
2201          case IDCANCEL:          case IDCANCEL:
2202              EndDialog (dlg, FALSE);              EndDialog (dlg, FALSE);
2203              break;              break;
# Line 2219  keyedit_main_dlg_proc (HWND dlg, UINT ms Line 2209  keyedit_main_dlg_proc (HWND dlg, UINT ms
2209          case IDC_KEYEDIT_REVOKE:          case IDC_KEYEDIT_REVOKE:
2210              gen_desig_revoke_cert (k, dlg);              gen_desig_revoke_cert (k, dlg);
2211              break;              break;
2212    
2213            case ID_KEYEDIT_UID_PRIM:
2214                do_editkey_primary (k, dlg, lvuid);
2215                break;
2216    
2217            case ID_KEYEDIT_UID_DEL:
2218                do_editkey_deluid (k, dlg, lvuid);
2219                break;
2220    
2221            case ID_KEYEDIT_UID_REV:
2222                do_editkey_revuid (k, dlg, lvuid);
2223                break;
2224          }          }
2225          break;          break;
2226      }      }

Legend:
Removed from v.211  
changed lines
  Added in v.231

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26