/[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 272 by twoaday, Fri Jul 28 11:11:09 2006 UTC revision 273 by twoaday, Fri Dec 8 10:22:17 2006 UTC
# Line 328  is_jpg_file (const char *fname) Line 328  is_jpg_file (const char *fname)
328      fp = fopen (fname, "rb");      fp = fopen (fname, "rb");
329      if (!fp)      if (!fp)
330          return false;          return false;
331      n = fread (buf, 1, 10, fp);      n = fread (buf, 1, DIM (buf), fp);
332      fclose (fp);      fclose (fp);
333      if (n < 10)      if (n < DIM (buf))
334          return false;          return false;
335      return buf[6] == 'J' && buf[7] == 'F' &&      return buf[6] == 'J' && buf[7] == 'F' &&
336             buf[8] == 'I' && buf[9] == 'F';             buf[8] == 'I' && buf[9] == 'F';
# Line 348  keyedit_addphoto_dlg_proc (HWND dlg, UIN Line 348  keyedit_addphoto_dlg_proc (HWND dlg, UIN
348      char file[128];      char file[128];
349      int id;      int id;
350    
351      switch( msg ) {      switch (msg) {
352      case WM_INITDIALOG:      case WM_INITDIALOG:
353          cb = (keyedit_cb_t)lparam;          cb = (keyedit_cb_t)lparam;
354          if (!cb)          if (!cb)
# Line 662  keyedit_addsubkey_dlg_proc (HWND dlg, UI Line 662  keyedit_addsubkey_dlg_proc (HWND dlg, UI
662          }          }
663          if (HIWORD (wparam) == LBN_SELCHANGE &&          if (HIWORD (wparam) == LBN_SELCHANGE &&
664              LOWORD (wparam) == IDC_ADDSUBKEY_ALGO) {              LOWORD (wparam) == IDC_ADDSUBKEY_ALGO) {
665                /* If the selected algorithm is DSA, automatically set the
666                   size to 1024, otherwise use the default keysize. */
667              index = SendMessage ((HWND)lparam, LB_GETCURSEL, 0, 0);              index = SendMessage ((HWND)lparam, LB_GETCURSEL, 0, 0);
668              SendDlgItemMessage (dlg, IDC_ADDSUBKEY_SIZE, CB_SETCURSEL,              SendDlgItemMessage (dlg, IDC_ADDSUBKEY_SIZE, CB_SETCURSEL,
669                                  index==0? 0 : 2, 0);                                  index==0? 0 : 2, 0);
# Line 672  keyedit_addsubkey_dlg_proc (HWND dlg, UI Line 674  keyedit_addsubkey_dlg_proc (HWND dlg, UI
674              keygen = (keygen_cb_t)ctx->opaque;              keygen = (keygen_cb_t)ctx->opaque;
675              assert (keygen);              assert (keygen);
676              hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO);              hwnd = GetDlgItem (dlg, IDC_ADDSUBKEY_ALGO);
677                /* Map combo box numbers to GPG answers. */
678              switch (listbox_get_cursel (hwnd)) {              switch (listbox_get_cursel (hwnd)) {
679              case 0: index = 2; break;              case 0: index = 2; break;
680              case 1: index = 4; break;              case 1: index = 4; break;
# Line 874  keyedit_set_pref_keyserver (winpt_key_t Line 877  keyedit_set_pref_keyserver (winpt_key_t
877          ke->setNoPassphrase (true);          ke->setNoPassphrase (true);
878      err = ke->setPreferredKeyserver (-1, url->url);      err = ke->setPreferredKeyserver (-1, url->url);
879      if (!err)      if (!err)
880          msg_box (dlg, _("Preferred keyserver successfully set."), _("Key Edit"), MB_OK);          msg_box (dlg, _("Preferred keyserver successfully set."),
881                     _("Key Edit"), MB_OK);
882      else      else
883          msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Key Edit"), MB_ERR);
884    
# Line 987  is_idea_protect_algo (const char *keyid) Line 991  is_idea_protect_algo (const char *keyid)
991      if (!k.is_v3)      if (!k.is_v3)
992          return 0;          return 0;
993      sym_prefs = k.ext->sym_prefs;      sym_prefs = k.ext->sym_prefs;
994        /* Assume that only v3 keys have no symmetric cipher
995           preferences and thus IDEA is explicit. */
996      if (!sym_prefs)      if (!sym_prefs)
997          return 1; /* assume that only v3 keys have no symmetric cipher preferences          return 1;
                      and thus IDEA is explicit. */  
998      for (n = 0; sym_prefs[n]; n++)      for (n = 0; sym_prefs[n]; n++)
999          ;          ;
1000      if ((n == 0 || n == 1) && *sym_prefs == 0x01)      if ((n == 0 || n == 1) && *sym_prefs == 0x01)
# Line 1134  subkey_list_init (HWND dlg, winpt_key_t Line 1139  subkey_list_init (HWND dlg, winpt_key_t
1139          if (sub->can_certify) t = "*"; else t = "";          if (sub->can_certify) t = "*"; else t = "";
1140          listview_add_sub_item (lv, i, SUBK_COL_C_FLAG, t);          listview_add_sub_item (lv, i, SUBK_COL_C_FLAG, t);
1141          if (sub->can_sign) t = "*"; else t = "";          if (sub->can_sign) t = "*"; else t = "";
1142          listview_add_sub_item( lv, i, SUBK_COL_S_FLAG, t );          listview_add_sub_item (lv, i, SUBK_COL_S_FLAG, t);
1143          if (sub->can_encrypt) t = "*"; else t = "";          if (sub->can_encrypt) t = "*"; else t = "";
1144          listview_add_sub_item( lv, i, SUBK_COL_E_FLAG, t );          listview_add_sub_item (lv, i, SUBK_COL_E_FLAG, t);
1145          if (sub->can_authenticate) t = "*"; else t = "";          if (sub->can_authenticate) t = "*"; else t = "";
1146          listview_add_sub_item (lv, i, SUBK_COL_A_FLAG, t);          listview_add_sub_item (lv, i, SUBK_COL_A_FLAG, t);
1147      }      }
# Line 1205  static void Line 1210  static void
1210  do_init_cmdlist (HWND dlg, int is_keypair)  do_init_cmdlist (HWND dlg, int is_keypair)
1211  {      {    
1212      const char *s;      const char *s;
1213      int i = 0;      int i;
1214    
1215      for (i = 0; (s=cmdlist[i].name); i++) {      for (i = 0; (s=cmdlist[i].name); i++) {
1216          if (is_keypair)          if (is_keypair)
# Line 1250  do_show_help (HWND dlg) Line 1255  do_show_help (HWND dlg)
1255           "ADDREVOKER  add a revocation key\r\n"           "ADDREVOKER  add a revocation key\r\n"
1256           "EXPIRE      change the expire date\r\n"           "EXPIRE      change the expire date\r\n"
1257           "SHOWPREF    list preferences (verbose)\r\n"           "SHOWPREF    list preferences (verbose)\r\n"
1258           "SETPREF     set preference list\r\n"           "SETPREF     update specific algorithm preferences\r\n"
          "UPDPREF     updated preferences\r\n"  
1259           "PASSWD      change the passphrase\r\n"           "PASSWD      change the passphrase\r\n"
1260           "PRIMARY     flag user ID as primary\r\n"           "PRIMARY     flag user ID as primary\r\n"
1261           "TRUST       change the ownertrust\r\n"           "TRUST       change the ownertrust\r\n"
# Line 1268  do_show_help (HWND dlg) Line 1272  do_show_help (HWND dlg)
1272  }  }
1273    
1274    
1275    static gpgme_subkey_t
1276    get_subkey_bypos (const char *keyid, int idx)
1277    {
1278        gpgme_key_t key;
1279    
1280        if (get_pubkey (keyid, &key))
1281            return NULL;
1282        return get_nth_key (key, idx);
1283    }
1284    
1285    
1286    
1287  static int  static int
1288  do_editkey_delkey (winpt_key_t k, HWND dlg, listview_ctrl_t lv)  do_editkey_delkey (winpt_key_t k, HWND dlg, listview_ctrl_t lv)
1289  {  {
1290      gpgme_error_t err;      gpgme_error_t err;
1291        gpgme_subkey_t subk;
1292      GpgKeyEdit *ke;      GpgKeyEdit *ke;
1293      int pos, id;      int pos, id;
1294        const char *warn;
1295      char tmp[64];      char tmp[64];
1296    
1297      if (!k->key_pair)      if (!k->key_pair)
# Line 1292  do_editkey_delkey (winpt_key_t k, HWND d Line 1310  do_editkey_delkey (winpt_key_t k, HWND d
1310          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);
1311          return FALSE;          return FALSE;
1312      }      }
1313        
     /* XXX: change the warning to make clear that verification won't work  
             any longer if this is a sign-only key. */  
1314      listview_get_item_text (lv, pos, 0, tmp, sizeof (tmp) -1);      listview_get_item_text (lv, pos, 0, tmp, sizeof (tmp) -1);
1315      id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING,      subk = get_subkey_bypos (k->keyid, pos);
1316                      _("\"Subkey %s.\"\n\n"      /* Issue different warning for the different key capabilities. */
1317                        "Anything encrypted to the selected subkey will no longer\n"      if (subk->can_encrypt)
1318                        "be able to be decrypted.\n\n"          warn = _("Anything encrypted to the selected subkey cannot be\n"
1319                        "Do you really want to delete this subkey?"), tmp);                   "decrypted any longer.");
1320        else if (subk->can_sign || subk->can_certify)
1321            warn = _("Anything signed by the selected subkey cannot be\n"
1322                     "verified any longer.");
1323        else
1324            warn = ""; /* just get rid of the warning. */
1325    
1326        id = log_box (_("Key Edit"), MB_YESNO|MB_ICONWARNING,
1327                      _("\"Subkey %s.\"\n\n%s\n\n"
1328                        "Do you really want to delete this subkey?"),
1329                      tmp, warn);
1330      if (id == IDNO)      if (id == IDNO)
1331          return FALSE;          return FALSE;
1332    

Legend:
Removed from v.272  
changed lines
  Added in v.273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26