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

Diff of /trunk/Src/wptKeyserverDlg.cpp

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

revision 129 by twoaday, Fri Dec 30 13:56:10 2005 UTC revision 165 by twoaday, Tue Jan 24 10:10:15 2006 UTC
# Line 40  Line 40 
40  #include "wptDlgs.h"  #include "wptDlgs.h"
41  #include "wptUTF8.h"  #include "wptUTF8.h"
42    
   
43  #define MAX_KEYSIZE 70000  #define MAX_KEYSIZE 70000
44    
45  char* get_reg_entry_keyserver (const char *);  char* get_reg_entry_keyserver (const char *);
46  int set_reg_entry_keyserver (const char *, const char *);  int set_reg_entry_keyserver (const char *, const char *);
47    
48    enum { KS_COL_NAME = 0, KS_COL_PORT, KS_COL_DEFAULT };
49    
50    /* Callback context to modify (add, edit) keyserver items. */
51    struct keyserver_rec_s {
52        char name[200];     /* hostname */
53        int  proto;         /* protocol */
54        int  port;          /* used port */
55        bool mode;          /* true = edit */
56        bool cancel;
57    };
58    typedef struct keyserver_rec_s *keyserver_rec_t;
59    
60  /* Print out keyserver error and a possible Winsock error. */  /* Print out keyserver error and a possible Winsock error. */
61  static void  static void
# Line 160  show_imported_keys (gpgme_import_result_ Line 170  show_imported_keys (gpgme_import_result_
170  /* Receive a key from the keyserver @kserver (port @port)  /* Receive a key from the keyserver @kserver (port @port)
171     with the pattern @pattern.     with the pattern @pattern.
172     Return value: 0 on success. */     Return value: 0 on success. */
173  int  static int
174  hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,  keyserver_recv_key (HWND dlg, const char *kserver, WORD port,
175                 const char *pattern, int proto, int flags,                      const char *pattern, int proto, int flags,
176                 char **r_fpr)                      char **r_fpr)
177  {  {
178      gpgme_ctx_t ctx;      gpgme_ctx_t ctx;
179      gpgme_data_t keydata;      gpgme_data_t keydata;
# Line 243  leave: Line 253  leave:
253  }  }
254    
255    
256  /* Alias for hkp_recv_key2 but without the ability to return  /* Alias for keyserver_recv_key but without the ability to return
257     the fingerprint of the key. */     the fingerprint of the key. */
258  int  int
259  hkp_recv_key (HWND dlg, const char *kserver, WORD port,  hkp_recv_key (HWND dlg, const char *kserver, WORD port,
260                const char *pattern, int proto, int flags)                const char *pattern, int proto, int flags)
261  {  {
262      return hkp_recv_key2 (dlg, kserver, port, pattern, proto, flags, NULL);      return keyserver_recv_key (dlg, kserver, port, pattern,
263                                   proto, flags, NULL);
264    }
265    
266    int
267    hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
268                   const char *pattern, int proto, char **r_fpr)
269    {
270        return keyserver_recv_key (dlg, kserver, port, pattern, proto, 0,
271                                   r_fpr);
272  }  }
273    
274    
# Line 261  check_pattern (const char *pattern) Line 280  check_pattern (const char *pattern)
280      int rc = 1;      int rc = 1;
281            
282      /* Whitespace are not allowed! */      /* Whitespace are not allowed! */
283      if (strchr( pattern, ' ')) {      if (strchr (pattern, ' ')) {
284          rc = WPTERR_GENERAL;          rc = WPTERR_GENERAL;
285          goto leave;          goto leave;
286      }      }
# Line 278  check_pattern (const char *pattern) Line 297  check_pattern (const char *pattern)
297          goto leave;          goto leave;
298      }      }
299            
300      if( ( strchr( pattern, '@' ) ) && ( strlen( pattern ) >= 3 ) ) {      if ((strchr (pattern, '@')) &&
301            (strlen (pattern) >= 3)) {
302          rc = 0;          rc = 0;
303          goto leave;          goto leave;
304      }      }
# Line 304  set_proxy (HWND dlg) Line 324  set_proxy (HWND dlg)
324      else      else
325          strcat (proxy, "none");          strcat (proxy, "none");
326      SetDlgItemText (dlg, IDC_KEYSERVER_PROXY, proxy);      SetDlgItemText (dlg, IDC_KEYSERVER_PROXY, proxy);
327  } /* set_proxy */  }
328    
329    
330  static int inline  static int inline
# Line 321  kserver_get_port (listview_ctrl_t lv) Line 341  kserver_get_port (listview_ctrl_t lv)
341  {  {
342      char buf[16];      char buf[16];
343    
344      listview_get_item_text (lv, kserver_get_pos (lv), 3, buf, 15);      listview_get_item_text (lv, kserver_get_pos (lv), KS_COL_PORT, buf, 15);
345      return (u16)strtoul (buf, NULL, 10);      return (u16)strtoul (buf, NULL, 10);
346  }  }
347    
348    
349    /* Load the default keyserver and mark it in @lv. */
350  static void  static void
351  load_default_ks (listview_ctrl_t lv)  load_default_ks (listview_ctrl_t lv)
352  {  {
# Line 334  load_default_ks (listview_ctrl_t lv) Line 356  load_default_ks (listview_ctrl_t lv)
356      p = get_reg_entry_keyserver ("Default");      p = get_reg_entry_keyserver ("Default");
357      if (!p)      if (!p)
358          return;          return;
359      for( i = 0; i < listview_count_items( lv, 0 ); i++ ) {      for (i = 0; i < listview_count_items( lv, 0); i++ ) {
360          listview_get_item_text( lv, i, 0, buf, sizeof (buf)-1 );          listview_get_item_text (lv, i, KS_COL_NAME, buf, sizeof (buf)-1);
361          if( !strncmp( p, buf, strlen( p ) ) ) {          if (!strncmp (p, buf, strlen (p))) {
362              listview_add_sub_item( lv, i, 2, "x" );              listview_add_sub_item (lv, i, KS_COL_DEFAULT, "x");
363              break;              break;
364          }          }
365      }      }
366      free_if_alloc (p);      free_if_alloc (p);
367  } /* load_default_ks */  }
   
368    
369    /* Save the selected keyserver from @lv as the default server. */
370  static int  static int
371  save_default_ks (listview_ctrl_t lv)  save_default_ks (listview_ctrl_t lv)
372  {  {
373      char buf[192], port[32];      char buf[192], port[32];
374      int idx, i;        int idx, i;  
375    
376      idx = listview_get_curr_pos( lv );      idx = listview_get_curr_pos (lv);
377      if( idx == -1 ) {      if (idx == -1) {
378          msg_box( NULL, _("Please select one of the servers."), _("Keyserver"), MB_ERR );          msg_box (NULL, _("Please select one of the servers."), _("Keyserver"), MB_ERR);
379          return -1;          return -1;
380      }      }
381      listview_get_item_text( lv, idx, 1, buf, sizeof (buf)-1 );      listview_get_item_text (lv, idx, KS_COL_NAME, buf, sizeof (buf)-1);
382      if( *buf != 'H' ) {      if (!strncmp (buf, "http", 4) && !strncmp (buf, "hkp", 3)) {
383          msg_box( NULL, _("Only HTTP keyserver can be used."), _("Keyserver"), MB_ERR );          msg_box (NULL, _("Only HTTP keyserver can be used."),
384                     _("Keyserver"), MB_ERR);
385          return -1;          return -1;
386      }      }
387      for (i = 0; i < listview_count_items( lv, 0 ); i++)      for (i = 0; i < listview_count_items (lv, 0); i++)
388          listview_add_sub_item (lv, i, 2, "");          listview_add_sub_item (lv, i, KS_COL_DEFAULT, "");
389      listview_add_sub_item (lv, idx, 2, "x");      listview_add_sub_item (lv, idx, KS_COL_DEFAULT, "x");
390      listview_get_item_text (lv, idx, 0, buf, sizeof (buf)-1);      listview_get_item_text (lv, idx, KS_COL_NAME, buf, sizeof (buf)-1);
391      set_reg_entry_keyserver ("Default", buf);      set_reg_entry_keyserver ("Default", buf);
392      i = kserver_get_port (lv);      i = kserver_get_port (lv);
393      sprintf (port, "%d", i);      sprintf (port, "%d", i);
394      set_reg_entry_keyserver ("Default_Port", port);      set_reg_entry_keyserver ("Default_Port", port);
395      keyserver_set_default (buf, (u16)i);      keyserver_set_default (buf, (u16)i);
396      return 0;      return 0;
397  } /* save_default_ks */  }
398    
399    
400  int  int
401  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)
402  {  {
403      struct listview_column_s keyserver[] = {      struct listview_column_s keyserver[] = {
404          {0, 160, (char *)_("DNS Name")},                  {0, 160, (char *)_("DNS Name")},
405          {1,  52, (char *)_("Protocol")},          {1,  46, (char *)_("Port")},
406          {2,  46, (char *)_("Default")},          {2,  60, (char *)_("Default")},
         {3,  46, (char *)_("Port")},  
407          {0,   0, NULL}          {0,   0, NULL}
408      };      };
409        HICON ico[1];
410      listview_ctrl_t lv;      listview_ctrl_t lv;
411      char buf[32];      char buf[32];
412      int j;      int j;
413    
414        ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_COMPUTER);
415      listview_new (&lv);          listview_new (&lv);    
416      lv->ctrl = hwnd;            lv->ctrl = hwnd;
417      for (j=0; keyserver[j].fieldname; j++)      for (j=0; keyserver[j].fieldname; j++)
418          listview_add_column (lv, &keyserver[j]);                  listview_add_column (lv, &keyserver[j]);
419        listview_set_image_list (lv, ico, 1);
420      for (j = 0; j<MAX_KEYSERVERS; j++) {      for (j = 0; j<MAX_KEYSERVERS; j++) {
421          if (!server[j].used)          if (!server[j].used)
422              continue;              continue;
423          listview_add_item (lv, " ");          listview_add_item_image (lv, " ", 0);
424          listview_add_sub_item (lv, 0, 0, server[j].name);          listview_add_sub_item (lv, 0, KS_COL_NAME, server[j].name);
         switch (server[j].proto) {  
         case KSPROTO_HTTP:  
             listview_add_sub_item( lv, 0, 1, "H" ); break;  
         case KSPROTO_LDAP:  
             listview_add_sub_item( lv, 0, 1, "L" ); break;  
         case KSPROTO_FINGER:  
             listview_add_sub_item( lv, 0, 1, "F" ); break;  
         }  
425          sprintf (buf, "%d", server[j].port);          sprintf (buf, "%d", server[j].port);
426          listview_add_sub_item (lv, 0, 3, buf);          listview_add_sub_item (lv, 0, KS_COL_PORT, buf);
427      }      }
428      load_default_ks (lv);      load_default_ks (lv);
429      if (listview_count_items (lv, 0) == 0) {      if (listview_count_items (lv, 0) == 0) {
430          listview_add_item (lv, "");          listview_add_item (lv, "");
431          listview_add_sub_item (lv, 0, 0, DEF_HKP_KEYSERVER);          listview_add_sub_item (lv, 0, KS_COL_NAME, DEF_HKP_KEYSERVER);
         listview_add_sub_item (lv, 0, 1, "H");  
432      }      }
433      listview_set_ext_style (lv);      listview_set_ext_style (lv);
434      *r_lv = lv;      *r_lv = lv;
# Line 420  keyserver_list_build (listview_ctrl_t *r Line 436  keyserver_list_build (listview_ctrl_t *r
436  }  }
437    
438    
439    static void
440    keyserver_remove (listview_ctrl_t lv)
441    {
442        char name[100];
443        int pos = listview_get_curr_pos (lv);
444        int i;
445    
446        listview_get_item_text (lv, pos, KS_COL_NAME, name, sizeof (name)-1);
447        for (i=0; i < MAX_KEYSERVERS; i++) {
448            if (server[i].name && strcmp (server[i].name, name) == 0)
449                server[i].used = 0;
450        }
451        listview_del_item (lv, pos);
452    }
453    
454    
455    static void
456    keyserver_edit (listview_ctrl_t lv, keyserver_rec_t ctx)
457    {
458        char buf[16];
459        bool fnd = false;
460        int i;
461    
462        for (i=0; i < MAX_KEYSERVERS; i++) {
463            if (server[i].name && strcmp (server[i].name, ctx->name) == 0) {
464                fnd = true;
465                break;
466            }
467        }
468        if (!fnd)
469            return;
470        server[i].port = ctx->port;
471    
472        i = listview_get_curr_pos (lv);
473        sprintf (buf, "%d", ctx->port);
474        listview_add_sub_item (lv, i, KS_COL_NAME, ctx->name);
475        listview_add_sub_item (lv, i, KS_COL_PORT, buf);
476    }
477    
478    static void
479    keyserver_add (listview_ctrl_t lv, keyserver_rec_t ctx)
480    {
481        char buf[16];
482        bool fnd = false;
483        int i;
484    
485        for (i=0; i < MAX_KEYSERVERS; i++) {
486            if (server[i].used == 0) {
487                fnd = true;
488                break;
489            }
490        }
491        if (!fnd) {
492            msg_box (NULL, _("No space for new keyserver entry"),
493                     _("Keyserver"), MB_ERR);
494            return;
495        }
496        free_if_alloc (server[i].name);
497        server[i].name = m_strdup (ctx->name);
498        server[i].port = ctx->port;
499        server[i].proto = ctx->proto;
500        server[i].used = 1;
501    
502        sprintf (buf, "%d", ctx->port);
503        listview_add_item (lv, " ");
504        listview_add_sub_item (lv, 0, KS_COL_NAME, ctx->name);
505        listview_add_sub_item (lv, 0, KS_COL_PORT, buf);
506    }
507    
508    
509    static void
510    fill_keyserv_types (HWND dlg)
511    {
512        HWND h = GetDlgItem (dlg, IDC_KSERVADD_TYPES);
513        combox_add_string (h, _("HKP Keyserver"));
514        combox_add_string (h, _("LDAP Keyserver"));
515        combox_add_string (h, _("Finger Keyserver"));
516        SendMessage (h, CB_SETCURSEL, 0, 0);
517    }
518    
519    
520    /* Dialog box procedure for modify keyservers. */
521    BOOL CALLBACK
522    keyserver_modify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
523    {
524        static keyserver_rec_t ctx;
525        char tmp[128];
526    
527        switch (msg) {
528        case WM_INITDIALOG:
529            fill_keyserv_types (dlg);
530            ctx = (keyserver_rec_t)lparam;
531            if (ctx->mode) {
532                SendDlgItemMessage (dlg, IDC_KSERVADD_TYPES, CB_SETCURSEL, ctx->proto, 0);
533                SetDlgItemText (dlg, IDC_KSERVADD_HOST, ctx->name);
534                SetDlgItemInt (dlg, IDC_KSERVADD_PORT, ctx->port, FALSE);
535                EnableWindow (GetDlgItem (dlg, IDC_KSERVADD_HOST), FALSE);
536                EnableWindow (GetDlgItem (dlg, IDC_KSERVADD_TYPES), FALSE);
537            }
538            else
539                SetDlgItemInt (dlg, IDC_KSERVADD_PORT, 11371, FALSE);
540            SetWindowText (dlg, _("Edit Keyserver"));
541            SetDlgItemText (dlg, IDOK, _("&Add"));
542            SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
543            SetDlgItemText (dlg, IDC_KSERVADD_TYPEINF, _("Type:"));
544            SetDlgItemText (dlg, IDC_KSERVADD_PORTINF, _("Port:"));
545            SetDlgItemText (dlg, IDC_KSERVADD_HOSTINF, _("Host name:"));
546            SetForegroundWindow (dlg);
547            break;
548    
549        case WM_COMMAND:
550            switch (LOWORD (wparam)) {
551            case IDOK:
552                if (!GetDlgItemText (dlg, IDC_KSERVADD_HOST, tmp, sizeof (tmp)-1)) {
553                    msg_box (dlg, _("Please enter a host name"), _("Keyserver"), MB_ERR);
554                    return FALSE;
555                }      
556                ctx->port = GetDlgItemInt (dlg, IDC_KSERVADD_PORT, NULL, FALSE);
557                if (ctx->port > 65535) {
558                    msg_box (dlg, _("Invalid port, valid numbers are < 65535"), _("Keyserver"), MB_ERR);
559                    return FALSE;
560                }
561                ctx->proto = SendDlgItemMessage (dlg, IDC_KSERVADD_TYPES, CB_GETCURSEL, 0, 0);
562                ctx->cancel = false;
563                ctx->name[0] = '\0';
564                if (!strstr (tmp, "://")) {
565                    switch (ctx->proto) {
566                    case KSPROTO_HTTP: strcpy (ctx->name, "http://"); break;
567                    case KSPROTO_LDAP: strcpy (ctx->name, "ldap://"); break;
568                    case KSPROTO_FINGER:strcpy (ctx->name, "finger://"); break;
569                    }
570                }
571                strcat (ctx->name, tmp);
572                ctx->cancel = false;
573                EndDialog (dlg, TRUE);
574                break;
575    
576            case IDCANCEL:
577                ctx->cancel = true;
578                EndDialog (dlg, FALSE);
579                break;
580            }
581            break;
582        }
583    
584        return FALSE;
585    }
586    
587  /* Dialog box procedure to access keyservers. */  /* Dialog box procedure to access keyservers. */
588  BOOL CALLBACK  BOOL CALLBACK
589  keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
590  {  {
591      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
592      static int lv_idx = 0;      static int lv_idx = 0;
     static struct genkey_s *key;  
593      keyserver_ctx ksc;      keyserver_ctx ksc;
594        struct keyserver_rec_s edit;
595      char kserver[128], pattern[128];      char kserver[128], pattern[128];
596      char proto[16];      char proto[16], *fpr = NULL;
597      int rc, proto_nr = 0;      int rc, proto_nr = 0;
598            
599      switch (msg) {      switch (msg) {
600      case WM_INITDIALOG:      case WM_INITDIALOG:
         if (lparam != 0)  
             key = (struct genkey_s*)lparam;  
601          SetWindowText (dlg, _("Keyserver Access"));          SetWindowText (dlg, _("Keyserver Access"));
602          SetDlgItemText (dlg, IDC_KEYSERVER_RECV, _("&Receive"));          SetDlgItemText (dlg, IDC_KEYSERVER_RECV, _("&Receive"));
603          SetDlgItemText (dlg, IDC_KEYSERVER_SEND,          SetDlgItemText (dlg, IDC_KEYSERVER_SEND,
# Line 456  keyserver_dlg_proc (HWND dlg, UINT msg, Line 618  keyserver_dlg_proc (HWND dlg, UINT msg,
618      case WM_NOTIFY:      case WM_NOTIFY:
619          NMHDR *notify;          NMHDR *notify;
620          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
621          if (notify && notify->code == NM_CLICK          if (!notify)
622                break;
623            if (notify->code == NM_CLICK
624              && notify->idFrom == IDC_KEYSERVER_LIST)              && notify->idFrom == IDC_KEYSERVER_LIST)
625              lv_idx = listview_get_curr_pos (lv);              lv_idx = listview_get_curr_pos (lv);
626            else if (notify->code == NM_RCLICK &&
627                     notify->idFrom == IDC_KEYSERVER_LIST) {
628                POINT p;
629                GetCursorPos (&p);
630                HMENU hm, pop;
631                hm = LoadMenu (glob_hinst, (LPCTSTR)IDR_WINPT_KEYSERVER_CTX);
632                pop = GetSubMenu (hm, 0);
633                set_menu_text (pop, ID_KSERVCTX_ADD, _("&Add"));
634                set_menu_text (pop, ID_KSERVCTX_DEL, _("&Remove"));
635                set_menu_text (pop, ID_KSERVCTX_EDIT, _("&Edit"));
636                TrackPopupMenu (pop, 0, p.x, p.y, 0, dlg, NULL);
637                DestroyMenu (hm);
638                DestroyMenu (pop);
639            }
640    
641          return TRUE;          return TRUE;
642                    
643      case WM_DESTROY:      case WM_DESTROY:
# Line 492  keyserver_dlg_proc (HWND dlg, UINT msg, Line 671  keyserver_dlg_proc (HWND dlg, UINT msg,
671                      return FALSE;                      return FALSE;
672                  }                  }
673              }              }
674              listview_get_item_text (lv, lv_idx, 1, proto, sizeof (proto)-1);              listview_get_item_text (lv, lv_idx, KS_COL_NAME,
675              if (*proto == 'L') {                                      proto, sizeof (proto)-1);
676                if (!strncmp (proto, "ldap", 4)) {
677                  msg_box (dlg, _("This is not implemented yet!"),                  msg_box (dlg, _("This is not implemented yet!"),
678                           _("Keyserver"), MB_ERR);                           _("Keyserver"), MB_ERR);
679                  return FALSE;                  return FALSE;
680              }              }
681              listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);              listview_get_item_text (lv, lv_idx, KS_COL_NAME,
682                                        kserver, sizeof (kserver)-1);
683              if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {              if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {
684                  msg_box (dlg, _("Please enter the search pattern."),                  msg_box (dlg, _("Please enter the search pattern."),
685                           _("Keyserver"), MB_INFO);                           _("Keyserver"), MB_INFO);
# Line 521  keyserver_dlg_proc (HWND dlg, UINT msg, Line 702  keyserver_dlg_proc (HWND dlg, UINT msg,
702                      return FALSE;                      return FALSE;
703                  }                  }
704              }              }
705              listview_get_item_text( lv, lv_idx, 1, proto, sizeof (proto)-1 );              listview_get_item_text (lv, lv_idx, KS_COL_NAME,
706                                        proto, sizeof (proto)-1);
707              proto_nr = KSPROTO_HTTP;              proto_nr = KSPROTO_HTTP;
708              if (*proto == 'L')              if (!strncmp  (proto, "ldap", 4))
709                  proto_nr = KSPROTO_LDAP;                  proto_nr = KSPROTO_LDAP;
710              else if (*proto == 'F')              else if (!strncmp (proto, "finger", 6))
711                  proto_nr = KSPROTO_FINGER;                  proto_nr = KSPROTO_FINGER;
712              listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);              listview_get_item_text (lv, lv_idx, KS_COL_NAME,
713              if( !GetDlgItemText( dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {                                      kserver, sizeof (kserver)-1);
714                if (!GetDlgItemText(dlg, IDC_KEYSERVER_SEARCH,
715                                    pattern, sizeof (pattern)-1)) {
716                  msg_box (dlg, _("Please enter the search pattern."),                  msg_box (dlg, _("Please enter the search pattern."),
717                           _("Keyserver"), MB_INFO);                           _("Keyserver"), MB_INFO);
718                  return FALSE;                  return FALSE;
719              }              }
720              if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) {              if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) {
721                  msg_box (dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO);                  msg_box (dlg, _("Only keyids are allowed."),
722                             _("Keyserver"), MB_INFO);
723                  return FALSE;                  return FALSE;
724              }              }
725              else if (proto_nr == KSPROTO_FINGER) {              else if (proto_nr == KSPROTO_FINGER) {
726                  if (strchr (pattern, '@') || strchr (pattern, ' ')) {                  if (strchr (pattern, '@') || strchr (pattern, ' ')) {
727                      msg_box (dlg, _("Only enter the name of the user."),                      msg_box (dlg, _("Only enter the name of the user."),
728                               _("FINGER Keyserver"), MB_INFO);                               _("Keyserver"), MB_INFO);
729                      return FALSE;                      return FALSE;
730                  }                  }
731              }              }
732              else if (check_pattern (pattern)) {              else if (check_pattern (pattern)) {
733                  msg_box (dlg, _("Only email addresses or keyids are allowed."),                  msg_box (dlg, _("Only email addresses or keyids are allowed."),
734                          _("HKP Keyserver"), MB_INFO);                          _("Keyserver"), MB_INFO);
735                  return FALSE;                  return FALSE;
736              }              }
737              rc = hkp_recv_key2 (dlg, kserver, kserver_get_port (lv),              rc = keyserver_recv_key (dlg, kserver, kserver_get_port (lv),
738                                  pattern, proto_nr, 0, key? &key->fpr : NULL);                                       pattern, proto_nr, 0,
739              if (!rc && key->fpr != NULL) {                                       &fpr);
740                  keycache_update (0, key->fpr);              if (!rc && fpr != NULL) {
741                  get_pubkey (key->fpr, &key->newkey);                  keycache_update (0, fpr);
742                  /* we do not need the fingerprint any longer. */                  free_if_alloc (fpr);
                 free_if_alloc (key->fpr);  
743              }              }
744              return TRUE;              return TRUE;
745    
746          case IDC_KEYSERVER_DEFAULT:          case IDC_KEYSERVER_DEFAULT:
747              save_default_ks (lv);              save_default_ks (lv);
748              break;              break;
749    
750            case ID_KSERVCTX_ADD:
751                memset (&edit, 0, sizeof (edit));
752                edit.mode = false;
753                dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_ADD, dlg,
754                                    keyserver_modify_dlg_proc,
755                                    (LPARAM)&edit, _("Edit Keyserver"), 0);
756                if (!edit.cancel)
757                    keyserver_add (lv, &edit);
758                return TRUE;
759    
760            case ID_KSERVCTX_EDIT:
761                memset (&edit, 0, sizeof (edit));
762                edit.mode = true;
763                listview_get_item_text (lv, lv_idx, KS_COL_NAME,
764                                        edit.name, sizeof (edit.name)-1);
765                listview_get_item_text (lv, lv_idx, KS_COL_PORT, pattern, 32);
766                edit.port = atoi (pattern);
767                if (!strncmp (edit.name, "hkp", 3) || !strncmp (edit.name, "http", 4))
768                    edit.proto = KSPROTO_HTTP;
769                else if (!strncmp (edit.name, "ldap", 4))
770                    edit.proto = KSPROTO_LDAP;
771                else
772                    edit.proto = KSPROTO_FINGER;
773                dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_ADD, dlg,
774                                    keyserver_modify_dlg_proc,
775                                    (LPARAM)&edit, _("Edit Keyserver"), 0);
776                if (!edit.cancel)
777                    keyserver_edit (lv, &edit);
778                break;
779    
780            case ID_KSERVCTX_DEL:
781                keyserver_remove (lv);
782                return TRUE;
783                            
784          case IDCANCEL:          case IDCANCEL:
785              EndDialog (dlg, FALSE);              EndDialog (dlg, FALSE);

Legend:
Removed from v.129  
changed lines
  Added in v.165

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26