/[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 25 by twoaday, Wed Oct 12 10:04:26 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_data_t keydata;  typedef struct keyserver_rec_s *keyserver_rec_t;
61      gpgme_error_t ec;  
62      char *rawkey = NULL, msg[1024];  
63      size_t n;  /* 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_new( &c );  {
67      if( ec )      const char *err = kserver_strerror ();
68          BUG( NULL );      const char *ws_err = wsock_strerror ();
69      gpgme_set_armor (c, 1);      
70      ec = gpgme_data_new( &keydata );      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      rc = (int) gpgme_op_export( c, pattern, 0, keydata );          log_box (_("Keyserver"), MB_ERR, "%s:%d: %s\n%s",
74      if( rc ) {                   host, port, winpt_strerror (rc), err? err : "");
75          msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Export"), MB_ERR );  }
76          goto leave;  
77      }  
78      rawkey = gpgme_data_release_and_get_mem (keydata, &n);  /* Send the extracted key with keyid @pattern to the
79      rc = kserver_sendkey (kserver, port, rawkey, n);     keyserver @kserver (port @port).
80      if (rc) {     Return value: 0 on success. */
81          hkp_err_box (dlg, kserver, port, rc);  int
82          goto leave;  hkp_send_key (HWND dlg, const char *kserver, WORD port, const char *pattern)
83      }  {
84            GPGME *gpg;
85      _snprintf (msg, sizeof (msg) -1, _("Key '%s' successfully sent"), pattern);      gpgme_error_t ec;
86      status_box (dlg, msg, _("GnuPG status"));      char *rawkey = NULL;
87            char msg[256];
88  leave:      
89      gpgme_release (c);      gpg = new GPGME ();
90      safe_free (rawkey);      gpg->setArmor (true);
91      return rc;      ec = gpg->exportToBuffer (pattern, &rawkey);
92  } /* hkp_send_key */      if (ec) {
93            msg_box (dlg, gpgme_strerror (ec), _("Export"), MB_ERR);
94            goto leave;
95  int      }
96  hkp_recv_key (HWND dlg, const char *kserver, u16 port,      op_begin ();
97                const char *pattern, int proto, int flags)      ec = kserver_sendkey (kserver, port, rawkey, strlen (rawkey));
98  {      op_end ();
99      gpgme_ctx_t ctx;      if (ec) {
100      gpgme_data_t keydata;          hkp_err_box (dlg, kserver, port, ec);
101      gpgme_error_t ec;          goto leave;
102      gpgme_import_result_t import_res;      }
103      int rc;      
104      char *rawkey = NULL, msg[384];      _snprintf (msg, sizeof (msg) -1, _("Key '%s' successfully sent"), pattern);
105            status_box (dlg, msg, _("GnuPG status"));
106      rawkey = new char[MAX_KEYSIZE];      
107      if (!rawkey)  leave:
108          BUG (0);      delete gpg;
109      memset (rawkey, 0, MAX_KEYSIZE);      free_if_alloc (rawkey);
110      if( proto == KSPROTO_LDAP ) {      return ec? -1 : 0;
111          rc = ldap_recvkey( kserver, pattern, rawkey, MAX_KEYSIZE-1 );  }
112          if( rc ) {  
113              msg_box( dlg, _("LDAP key import failed.\n"  
114                              "Please make sure you have an online connection"  
115                              " and gpgkeys_ldap.exe is installed"),  /* Show all received keys from the keyserver. */
116                              _("Keyserver"), MB_ERR );  static void
117              free_if_alloc( rawkey );  show_imported_keys (gpgme_import_result_t res)
118              return rc;  {
119          }      gpgme_import_status_t t;
120      }      gpgme_key_t key;
121      else if (proto == KSPROTO_FINGER) {      gpgme_data_t msg;
122          rc = finger_recvkey (kserver, pattern, rawkey, MAX_KEYSIZE-1);      gpgme_ctx_t ctx;
123          if (rc) {      gpgme_error_t err;
124              log_box (_("Keyserver"), MB_ERR, _("Finger key import failed: %s\n"),      const char *s;
125                       winpt_strerror (rc));      char *p, *uid;
126              free_if_alloc (rawkey);      size_t n=0;
127              return rc;  
128          }      if (!res)
129      }          return;
130      else if( ( rc = kserver_recvkey( kserver, port, kserver_check_keyid( pattern ),  
131                                       rawkey, MAX_KEYSIZE-1 ) ) ) {      err = gpgme_data_new (&msg);
132          hkp_err_box (dlg, kserver, port, rc);      if (err)
133          free_if_alloc (rawkey);          BUG (NULL);
134          return rc;      err = gpgme_new (&ctx);
135      }      if (err)
136      else {          BUG (NULL);
137          if( !strstr( rawkey, "BEGIN PGP PUBLIC KEY BLOCK" ) ) {      if (res->considered > 1) {
138              msg_box( dlg, _("This is not a valid OpenPGP key."), _("Keyserver"), MB_ERR );          s = _("WARNING: multiple keys matched request.\n\n");
139              goto leave;          gpgme_data_write (msg, s, strlen (s));
140          }      }
141          ec = gpgme_new( &ctx );  
142          if( ec )      if (res->unchanged == res->considered)
143              BUG( NULL );          s = _("Key(s) successfully received but nothing was changed.");
144          gpgme_data_new_from_mem( &keydata, rawkey, strlen( rawkey ), 1 );      else
145          rc = gpgme_op_import( ctx, keydata );          s = _("Key(s) sucessfully received and imported.");
146          if( rc ) {          // nice to have the amount of new signatures...
147              msg_box( dlg, gpgme_strerror( (gpgme_error_t)rc ), _("Import"), MB_ERR );      gpgme_data_write (msg, s, strlen (s));
148              goto leave;      gpgme_data_write (msg, "\n\n", 2);
149          }  
150          import_res = gpgme_op_import_result (ctx);      for (t=res->imports; t; t = t->next) {
151      }          if (!gpgme_get_key (ctx, t->fpr, &key, 0)) {
152                    s = uid = utf8_to_native (key->uids->uid);
153      /* if we use the refresh mode, a lot of keys will be fetched and thus only              gpgme_data_write (msg, s, strlen (s));
154         a summarize at the end is presented and not for each key. */              gpgme_data_write (msg, "\n", 1);
155      if (!(flags & KM_KS_REFRESH)) {              gpgme_key_release (key);
156          if (import_res->new_user_ids == 0) {              safe_free (uid);
157              _snprintf (msg, DIM (msg)-1,          }
158                         _("Key '%s' successfully received but nothing was changed."), pattern );      }
159              status_box (dlg, msg, _("GnuPG Status"));      gpgme_data_write (msg, "\0", 1);
160              rc = WPTERR_GENERAL;      p = gpgme_data_release_and_get_mem (msg, &n);
161              goto leave;      if (p != NULL) {
162          }          msg_box (NULL, p, _("Imported Keys"), MB_INFO);
163          _snprintf (msg, DIM (msg)-1, _("Key '%s' sucessfully received and imported."), pattern);          gpgme_free (p);
164          status_box (dlg, msg, _("GnuPG Status"));      }
165      }      gpgme_release (ctx);
166        }
167  leave:  
168      free_if_alloc (rawkey);  
169      gpgme_release (ctx);  /* Receive a key from the keyserver @kserver (port @port)
170      gpgme_data_release (keydata);     with the pattern @pattern.
171       Return value: 0 on success. */
172      return rc;  static int
173  } /* hkp_recv_key */  keyserver_recv_key (HWND dlg, const char *kserver, WORD port,
174                        const char *pattern, int proto, int flags,
175                        char **r_fpr)
176  #define my_iskeychar(a) ( ( (a) >='0' && (a) <= '9' ) || ( (a) >= 'A' && (a) <= 'F' ) )  {    
177        gpgme_import_result_t import_res = NULL;
178  static int      gpgme_error_t err;
179  check_pattern( const char *pattern )      GPGME *gpg = NULL;
180  {      char *rawkey = NULL;
181      int rc = 1;      size_t keylen = 0;
182            int rc;
183      /* Whitespace are not allowed! */  
184      if( strchr( pattern, ' ') ) {      if (proto == KSPROTO_LDAP) {
185          rc = WPTERR_GENERAL;          rc = ldap_recvkey (kserver, pattern, &rawkey, &keylen);
186          goto leave;          if (rc) {
187      }              msg_box (dlg, _("LDAP key import failed.\n"
188                                    "Please make sure you have an online connection"
189      if( (( strstr( pattern, "0x" ) ) && ( strlen( pattern ) == 10 ) )                              " and gpgkeys_ldap.exe is installed"),
190           || (strstr(pattern, "0x")) && ( strlen( pattern )  == 18 ) ) {                              _("Keyserver"), MB_ERR);
191          rc = 0;              free_if_alloc (rawkey);
192          goto leave;              return rc;
193      }          }
194            }
195      if( (( my_iskeychar( pattern[0] )) && ( strlen( pattern )  == 8 ) )      else if (proto == KSPROTO_FINGER) {
196           || (my_iskeychar(pattern[0])) && ( strlen( pattern ) == 16) ) {          rc = finger_recvkey (kserver, pattern, &rawkey, &keylen);
197          rc = 0;          if (rc) {
198          goto leave;              log_box (_("Keyserver"), MB_ERR,
199      }                       _("Finger key import failed: %s\n"), winpt_strerror (rc));
200                    free_if_alloc (rawkey);
201      if( ( strchr( pattern, '@' ) ) && ( strlen( pattern ) >= 3 ) ) {              return rc;
202          rc = 0;          }
203          goto leave;      }
204      }      else if ((rc = kserver_recvkey (kserver, port,
205                                            kserver_check_keyid (pattern),
206  leave:                                      &rawkey, &keylen))) {
207      return rc;          hkp_err_box (dlg, kserver, port, rc);
208  } /* check_pattern */          free_if_alloc (rawkey);
209            return rc;
210        }
211  static void  
212  set_proxy (HWND dlg)      if (!strstr (rawkey, "BEGIN PGP PUBLIC KEY BLOCK")) {
213  {          msg_box (dlg, _("This is not a valid OpenPGP key."),
214      char proxy[384];                   _("Keyserver"), MB_ERR);
215      int port = 0;          goto leave;
216            }
217      strcpy (proxy, "HTTP proxy: ");      gpg = new GPGME ();
218      if (kserver_get_proxy (&port)) {      err = gpg->importFromBuffer (rawkey);
219          char t[256];      if (err) {
220          const char *http = kserver_get_proxy (&port);          msg_box (dlg, gpgme_strerror (err), _("Import"), MB_ERR);
221          _snprintf (t, sizeof (t) - 1, "\"%s:%d\"", http, port);          goto leave;
222          strcat (proxy, t);      }
223      }      import_res = gpg->importGetResult ();
224      else      if (import_res && r_fpr)
225          strcat( proxy, "none" );          *r_fpr = m_strdup (import_res->imports->fpr);
226      SetDlgItemText( dlg, IDC_KEYSERVER_PROXY, proxy );      
227  } /* set_proxy */      /* if we use the refresh mode, a lot of keys will be fetched and thus only
228           a summarize at the end is presented and not for each key. */
229        if (import_res && !(flags & KM_KS_REFRESH)) {
230  static int inline          show_imported_keys (import_res);
231  kserver_get_pos (listview_ctrl_t lv)          if (import_res->unchanged == import_res->considered) {
232  {              rc = WPTERR_GENERAL; /* no keys updated. */
233      if (listview_count_items (lv, 0) == 1)              goto leave;
234          return 0;          }
235      return listview_get_curr_pos (lv);      }
236  }  
237    leave:
238        free_if_alloc (rawkey);
239  static u16 inline      if (gpg != NULL)
240  kserver_get_port (listview_ctrl_t lv)          delete gpg;
241  {      return rc;
242      char buf[16];  }
243    
244      listview_get_item_text (lv, kserver_get_pos (lv), 3, buf, 15);  
245      return (u16)strtoul (buf, NULL, 10);  /* Alias for keyserver_recv_key but without the ability to return
246  }     the fingerprint of the key. */
247    int
248  static void  hkp_recv_key (HWND dlg, const char *kserver, WORD port,
249  load_default_ks (listview_ctrl_t lv)                const char *pattern, int proto, int flags)
250  {  {
251      char * p, buf[192];      return keyserver_recv_key (dlg, kserver, port, pattern,
252      int i;                                 proto, flags, NULL);
253    }
254      p = get_reg_entry_keyserver ("Default");  
255      if (!p)  int
256          return;  hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
257      for( i = 0; i < listview_count_items( lv, 0 ); i++ ) {                 const char *pattern, int proto, char **r_fpr)
258          listview_get_item_text( lv, i, 0, buf, sizeof (buf)-1 );  {
259          if( !strncmp( p, buf, strlen( p ) ) ) {      return keyserver_recv_key (dlg, kserver, port, pattern,
260              listview_add_sub_item( lv, i, 2, "x" );                                 proto, 0, r_fpr);
261              break;  }
262          }  
263      }  
264      free_if_alloc (p);  /* Utility function to fetch a key from the keyserver
265  } /* load_default_ks */     based on a given signature (@sig).
266       Return 0 on success. */
267    int
268  static int  fetch_key_from_keyserver (HWND dlg, gpgme_signature_t sig)
269  save_default_ks (listview_ctrl_t lv)  {
270  {      const char *keyid;
271      char buf[192], port[32];      int id;
272      int idx, i;    
273        if (!sig->fpr)
274      idx = listview_get_curr_pos( lv );          return FALSE;
275      if( idx == -1 ) {      keyid = get_keyid_from_fpr (sig->fpr);          
276          msg_box( NULL, _("Please select one of the servers."), _("Keyserver"), MB_ERR );      id = log_box (_("Verify"), MB_INFO|MB_YESNO,
277          return -1;                    _("Signature made %s using %s key ID 0x%s\n"
278      }                      "Cannot check signature: public key not found\n\n"
279      listview_get_item_text( lv, idx, 1, buf, sizeof (buf)-1 );                      "Do you want to try to retrieve the key from the keyserver?"),
280      if( *buf != 'H' ) {                    strtimestamp (sig->timestamp),
281          msg_box( NULL, _("Only HTTP keyserver can be used."), _("Keyserver"), MB_ERR );                    get_key_pubalgo (sig->pubkey_algo), keyid);
282          return -1;      if (id == IDNO) {
283      }          msg_box (dlg, get_gpg_sigstat (GPGME_SIGSUM_KEY_MISSING),
284      for (i = 0; i < listview_count_items( lv, 0 ); i++)                   _("Verify"), MB_WARN);
285          listview_add_sub_item (lv, i, 2, "");          return -1;
286      listview_add_sub_item (lv, idx, 2, "x");      }
287      listview_get_item_text (lv, idx, 0, buf, sizeof (buf)-1);  
288      set_reg_entry_keyserver ("Default", buf);      if (!hkp_recv_key (dlg, default_keyserver, default_keyserver_port,
289      i = kserver_get_port (lv);                         keyid, 0, 0)) {
290      sprintf (port, "%d", i);          keycache_update (0, keyid);
291      set_reg_entry_keyserver ("Default_Port", port);          return 0;
292      keyserver_set_default (buf, (u16)i);      }
293      return 0;      return -1;
294  } /* save_default_ks */  }
295    
296    /* Check if the given pattern are either a valid
297  int     email address, a {long, short} keyid or a fingerprint.
298  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)     Return 0 on success. */
299  {  static int
300      struct listview_column_s keyserver[] = {  check_pattern (const char *pattern)
301          {0, 160, (char *)_("DNS Name")},          {    
302          {1,  52, (char *)_("Protocol")},      size_t i;
303          {2,  46, (char *)_("Default")},  
304          {3,  46, (char *)_("Port")},      if (strchr (pattern, ' '))
305          {0,   0, NULL}          return WPTERR_GENERAL; /* do not allow white spaces. */
306      };      
307      listview_ctrl_t lv;      if (strchr (pattern, '@') && strlen (pattern) >= 3 &&
308      char buf[32];          !check_email_address (pattern))
309      int j;          return 0;
310    
311      listview_new (&lv);          if (strstr (pattern, "0x"))
312      lv->ctrl = hwnd;                pattern += 2;
313      for (j=0; keyserver[j].fieldname; j++)      if (strlen (pattern) != 8 &&
314          listview_add_column (lv, &keyserver[j]);                  strlen (pattern) != 16 &&
315      for (j = 0; j<MAX_KEYSERVERS; j++) {          strlen (pattern) != 40)
316          if (!server[j].used)          return WPTERR_GENERAL;
317              continue;  
318          listview_add_item (lv, " ");      for (i=0; i < strlen (pattern); i++) {
319          listview_add_sub_item (lv, 0, 0, server[j].name);          if (!isxdigit (pattern[i]))
320          switch (server[j].proto) {              return WPTERR_GENERAL;
321          case KSPROTO_HTTP:      }
322              listview_add_sub_item( lv, 0, 1, "H" ); break;      return 0;
323          case KSPROTO_LDAP:  }
324              listview_add_sub_item( lv, 0, 1, "L" ); break;  
325          case KSPROTO_FINGER:  
326              listview_add_sub_item( lv, 0, 1, "F" ); break;  /* Return human readable name for the proxy protocol. */
327          }  static const char*
328          sprintf (buf, "%d", server[j].port);  name_from_proto (int proto)
329          listview_add_sub_item (lv, 0, 3, buf);  {
330      }      const char *s;
331      load_default_ks (lv);  
332      if (listview_count_items (lv, 0) == 0) {      switch (proto) {
333          listview_add_item (lv, "");      case PROXY_PROTO_NONE:      s = ""; break;
334          listview_add_sub_item (lv, 0, 0, DEF_HKP_KEYSERVER);      case PROXY_PROTO_HTTP:      s = "HTTP"; break;
335          listview_add_sub_item (lv, 0, 1, "H");      case PROXY_PROTO_SOCKS5:    s = "SOCKS5"; break;
336      }      default:                    s = "HTTP"; break;
337      listview_set_ext_style (lv);      }
338      *r_lv = lv;      return s;
339      return 0;  }
340  }  
341    
342    static int inline
343  BOOL CALLBACK  kserver_get_pos (listview_ctrl_t lv)
344  keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  {
345  {      if (listview_count_items (lv, 0) == 1)
346      static listview_ctrl_t lv = NULL;          return 0;
347      static int lv_idx = 0;      return listview_get_curr_pos (lv);
348      int rc, proto_nr = 0;  }
349      char kserver[128], pattern[128];  
350      char proto[16];      
351      keyserver_ctx ksc;  static WORD inline
352        kserver_get_port (listview_ctrl_t lv)
353      switch ( msg ) {  {
354      case WM_INITDIALOG:      char buf[16];
355  #ifndef LANG_DE  
356          SetWindowText( dlg, _("Keyserver Access") );      listview_get_item_text (lv, kserver_get_pos (lv),
357          SetDlgItemText( dlg, IDC_KEYSERVER_SEND,                              KS_COL_PORT, buf, sizeof (buf)-1);
358                          _("Send key (default is receiving)") );      return (WORD)strtoul (buf, NULL, 10);
359          SetDlgItemText( dlg, IDC_KEYSERVER_INFO,  }
360                          _("Please enter the key ID or email address you search for"));  
361          SetDlgItemText( dlg, IDC_KEYSERVER_INDEX, _("&Search") );  
362  #endif  static void
363          set_proxy (dlg);  set_default_ks (listview_ctrl_t lv)
364          keyserver_list_build (&lv, GetDlgItem (dlg, IDC_KEYSERVER_LIST));  {
365          center_window (dlg, NULL);      char *p, buf[128];
366          SetForegroundWindow (dlg);      int i;
367          return TRUE;  
368                p = get_reg_entry_keyserver ("Default");
369      case WM_NOTIFY:      if (!p)
370          NMHDR *notify;          return;
371          notify = (NMHDR *)lparam;      for (i=0; i < listview_count_items (lv, 0); i++) {
372          if( notify && notify->code == NM_CLICK          listview_get_item_text (lv, i, KS_COL_NAME, buf, sizeof (buf)-1);      
373              && notify->idFrom == IDC_KEYSERVER_LIST )          if (!stricmp (buf, p)) {
374              lv_idx = listview_get_curr_pos( lv );              listview_select_one (lv, i);
375          return TRUE;              break;
376                    }
377      case WM_DESTROY:      }
378          if( lv ) {      free_if_alloc (p);
379              listview_release( lv );  }
380              lv = NULL;  
381          }  
382          lv_idx = 0;  /* Save the selected keyserver from @lv as the default server. */
383          return FALSE;  static int
384            save_default_ks (listview_ctrl_t lv)
385      case WM_SYSCOMMAND:  {
386          if( LOWORD( wparam ) == SC_CLOSE )      char buf[192], port[32];
387              EndDialog( dlg, TRUE );      int idx, i;  
388          return FALSE;  
389                idx = listview_get_curr_pos (lv);
390      case WM_COMMAND:      if (idx == -1) {
391          switch( LOWORD( wparam ) ) {          msg_box (NULL, _("Please select one of the servers."),
392          case IDC_KEYSERVER_PROXSETT:                   _("Keyserver"), MB_ERR);
393              dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_PROXY, glob_hwnd,          return -1;
394                                keyserver_proxy_dlg_proc, NULL,      }
395                                _("Proxy Settings"), IDS_WINPT_KEYSERVER_PROXY );      listview_get_item_text (lv, idx, KS_COL_NAME, buf, sizeof (buf)-1);
396              set_proxy( dlg );      if (strnicmp (buf, "http", 4) && strnicmp (buf, "hkp", 3)) {
397              return TRUE;          msg_box (NULL, _("Only HKP keyserver can be used."),
398                                 _("Keyserver"), MB_ERR);
399          case IDC_KEYSERVER_INDEX:          return -1;
400              if (!lv_idx) {      }
401                  lv_idx = kserver_get_pos (lv);      set_reg_entry_keyserver ("Default", buf);
402                  if (lv_idx == -1) {      i = kserver_get_port (lv);
403                      msg_box (dlg, _("Please select one of the keyservers."), _("Keyserver"), MB_INFO);      sprintf (port, "%d", i);
404                      return FALSE;      set_reg_entry_keyserver ("Default_Port", port);
405                  }      keyserver_set_default (buf, (WORD)i);
406              }      return 0;
407              listview_get_item_text (lv, lv_idx, 1, proto, sizeof (proto)-1);  }
408              if (*proto == 'L') {  
409                  msg_box( dlg, _("This is not implemented yet!"), _("Keyserver"), MB_ERR );  
410                  return FALSE;  int
411              }  keyserver_list_build (listview_ctrl_t *r_lv, HWND hwnd)
412              listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);  {
413              if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {      struct listview_column_s keyserver[] = {
414                  msg_box (dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO);          {0, 180, (char *)_("DNS Name")},
415                  return FALSE;          {1,  55, (char *)_("Port")},
416              }          {0,   0, NULL}
417              ksc.name = kserver;      };
418              ksc.pattern = pattern;      HICON ico[1];
419              ksc.port = kserver_get_port (lv);      listview_ctrl_t lv;
420              DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_HKPSEARCH, dlg,      char buf[32];
421                              hkpsearch_dlg_proc, (LPARAM) &ksc );      int j;
422              return TRUE;  
423                    ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_COMPUTER);
424          case IDC_KEYSERVER_RECV:      listview_new (&lv, hwnd);    
425              memset (&kserver, 0, sizeof (kserver));      for (j=0; keyserver[j].fieldname; j++)
426              if (!lv_idx) {          listview_add_column (lv, &keyserver[j]);
427                  lv_idx = kserver_get_pos (lv);      listview_set_image_list (lv, 16, 16, ico, 1);
428                  if (lv_idx == -1) {      for (j = 0; j < MAX_KEYSERVERS; j++) {
429                      msg_box( dlg, _("Please select one of the keyservers."), _("Keyserver"), MB_INFO );          if (!server[j].used)
430                      return FALSE;              continue;
431                  }          listview_add_item_image (lv, " ", 0);
432              }          listview_add_sub_item (lv, 0, KS_COL_NAME, server[j].name);
433              listview_get_item_text( lv, lv_idx, 1, proto, sizeof (proto)-1 );          sprintf (buf, "%d", server[j].port);
434              proto_nr = KSPROTO_HTTP;          listview_add_sub_item (lv, 0, KS_COL_PORT, buf);
435              if( *proto == 'L' )      }
436                  proto_nr = KSPROTO_LDAP;      if (listview_count_items (lv, 0) == 0) {
437              else if( *proto == 'F' )          listview_add_item (lv, "");
438                  proto_nr = KSPROTO_FINGER;          listview_add_sub_item (lv, 0, KS_COL_NAME, DEF_HKP_KEYSERVER);
439              listview_get_item_text( lv, lv_idx, 0, kserver, sizeof (kserver)-1 );      }
440              if( !GetDlgItemText( dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1 ) ) {      listview_set_ext_style (lv);
441                  msg_box( dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO );      *r_lv = lv;
442                  return FALSE;      return 0;
443              }  }
444              if( proto_nr == KSPROTO_LDAP && strchr( pattern, '@' ) ) {  
445                  msg_box( dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO );  
446                  return FALSE;  static void
447              }  keyserver_remove (listview_ctrl_t lv)
448              else if (proto_nr == KSPROTO_FINGER) {  {
449                  if (strchr (pattern, '@') || strchr (pattern, ' ')) {      char name[100];
450                      msg_box (dlg, _("Only enter the name of the user."), _("FINGER Keyserver"), MB_INFO);      int pos = listview_get_curr_pos (lv);
451                      return FALSE;      int i;
452                  }  
453              }      listview_get_item_text (lv, pos, KS_COL_NAME, name, sizeof (name)-1);
454              else if( check_pattern( pattern ) ) {      for (i=0; i < MAX_KEYSERVERS; i++) {
455                  msg_box( dlg, _("Only email addresses or keyids are allowed."), _("HKP Keyserver"), MB_INFO );          if (server[i].name && stricmp (server[i].name, name) == 0)
456                  return FALSE;              server[i].used = 0;
457              }      }
458              rc = hkp_recv_key (dlg, kserver, kserver_get_port (lv), pattern, proto_nr, 0);      listview_del_item (lv, pos);
459              if (!rc)  }
460                  keycache_set_reload (1);  
461              return TRUE;  
462    static void
463          case IDC_KEYSERVER_DEFAULT:  keyserver_edit (listview_ctrl_t lv, keyserver_rec_t ctx)
464              save_default_ks( lv );  {
465              break;      char buf[16];
466                    bool fnd = false;
467          case IDCANCEL:      int i;
468              EndDialog( dlg, FALSE );  
469              return FALSE;      for (i=0; i < MAX_KEYSERVERS; i++) {
470          }          if (server[i].name && stricmp (server[i].name, ctx->name) == 0) {
471          break;              fnd = true;
472      }              break;
473                }
474      return FALSE;      }
475  } /* keyserver_dlg_proc */      if (!fnd)
476            return;
477        server[i].port = ctx->port;
478    
479        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.25  
changed lines
  Added in v.273

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26