/[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 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC revision 273 by twoaday, Fri Dec 8 10:22:17 2006 UTC
# Line 1  Line 1 
1  /* wptKeyserverDlg.cpp - Keyserver dialog  /* wptKeyserverDlg.cpp - Keyserver dialog
2   *      Copyright (C) 2000-2005 Timo Schulz   *      Copyright (C) 2000-2006 Timo Schulz
3   *   *      Copyright (C) 2005, 2006 g10 Code GmbH
4   * This file is part of WinPT.   *
5   *   * This file is part of WinPT.
6   * WinPT is free software; you can redistribute it and/or modify   *
7   * it under the terms of the GNU General Public License as published by   * WinPT is free software; you can redistribute it and/or modify
8   * the Free Software Foundation; either version 2 of the License, or   * it under the terms of the GNU General Public License as published by
9   * (at your option) any later version.   * the Free Software Foundation; either version 2 of the License, or
10   *   * (at your option) any later version.
11   * WinPT is distributed in the hope that it will be useful,   *
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * WinPT is distributed in the hope that it will be useful,
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * GNU General Public License for more details.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   *   * GNU General Public License for more details.
16   * You should have received a copy of the GNU General Public License   *
17   * along with WinPT; if not, write to the Free Software Foundation,   * You should have received a copy of the GNU General Public License
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * along with WinPT; if not, write to the Free Software Foundation,
19   */   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20     */
21  #include <windows.h>  #ifdef HAVE_CONFIG_H
22  #include <commctrl.h>  #include <config.h>
23  #include <malloc.h>  #endif
24    
25  #include "../resource.h"  #include <windows.h>
26  #include "wptKeyserver.h"  #include <commctrl.h>
27  #include "wptErrors.h"  #include <ctype.h>
28  #include "wptTypes.h"  
29  #include "wptCommonCtl.h"  #include "resource.h"
30  #include "wptNLS.h"  #include "wptErrors.h"
31  #include "wptW32API.h"  #include "wptTypes.h"
32  #include "wptVersion.h"  #include "wptCommonCtl.h"
33  #include "wptGPG.h"  #include "wptNLS.h"
34  #include "wptKeyManager.h"  #include "wptW32API.h"
35  #include "wptContext.h" /* for passphrase_s */  #include "wptVersion.h"
36  #include "wptDlgs.h"  #include "wptGPG.h"
37    #include "wptGPGME.h"
38    #include "wptKeyserver.h"
39  #define MAX_KEYSIZE 70000  #include "wptContext.h" /* for passphrase_s */
40    #include "wptKeyManager.h"
41  char * get_reg_entry_keyserver (const char *);  #include "wptDlgs.h"
42  int set_reg_entry_keyserver (const char *, const char *);  #include "wptUTF8.h"
43    #include "wptRegistry.h"
44    #include "wptKeylist.h"
45  static void  
46  hkp_err_box (HWND dlg, const char * host, u16 port, int rc)  char* get_reg_entry_keyserver (const char *);
47  {  int set_reg_entry_keyserver (const char *, const char *);
48      const char *err = kserver_strerror();  
49    /* Symbolic column IDs */
50      log_box( _("Keyserver"), MB_ERR, "%s:%d: %s", host, port, winpt_strerror (rc));  enum { KS_COL_NAME = 0, KS_COL_PORT };
51      if (err)  
52          msg_box (dlg, err, wsock_strerror (), MB_ERR);  /* Callback context to modify (add, edit) keyserver items. */
53  } /* hkp_err_box */  struct keyserver_rec_s {
54        char name[200];     /* hostname */
55        int  proto;         /* protocol */
56  int      int  port;          /* used port */
57  hkp_send_key (HWND dlg, const char *kserver, u16 port, const char *pattern)      bool mode;          /* true = edit */
58  {      bool cancel;
59      gpgme_ctx_t c;        };
60      gpgme_recipients_t rset;  typedef struct keyserver_rec_s *keyserver_rec_t;
61      gpgme_data_t keydata;  
62      gpgme_error_t ec;  
63      char *rawkey = NULL, msg[1024];  /* Print out keyserver error and a possible Winsock error. */
64      int rc;  static void
65        hkp_err_box (HWND dlg, const char *host, WORD port, int rc)
66      ec = gpgme_recipients_new( &rset );  {
67      if( ec )      const char *err = kserver_strerror ();
68          BUG( NULL );      const char *ws_err = wsock_strerror ();
69      gpgme_recipients_add_name( rset, pattern );      
70      ec = gpgme_new( &c );      if (ws_err && strlen (ws_err) > 0)
71      if( ec )          log_box (_("Keyserver"), MB_ERR, "%s:%d: %s", host, port, ws_err);
72          BUG( NULL );      else
73      gpgme_control( c, GPGME_CTRL_ARMOR, 1 );          log_box (_("Keyserver"), MB_ERR, "%s:%d: %s\n%s",
74      ec = gpgme_data_new( &keydata );                   host, port, winpt_strerror (rc), err? err : "");
75      if( ec )  }
76          BUG( NULL );  
77      rc = (int) gpgme_op_export( c, rset, keydata );  
78      if( rc ) {  /* Send the extracted key with keyid @pattern to the
79          msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Export"), MB_ERR );     keyserver @kserver (port @port).
80          goto leave;     Return value: 0 on success. */
81      }  int
82      rawkey = gpgme_data_release_and_return_string (keydata);  hkp_send_key (HWND dlg, const char *kserver, WORD port, const char *pattern)
83      rc = kserver_sendkey (kserver, port, rawkey, strlen (rawkey));  {
84      if (rc) {      GPGME *gpg;
85          hkp_err_box (dlg, kserver, port, rc);      gpgme_error_t ec;
86          goto leave;      char *rawkey = NULL;
87      }      char msg[256];
88            
89      _snprintf (msg, sizeof (msg) -1, _("Key '%s' successfully sent"), pattern);      gpg = new GPGME ();
90      status_box (dlg, msg, _("GnuPG status"));      gpg->setArmor (true);
91            ec = gpg->exportToBuffer (pattern, &rawkey);
92  leave:      if (ec) {
93      gpgme_release (c);          msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR);
94      gpgme_recipients_release (rset);          goto leave;
95      safe_free (rawkey);      }
96      return rc;      op_begin ();
97  } /* hkp_send_key */      ec = kserver_sendkey (kserver, port, rawkey, strlen (rawkey));
98        op_end ();
99        if (ec) {
100  int          hkp_err_box (dlg, kserver, port, ec);
101  hkp_recv_key (HWND dlg, const char *kserver, u16 port,          goto leave;
102                const char *pattern, int proto, int flags)      }
103  {      
104      gpgme_ctx_t ctx;      _snprintf (msg, sizeof (msg) -1, _("Key '%s' successfully sent"), pattern);
105      gpgme_data_t keydata;      status_box (dlg, msg, _("GnuPG status"));
106      gpgme_error_t ec;      
107      int rc, import_res[14];  leave:
108      char *rawkey = NULL, msg[384];      delete gpg;
109            free_if_alloc (rawkey);
110      rawkey = new char[MAX_KEYSIZE];      return ec? -1 : 0;
111      if (!rawkey)  }
112          BUG (0);  
113      memset (rawkey, 0, MAX_KEYSIZE);  
114      if( proto == KSPROTO_LDAP ) {  
115          rc = ldap_recvkey( kserver, pattern, rawkey, MAX_KEYSIZE-1 );  /* Show all received keys from the keyserver. */
116          if( rc ) {  static void
117              msg_box( dlg, _("LDAP key import failed.\n"  show_imported_keys (gpgme_import_result_t res)
118                              "Please make sure you have an online connection"  {
119                              " and gpgkeys_ldap.exe is installed"),      gpgme_import_status_t t;
120                              _("Keyserver"), MB_ERR );      gpgme_key_t key;
121              free_if_alloc( rawkey );      gpgme_data_t msg;
122              return rc;      gpgme_ctx_t ctx;
123          }      gpgme_error_t err;
124      }      const char *s;
125      else if (proto == KSPROTO_FINGER) {      char *p, *uid;
126          rc = finger_recvkey (kserver, pattern, rawkey, MAX_KEYSIZE-1);      size_t n=0;
127          if (rc) {  
128              log_box (_("Keyserver"), MB_ERR, _("Finger key import failed: %s\n"),      if (!res)
129                       winpt_strerror (rc));          return;
130              free_if_alloc (rawkey);  
131              return rc;      err = gpgme_data_new (&msg);
132          }      if (err)
133      }          BUG (NULL);
134      else if( ( rc = kserver_recvkey( kserver, port, kserver_check_keyid( pattern ),      err = gpgme_new (&ctx);
135                                       rawkey, MAX_KEYSIZE-1 ) ) ) {      if (err)
136          hkp_err_box (dlg, kserver, port, rc);          BUG (NULL);
137          free_if_alloc (rawkey);      if (res->considered > 1) {
138          return rc;          s = _("WARNING: multiple keys matched request.\n\n");
139      }          gpgme_data_write (msg, s, strlen (s));
140      else {      }
141          if( !strstr( rawkey, "BEGIN PGP PUBLIC KEY BLOCK" ) ) {  
142              msg_box( dlg, _("This is not a valid OpenPGP key."), _("Keyserver"), MB_ERR );      if (res->unchanged == res->considered)
143              goto leave;          s = _("Key(s) successfully received but nothing was changed.");
144          }      else
145          ec = gpgme_new( &ctx );          s = _("Key(s) sucessfully received and imported.");
146          if( ec )          // nice to have the amount of new signatures...
147              BUG( NULL );      gpgme_data_write (msg, s, strlen (s));
148          gpgme_data_new_from_mem( &keydata, rawkey, strlen( rawkey ), 1 );      gpgme_data_write (msg, "\n\n", 2);
149          rc = gpgme_op_import( ctx, NULL, keydata );  
150          if( rc ) {      for (t=res->imports; t; t = t->next) {
151              msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Import"), MB_ERR );          if (!gpgme_get_key (ctx, t->fpr, &key, 0)) {
152              goto leave;              s = uid = utf8_to_native (key->uids->uid);
153          }              gpgme_data_write (msg, s, strlen (s));
154          gpgme_get_import_status (ctx, import_res, NULL);              gpgme_data_write (msg, "\n", 1);
155      }              gpgme_key_release (key);
156                    safe_free (uid);
157      /* if we use the refresh mode, a lot of keys will be fetched and thus only          }
158         a summarize at the end is presented and not for each key. */      }
159      if (!(flags & KM_KS_REFRESH)) {      gpgme_data_write (msg, "\0", 1);
160          if (import_res[GPGME_IMPSTAT_NPKEYS] == 0) {      p = gpgme_data_release_and_get_mem (msg, &n);
161              _snprintf (msg, DIM (msg)-1,      if (p != NULL) {
162                         _("Key '%s' successfully received but nothing was changed."), pattern );          msg_box (NULL, p, _("Imported Keys"), MB_INFO);
163              status_box (dlg, msg, _("GnuPG Status"));          gpgme_free (p);
164              rc = WPTERR_GENERAL;      }
165              goto leave;      gpgme_release (ctx);
166          }  }
167          _snprintf (msg, DIM (msg)-1, _("Key '%s' sucessfully received and imported."), pattern);  
168          status_box (dlg, msg, _("GnuPG Status"));  
169      }  /* Receive a key from the keyserver @kserver (port @port)
170           with the pattern @pattern.
171  leave:     Return value: 0 on success. */
172      free_if_alloc (rawkey);  static int
173      gpgme_release (ctx);  keyserver_recv_key (HWND dlg, const char *kserver, WORD port,
174      gpgme_data_release (keydata);                      const char *pattern, int proto, int flags,
175                        char **r_fpr)
176      return rc;  {    
177  } /* hkp_recv_key */      gpgme_import_result_t import_res = NULL;
178        gpgme_error_t err;
179        GPGME *gpg = NULL;
180  #define my_iskeychar(a) ( ( (a) >='0' && (a) <= '9' ) || ( (a) >= 'A' && (a) <= 'F' ) )      char *rawkey = NULL;
181        size_t keylen = 0;
182  static int      int rc;
183  check_pattern( const char *pattern )  
184  {      if (proto == KSPROTO_LDAP) {
185      int rc = 1;          rc = ldap_recvkey (kserver, pattern, &rawkey, &keylen);
186                if (rc) {
187      /* Whitespace are not allowed! */              msg_box (dlg, _("LDAP key import failed.\n"
188      if( strchr( pattern, ' ') ) {                              "Please make sure you have an online connection"
189          rc = WPTERR_GENERAL;                              " and gpgkeys_ldap.exe is installed"),
190          goto leave;                              _("Keyserver"), MB_ERR);
191      }              free_if_alloc (rawkey);
192                    return rc;
193      if( (( strstr( pattern, "0x" ) ) && ( strlen( pattern ) == 10 ) )          }
194           || (strstr(pattern, "0x")) && ( strlen( pattern )  == 18 ) ) {      }
195          rc = 0;      else if (proto == KSPROTO_FINGER) {
196          goto leave;          rc = finger_recvkey (kserver, pattern, &rawkey, &keylen);
197      }          if (rc) {
198                    log_box (_("Keyserver"), MB_ERR,
199      if( (( my_iskeychar( pattern[0] )) && ( strlen( pattern )  == 8 ) )                       _("Finger key import failed: %s\n"), winpt_strerror (rc));
200           || (my_iskeychar(pattern[0])) && ( strlen( pattern ) == 16) ) {              free_if_alloc (rawkey);
201          rc = 0;              return rc;
202          goto leave;          }
203      }      }
204            else if ((rc = kserver_recvkey (kserver, port,
205      if( ( strchr( pattern, '@' ) ) && ( strlen( pattern ) >= 3 ) ) {                                      kserver_check_keyid (pattern),
206          rc = 0;                                      &rawkey, &keylen))) {
207          goto leave;          hkp_err_box (dlg, kserver, port, rc);
208      }          free_if_alloc (rawkey);
209                return rc;
210  leave:      }
211      return rc;  
212  } /* check_pattern */      if (!strstr (rawkey, "BEGIN PGP PUBLIC KEY BLOCK")) {
213            msg_box (dlg, _("This is not a valid OpenPGP key."),
214                     _("Keyserver"), MB_ERR);
215  static void          goto leave;
216  set_proxy (HWND dlg)      }
217  {      gpg = new GPGME ();
218      char proxy[384];      err = gpg->importFromBuffer (rawkey);
219      int port = 0;      if (err) {
220                msg_box (dlg, gpgme_strerror (err), _("Import"), MB_ERR);
221      strcpy (proxy, "HTTP proxy: ");          goto leave;
222      if (kserver_get_proxy (&port)) {      }
223          char t[256];      import_res = gpg->importGetResult ();
224          const char *http = kserver_get_proxy (&port);      if (import_res && r_fpr)
225          _snprintf (t, sizeof (t) - 1, "\"%s:%d\"", http, port);          *r_fpr = m_strdup (import_res->imports->fpr);
226          strcat (proxy, t);      
227      }      /* if we use the refresh mode, a lot of keys will be fetched and thus only
228      else         a summarize at the end is presented and not for each key. */
229          strcat( proxy, "none" );      if (import_res && !(flags & KM_KS_REFRESH)) {
230      SetDlgItemText( dlg, IDC_KEYSERVER_PROXY, proxy );          show_imported_keys (import_res);
231  } /* set_proxy */          if (import_res->unchanged == import_res->considered) {
232                rc = WPTERR_GENERAL; /* no keys updated. */
233                goto leave;
234  static int inline          }
235  kserver_get_pos (listview_ctrl_t lv)      }
236  {  
237      if (listview_count_items (lv, 0) == 1)  leave:
238          return 0;      free_if_alloc (rawkey);
239      return listview_get_curr_pos (lv);      if (gpg != NULL)
240  }          delete gpg;
241        return rc;
242    }
243  static u16 inline  
244  kserver_get_port (listview_ctrl_t lv)  
245  {  /* Alias for keyserver_recv_key but without the ability to return
246      char buf[16];     the fingerprint of the key. */
247    int
248      listview_get_item_text (lv, kserver_get_pos (lv), 3, buf, 15);  hkp_recv_key (HWND dlg, const char *kserver, WORD port,
249      return (u16)strtoul (buf, NULL, 10);                const char *pattern, int proto, int flags)
250  }  {
251        return keyserver_recv_key (dlg, kserver, port, pattern,
252  static void                                 proto, flags, NULL);
253  load_default_ks (listview_ctrl_t lv)  }
254  {  
255      char * p, buf[192];  int
256      int i;  hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
257                   const char *pattern, int proto, char **r_fpr)
258      p = get_reg_entry_keyserver ("Default");  {
259      if (!p)      return keyserver_recv_key (dlg, kserver, port, pattern,
260          return;                                 proto, 0, r_fpr);
261      for( i = 0; i < listview_count_items( lv, 0 ); i++ ) {  }
262          listview_get_item_text( lv, i, 0, buf, sizeof (buf)-1 );  
263          if( !strncmp( p, buf, strlen( p ) ) ) {  
264              listview_add_sub_item( lv, i, 2, "x" );  /* Utility function to fetch a key from the keyserver
265              break;     based on a given signature (@sig).
266          }     Return 0 on success. */
267      }  int
268      free_if_alloc (p);  fetch_key_from_keyserver (HWND dlg, gpgme_signature_t sig)
269  } /* load_default_ks */  {
270        const char *keyid;
271        int id;
272  static int  
273  save_default_ks (listview_ctrl_t lv)      if (!sig->fpr)
274  {          return FALSE;
275      char buf[192], port[32];      keyid = get_keyid_from_fpr (sig->fpr);          
276      int idx, i;        id = log_box (_("Verify"), MB_INFO|MB_YESNO,
277                      _("Signature made %s using %s key ID 0x%s\n"
278      idx = listview_get_curr_pos( lv );                      "Cannot check signature: public key not found\n\n"
279      if( idx == -1 ) {                      "Do you want to try to retrieve the key from the keyserver?"),
280          msg_box( NULL, _("Please select one of the servers."), _("Keyserver"), MB_ERR );                    strtimestamp (sig->timestamp),
281          return -1;                    get_key_pubalgo (sig->pubkey_algo), keyid);
282      }      if (id == IDNO) {
283      listview_get_item_text( lv, idx, 1, buf, sizeof (buf)-1 );          msg_box (dlg, get_gpg_sigstat (GPGME_SIGSUM_KEY_MISSING),
284      if( *buf != 'H' ) {                   _("Verify"), MB_WARN);
285          msg_box( NULL, _("Only HTTP keyserver can be used."), _("Keyserver"), MB_ERR );          return -1;
286          return -1;      }
287      }  
288      for (i = 0; i < listview_count_items( lv, 0 ); i++)      if (!hkp_recv_key (dlg, default_keyserver, default_keyserver_port,
289          listview_add_sub_item (lv, i, 2, "");                         keyid, 0, 0)) {
290      listview_add_sub_item (lv, idx, 2, "x");          keycache_update (0, keyid);
291      listview_get_item_text (lv, idx, 0, buf, sizeof (buf)-1);          return 0;
292      set_reg_entry_keyserver ("Default", buf);      }
293      i = kserver_get_port (lv);      return -1;
294      sprintf (port, "%d", i);  }
295      set_reg_entry_keyserver ("Default_Port", port);  
296      keyserver_set_default (buf, (u16)i);  /* Check if the given pattern are either a valid
297      return 0;     email address, a {long, short} keyid or a fingerprint.
298  } /* save_default_ks */     Return 0 on success. */
299    static int
300    check_pattern (const char *pattern)
301  int  {    
302  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)      size_t i;
303  {  
304      struct listview_column_s keyserver[] = {      if (strchr (pattern, ' '))
305          {0, 160, (char *)_("DNS Name")},                  return WPTERR_GENERAL; /* do not allow white spaces. */
306          {1,  52, (char *)_("Protocol")},      
307          {2,  46, (char *)_("Default")},      if (strchr (pattern, '@') && strlen (pattern) >= 3 &&
308          {3,  46, (char *)_("Port")},          !check_email_address (pattern))
309          {0,   0, NULL}          return 0;
310      };  
311      listview_ctrl_t lv;      if (strstr (pattern, "0x"))
312      char buf[32];          pattern += 2;
313      int j;      if (strlen (pattern) != 8 &&
314            strlen (pattern) != 16 &&
315      listview_new (&lv);              strlen (pattern) != 40)
316      lv->ctrl = hwnd;                return WPTERR_GENERAL;
317      for (j=0; keyserver[j].fieldname; j++)  
318          listview_add_column (lv, &keyserver[j]);              for (i=0; i < strlen (pattern); i++) {
319      for (j = 0; j<MAX_KEYSERVERS; j++) {          if (!isxdigit (pattern[i]))
320          if (!server[j].used)              return WPTERR_GENERAL;
321              continue;      }
322          listview_add_item (lv, " ");      return 0;
323          listview_add_sub_item (lv, 0, 0, server[j].name);  }
324          switch (server[j].proto) {  
325          case KSPROTO_HTTP:  
326              listview_add_sub_item( lv, 0, 1, "H" ); break;  /* Return human readable name for the proxy protocol. */
327          case KSPROTO_LDAP:  static const char*
328              listview_add_sub_item( lv, 0, 1, "L" ); break;  name_from_proto (int proto)
329          case KSPROTO_FINGER:  {
330              listview_add_sub_item( lv, 0, 1, "F" ); break;      const char *s;
331          }  
332          sprintf (buf, "%d", server[j].port);      switch (proto) {
333          listview_add_sub_item (lv, 0, 3, buf);      case PROXY_PROTO_NONE:      s = ""; break;
334      }      case PROXY_PROTO_HTTP:      s = "HTTP"; break;
335      load_default_ks (lv);      case PROXY_PROTO_SOCKS5:    s = "SOCKS5"; break;
336      if (listview_count_items (lv, 0) == 0) {      default:                    s = "HTTP"; break;
337          listview_add_item (lv, "");      }
338          listview_add_sub_item (lv, 0, 0, DEF_HKP_KEYSERVER);      return s;
339          listview_add_sub_item (lv, 0, 1, "H");  }
340      }  
341      listview_set_ext_style (lv);  
342      *r_lv = lv;  static int inline
343      return 0;  kserver_get_pos (listview_ctrl_t lv)
344  }  {
345        if (listview_count_items (lv, 0) == 1)
346            return 0;
347  BOOL CALLBACK      return listview_get_curr_pos (lv);
348  keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  }
349  {  
350      static listview_ctrl_t lv = NULL;  
351      static int lv_idx = 0;  static WORD inline
352      int rc, proto_nr = 0;  kserver_get_port (listview_ctrl_t lv)
353      char kserver[128], pattern[128];  {
354      char proto[16];          char buf[16];
355      keyserver_ctx ksc;  
356            listview_get_item_text (lv, kserver_get_pos (lv),
357      switch ( msg ) {                              KS_COL_PORT, buf, sizeof (buf)-1);
358      case WM_INITDIALOG:      return (WORD)strtoul (buf, NULL, 10);
359  #ifndef LANG_DE  }
360          SetWindowText( dlg, _("Keyserver Access") );  
361          SetDlgItemText( dlg, IDC_KEYSERVER_SEND,  
362                          _("Send key (default is receiving)") );  static void
363          SetDlgItemText( dlg, IDC_KEYSERVER_INFO,  set_default_ks (listview_ctrl_t lv)
364                          _("Please enter the key ID or email address you search for"));  {
365          SetDlgItemText( dlg, IDC_KEYSERVER_INDEX, _("&Search") );      char *p, buf[128];
366  #endif      int i;
367          set_proxy (dlg);  
368          keyserver_list_build (&lv, GetDlgItem (dlg, IDC_KEYSERVER_LIST));      p = get_reg_entry_keyserver ("Default");
369          center_window (dlg);      if (!p)
370          SetForegroundWindow (dlg);          return;
371          return TRUE;      for (i=0; i < listview_count_items (lv, 0); i++) {
372                    listview_get_item_text (lv, i, KS_COL_NAME, buf, sizeof (buf)-1);      
373      case WM_NOTIFY:          if (!stricmp (buf, p)) {
374          NMHDR *notify;              listview_select_one (lv, i);
375          notify = (NMHDR *)lparam;              break;
376          if( notify && notify->code == NM_CLICK          }
377              && notify->idFrom == IDC_KEYSERVER_LIST )      }
378              lv_idx = listview_get_curr_pos( lv );      free_if_alloc (p);
379          return TRUE;  }
380            
381      case WM_DESTROY:  
382          if( lv ) {  /* Save the selected keyserver from @lv as the default server. */
383              listview_release( lv );  static int
384              lv = NULL;  save_default_ks (listview_ctrl_t lv)
385          }  {
386          lv_idx = 0;      char buf[192], port[32];
387          return FALSE;      int idx, i;  
388            
389      case WM_SYSCOMMAND:      idx = listview_get_curr_pos (lv);
390          if( LOWORD( wparam ) == SC_CLOSE )      if (idx == -1) {
391              EndDialog( dlg, TRUE );          msg_box (NULL, _("Please select one of the servers."),
392          return FALSE;                   _("Keyserver"), MB_ERR);
393                    return -1;
394      case WM_COMMAND:      }
395          switch( LOWORD( wparam ) ) {      listview_get_item_text (lv, idx, KS_COL_NAME, buf, sizeof (buf)-1);
396          case IDC_KEYSERVER_PROXSETT:      if (strnicmp (buf, "http", 4) && strnicmp (buf, "hkp", 3)) {
397              dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_PROXY, glob_hwnd,          msg_box (NULL, _("Only HKP keyserver can be used."),
398                                keyserver_proxy_dlg_proc, NULL,                   _("Keyserver"), MB_ERR);
399                                _("Proxy Settings"), IDS_WINPT_KEYSERVER_PROXY );          return -1;
400              set_proxy( dlg );      }
401              return TRUE;      set_reg_entry_keyserver ("Default", buf);
402                    i = kserver_get_port (lv);
403          case IDC_KEYSERVER_INDEX:      sprintf (port, "%d", i);
404              if (!lv_idx) {      set_reg_entry_keyserver ("Default_Port", port);
405                  lv_idx = kserver_get_pos (lv);      keyserver_set_default (buf, (WORD)i);
406                  if (lv_idx == -1) {      return 0;
407                      msg_box (dlg, _("Please select one of the keyservers."), _("Keyserver"), MB_INFO);  }
408                      return FALSE;  
409                  }  
410              }  int
411              listview_get_item_text (lv, lv_idx, 1, proto, sizeof (proto)-1);  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)
412              if (*proto == 'L') {  {
413                  msg_box( dlg, _("This is not implemented yet!"), _("Keyserver"), MB_ERR );      struct listview_column_s keyserver[] = {
414                  return FALSE;          {0, 180, (char *)_("DNS Name")},
415              }          {1,  55, (char *)_("Port")},
416              listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);          {0,   0, NULL}
417              if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {      };
418                  msg_box (dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO);      HICON ico[1];
419                  return FALSE;      listview_ctrl_t lv;
420              }      char buf[32];
421              ksc.name = kserver;      int j;
422              ksc.pattern = pattern;  
423              ksc.port = kserver_get_port (lv);      ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_COMPUTER);
424              DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_HKPSEARCH, dlg,      listview_new (&lv, hwnd);    
425                              hkpsearch_dlg_proc, (LPARAM) &ksc );      for (j=0; keyserver[j].fieldname; j++)
426              return TRUE;          listview_add_column (lv, &keyserver[j]);
427                    listview_set_image_list (lv, 16, 16, ico, 1);
428          case IDC_KEYSERVER_RECV:      for (j = 0; j < MAX_KEYSERVERS; j++) {
429              memset (&kserver, 0, sizeof (kserver));          if (!server[j].used)
430              if (!lv_idx) {              continue;
431                  lv_idx = kserver_get_pos (lv);          listview_add_item_image (lv, " ", 0);
432                  if (lv_idx == -1) {          listview_add_sub_item (lv, 0, KS_COL_NAME, server[j].name);
433                      msg_box( dlg, _("Please select one of the keyservers."), _("Keyserver"), MB_INFO );          sprintf (buf, "%d", server[j].port);
434                      return FALSE;          listview_add_sub_item (lv, 0, KS_COL_PORT, buf);
435                  }      }
436              }      if (listview_count_items (lv, 0) == 0) {
437              listview_get_item_text( lv, lv_idx, 1, proto, sizeof (proto)-1 );          listview_add_item (lv, "");
438              proto_nr = KSPROTO_HTTP;          listview_add_sub_item (lv, 0, KS_COL_NAME, DEF_HKP_KEYSERVER);
439              if( *proto == 'L' )      }
440                  proto_nr = KSPROTO_LDAP;      listview_set_ext_style (lv);
441              else if( *proto == 'F' )      *r_lv = lv;
442                  proto_nr = KSPROTO_FINGER;      return 0;
443              listview_get_item_text( lv, lv_idx, 0, kserver, sizeof (kserver)-1 );  }
444              if( !GetDlgItemText( dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1 ) ) {  
445                  msg_box( dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO );  
446                  return FALSE;  static void
447              }  keyserver_remove (listview_ctrl_t lv)
448              if( proto_nr == KSPROTO_LDAP && strchr( pattern, '@' ) ) {  {
449                  msg_box( dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO );      char name[100];
450                  return FALSE;      int pos = listview_get_curr_pos (lv);
451              }      int i;
452              else if (proto_nr == KSPROTO_FINGER) {  
453                  if (strchr (pattern, '@') || strchr (pattern, ' ')) {      listview_get_item_text (lv, pos, KS_COL_NAME, name, sizeof (name)-1);
454                      msg_box (dlg, _("Only enter the name of the user."), _("FINGER Keyserver"), MB_INFO);      for (i=0; i < MAX_KEYSERVERS; i++) {
455                      return FALSE;          if (server[i].name && stricmp (server[i].name, name) == 0)
456                  }              server[i].used = 0;
457              }      }
458              else if( check_pattern( pattern ) ) {      listview_del_item (lv, pos);
459                  msg_box( dlg, _("Only email addresses or keyids are allowed."), _("HKP Keyserver"), MB_INFO );  }
460                  return FALSE;  
461              }  
462              rc = hkp_recv_key (dlg, kserver, kserver_get_port (lv), pattern, proto_nr, 0);  static void
463              if (!rc)  keyserver_edit (listview_ctrl_t lv, keyserver_rec_t ctx)
464                  keycache_set_reload (1);  {
465              return TRUE;      char buf[16];
466        bool fnd = false;
467          case IDC_KEYSERVER_DEFAULT:      int i;
468              save_default_ks( lv );  
469              break;      for (i=0; i < MAX_KEYSERVERS; i++) {
470                        if (server[i].name && stricmp (server[i].name, ctx->name) == 0) {
471          case IDCANCEL:              fnd = true;
472              EndDialog( dlg, FALSE );              break;
473              return FALSE;          }
474          }      }
475          break;      if (!fnd)
476      }          return;
477            server[i].port = ctx->port;
478      return FALSE;  
479  } /* keyserver_dlg_proc */      i = listview_get_curr_pos (lv);
480        sprintf (buf, "%d", ctx->port);
481        listview_add_sub_item (lv, i, KS_COL_NAME, ctx->name);
482        listview_add_sub_item (lv, i, KS_COL_PORT, buf);
483    }
484    
485    static void
486    keyserver_add (listview_ctrl_t lv, keyserver_rec_t ctx)
487    {
488        char buf[16];
489        bool fnd = false;
490        int i;
491    
492        for (i=0; i < MAX_KEYSERVERS; i++) {
493            if (server[i].used == 0) {
494                fnd = true;
495                break;
496            }
497        }
498        if (!fnd) {
499            msg_box (NULL, _("No space for new keyserver entry"),
500                     _("Keyserver"), MB_ERR);
501            return;
502        }
503        free_if_alloc (server[i].name);
504        server[i].name = m_strdup (ctx->name);
505        server[i].port = ctx->port;
506        server[i].proto = ctx->proto;
507        server[i].used = 1;
508    
509        sprintf (buf, "%d", ctx->port);
510        listview_add_item (lv, " ");
511        listview_add_sub_item (lv, 0, KS_COL_NAME, ctx->name);
512        listview_add_sub_item (lv, 0, KS_COL_PORT, buf);
513    }
514    
515    
516    static void
517    fill_keyserv_types (HWND dlg)
518    {
519        HWND h = GetDlgItem (dlg, IDC_KSERVADD_TYPES);
520        combox_add_string (h, _("HKP Keyserver"));
521        combox_add_string (h, _("LDAP Keyserver"));
522        combox_add_string (h, _("Finger Keyserver"));
523        SendMessage (h, CB_SETCURSEL, 0, 0);
524    }
525    
526    
527    /* Dialog box procedure for modify keyservers. */
528    BOOL CALLBACK
529    keyserver_modify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
530    {
531        static keyserver_rec_t ctx;
532        char tmp[128];
533    
534        switch (msg) {
535        case WM_INITDIALOG:
536            fill_keyserv_types (dlg);
537            ctx = (keyserver_rec_t)lparam;
538            if (ctx->mode) {
539                SendDlgItemMessage (dlg, IDC_KSERVADD_TYPES, CB_SETCURSEL, ctx->proto, 0);
540                SetDlgItemText (dlg, IDC_KSERVADD_HOST, ctx->name);
541                SetDlgItemInt (dlg, IDC_KSERVADD_PORT, ctx->port, FALSE);
542                EnableWindow (GetDlgItem (dlg, IDC_KSERVADD_HOST), FALSE);
543                EnableWindow (GetDlgItem (dlg, IDC_KSERVADD_TYPES), FALSE);
544            }
545            else
546                SetDlgItemInt (dlg, IDC_KSERVADD_PORT, 11371, FALSE);      
547            SetWindowText (dlg, _("Edit Keyserver"));
548            SetDlgItemText (dlg, IDOK, _("&Add"));
549            SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
550            SetDlgItemText (dlg, IDC_KSERVADD_TYPEINF, _("Type:"));
551            SetDlgItemText (dlg, IDC_KSERVADD_PORTINF, _("Port:"));
552            SetDlgItemText (dlg, IDC_KSERVADD_HOSTINF, _("Host name:"));
553            SetForegroundWindow (dlg);
554            break;
555    
556        case WM_COMMAND:
557            switch (LOWORD (wparam)) {
558            case IDOK:
559                if (!GetDlgItemText (dlg, IDC_KSERVADD_HOST, tmp, sizeof (tmp)-1)) {
560                    msg_box (dlg, _("Please enter a host name"), _("Keyserver"), MB_ERR);
561                    return FALSE;
562                }      
563                ctx->port = GetDlgItemInt (dlg, IDC_KSERVADD_PORT, NULL, FALSE);
564                if (ctx->port > 65535) {
565                    msg_box (dlg, _("Invalid port, valid numbers are < 65535"), _("Keyserver"), MB_ERR);
566                    return FALSE;
567                }
568                ctx->proto = SendDlgItemMessage (dlg, IDC_KSERVADD_TYPES, CB_GETCURSEL, 0, 0);
569                ctx->cancel = false;
570                ctx->name[0] = '\0';
571                if (!strstr (tmp, "://")) {
572                    switch (ctx->proto) {
573                    case KSPROTO_HTTP: strcpy (ctx->name, "http://"); break;
574                    case KSPROTO_LDAP: strcpy (ctx->name, "ldap://"); break;
575                    case KSPROTO_FINGER:strcpy (ctx->name, "finger://"); break;
576                    }
577                }
578                strcat (ctx->name, tmp);
579                ctx->cancel = false;
580                EndDialog (dlg, TRUE);
581                break;
582    
583            case IDCANCEL:
584                ctx->cancel = true;
585                EndDialog (dlg, FALSE);
586                break;
587            }
588            break;
589        }
590    
591        return FALSE;
592    }
593    
594    
595    /* XXX: factor out the pattern code for generic use. */
596    
597    /* Add search pattern @patt to the combo box if it is
598       not already available in the list. */
599    static void
600    add_pattern_to_combox (HWND dlg, int ctlid, const char *patt)
601    {
602        int err;
603    
604        err = SendDlgItemMessage (dlg, ctlid, CB_FINDSTRINGEXACT,
605                                  0, (LPARAM)(LPCSTR)patt);
606        if (err != CB_ERR)
607            return;
608        SendDlgItemMessage (dlg, IDC_KEYSERVER_SEARCH, CB_ADDSTRING,
609                            0, (LPARAM)(LPCSTR)patt);
610    }
611    
612    
613    /* Restore saved pattern from the registry back to the combo box.
614       If no pattern were saved, do nothing and just return. */
615    static void
616    load_pattern_to_combox (HWND dlg, int ctlid, const char *rkey_name)
617    {
618        char *p, *tok;
619    
620        p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", rkey_name);
621        if (!p || strlen (p) < 2) {
622            free_if_alloc (p);
623            return;
624        }
625        tok = strtok (p, "$");
626        while (tok != NULL) {
627            SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)tok);
628            tok = strtok (NULL, "$");
629        }
630        free_if_alloc (p);
631    }
632    
633    
634    /* Save all entries from the combo box given in @ctlid to the
635       registry. Concat all values and use '$' as a separator. */
636    static void
637    save_pattern_from_combox (HWND dlg, int ctlid, const char *rkey_name)
638    {
639        char *p, tmp[64];
640        int i;
641        int n, len=0;
642    
643        n = SendDlgItemMessage (dlg, ctlid, CB_GETCOUNT, 0, 0);
644        if (n == 0 || n == CB_ERR)
645            return;
646        /* it is very unlikely that the combox contain hundred of pattern
647           but even so we limit the value to 16 which should be sufficient. */
648        if (n > 16) n = 16;
649        for (i=0; i < n; i++)
650            len += SendDlgItemMessage (dlg, ctlid, CB_GETLBTEXTLEN,
651                                       (WPARAM)i, 0) + 1 + 1;
652        p = new char[len+1];
653        memset (p, 0, len+1);
654        for (i=0; i < n; i++) {
655            memset (tmp, 0, sizeof (tmp));
656            SendDlgItemMessage (dlg, ctlid, CB_GETLBTEXT,
657                                (WPARAM)i, (LPARAM)tmp);
658            strcat (p, tmp);
659            strcat (p, "$");
660        }
661        set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", rkey_name, p);
662        free_if_alloc (p);
663    }
664    
665    
666    /* Dialog box procedure to access keyservers. */
667    BOOL CALLBACK
668    keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
669    {
670        static listview_ctrl_t lv = NULL;
671        static int lv_idx = 0;
672        keyserver_ctx ksc;
673        struct keyserver_rec_s edit;
674        char kserver[128], pattern[128];
675        char proto[16], *fpr = NULL;
676        int rc, proto_nr = 0;
677        
678        switch (msg) {
679        case WM_INITDIALOG:
680            SetWindowText (dlg, _("Keyserver Access"));
681            SetDlgItemText (dlg, IDC_KEYSERVER_RECV, _("&Receive"));
682            SetDlgItemText (dlg, IDC_KEYSERVER_SEND,
683                            _("Send key (default is receiving)"));
684            SetDlgItemText (dlg, IDC_KEYSERVER_INFO,
685                            _("Key ID or email address you want to search for"));
686            SetDlgItemText (dlg, IDC_KEYSERVER_INDEX, _("&Search"));
687            SetDlgItemText (dlg, IDC_KEYSERVER_PROXSETT, _("C&hange proxy"));
688            SetDlgItemText (dlg, IDC_KEYSERVER_DEFAULT, _("Set &default"));
689            SetDlgItemText (dlg, IDCANCEL, _("&Close"));
690            
691            load_pattern_to_combox (dlg, IDC_KEYSERVER_SEARCH, "KSsearch");
692            keyserver_list_build (&lv, GetDlgItem (dlg, IDC_KEYSERVER_LIST));
693            set_default_ks (lv);
694            center_window (dlg, NULL);
695            SetForegroundWindow (dlg);
696            return TRUE;
697            
698        case WM_NOTIFY:
699            NMHDR *notify;
700            notify = (NMHDR *)lparam;
701            if (!notify)
702                break;
703            if (notify->code == NM_CLICK
704                && notify->idFrom == IDC_KEYSERVER_LIST)
705                lv_idx = listview_get_curr_pos (lv);
706            else if (notify->code == NM_RCLICK &&
707                     notify->idFrom == IDC_KEYSERVER_LIST) {
708                POINT p;
709                GetCursorPos (&p);
710                HMENU hm, pop;
711                hm = LoadMenu (glob_hinst, (LPCTSTR)IDR_WINPT_KEYSERVER_CTX);
712                pop = GetSubMenu (hm, 0);
713                set_menu_text (pop, ID_KSERVCTX_ADD, _("&Add"));
714                set_menu_text (pop, ID_KSERVCTX_DEL, _("&Remove"));
715                set_menu_text (pop, ID_KSERVCTX_EDIT, _("&Edit"));
716                TrackPopupMenu (pop, 0, p.x, p.y, 0, dlg, NULL);
717                DestroyMenu (hm);
718                DestroyMenu (pop);
719            }
720            else if (notify->code == LVN_ITEMCHANGED &&
721                     ((LPNMLISTVIEW)lparam)->uNewState) {
722                listview_get_item_text (lv, listview_get_curr_pos (lv),
723                                        KS_COL_NAME, kserver, sizeof (kserver)-1);
724                if (!strnicmp (kserver, "ldap://", 7))
725                    EnableWindow (GetDlgItem (dlg, IDC_KEYSERVER_INDEX), FALSE);
726                else
727                    EnableWindow (GetDlgItem (dlg, IDC_KEYSERVER_INDEX), TRUE);
728            }
729            return TRUE;
730            
731        case WM_DESTROY:
732            if (lv) {
733                listview_release (lv);
734                lv = NULL;
735            }
736            lv_idx = 0;
737            save_pattern_from_combox (dlg, IDC_KEYSERVER_SEARCH, "KSsearch");
738            return FALSE;
739            
740        case WM_SYSCOMMAND:
741            if (LOWORD (wparam) == SC_CLOSE)
742                EndDialog (dlg, TRUE);
743            return FALSE;  
744    
745        case WM_COMMAND:
746            switch (LOWORD (wparam)) {
747            case IDC_KEYSERVER_PROXSETT:
748                dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_PROXY,
749                                  dlg, keyserver_proxy_dlg_proc, 0,
750                                  _("Proxy Settings"), IDS_WINPT_KEYSERVER_PROXY);
751                return TRUE;
752                
753            case IDC_KEYSERVER_INDEX:
754                if (!lv_idx)
755                    lv_idx = kserver_get_pos (lv);
756                
757                if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {
758                    msg_box (dlg, _("Please enter the search pattern."),
759                             _("Keyserver"), MB_INFO);
760                    return TRUE;
761                }
762    
763                if (lv_idx != -1) {
764                    listview_get_item_text (lv, lv_idx, KS_COL_NAME,
765                                            kserver, sizeof (kserver)-1);
766                    ksc.name = kserver;
767                    ksc.port = kserver_get_port (lv);
768                }
769                else {
770                    ksc.name = DEF_HKP_KEYSERVER;
771                    ksc.port = HKP_PORT;
772                }
773                ksc.pattern = pattern;
774                DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_HKPSEARCH, dlg,
775                                hkpsearch_dlg_proc, (LPARAM) &ksc);
776                return TRUE;
777                
778            case IDC_KEYSERVER_RECV:            
779                memset (&kserver, 0, sizeof (kserver));
780                if (!lv_idx) {
781                    lv_idx = kserver_get_pos (lv);
782                    if (lv_idx == -1) {
783                        msg_box (dlg, _("Please select one of the keyservers."),
784                                _("Keyserver"), MB_INFO);
785                        return TRUE;
786                    }
787                }
788                listview_get_item_text (lv, lv_idx, KS_COL_NAME,
789                                        proto, sizeof (proto)-1);
790                proto_nr = KSPROTO_HTTP;
791                if (!strnicmp  (proto, "ldap", 4))
792                    proto_nr = KSPROTO_LDAP;
793                else if (!strnicmp (proto, "finger", 6))
794                    proto_nr = KSPROTO_FINGER;
795                listview_get_item_text (lv, lv_idx, KS_COL_NAME,
796                                        kserver, sizeof (kserver)-1);
797                if (!GetDlgItemText(dlg, IDC_KEYSERVER_SEARCH,
798                                    pattern, sizeof (pattern)-1)) {
799                    msg_box (dlg, _("Please enter the search pattern."),
800                             _("Keyserver"), MB_INFO);
801                    return FALSE;
802                }
803                if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) {
804                    msg_box (dlg, _("Only keyids are allowed."),
805                             _("Keyserver"), MB_INFO);
806                    return FALSE;
807                }
808                else if (proto_nr == KSPROTO_FINGER) {
809                    if (strchr (pattern, '@') || strchr (pattern, ' ')) {
810                        msg_box (dlg, _("Only enter the name of the user."),
811                                 _("Keyserver"), MB_INFO);
812                        return TRUE;
813                    }
814                }
815                else if (check_pattern (pattern)) {
816                    msg_box (dlg, _("Only email addresses or keyids are allowed."),
817                            _("Keyserver"), MB_INFO);
818                    return TRUE;
819                }
820                rc = keyserver_recv_key (dlg, kserver, kserver_get_port (lv),
821                                         pattern, proto_nr, 0,
822                                         &fpr);
823                if (!rc && fpr != NULL) {
824                    keycache_update (0, fpr);
825                    free_if_alloc (fpr);
826                }
827                if (!rc)
828                    add_pattern_to_combox (dlg, IDC_KEYSERVER_SEARCH, pattern);
829                return TRUE;
830    
831            case IDC_KEYSERVER_DEFAULT:
832                save_default_ks (lv);
833                return TRUE;
834    
835            case ID_KSERVCTX_ADD:
836                memset (&edit, 0, sizeof (edit));
837                edit.mode = false;
838                dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_ADD, dlg,
839                                    keyserver_modify_dlg_proc,
840                                    (LPARAM)&edit, _("Edit Keyserver"), 0);
841                if (!edit.cancel)
842                    keyserver_add (lv, &edit);
843                return TRUE;
844    
845            case ID_KSERVCTX_EDIT:
846                memset (&edit, 0, sizeof (edit));
847                edit.mode = true;
848                listview_get_item_text (lv, lv_idx, KS_COL_NAME,
849                                        edit.name, sizeof (edit.name)-1);
850                listview_get_item_text (lv, lv_idx, KS_COL_PORT, pattern, 32);
851                edit.port = atoi (pattern);
852                if (!strnicmp (edit.name, "hkp", 3) || !strnicmp (edit.name, "http", 4))
853                    edit.proto = KSPROTO_HTTP;
854                else if (!strnicmp (edit.name, "ldap", 4))
855                    edit.proto = KSPROTO_LDAP;
856                else
857                    edit.proto = KSPROTO_FINGER;
858                dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_ADD, dlg,
859                                    keyserver_modify_dlg_proc,
860                                    (LPARAM)&edit, _("Edit Keyserver"), 0);
861                if (!edit.cancel)
862                    keyserver_edit (lv, &edit);
863                break;
864    
865            case ID_KSERVCTX_DEL:
866                keyserver_remove (lv);
867                return TRUE;
868                
869            case IDCANCEL:
870                EndDialog (dlg, FALSE);
871                return TRUE;
872            }
873            break;
874        }
875        
876        return FALSE;
877    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26