evolution-exchange r1650 - trunk/storage



Author: tml
Date: Tue May 13 16:34:27 2008
New Revision: 1650
URL: http://svn.gnome.org/viewvc/evolution-exchange?rev=1650&view=rev

Log:
2008-05-13  Tor Lillqvist  <tml novell com>

	More outstanding Win32 portability changes from a couple of years
	ago.

	* storage/Makefile.am: Link with SOCKET_LIBS, too. On Windows, use
	a relative path for CONNECTOR_PATH in the server file instead of
	the absolute compile-time EVOLUTION_privlibexecdir. Replace also
	EXEEXT in the server file.

	* storage/exchage-storage.h: On Windows, declare three char*
	variables that will hold the datadir, gladedir and imagesdir
	constructed at run-time.

	* storage/main.c: Define and initialise the three char* variables
	mentioned above. Assume that evolution-exchange is installed in
	the same run-time prefix as evolution-data-server. Use
	g_get_tmp_dir() instead of hardcoding /tmp. Use gstdio wrappers to
	cope with arbitrary Unicode pathnames on Windows. Don't bother
	with the folder mode checks on Windows, as the stat::st_mode field
	is mostly meaningless.

	* storage/GNOME_Evolution_Exchange_Storage.server.in.in: Add
	EXEEXT to the executable name.



Modified:
   trunk/storage/GNOME_Evolution_Exchange_Storage.server.in.in
   trunk/storage/Makefile.am
   trunk/storage/exchange-storage.h
   trunk/storage/main.c

Modified: trunk/storage/GNOME_Evolution_Exchange_Storage.server.in.in
==============================================================================
--- trunk/storage/GNOME_Evolution_Exchange_Storage.server.in.in	(original)
+++ trunk/storage/GNOME_Evolution_Exchange_Storage.server.in.in	Tue May 13 16:34:27 2008
@@ -2,7 +2,7 @@
 
 <oaf_server iid="OAFIID:GNOME_Evolution_Exchange_Component_Factory:@BASE_VERSION@"
 	    type="exe"
-	    location="@CONNECTOR_PATH@/evolution-exchange-storage">
+	    location="@CONNECTOR_PATH@/evolution-exchange-storage EXEEXT@">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:GNOME/ObjectFactory:1.0"/>
@@ -40,7 +40,7 @@
 
 <oaf_server iid="OAFIID:GNOME_Evolution_Exchange_Connector_BookFactory:@API_VERSION@"
             type="exe"
-            location="@CONNECTOR_PATH@/evolution-exchange-storage">
+            location="@CONNECTOR_PATH@/evolution-exchange-storage EXEEXT@">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:GNOME/Evolution/DataServer/BookFactory:@API_VERSION@"/>
@@ -58,7 +58,7 @@
 
 <oaf_server iid="OAFIID:GNOME_Evolution_Exchange_Connector_CalFactory:@API_VERSION@"
             type="exe"
-            location="@CONNECTOR_PATH@/evolution-exchange-storage">
+            location="@CONNECTOR_PATH@/evolution-exchange-storage EXEEXT@">
 
 	<oaf_attribute name="repo_ids" type="stringv">
 		<item value="IDL:GNOME/Evolution/DataServer/CalFactory:@API_VERSION@"/>

Modified: trunk/storage/Makefile.am
==============================================================================
--- trunk/storage/Makefile.am	(original)
+++ trunk/storage/Makefile.am	Tue May 13 16:34:27 2008
@@ -45,7 +45,8 @@
 	$(top_builddir)/camel/camel-stub-marshal.lo		\
 	$(LDAP_LIBS)						\
 	$(EXCHANGE_STORAGE_LIBS)				\
-	$(LIBEXCHANGE_LIBS)
+	$(LIBEXCHANGE_LIBS)					\
+	$(SOCKET_LIBS)
 
 
 exchange_connector_setup_SOURCES =				\
@@ -79,10 +80,17 @@
 server_in_files = GNOME_Evolution_Exchange_Storage.server.in.in
 server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server)
 
+if OS_WIN32
+CONNECTOR_PATH_IN_SERVER_FILE=../../../libexec/evolution/${BASE_VERSION}
+else
+CONNECTOR_PATH_IN_SERVER_FILE=${EVOLUTION_privlibexecdir}
+endif
+
 %_$(BASE_VERSION).server.in: %.server.in.in
-	sed -e "s;\ CONNECTOR_PATH\@;${EVOLUTION_privlibexecdir};g"	\
+	sed -e "s;\ CONNECTOR_PATH\@;${CONNECTOR_PATH_IN_SERVER_FILE};g"	\
 	    -e "s;\ IMAGESDIR\@;${imagesdir};g"				\
 	    -e "s;\ BASE_VERSION\@;${BASE_VERSION};g"			\
+	    -e "s;\ EXEEXT\@;${EXEEXT};g"				\
 	    -e "s;\ API_VERSION\@;${API_VERSION};g"			\
 	    -e "s;\ EDS_BASE_VERSION\@;${EDS_BASE_VERSION};g"		\
 	    < $< > $@

Modified: trunk/storage/exchange-storage.h
==============================================================================
--- trunk/storage/exchange-storage.h	(original)
+++ trunk/storage/exchange-storage.h	Tue May 13 16:34:27 2008
@@ -33,6 +33,14 @@
 
 EStorage         *exchange_storage_new      (ExchangeAccount *account);
 
+#ifdef G_OS_WIN32
+
+extern const char *_exchange_storage_datadir;
+extern const char *_exchange_storage_gladedir;
+extern const char *_exchange_storage_imagesdir;
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/storage/main.c
==============================================================================
--- trunk/storage/main.c	(original)
+++ trunk/storage/main.c	Tue May 13 16:34:27 2008
@@ -29,6 +29,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-generic-factory.h>
 #include <bonobo/bonobo-exception.h>
@@ -42,6 +45,8 @@
 #include <libedata-cal/e-data-cal-factory.h>
 #include <libebackend/e-data-server-module.h>
 
+#include <libedataserver/e-data-server-util.h>
+
 #include <e2k-utils.h>
 #include <exchange-constants.h>
 #include "addressbook/e-book-backend-exchange.h"
@@ -61,6 +66,12 @@
 
 ExchangeComponent *global_exchange_component;
 
+#ifdef G_OS_WIN32
+const char *_exchange_storage_datadir;
+const char *_exchange_storage_gladedir;
+const char *_exchange_storage_imagesdir;
+#endif
+
 static BonoboObject *
 exchange_component_factory (BonoboGenericFactory *factory,
 			    const char *component_id, void *component)
@@ -171,10 +182,35 @@
 int
 main (int argc, char **argv)
 {
-	char *path;
+	char *userdir, *path;
 	char *config_directory;
 
+#ifdef G_OS_WIN32
+	{
+		char *localedir;
+
+		/* We assume evolution-exchange is installed in the
+		 * same run-time prefix as evolution-data-server.
+		 */
+		_exchange_storage_datadir = e_util_replace_prefix (PREFIX, e_util_get_prefix (), DATADIR);
+		_exchange_storage_gladedir = e_util_replace_prefix (PREFIX, e_util_get_prefix (), CONNECTOR_GLADEDIR);
+		_exchange_storage_imagesdir = e_util_replace_prefix (PREFIX, e_util_get_prefix (), CONNECTOR_IMAGESDIR);
+		
+		localedir = e_util_replace_prefix (CONNECTOR_LOCALEDIR, e_util_get_cp_prefix (), CONNECTOR_LOCALEDIR);
+		bindtextdomain (GETTEXT_PACKAGE, localedir);
+	}
+
+/* PREFIX and DATADIR are part of GNOME_PROGRAM_STANDARD_PROPERTIES */
+
+#undef PREFIX
+#define PREFIX e_util_get_prefix ()
+
+#undef DATADIR
+#define DATADIR _exchange_storage_datadir
+
+#else
 	bindtextdomain (GETTEXT_PACKAGE, CONNECTOR_LOCALEDIR);
+#endif
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
@@ -188,20 +224,24 @@
 	camel_init (config_directory, FALSE);
 	g_free(config_directory);
 
-	path = g_strdup_printf ("/tmp/.exchange-%s", g_get_user_name ());
-	if (mkdir (path, 0700) == -1) {
+	userdir = g_strdup_printf (".exchange-%s", g_get_user_name ());
+	path = g_build_filename (g_get_tmp_dir (), userdir, NULL);
+	g_free (userdir);
+	if (g_mkdir (path, 0700) == -1) {
 		if (errno == EEXIST) {
 			struct stat st;
 
-			if (stat (path, &st) == -1) {
+			if (g_stat (path, &st) == -1) {
 				g_warning ("Could not stat %s", path);
 				return 1;
 			}
+#ifdef G_OS_UNIX
 			if (st.st_uid != getuid () ||
 			    (st.st_mode & 07777) != 0700) {
 				g_warning ("Bad socket dir %s", path);
 				return 1;
 			}
+#endif
 		} else {
 			g_warning ("Can't create %s", path);
 			return 1;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]