[Winpt-commits] r115 - in trunk: . Include Src

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 7 09:11:35 CET 2005


Author: twoaday
Date: 2005-12-07 09:11:34 +0100 (Wed, 07 Dec 2005)
New Revision: 115

Modified:
   trunk/Include/wptContext.h
   trunk/Include/wptKeyserver.h
   trunk/NEWS
   trunk/Src/ChangeLog
   trunk/Src/WinPT.cpp
   trunk/Src/wptKeyManagerDlg.cpp
   trunk/Src/wptKeygenDlg.cpp
   trunk/Src/wptKeyserverDlg.cpp
   trunk/configure.ac
Log:
2005-12-06  Timo Schulz  <ts at g10code.com>
 
        * WinPT.cpp (WinMain): Load the gettext environment soon
        as possible so all 'first start' messages are localized.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): If a single key is
        received via the keyserver, return the gpgme key context on
        success and add it directly to the list.
        * wptKeyserverDlg.cpp (keyserver_dlg_proc): Support a param
        to store the key.
        (hkp_recv_key2): Add extra param for the fingerprint.
        (hkp_recv_key): Call hkp_recv_key2 without fingerprint.
         


Modified: trunk/Include/wptContext.h
===================================================================
--- trunk/Include/wptContext.h	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Include/wptContext.h	2005-12-07 08:11:34 UTC (rev 115)
@@ -106,6 +106,7 @@
     gpgme_key_t  newkey;	/* handle to the new key */
     int		 interactive;
     unsigned int first_start:1;
+    char	 *fpr;		/* fingerprint of the key. */
 };
 
 #endif /* WPT_CONTEXT_H */

Modified: trunk/Include/wptKeyserver.h
===================================================================
--- trunk/Include/wptKeyserver.h	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Include/wptKeyserver.h	2005-12-07 08:11:34 UTC (rev 115)
@@ -28,8 +28,8 @@
 #define DEF_HKP_KEYSERVER "http://subkeys.pgp.net"
 
 enum proxy_t {
-    PROXY_USER = 0,
-    PROXY_PASS = 1,
+    PROXY_USER = 0,	/* proxy username */
+    PROXY_PASS = 1,	/* proxy password */
 };
 
 /* Valid key server protocols. */
@@ -75,7 +75,7 @@
 
 #define MAX_KEYSERVERS 32
 extern keyserver server[MAX_KEYSERVERS]; /* runtime initialized */
-extern char * default_keyserver;
+extern char *default_keyserver;
 extern unsigned short default_keyserver_port;
 
 struct keyserver_key {
@@ -111,11 +111,13 @@
 int check_IP_or_hostname (const char *name);
 int kserver_check_inet_connection (void);
 int kserver_connect (const char *hostname, unsigned short port, int *conn_fd);
-int kserver_sendkey (const char *hostname, unsigned short port, const char *pubkey, int len);
+int kserver_sendkey (const char *hostname, unsigned short port, 
+		     const char *pubkey, int len);
 int kserver_recvkey (const char *hostname, unsigned short port, 
 		     const char *keyid, char *key, int maxkeylen);
 
-int kserver_search_init(const char *hostname, unsigned short port, const char *keyid, int *conn_fd);
+int kserver_search_init(const char *hostname, unsigned short port, 
+			const char *keyid, int *conn_fd);
 int kserver_search_chkresp (int conn_fd);
 int kserver_search (int conn_fd, keyserver_key *key);
 
@@ -126,8 +128,12 @@
 		    int maxkeylen);
 
 /*-- Dialog support --*/
-int hkp_send_key (HWND dlg, const char *kserver, unsigned short port, const char *pattern);
-int hkp_recv_key (HWND dlg, const char *kserver, unsigned short port, const char *pattern, 
-		  int proto, int flags);
+int hkp_send_key (HWND dlg, const char *kserver, unsigned short port, 
+		  const char *pattern);
+int hkp_recv_key (HWND dlg, const char *kserver, unsigned short port, 
+		  const char *pattern, int proto, int flags);
+int hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
+		   const char *pattern, int proto, int flags,
+		   char **r_fpr);
 
-#endif /* WPT_KEYSERVER_H_ */
+#endif /* WPT_KEYSERVER_H */

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/NEWS	2005-12-07 08:11:34 UTC (rev 115)
@@ -678,4 +678,10 @@
   do not assume 'ENCRYPTED'.
 * Fix a problem that the key cache will not be reloaded
   when a keys was updated/imported via the keyserver.
+
+(0.11.3)
+* Directly reload the key after it was received from a
+  keyserver.
+* Initialize gettext early as possible to avoid that
+  greeting messages are still in English.
   
\ No newline at end of file

Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Src/ChangeLog	2005-12-07 08:11:34 UTC (rev 115)
@@ -1,3 +1,15 @@
+2005-12-06  Timo Schulz  <ts at g10code.com>
+
+	* WinPT.cpp (WinMain): Load the gettext environment soon
+	as possible so all 'first start' messages are localized.
+	* wptKeyManagerDlg.cpp (keymanager_dlg_proc): If a single key is
+        received via the keyserver, return the gpgme key context on
+	success and add it directly to the list.
+	* wptKeyserverDlg.cpp (keyserver_dlg_proc): Support a param
+	to store the key.
+	(hkp_recv_key2): Add extra param for the fingerprint.
+	(hkp_recv_key): Call hkp_recv_key2 without fingerprint.
+	
 2005-12-01  Timo Schulz  <ts at g10code.com>
 
 	* wptClipVerifyDlg.cpp (clipverify_dlg_proc): Use new semantic

Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Src/WinPT.cpp	2005-12-07 08:11:34 UTC (rev 115)
@@ -290,6 +290,7 @@
 	mobile = 1;
     }
 
+    load_gettext (winpt_inst_found);    
     set_default_kserver ();
 
     if (!mobile) {
@@ -386,7 +387,6 @@
 	    return 0;
     }
 
-    load_gettext (winpt_inst_found);
     init_gnupg_table ();
 
     nfiles = fm_parse_command_line (cmdline);

Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Src/wptKeyManagerDlg.cpp	2005-12-07 08:11:34 UTC (rev 115)
@@ -1251,9 +1251,12 @@
 	    return TRUE;
             
         case ID_KEYMISC_SENDRECV:
+	    memset (&genkey, 0, sizeof (genkey));
             dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg,
-                              keyserver_dlg_proc, 0, _("Keyserver Access"), 
-			      IDS_WINPT_KEYSERVER );
+                              keyserver_dlg_proc, (LPARAM)&genkey, 
+			      _("Keyserver Access"), IDS_WINPT_KEYSERVER);
+	    if (genkey.newkey != NULL)
+		keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey);	    
             return TRUE;
             
         case ID_KEYMISC_GPGPREFS:

Modified: trunk/Src/wptKeygenDlg.cpp
===================================================================
--- trunk/Src/wptKeygenDlg.cpp	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Src/wptKeygenDlg.cpp	2005-12-07 08:11:34 UTC (rev 115)
@@ -532,26 +532,25 @@
             err = gpg_genkey (p, keygen_cb, &fpr);
             wipememory (pwd, sizeof (pwd));	
 	    wipememory (pwd2, sizeof (pwd2));
-            if( p ) {
+            if (p) {
 		wipememory (p, strlen (p));  /* burn the passphrase! */
                 free (p);
             }
             keygen_cb_dlg_destroy ();
             keygen_cb (NULL, NULL, 0, 0, 0); /* flush */
-            if( err ) {
+            if (err) {
 		if (fpr)
 		    free (fpr);
-                msg_box (dlg, gpgme_strerror( err ), _("Key Generation"), MB_ERR);
+                msg_box (dlg, gpgme_strerror (err), _("Key Generation"), MB_ERR);
                 return FALSE;
             }
-            status_box( dlg, _("Key Generation completed"), _("GnuPG Status") );
+            status_box (dlg, _("Key Generation completed"), _("GnuPG Status"));
             
 	    keycache_update (0, fpr);
 	    keycache_update (1, fpr);
 	    if (ctx != NULL && ctx->first_start == 0)
 		get_pubkey (fpr, &ctx->newkey);
-	    if (fpr)
-		free (fpr);
+	    safe_free (fpr);
 
             clear_dlg_fields (dlg);
             backup_keyrings (dlg);
@@ -597,7 +596,6 @@
 	SetWindowText (dlg, _("Key Generation Wizard"));
 	SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
 	SetDlgItemText (dlg, IDC_KEYWIZARD_EXPERT, _("E&xpert"));
-	
 	SetForegroundWindow (dlg);
 	center_window (dlg, NULL);
 	break;

Modified: trunk/Src/wptKeyserverDlg.cpp
===================================================================
--- trunk/Src/wptKeyserverDlg.cpp	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/Src/wptKeyserverDlg.cpp	2005-12-07 08:11:34 UTC (rev 115)
@@ -1,5 +1,6 @@
 /* wptKeyserverDlg.cpp - Keyserver dialog
  *	Copyright (C) 2000-2005 Timo Schulz
+ *	Copyright (C) 2005 g10 Code GmbH
  *
  * This file is part of WinPT.
  *
@@ -105,17 +106,19 @@
    with the pattern @pattern.
    Return value: 0 on success. */
 int
-hkp_recv_key (HWND dlg, const char *kserver, WORD port, 
-	      const char *pattern, int proto, int flags)
+hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
+	       const char *pattern, int proto, int flags,
+	       char **r_fpr)
 {
     gpgme_ctx_t ctx;
     gpgme_data_t keydata;
     gpgme_error_t ec;
-    gpgme_import_result_t import_res = NULL;
-    int rc;
+    gpgme_import_result_t import_res = NULL;    
     char *rawkey = NULL;
     char msg[384];
+    int rc;
     
+    /* XXX: implement dynamic buffers. */
     rawkey = new char[MAX_KEYSIZE];
     if (!rawkey)
 	BUG (0);
@@ -163,6 +166,8 @@
             goto leave;
         }
 	import_res = gpgme_op_import_result (ctx);
+	if (r_fpr)
+	    *r_fpr = m_strdup (import_res->imports->fpr);
     }
     
     /* if we use the refresh mode, a lot of keys will be fetched and thus only
@@ -188,6 +193,16 @@
 }
 
 
+/* Alias for hkp_recv_key2 but without the ability to return 
+   the fingerprint of the key. */
+int
+hkp_recv_key (HWND dlg, const char *kserver, WORD port,
+	      const char *pattern, int proto, int flags)
+{
+    return hkp_recv_key2 (dlg, kserver, port, pattern, proto, flags, NULL);
+}
+
+
 #define my_iskeychar(a) (((a) >='0' && (a) <= '9' ) || ((a) >= 'A' && (a) <= 'F'))
 
 static int
@@ -361,13 +376,16 @@
 {
     static listview_ctrl_t lv = NULL;
     static int lv_idx = 0;
+    static struct genkey_s *key;
+    keyserver_ctx ksc;
+    char kserver[128], pattern[128];
+    char proto[16];
     int rc, proto_nr = 0;
-    char kserver[128], pattern[128];
-    char proto[16];    
-    keyserver_ctx ksc;
     
-    switch ( msg ) {
+    switch (msg) {
     case WM_INITDIALOG:
+	if (lparam != 0)
+	    key = (struct genkey_s*)lparam;
         SetWindowText (dlg, _("Keyserver Access"));
 	SetDlgItemText (dlg, IDC_KEYSERVER_RECV, _("&Receive"));
         SetDlgItemText (dlg, IDC_KEYSERVER_SEND, 
@@ -388,31 +406,31 @@
     case WM_NOTIFY:
         NMHDR *notify;
         notify = (NMHDR *)lparam;
-        if( notify && notify->code == NM_CLICK
-            && notify->idFrom == IDC_KEYSERVER_LIST )
-            lv_idx = listview_get_curr_pos( lv );
+        if (notify && notify->code == NM_CLICK
+            && notify->idFrom == IDC_KEYSERVER_LIST)
+            lv_idx = listview_get_curr_pos (lv);
         return TRUE;
         
     case WM_DESTROY:
-        if( lv ) {
-            listview_release( lv );
+        if (lv) {
+            listview_release (lv);
             lv = NULL;
         }
         lv_idx = 0;
         return FALSE;
         
     case WM_SYSCOMMAND:
-        if( LOWORD( wparam ) == SC_CLOSE )
-            EndDialog( dlg, TRUE );
+        if (LOWORD (wparam) == SC_CLOSE)
+            EndDialog (dlg, TRUE);
         return FALSE;
         
     case WM_COMMAND:
-        switch( LOWORD( wparam ) ) {
+        switch (LOWORD (wparam)) {
         case IDC_KEYSERVER_PROXSETT:
-            dialog_box_param( glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_PROXY, glob_hwnd,
-                              keyserver_proxy_dlg_proc, NULL, 
-                              _("Proxy Settings"), IDS_WINPT_KEYSERVER_PROXY );
-            set_proxy( dlg );
+            dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYSERVER_PROXY, 
+			      dlg, keyserver_proxy_dlg_proc, 0,
+                              _("Proxy Settings"), IDS_WINPT_KEYSERVER_PROXY);
+            set_proxy (dlg);
             return TRUE;
             
         case IDC_KEYSERVER_INDEX:
@@ -426,19 +444,21 @@
             }
             listview_get_item_text (lv, lv_idx, 1, proto, sizeof (proto)-1);
             if (*proto == 'L') {
-                msg_box( dlg, _("This is not implemented yet!"), _("Keyserver"), MB_ERR );
+                msg_box (dlg, _("This is not implemented yet!"), 
+			 _("Keyserver"), MB_ERR);
                 return FALSE;
             }
             listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);
             if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {
-                msg_box (dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO);
+                msg_box (dlg, _("Please enter the search pattern."), 
+			 _("Keyserver"), MB_INFO);
                 return FALSE;
             }
             ksc.name = kserver;
             ksc.pattern = pattern;
 	    ksc.port = kserver_get_port (lv);
-            DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_HKPSEARCH, dlg,
-                            hkpsearch_dlg_proc, (LPARAM) &ksc );
+            DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_HKPSEARCH, dlg,
+                            hkpsearch_dlg_proc, (LPARAM) &ksc);
             return TRUE;
             
         case IDC_KEYSERVER_RECV:
@@ -453,32 +473,40 @@
             }
             listview_get_item_text( lv, lv_idx, 1, proto, sizeof (proto)-1 );
 	    proto_nr = KSPROTO_HTTP;
-            if( *proto == 'L' )
+            if (*proto == 'L')
 		proto_nr = KSPROTO_LDAP;
-	    else if( *proto == 'F' )
+	    else if (*proto == 'F')
 		proto_nr = KSPROTO_FINGER;
-            listview_get_item_text( lv, lv_idx, 0, kserver, sizeof (kserver)-1 );
-            if( !GetDlgItemText( dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1 ) ) {
-                msg_box( dlg, _("Please enter the search pattern."), _("Keyserver"), MB_INFO );
+            listview_get_item_text (lv, lv_idx, 0, kserver, sizeof (kserver)-1);
+            if( !GetDlgItemText( dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {
+                msg_box (dlg, _("Please enter the search pattern."),
+			 _("Keyserver"), MB_INFO);
                 return FALSE;
             }
-            if( proto_nr == KSPROTO_LDAP && strchr( pattern, '@' ) ) {
-                msg_box( dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO );
+            if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) {
+                msg_box (dlg, _("Only keyids are allowed."), _("LDAP Keyserver"), MB_INFO);
                 return FALSE;
             }
 	    else if (proto_nr == KSPROTO_FINGER) {
 		if (strchr (pattern, '@') || strchr (pattern, ' ')) {
-		    msg_box (dlg, _("Only enter the name of the user."), _("FINGER Keyserver"), MB_INFO);
+		    msg_box (dlg, _("Only enter the name of the user."), 
+			     _("FINGER Keyserver"), MB_INFO);
 		    return FALSE;
 		}
 	    }
-            else if( check_pattern( pattern ) ) {
-                msg_box( dlg, _("Only email addresses or keyids are allowed."), _("HKP Keyserver"), MB_INFO );
+            else if (check_pattern (pattern)) {
+                msg_box (dlg, _("Only email addresses or keyids are allowed."),
+			_("HKP Keyserver"), MB_INFO);
                 return FALSE;
             }
-	    rc = hkp_recv_key (dlg, kserver, kserver_get_port (lv), pattern, proto_nr, 0);
-	    if (!rc)
-		keycache_set_reload (1);
+	    rc = hkp_recv_key2 (dlg, kserver, kserver_get_port (lv),
+				pattern, proto_nr, 0, key? &key->fpr : NULL);
+	    if (!rc && key->fpr != NULL) {
+		keycache_update (0, key->fpr);
+		get_pubkey (key->fpr, &key->newkey);
+		/* we do not need the fingerprint any longer. */
+		free_if_alloc (key->fpr);
+	    }
             return TRUE;
 
 	case IDC_KEYSERVER_DEFAULT:
@@ -494,4 +522,3 @@
     
     return FALSE;
 }
-

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2005-12-06 17:29:57 UTC (rev 114)
+++ trunk/configure.ac	2005-12-07 08:11:34 UTC (rev 115)
@@ -15,7 +15,7 @@
 
 # Version number: Remember to change it immediately *after* a release.
 #                 Add a "-cvs" prefix for non-released code.
-AC_INIT(WinPT, 0.11.2, http://www.winpt.org)
+AC_INIT(WinPT, 0.11.3-cvs, http://www.winpt.org)
 
 NEED_GPGME_API=1
 NEED_GPGME_VERSION=1.1.0



More information about the Winpt-commits mailing list