[Winpt-commits] r154 - trunk/Src

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 18 13:38:46 CET 2006


Author: twoaday
Date: 2006-01-18 13:38:46 +0100 (Wed, 18 Jan 2006)
New Revision: 154

Modified:
   trunk/Src/WinPT.cpp
Log:
A patch was missing.


Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp	2006-01-18 12:03:30 UTC (rev 153)
+++ trunk/Src/WinPT.cpp	2006-01-18 12:38:46 UTC (rev 154)
@@ -22,6 +22,7 @@
 #endif
 
 #include <windows.h>
+#include <shlobj.h>
 
 #include "resource.h"
 #include "wptTypes.h"
@@ -40,6 +41,7 @@
 #include "wptCardEdit.h"
 #include "wptCrypto.h"
 
+
 HINSTANCE glob_hinst;	/* global instance for the dialogs */
 HWND glob_hwnd;		/* global window handle for the dialogs */
 HWND activ_hwnd;
@@ -218,7 +220,7 @@
 	return false;
     }
     /* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */
-    if (ma > 1 || pa >= 3)
+    if (ma > 1 || pa >= 3)    
 	scard_support = 1;
 
     gpgver[0] = ma;
@@ -233,18 +235,49 @@
 static int
 load_keyserver_conf (int quiet)
 {
+    char *buf;
     const char *t;
     int rc;
 
-    if (reg_prefs.kserv_conf)
-	t = reg_prefs.kserv_conf;
-    else if (!file_exist_check (get_prog_part ("keyserver.conf", 0)))
+    /* Create $APPDATA\winpt if needed. */
+    buf = make_special_filename (CSIDL_APPDATA, "winpt", NULL);
+    if (buf && dir_exist_check (buf) && !CreateDirectory (buf, NULL)) {
+	MessageBox (NULL, _("Failed to create WinPT directory"), 
+		    _("Keyserver"), MB_ERR);
+	free_if_alloc (buf);
+	return -1;
+    }
+    free_if_alloc (buf);
+
+    /* Check for $APPDATA\winpt\keyserver.conf */
+    buf = make_special_filename (CSIDL_APPDATA, "winpt\\keyserver.conf", NULL);
+
+    if (!file_exist_check (get_prog_part ("keyserver.conf", 0)))
 	t = get_prog_part ("keyserver.conf", 0);
-    else 
+    else
 	t = "keyserver.conf";
+    if (file_exist_check (t) == 0 && file_exist_check (buf) != 0) {
+	log_box (_("Keyserver"), MB_INFO, 
+		 _("keyserver.conf will be copied to \"%s\"\r\n"), buf);
+	if (!CopyFile (t, buf, FALSE)) {
+	    MessageBox (NULL, _("Failed to copy the keyserver.conf"), 
+			_("Keyserver"), MB_ERR);
+	    free_if_alloc (buf);
+	    return -1;
+	}
+	t = buf;
+    }
+    else
+	t = buf;
+    
     rc = kserver_load_conf (t);
     if (rc && !quiet)
 	msg_box (NULL, winpt_strerror (rc), _("Keyserver"), MB_ERR);
+    else {
+	free_if_alloc (reg_prefs.kserv_conf);
+	reg_prefs.kserv_conf = m_strdup (t);
+    }
+    free_if_alloc (buf);
     return rc;
 }
 



More information about the Winpt-commits mailing list