[evolution-patches] Evolution-exchange's outstanding Win32 diffs



I remembered that most of the Win32 work on evolution-exchange is yet to
be committed. Could somebody have a quick glance through this and give
an okay, thanks?

Cheers,
--tml

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.446
diff -p -u -2 -r1.446 ChangeLog
--- ChangeLog	18 Jan 2006 11:06:57 -0000	1.446
+++ ChangeLog	18 Jan 2006 11:07:22 -0000
@@ -1,4 +1,104 @@
 2006-01-18  Tor Lillqvist  <tml novell com>
 
+	Win32 port changes.
+
+	* addressbook/e-book-backend-exchange.c
+	* calendar/e-cal-backend-exchange.c
+	* mail/mail-stub-listener.c: Use gstdio wrappers.
+
+	* addressbook/e-book-backend-gal.c: Don't include ldap.h here, it
+	or its Win32 counterpart winldap.h is included through
+	e2k-global-catalog-ldap.h anyway.
+	(ldap_op_finished): Use ldap_abandon() instead of the nonstandard
+	ldap_abandon_ext(). The extra parameters were NULL anyway, meaning
+	it's equivalent to calling ldap_abandon().
+
+	* calendar/e-cal-backend-exchange.c: Use GLib file name and URI
+	manipulation functionality.
+	(load_cache): More illegal file name chars on Win32. Use GLib
+	functionality to manipulate file names. Just print a warning
+	instead of symlinking, as there are no symlinks on Win32. Will
+	have to figure out what is the right thing to do on Win32 later.
+
+	* camel/Makefile.am: Use -no-undefined on Win32. Link with
+	SOCKET_LIBS and PTHREAD_LIB.
+
+	* camel/camel-exchange-store.c (e_filename_make_safe)
+	* storage/exchange-component.c (e_filename_make_safe): Remove
+	these two copies of this function. Just use the one in
+	libedataserver. We use other functions from libedataserver already
+	anyway.
+
+	* camel/camel-exchange-store.c (exchange_connect): Use
+	g_get_tmp_dir() instead of hardcoding /tmp.
+	(exchange_get_folder): Use g_file_test() instead of access().
+
+	* camel/camel-exchange-summary.c: Drop stray inclusion of
+	sys/uio.h.
+
+	* camel/camel-stub-marshal.c: Use Winsock API on Win32. Just use
+	ifdefs here, instead of wrapper macros.
+	(camel_stub_marshal_free): Use closesocket().
+	(do_read): Use recv(). The socket is in non-blocking mode on Win32
+	but the code that calls do_read() isn't ready to handle that, so
+	just busy wait here sleeping for 20 milliseconds each round until
+	we get something.
+	(camel_stub_marshal_flush): Use send() and closesocket().
+
+	* camel/camel-stub.h: Use separate boolean flag
+	CamelStub::have_status_thread. There is no portable way to check a
+	pthread_t for initializedness.
+
+	* camel/camel-stub.c: Use Winsock API on Win32. No Unix domain
+	sockets on Win32. Check CamelStub::have_status_thread instead of
+	checking the status_thread field.
+	(connect_to_storage): In the Win32 implementation the "Unix domain
+	socket" is a regular file containing the sockaddr_in for a TCP
+	socket. Take the socket path as a parameter. Read the file and
+	connect to that socket.
+	(camel_stub_new): Adjust correspondingly.
+
+	* mail/mail-stub-exchange.c: Use g_get_host_name() when building
+	against GLib 2.8 or later.
+
+	* mail/mail-stub-listener.c: Use Winsock API on Win32. No Unix
+	domain sockets on Win32.
+	(new_connection): Drop unused sa_un and len variables. Just pass
+	NULL as parameters 2 and 3 to accept().
+	(mail_stub_listener_construct): On Win32, instead of creating a
+	Unix domain socket, create a TCP socket bound to the loopback
+	interface and write its sockaddr_in to a regular file from which
+	the client will read the address. Sure, this presumably has
+	(intra-machine) security issues.
+
+	* mail/mail-stub.c: Use g_io_channel_win32_new_socket() on Win32
+	instead of g_io_channel_unix_new(), to spell it out that we know
+	it is a socket. Otherwise there is a real risk that the socket we
+	are handling also happens to be a file descriptor, and GLib can't
+	know which interpretation is intended if we call
+	g_io_channel_unix_new() (and will in fact choose to think it's a
+	file descriptor).
+
+	* storage/GNOME_Evolution_Exchange_Storage.server.in.in: Use
+	EXEEXT.
+
+	* storage/Makefile.am: Substitute EXEEXT in .server file.
+
+	* storage/exchange-component.c (config_listener_account_created):
+	Use g_get_tmp_dir() instead of hardcoding /tmp.
+	(default_linestatus_notify_handler): Use guint instead of uint.
+
+	* storage/exchange-config-listener.c: Use e_xml_parse_file() and
+	e_xml_save_file() instead of libxml directly. Use GDir instead of
+	dirent.
+
+	* storage/exchange-migrate.c: Bypass migration code on Win32 as
+	there are no old versions to migrate from.
+
+	* storage/main.c: Use g_get_tmp_dir() instead of hardcoding
+	/tmp. Use gstdio wrappers.
+
+2006-01-18  Tor Lillqvist  <tml novell com>
+
 	* evolution-exchange-zip.in: New file, used to build a zipfile
 	Win32 binary distribution of evolution-exchange for developers and
Index: addressbook/e-book-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/addressbook/e-book-backend-exchange.c,v
retrieving revision 1.47
diff -p -u -2 -r1.47 e-book-backend-exchange.c
--- addressbook/e-book-backend-exchange.c	21 Dec 2005 06:51:49 -0000	1.47
+++ addressbook/e-book-backend-exchange.c	18 Jan 2006 11:07:24 -0000
@@ -32,4 +32,7 @@
 #include <time.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <libedataserver/e-sexp.h>
 #include <libedataserver/e-uid.h>
@@ -505,5 +508,5 @@ update_cache (EBookBackendExchange *be)
 		e_file_cache_get_filename (E_FILE_CACHE(bepriv->cache)); 
 
-	stat (cache_file_name, &buf);
+	g_stat (cache_file_name, &buf);
 	mod_time = buf.st_mtime;
 	tm = gmtime (&mod_time);
Index: addressbook/e-book-backend-gal.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/addressbook/e-book-backend-gal.c,v
retrieving revision 1.28
diff -p -u -2 -r1.28 e-book-backend-gal.c
--- addressbook/e-book-backend-gal.c	26 Aug 2005 14:33:49 -0000	1.28
+++ addressbook/e-book-backend-gal.c	18 Jan 2006 11:07:26 -0000
@@ -35,13 +35,4 @@
 #include "exchange-component.h"
 
-#ifdef DEBUG
-#define LDAP_DEBUG
-#define LDAP_DEBUG_ADD
-#endif
-#include <ldap.h>
-#ifdef DEBUG
-#undef LDAP_DEBUG
-#endif
-
 #define d(x)
 
@@ -1692,5 +1683,5 @@ ldap_cancel_op(void *key, void *value, v
 	g_mutex_lock (bl->priv->ldap_lock);
 	if (bl->priv->ldap)
-		ldap_abandon_ext (bl->priv->ldap, op->id, NULL, NULL);
+		ldap_abandon (bl->priv->ldap, op->id);
 	g_mutex_unlock (bl->priv->ldap_lock);
 }
@@ -1713,5 +1704,4 @@ set_mode (EBookBackend *backend, int mod
 	EBookBackendGAL *be = E_BOOK_BACKEND_GAL (backend);
 	EBookBackendGALPrivate *bepriv;
-	ExchangeAccountResult result;
 
 	bepriv = be->priv;
Index: calendar/e-cal-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange.c,v
retrieving revision 1.53
diff -p -u -2 -r1.53 e-cal-backend-exchange.c
--- calendar/e-cal-backend-exchange.c	18 Jan 2006 10:50:02 -0000	1.53
+++ calendar/e-cal-backend-exchange.c	18 Jan 2006 11:07:27 -0000
@@ -30,4 +30,7 @@
 #include <libedataserver/e-time-utils.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 
@@ -45,7 +48,11 @@
 #include <mapi.h>
 
-#include <e-folder-exchange.h>
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#include "e-folder-exchange.h"
 #include "exchange-component.h"
-#include <exchange-hierarchy.h>
+#include "exchange-hierarchy.h"
 
 struct ECalBackendExchangePrivate {
@@ -140,5 +147,5 @@ load_cache (ECalBackendExchange *cbex, E
 	icalcomponent_kind kind;
 	icalproperty *prop;
-	char *lastmod, *mangled_uri, *storage_dir, *end;
+	char *lastmod, *mangled_uri, *storage_dir;
 	const char *uristr;
 	int i;
@@ -159,12 +166,23 @@ load_cache (ECalBackendExchange *cbex, E
 		case ':' :
 		case '/' :
+#ifdef G_OS_WIN32
+		case '\\' :
+		case '<' :
+		case '>' :
+		case '|' :
+#endif
 			mangled_uri[i] = '_';
 		}
 	}
 	cbex->priv->local_attachment_store = g_strdup_printf ("%s/.evolution/exchange/%s", g_get_home_dir (), mangled_uri);
-	end = strrchr (cbex->priv->object_cache_file, '/');
-	storage_dir = g_strndup (cbex->priv->object_cache_file, end - cbex->priv->object_cache_file);
-	if (lstat(cbex->priv->local_attachment_store , &buf) < 0) {
+	storage_dir = g_path_get_dirname (cbex->priv->object_cache_file);
+	if (g_lstat(cbex->priv->local_attachment_store , &buf) < 0) {
+#ifdef G_OS_UNIX
 		symlink (storage_dir, cbex->priv->local_attachment_store);
+#else
+		g_warning ("should symlink %s->%s, huh?",
+			   cbex->priv->local_attachment_store,
+			   storage_dir);
+#endif
 	}
 	g_free (storage_dir);
@@ -257,5 +275,5 @@ timeout_save_cache (gpointer user_data)
 
 	tmpfile = g_strdup_printf ("%s~", cbex->priv->object_cache_file);
-	f = fopen (tmpfile, "w");
+	f = g_fopen (tmpfile, "wb");
 	if (!f)
 		goto error;
@@ -266,6 +284,6 @@ timeout_save_cache (gpointer user_data)
 		goto error;
 
-	if (rename (tmpfile, cbex->priv->object_cache_file) != 0)
-		unlink (tmpfile);
+	if (g_rename (tmpfile, cbex->priv->object_cache_file) != 0)
+		g_unlink (tmpfile);
 error:
 	g_free (tmpfile);
@@ -1468,5 +1486,5 @@ save_attach_file (const char *dest_file,
 
 	/* Write it to our local exchange store in .evolution */
-	fd = open (dest_file, O_RDWR | O_CREAT | O_TRUNC, 0600);
+	fd = g_open (dest_file, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
 	if (fd < 0) {
 		d(printf ("open of destination file for attachments failed\n"));
@@ -1479,5 +1497,5 @@ save_attach_file (const char *dest_file,
 	}
 	/* FIXME : Add a ATTACH:CID:someidentifier here */
-	dest_url = g_strdup_printf ("file://%s", dest_file);
+	dest_url = g_filename_to_uri (dest_file, NULL, NULL);
 
 end :
@@ -1546,5 +1564,5 @@ get_attach_file_contents (const char *fi
 	char *file_contents = NULL;
 
-	fd = open (filename, O_RDONLY);
+	fd = g_open (filename, O_RDONLY | O_BINARY, 0);
 	if (fd < 0) {
 		d(printf ("Could not open the attachment file : %s\n", filename));
@@ -1591,4 +1609,5 @@ build_msg ( ECalBackendExchange *cbex, E
 	GSList *attach_list = NULL, *l, *new_attach_list = NULL;
 	char *fname, *file_contents = NULL, *filename, *dest_url, *mime_filename, *attach_file;
+	char *mime_type;
 	int len = 0;
 
@@ -1611,23 +1630,29 @@ build_msg ( ECalBackendExchange *cbex, E
 	for (l = attach_list; l ; l = l->next){
 		if (!strncmp ((char *)l->data, "file://", 7)) {
-			fname = (char *)(l->data) + strlen ("file://");
-			filename = g_strrstr (fname, "/") + 1;
-			mime_filename = filename + strlen(uid) + 1;
-			attach_file = g_strdup (fname);
+			fname = g_filename_from_uri ((char *)l->data, NULL, NULL);
+			filename = g_path_get_basename (fname);
+			mime_filename = g_strdup (filename + strlen(uid) + 1);
+			g_free (filename);
+			attach_file = fname;
 		} else {
 			fname = (char *)(l->data);
-			filename = g_strrstr (fname, "/") + 1;
-			mime_filename = filename;
-			attach_file = g_strdup_printf ("%s/%s-%s", cbex->priv->local_attachment_store, uid, filename);
+			mime_filename = g_path_get_basename (fname);
+			attach_file = g_strdup_printf ("%s/%s-%s", cbex->priv->local_attachment_store, uid, mime_filename);
 		}
+		/* mime_filename and attach_file should be g_freed */
 	
 		file_contents = get_attach_file_contents (fname, &len);
-			if (!file_contents)
+		if (!file_contents){
+			g_free (attach_file);
+			g_free (mime_filename);
 			continue;
+		}
 
 		dest_url = save_attach_file (attach_file, file_contents, len);
 		g_free (attach_file);
-		if (!dest_url)
+		if (!dest_url){
+			g_free (mime_filename);
 			continue;
+		}
 		new_attach_list = g_slist_append (new_attach_list, dest_url);
 
@@ -1638,5 +1663,8 @@ build_msg ( ECalBackendExchange *cbex, E
 		camel_object_unref (stream);
 
-		char *mime_type = gnome_vfs_get_mime_type (dest_url + strlen ("file://"));
+		filename = g_filename_from_uri (dest_url, NULL, NULL);
+		mime_type = gnome_vfs_get_mime_type (filename);
+		g_free (filename);
+
 		type = camel_content_type_decode (mime_type);
 		camel_data_wrapper_set_mime_type_field (wrapper, type);
@@ -1651,4 +1679,5 @@ build_msg ( ECalBackendExchange *cbex, E
 		camel_mime_part_set_content_id (mime_part, cid);	
 		camel_mime_part_set_description (mime_part, mime_filename);
+		g_free (mime_filename);
 		camel_mime_part_set_disposition (mime_part, "attachment");
 		camel_multipart_set_boundary (multipart, NULL);
Index: camel/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/Makefile.am,v
retrieving revision 1.9
diff -p -u -2 -r1.9 Makefile.am
--- camel/Makefile.am	16 Sep 2005 04:24:25 -0000	1.9
+++ camel/Makefile.am	18 Jan 2006 11:07:27 -0000
@@ -10,4 +10,5 @@ INCLUDES =					\
 	$(SHELL_CFLAGS)				\
 	$(LIBEXCHANGE_CFLAGS)			\
+	-DPREFIX=\"$(prefix)\"			\
 	-DCONNECTOR_LOCALEDIR=\"$(localedir)\"	\
 	-DG_LOG_DOMAIN=\"camel-exchange-provider\"	
@@ -35,10 +36,12 @@ noinst_HEADERS =				\
 	camel-stub.h
 
-libcamelexchange_la_LDFLAGS = -avoid-version -module
+libcamelexchange_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
 
 libcamelexchange_la_LIBADD = 			\
 	$(LDAP_LIBS)				\
 	$(LIBEXCHANGE_LIBS)			\
-	$(EXCHANGE_STORAGE_LIBS)
+	$(EXCHANGE_STORAGE_LIBS)		\
+	$(SOCKET_LIBS)				\
+	$(PTHREAD_LIB)
 
 EXTRA_DIST = libcamelexchange.urls
Index: camel/camel-exchange-provider.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-provider.c,v
retrieving revision 1.27
diff -p -u -2 -r1.27 camel-exchange-provider.c
--- camel/camel-exchange-provider.c	29 Aug 2005 09:51:53 -0000	1.27
+++ camel/camel-exchange-provider.c	18 Jan 2006 11:07:27 -0000
@@ -26,4 +26,6 @@
 #include <string.h>
 
+#include <libedataserver/e-data-server-util.h> /* For some Win32 functions */
+
 #include <camel/camel-i18n.h>
 #include <camel/camel-provider.h>
@@ -35,4 +37,17 @@
 static guint exchange_url_hash (gconstpointer key);
 static gint exchange_url_equal (gconstpointer a, gconstpointer b);
+
+#ifdef G_OS_WIN32
+
+static const char *
+get_localedir (void)
+{
+	return e_util_replace_prefix (PREFIX, e_util_get_cp_prefix (), CONNECTOR_LOCALEDIR);
+}
+
+#undef CONNECTOR_LOCALEDIR
+#define CONNECTOR_LOCALEDIR get_localedir ()
+
+#endif
 
 CamelProviderConfEntry exchange_conf_entries[] = {
Index: camel/camel-exchange-store.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-store.c,v
retrieving revision 1.27
diff -p -u -2 -r1.27 camel-exchange-store.c
--- camel/camel-exchange-store.c	28 Sep 2005 13:46:00 -0000	1.27
+++ camel/camel-exchange-store.c	18 Jan 2006 11:07:28 -0000
@@ -26,9 +26,15 @@
 #include <string.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <camel/camel-i18n.h>
+#include <camel/camel-session.h>
+
+#include <e-util/e-util.h>
+#include <libedataserver/e-data-server-util.h>
 
 #include "camel-exchange-store.h"
 #include "camel-exchange-folder.h"
-#include <camel/camel-session.h>
 
 #define SUBFOLDER_DIR_NAME     "subfolders"
@@ -317,27 +323,4 @@ get_name (CamelService *service, gboolea
 #define EXCHANGE_STOREINFO_VERSION 1
 
-/* SURF : Picked this from gal/util/e-util.c */
-/* This only makes a filename safe for usage as a filename.  
-	It still may have shell meta-characters in it. */
-static void
-e_filename_make_safe (gchar *string)
-{
-	gchar *p, *ts;
-	gunichar c;
-	
-	g_return_if_fail (string != NULL);
-	p = string;
-
-	while(p && *p) {
-		c = g_utf8_get_char (p);
-		ts = p;
-		p = g_utf8_next_char (p);
-		if (!g_unichar_isprint(c) || ( c < 0xff && strchr (" /'\"`&();|<>$%{}!", c&0xff ))) {
-			while (ts<p) 	
-				*ts++ = '_';
-		}
-	}
-}
-
 static void
 camel_exchange_get_password (CamelService *service, CamelException *ex)
@@ -377,5 +360,5 @@ exchange_connect (CamelService *service,
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service);
-	char *real_user, *socket_path;
+	char *real_user, *socket_path, *user_at_host;
 	gchar *password = NULL;
 	guint32 connect_status;
@@ -396,8 +379,11 @@ exchange_connect (CamelService *service,
 		else
 			real_user = service->url->user;
-		socket_path = g_strdup_printf ("/tmp/.exchange-%s/%s %s",
+		user_at_host = g_strdup_printf ("%s %s", real_user, service->url->host);
+		e_filename_make_safe (user_at_host);
+		socket_path = g_strdup_printf ("%s/.exchange-%s/%s",
+					       g_get_tmp_dir (),
 					       g_get_user_name (),
-					       real_user, service->url->host);
-		e_filename_make_safe (strchr (socket_path + 5, '/') + 1);
+					       user_at_host);
+		g_free (user_at_host);
 		
 		exch->stub = camel_stub_new (socket_path, _("Evolution Exchange backend process"), ex);
@@ -481,5 +467,5 @@ exchange_get_folder (CamelStore *store, 
 	
 	if (!camel_exchange_store_connected (exch, ex)) {
-		if (!folder_dir || access (folder_dir, F_OK) != 0) {
+		if (!folder_dir || !g_file_test (folder_dir, G_FILE_TEST_IS_DIR)) {
 			g_free (folder_dir);
 			camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
Index: camel/camel-exchange-summary.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-summary.c,v
retrieving revision 1.5
diff -p -u -2 -r1.5 camel-exchange-summary.c
--- camel/camel-exchange-summary.c	30 Jul 2005 10:08:07 -0000	1.5
+++ camel/camel-exchange-summary.c	18 Jan 2006 11:07:29 -0000
@@ -23,5 +23,4 @@
 
 #include <sys/stat.h>
-#include <sys/uio.h>
 #include <unistd.h>
 #include <errno.h>
Index: camel/camel-stub-marshal.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-stub-marshal.c,v
retrieving revision 1.2
diff -p -u -2 -r1.2 camel-stub-marshal.c
--- camel/camel-stub-marshal.c	14 Sep 2004 19:28:45 -0000	1.2
+++ camel/camel-stub-marshal.c	18 Jan 2006 11:07:29 -0000
@@ -26,5 +26,13 @@
 #include <string.h>
 #include <stdlib.h>
+
+#include <glib.h>
+
+#ifndef G_OS_WIN32
 #include <unistd.h>
+#else
+#undef DATADIR
+#include <winsock2.h>
+#endif
 
 #include "camel-stub-marshal.h"
@@ -76,5 +84,9 @@ void
 camel_stub_marshal_free (CamelStubMarshal *marshal)
 {
+#ifndef G_OS_WIN32
 	close (marshal->fd);
+#else
+	closesocket (marshal->fd);
+#endif
 	g_byte_array_free (marshal->out, TRUE);
 	g_byte_array_free (marshal->in, TRUE);
@@ -88,4 +100,5 @@ do_read (CamelStubMarshal *marshal, char
 
 	while (len) {
+#ifndef G_OS_WIN32
 		nread = read (marshal->fd, buf, len);
 		if (nread < 1) {
@@ -101,4 +114,18 @@ do_read (CamelStubMarshal *marshal, char
 			return FALSE;
 		}
+#else
+		while ((nread = recv (marshal->fd, buf, len, 0)) == SOCKET_ERROR &&
+		       WSAGetLastError () == WSAEWOULDBLOCK)
+			Sleep (20);
+
+		if (nread == 0 || nread == SOCKET_ERROR) {
+			/* No WSAEINTR error modes in WinSock 2 */
+			if (nread == SOCKET_ERROR && DEBUGGING)
+				printf ("<<< read: %d (%s)\n", nread, g_win32_error_message (WSAGetLastError ()));
+			closesocket (marshal->fd);
+			marshal->fd = -1;
+			return FALSE;
+		}
+#endif
 		len -= nread;
 		buf += nread;
@@ -449,4 +476,5 @@ camel_stub_marshal_flush (CamelStubMarsh
 
 	while (left) {
+#ifndef G_OS_WIN32
 		nwrote = write (marshal->fd, marshal->out->data + off, left);
 		if (nwrote == -1 && errno == EINTR) {
@@ -464,4 +492,16 @@ camel_stub_marshal_flush (CamelStubMarsh
 			return -1;
 		}
+#else
+		nwrote = send (marshal->fd, marshal->out->data + off, left, 0);
+		if (nwrote == 0 || nwrote == SOCKET_ERROR) {
+			if (DEBUGGING && nwrote == SOCKET_ERROR)
+				printf (">>> write: %d (%s)\n", nwrote, g_win32_error_message (WSAGetLastError ()));
+			if (nwrote == SOCKET_ERROR) {
+				closesocket (marshal->fd);
+				marshal->fd = -1;
+			}
+			return -1;
+		}
+#endif
 		off += nwrote;
 		left -= nwrote;
Index: camel/camel-stub.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-stub.c,v
retrieving revision 1.4
diff -p -u -2 -r1.4 camel-stub.c
--- camel/camel-stub.c	12 Jan 2005 08:51:39 -0000	1.4
+++ camel/camel-stub.c	18 Jan 2006 11:07:29 -0000
@@ -32,7 +32,12 @@
 #include <errno.h>
 #include <string.h>
+
+#ifndef G_OS_WIN32
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
+#else
+#include <winsock2.h>
+#endif
 
 CamelStub *das_global_camel_stub;
@@ -49,4 +54,5 @@ init (CamelStub *stub)
 	stub->read_lock = g_mutex_new ();
 	stub->write_lock = g_mutex_new ();
+	stub->have_status_thread = FALSE;
 }
 
@@ -57,5 +63,5 @@ finalize (CamelStub *stub)
 		camel_stub_marshal_free (stub->cmd);
 
-	if (stub->status_thread) {
+	if (stub->have_status_thread) {
 		void *unused;
 
@@ -123,4 +129,6 @@ status_main (void *data)
 }
 
+#ifndef G_OS_WIN32
+
 static int
 connect_to_storage (CamelStub *stub, struct sockaddr_un *sa_un,
@@ -156,4 +164,66 @@ connect_to_storage (CamelStub *stub, str
 }
 
+#else
+
+static int
+connect_to_storage (CamelStub *stub, const char *socket_path,
+		    CamelException *ex)
+{
+	SOCKET fd;
+	struct sockaddr_in *sa_in;
+	gsize contents_length;
+	GError *error = NULL;
+	int rc;
+
+	if (!g_file_get_contents (socket_path, (gchar **) &sa_in,
+				  &contents_length, &error)) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+				      _("Count not read file '%s': %s"),
+				      socket_path, error->message);
+		g_error_free (error);
+		return -1;
+	}
+
+	if (contents_length != sizeof (*sa_in)) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+				      _("Wrong size file '%s'"),
+				      socket_path);
+		g_free (sa_in);
+		return -1;
+	}
+
+	fd = socket (AF_INET, SOCK_STREAM, 0);
+	if (fd == INVALID_SOCKET) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+				      _("Could not create socket: %s"),
+				      g_win32_error_message (WSAGetLastError ()));
+		return -1;
+	}
+	rc = connect (fd, (struct sockaddr *)sa_in, sizeof (*sa_in));
+	g_free (sa_in);
+
+	if (rc == SOCKET_ERROR) {
+		closesocket (fd);
+		if (WSAGetLastError () == WSAECONNREFUSED) {
+			/* The user has an account configured but the
+			 * backend isn't listening, which probably means that
+			 * he doesn't have a license.
+			 */
+			camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+					     "Cancelled");
+		} else {
+			camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+					      _("Could not connect to %s: %s"),
+					      stub->backend_name,
+					      g_win32_error_message (WSAGetLastError ()));
+		}
+		return -1;
+	}
+	return fd;
+}
+
+#endif
+
+
 /**
  * camel_stub_new:
@@ -172,7 +242,10 @@ camel_stub_new (const char *socket_path,
 {
 	CamelStub *stub;
+#ifndef G_OS_WIN32
 	struct sockaddr_un sa_un;
+#endif
 	int fd;
 
+#ifndef G_OS_WIN32
 	if (strlen (socket_path) > sizeof (sa_un.sun_path) - 1) {
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -182,9 +255,14 @@ camel_stub_new (const char *socket_path,
 	sa_un.sun_family = AF_UNIX;
 	strcpy (sa_un.sun_path, socket_path);
-
+#endif
+	
 	stub = (CamelStub *)camel_object_new (CAMEL_STUB_TYPE);
 	stub->backend_name = g_strdup (backend_name);
 
+#ifndef G_OS_WIN32
 	fd = connect_to_storage (stub, &sa_un, ex);
+#else
+	fd = connect_to_storage (stub, socket_path, ex);
+#endif
 	if (fd == -1) {
 		camel_object_unref (CAMEL_OBJECT (stub));
@@ -193,5 +271,9 @@ camel_stub_new (const char *socket_path,
 	stub->cmd = camel_stub_marshal_new (fd);
 
+#ifndef G_OS_WIN32
 	fd = connect_to_storage (stub, &sa_un, ex);
+#else
+	fd = connect_to_storage (stub, socket_path, ex);
+#endif
 	if (fd == -1) {
 		camel_object_unref (CAMEL_OBJECT (stub));
Index: camel/camel-stub.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-stub.h,v
retrieving revision 1.2
diff -p -u -2 -r1.2 camel-stub.h
--- camel/camel-stub.h	14 Sep 2004 19:28:45 -0000	1.2
+++ camel/camel-stub.h	18 Jan 2006 11:07:29 -0000
@@ -32,4 +32,5 @@ typedef struct {
 	CamelStubMarshal *cmd, *status;
 	pthread_t status_thread;
+	gboolean have_status_thread;
 } CamelStub;
 
Index: mail/mail-stub-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub-exchange.c,v
retrieving revision 1.32
diff -p -u -2 -r1.32 mail-stub-exchange.c
--- mail/mail-stub-exchange.c	17 Dec 2005 07:27:19 -0000	1.32
+++ mail/mail-stub-exchange.c	18 Jan 2006 11:07:32 -0000
@@ -2439,6 +2439,10 @@ send_message (MailStub *stub, const char
 	 * received via WebDAV.
 	 */
+#if GLIB_CHECK_VERSION (2, 8, 0)
+	strcpy (hostname, g_get_host_name ());
+#else
 	if (gethostname (hostname, sizeof (hostname)) != 0)
 		strcpy (hostname, "localhost");
+#endif
 	timestamp = e2k_make_timestamp_rfc822 (time (NULL));
 	g_string_append_printf (data, "Received: from %s by %s; %s\r\n",
Index: mail/mail-stub-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub-listener.c,v
retrieving revision 1.3
diff -p -u -2 -r1.3 mail-stub-listener.c
--- mail/mail-stub-listener.c	14 Jun 2005 13:12:43 -0000	1.3
+++ mail/mail-stub-listener.c	18 Jan 2006 11:07:32 -0000
@@ -24,8 +24,15 @@
 #endif
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#ifndef G_OS_WIN32
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
+#else
+#include <winsock2.h>
+#endif
 
 #include "mail-stub-listener.h"
@@ -73,5 +80,5 @@ finalize (GObject *object)
 		g_io_channel_unref (listener->channel);
 	if (listener->socket_path) {
-		unlink (listener->socket_path);
+		g_unlink (listener->socket_path);
 		g_free (listener->socket_path);
 	}
@@ -87,10 +94,7 @@ new_connection (GIOChannel *source, GIOC
 {
 	MailStubListener *listener = data;
-	struct sockaddr_un sa_un;
-	socklen_t len;
 	int fd;
 
-	len = sizeof (sa_un);
-	fd = accept (g_io_channel_unix_get_fd (source), (struct sockaddr *)&sa_un, &len);
+	fd = accept (g_io_channel_unix_get_fd (source), NULL, NULL);
 	if (fd == -1)
 		return TRUE;
@@ -111,7 +115,14 @@ gboolean
 mail_stub_listener_construct (MailStubListener *listener, const char *socket_path)
 {
+#ifndef G_OS_WIN32
 	struct sockaddr_un sa_un;
+#else
+	struct sockaddr_in sa_in;
+	int addr_len;
+	GError *error = NULL;
+#endif
 	int fd;
 
+#ifndef G_OS_WIN32
 	g_return_val_if_fail (strlen (socket_path) < sizeof (sa_un.sun_path), FALSE);
 
@@ -131,4 +142,50 @@ mail_stub_listener_construct (MailStubLi
 
 	listener->channel = g_io_channel_unix_new (fd);
+#else
+	fd = socket (AF_INET, SOCK_STREAM, 0);
+	if (fd == SOCKET_ERROR)
+		return FALSE;
+	memset (&sa_in, 0, sizeof (sa_in));
+	sa_in.sin_family = AF_INET;
+	sa_in.sin_port = 0;
+	sa_in.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+
+	if (bind (fd, (struct sockaddr *) &sa_in, sizeof (sa_in)) == SOCKET_ERROR) {
+		g_warning ("bind() failed: %s",
+			   g_win32_error_message (WSAGetLastError ()));
+		closesocket (fd);
+		return FALSE;
+	}
+
+	if (listen (fd, 1) == SOCKET_ERROR) {
+		g_warning ("listen() failed: %s",
+		g_win32_error_message (WSAGetLastError ()));
+		closesocket (fd);
+		return FALSE;
+	}	   
+
+	addr_len = sizeof (sa_in);
+	if (getsockname (fd, (struct sockaddr *) &sa_in, &addr_len) == SOCKET_ERROR) {
+		g_warning ("getsockname() failed: %s",
+			   g_win32_error_message (WSAGetLastError ()));
+		closesocket (fd);
+		return FALSE;
+	}
+
+	g_unlink (socket_path);
+	listener->socket_path = g_strdup (socket_path);
+
+	printf ("listening on port %d\n", ntohs(sa_in.sin_port));
+
+	if (!g_file_set_contents (socket_path, (char *) &sa_in, addr_len, &error)) {
+		g_warning ("Could not save socket address in '%s': %s",
+			   socket_path, error->message);
+		g_error_free (error);
+		closesocket (fd);
+		return FALSE;
+	}
+
+	listener->channel = g_io_channel_win32_new_socket (fd);
+#endif
 	g_io_add_watch (listener->channel, G_IO_IN, new_connection, listener);
 
Index: mail/mail-stub.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub.c,v
retrieving revision 1.10
diff -p -u -2 -r1.10 mail-stub.c
--- mail/mail-stub.c	22 Aug 2005 14:22:02 -0000	1.10
+++ mail/mail-stub.c	18 Jan 2006 11:07:32 -0000
@@ -24,8 +24,14 @@
 #endif
 
+#include <glib.h>
+
+#ifndef G_OS_WIN32
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
+#else
+#include <winsock2.h>
+#endif
 
 #include <e2k-uri.h>
@@ -763,5 +769,9 @@ void
 mail_stub_construct (MailStub *stub, int cmd_fd, int status_fd)
 {
+#ifndef G_OS_WIN32
 	stub->channel = g_io_channel_unix_new (cmd_fd);
+#else
+	stub->channel = g_io_channel_win32_new_socket (cmd_fd);
+#endif
 	g_io_add_watch (stub->channel, G_IO_IN | G_IO_ERR | G_IO_HUP,
 			connection_handler, stub);
Index: storage/GNOME_Evolution_Exchange_Storage.server.in.in
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/GNOME_Evolution_Exchange_Storage.server.in.in,v
retrieving revision 1.10
diff -p -u -2 -r1.10 GNOME_Evolution_Exchange_Storage.server.in.in
--- storage/GNOME_Evolution_Exchange_Storage.server.in.in	18 Jan 2006 09:07:18 -0000	1.10
+++ storage/GNOME_Evolution_Exchange_Storage.server.in.in	18 Jan 2006 11:07:33 -0000
@@ -3,5 +3,5 @@
 <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">
Index: storage/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/Makefile.am,v
retrieving revision 1.28
diff -p -u -2 -r1.28 Makefile.am
--- storage/Makefile.am	14 Jan 2006 09:47:25 -0000	1.28
+++ storage/Makefile.am	18 Jan 2006 11:07:33 -0000
@@ -46,5 +46,6 @@ evolution_exchange_storage_LDADD =				\
 	$(LDAP_LIBS)						\
 	$(EXCHANGE_STORAGE_LIBS)				\
-	$(LIBEXCHANGE_LIBS)
+	$(LIBEXCHANGE_LIBS)					\
+	$(SOCKET_LIBS)
 
 
@@ -84,4 +85,5 @@ server_DATA = $(server_in_files:.server.
 	    -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"		\
Index: storage/exchange-autoconfig-wizard.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-autoconfig-wizard.c,v
retrieving revision 1.7
diff -p -u -2 -r1.7 exchange-autoconfig-wizard.c
--- storage/exchange-autoconfig-wizard.c	6 Jan 2006 07:27:28 -0000	1.7
+++ storage/exchange-autoconfig-wizard.c	18 Jan 2006 11:07:33 -0000
@@ -42,4 +42,16 @@
 #include <libgnomeui/gnome-href.h>
 
+#include "exchange-storage.h"
+
+#ifdef G_OS_WIN32
+
+#undef CONNECTOR_GLADEDIR
+#define CONNECTOR_GLADEDIR _exchange_storage_gladedir
+
+#undef CONNECTOR_IMAGESDIR
+#define CONNECTOR_IMAGESDIR _exchange_storage_imagesdir
+
+#endif
+
 typedef struct {
 	GnomeDruid *druid;
@@ -110,8 +122,13 @@ autoconfig_gui_new (void)
 {
 	ExchangeAutoconfigGUI *gui;
+	char *gladefile;
 
 	gui = g_new0 (ExchangeAutoconfigGUI, 1);
 
-	gui->xml = glade_xml_new (CONNECTOR_GLADEDIR "/exchange-autoconfig-wizard.glade", NULL, NULL);
+	gladefile = g_build_filename (CONNECTOR_GLADEDIR,
+				      "exchange-autoconfig-wizard.glade",
+				      NULL);
+	gui->xml = glade_xml_new (gladefile, NULL, NULL);
+	g_free (gladefile);
 	if (!gui->xml) {
 		g_warning ("Could not find exchange-autoconfig-wizard.glade");
@@ -604,4 +621,5 @@ exchange_autoconfig_druid_run (void)
 	GdkPixbuf *icon;
 	int i;
+	gchar *pngfile;
 
 	gui = autoconfig_gui_new ();
@@ -613,5 +631,9 @@ exchange_autoconfig_druid_run (void)
 	gui->pages = g_ptr_array_new ();
 
-	icon = gdk_pixbuf_new_from_file (CONNECTOR_IMAGESDIR "/connector.png", NULL);
+	pngfile = g_build_filename (CONNECTOR_IMAGESDIR,
+				    "connector.png",
+				    NULL);
+	icon = gdk_pixbuf_new_from_file (pngfile, NULL);
+	g_free (pngfile);
 	for (i = 0; i < num_autoconfig_pages; i++) {
 		page = glade_xml_get_widget (gui->xml, autoconfig_pages[i].page_name);
Index: storage/exchange-change-password.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-change-password.c,v
retrieving revision 1.3
diff -p -u -2 -r1.3 exchange-change-password.c
--- storage/exchange-change-password.c	15 Jul 2004 16:42:59 -0000	1.3
+++ storage/exchange-change-password.c	18 Jan 2006 11:07:33 -0000
@@ -33,5 +33,13 @@
 #include <gtk/gtklabel.h>
 
-#define FILENAME CONNECTOR_GLADEDIR "/exchange-change-password.glade"
+#include "exchange-storage.h"
+
+#ifdef G_OS_WIN32
+
+#undef CONNECTOR_GLADEDIR
+#define CONNECTOR_GLADEDIR _exchange_storage_gladedir
+
+#endif
+
 #define ROOTNODE "pass_dialog"
 #define STARTNODE "pass_vbox"
@@ -81,6 +89,11 @@ exchange_get_new_password (const char *e
 	GtkLabel *top_label;
 	char *new_pass;
+	gchar *gladefile;
 
-	xml = glade_xml_new (FILENAME, ROOTNODE, NULL);
+	gladefile = g_build_filename (CONNECTOR_GLADEDIR,
+				      "exchange-change-password.glade",
+				      NULL);
+	xml = glade_xml_new (gladefile, ROOTNODE, NULL);
+	g_free (gladefile);
 	top_widget = glade_xml_get_widget (xml, ROOTNODE);
 
Index: storage/exchange-component.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-component.c,v
retrieving revision 1.20
diff -p -u -2 -r1.20 exchange-component.c
--- storage/exchange-component.c	23 Dec 2005 03:23:59 -0000	1.20
+++ storage/exchange-component.c	18 Jan 2006 11:07:34 -0000
@@ -22,7 +22,4 @@
 #endif
 
-#include "exchange-component.h"
-#include "shell/e-component-view.h"
-
 #include <unistd.h>
 
@@ -31,13 +28,18 @@
 #include <bonobo/bonobo-main.h>
 
+#include <e-util/e-util.h>
+
 #include <exchange-account.h>
 #include <exchange-constants.h>
-#include "exchange-config-listener.h"
 #include <e-folder-exchange.h>
 #include <e-shell-marshal.h>
 
+#include "shell/e-component-view.h"
+
 #include "mail-stub-listener.h"
 #include "mail-stub-exchange.h"
 
+#include "exchange-component.h"
+#include "exchange-config-listener.h"
 #include "exchange-migrate.h" 
 
@@ -46,5 +48,4 @@
 #define PARENT_TYPE bonobo_object_get_type ()
 static BonoboObjectClass *parent_class = NULL;
-static void e_filename_make_safe (gchar *string);
 static void exchange_component_update_accounts (ExchangeComponent *component,
 							gboolean status);
@@ -306,28 +307,4 @@ exchange_component_update_accounts (Exch
 }
 
-/* SURF : Picked this from gal/util/e-util.c */
-/* This only makes a filename safe for usage as a filename.  It still may have shell meta-characters in it. */
-static void
-e_filename_make_safe (gchar *string)
-{
-	gchar *p, *ts;
-	gunichar c;
-	
-	g_return_if_fail (string != NULL);
-	p = string;
-
-	while(p && *p) {
-		c = g_utf8_get_char (p);
-		ts = p;
-		p = g_utf8_next_char (p);
-		if (!g_unichar_isprint(c) || ( c < 0xff && strchr (" /'\"`&();|<>$%{}!", c&0xff ))) {
-			while (ts<p) 	
-				*ts++ = '_';
-		}
-	}
-}
-
-
-
 static void
 new_connection (MailStubListener *listener, int cmd_fd, int status_fd,
@@ -376,5 +353,6 @@ config_listener_account_created (Exchang
 	e_filename_make_safe (account_filename);
 	
-	path = g_strdup_printf ("/tmp/.exchange-%s/%s",
+	path = g_strdup_printf ("%s/.exchange-%s/%s",
+				g_get_tmp_dir (),
 				g_get_user_name (),
 				account_filename);
@@ -408,5 +386,5 @@ config_listener_account_removed (Exchang
 
 static void
-default_linestatus_notify_handler (ExchangeComponent *component, uint status)
+default_linestatus_notify_handler (ExchangeComponent *component, guint status)
 {
 	CORBA_Environment ev;
Index: storage/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-config-listener.c,v
retrieving revision 1.31
diff -p -u -2 -r1.31 exchange-config-listener.c
--- storage/exchange-config-listener.c	28 Sep 2005 13:46:01 -0000	1.31
+++ storage/exchange-config-listener.c	18 Jan 2006 11:07:34 -0000
@@ -23,32 +23,32 @@
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
-#include "exchange-config-listener.h"
-
-#include <exchange-account.h>
-#include <e-folder-exchange.h>
-#include <e2k-marshal.h>
-#include <e2k-uri.h>
-#include "mail-stub-listener.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include <e-util/e-dialog-utils.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
 #include <libedataserver/e-source-group.h>
+#include <libedataserver/e-xml-utils.h>
 #include <libedataserver/e-xml-hash-utils.h>
 
 #include <camel/camel-url.h>
 
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
+#include <exchange-account.h>
+#include <e2k-marshal.h>
+#include <e2k-uri.h>
+#include <e-util/e-dialog-utils.h>
 
+#include "mail-stub-listener.h"
+
+#include "e-folder-exchange.h"
+#include "exchange-config-listener.h"
 
 struct _ExchangeConfigListenerPrivate {
@@ -195,7 +195,6 @@ update_foreign_uri (const char *path, co
 {
 	char *file_path, *phy_uri, *foreign_uri, *new_phy_uri;
-	struct stat file_stat;
 	GHashTable *old_props = NULL;
-	xmlDoc *old_doc, *new_doc = NULL;
+	xmlDoc *old_doc = NULL, *new_doc = NULL;
 
 	if (!path)
@@ -203,8 +202,8 @@ update_foreign_uri (const char *path, co
 
 	file_path = g_build_filename (path, "hierarchy.xml", NULL);
-	if (stat (file_path, &file_stat) < 0)
+	if (!g_file_test (file_path, G_FILE_TEST_EXISTS))
 		goto cleanup;
 
-	old_doc = xmlParseFile (file_path);
+	old_doc = e_xml_parse_file (file_path);
 	if (!old_doc)
 		goto cleanup;
@@ -232,5 +231,5 @@ update_foreign_uri (const char *path, co
 
 	new_doc = e_xml_from_hash (old_props, E_XML_HASH_TYPE_PROPERTY, "foreign-hierarchy");
-	xmlSaveFile (file_path, new_doc);
+	e_xml_save_file (file_path, new_doc);
 
 	xmlFreeDoc (new_doc);
@@ -245,19 +244,19 @@ static void
 migrate_foreign_hierarchy (ExchangeAccount *account)
 {
-	DIR *d;
-	struct dirent *dentry;
+	GDir *d;
+	const char *dentry;
 	char *dir;
 
-	d = opendir (account->storage_dir);
+	d = g_dir_open (account->storage_dir, 0, NULL);
 	if (d) {
-		while ((dentry = readdir (d))) {
-			if (!strchr (dentry->d_name, '@'))
+		while ((dentry = g_dir_read_name (d))) {
+			if (!strchr (dentry, '@'))
 				continue;
 			dir = g_strdup_printf ("%s/%s", account->storage_dir, 
-							dentry->d_name);
+							dentry);
 			update_foreign_uri (dir, account->account_filename);
 			g_free (dir);
 		}
-		closedir (d);
+		g_dir_close (d);
 	}
 }
Index: storage/exchange-migrate.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-migrate.c,v
retrieving revision 1.7
diff -p -u -2 -r1.7 exchange-migrate.c
--- storage/exchange-migrate.c	10 Jan 2006 08:20:23 -0000	1.7
+++ storage/exchange-migrate.c	18 Jan 2006 11:07:35 -0000
@@ -48,4 +48,12 @@ CORBA_short min=0;
 CORBA_short rev=0;
 
+#ifndef G_OS_WIN32
+
+/* No need for migration code from evolution-exchange 1.x on Win32.
+ * If and when the same code is partly used for migrating between
+ * future evolution-exchange versions, that code will have to be
+ * revised and ported as necessary.
+ */
+
 gchar *label_string = NULL;
 
@@ -450,4 +458,6 @@ migrate_common (gchar *src_path, const g
 }
 
+#endif
+
 void
 exchange_migrate (const CORBA_short major, 
@@ -465,5 +475,5 @@ exchange_migrate (const CORBA_short majo
 	/* FIXME: version check */
 	if (maj == 1 && min <= 5) {
-
+#ifndef G_OS_WIN32
 		if (!base_dir)
 			return;
@@ -508,4 +518,5 @@ exchange_migrate (const CORBA_short majo
 			show_error_dialog ();
 
+#endif
 	}
 }
Index: storage/exchange-storage.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-storage.h,v
retrieving revision 1.1.1.2
diff -p -u -2 -r1.1.1.2 exchange-storage.h
--- storage/exchange-storage.h	11 May 2004 15:15:59 -0000	1.1.1.2
+++ storage/exchange-storage.h	18 Jan 2006 11:07:35 -0000
@@ -34,4 +34,12 @@ GType             exchange_storage_get_t
 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
 }
Index: storage/main.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/main.c,v
retrieving revision 1.20
diff -p -u -2 -r1.20 main.c
--- storage/main.c	17 Dec 2005 07:27:18 -0000	1.20
+++ storage/main.c	18 Jan 2006 11:07:35 -0000
@@ -30,4 +30,7 @@
 #include <unistd.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-generic-factory.h>
@@ -42,4 +45,5 @@
 #include <libedata-cal/e-data-cal-factory.h>
 #include <libedataserver/e-data-server-module.h>
+#include <libedataserver/e-data-server-util.h>
 
 #include <e2k-utils.h>
@@ -62,4 +66,10 @@ static EDataBookFactory *book_factory = 
 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,
@@ -172,8 +182,33 @@ int
 main (int argc, char **argv)
 {
-	char *path;
+	char *userdir, *path;
 	char *config_directory;
 
+#ifdef G_OS_WIN32
+	{
+		char *localedir;
+
+		/* We assume exchange-connector 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);
@@ -189,13 +224,16 @@ main (int argc, char **argv)
 	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) {
@@ -203,4 +241,5 @@ main (int argc, char **argv)
 				return 1;
 			}
+#endif
 		} else {
 			g_warning ("Can't create %s", path);
Index: storage/ximian-connector-setup.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/ximian-connector-setup.c,v
retrieving revision 1.4
diff -p -u -2 -r1.4 ximian-connector-setup.c
--- storage/ximian-connector-setup.c	14 Jun 2005 13:12:43 -0000	1.4
+++ storage/ximian-connector-setup.c	18 Jan 2006 11:07:35 -0000
@@ -32,4 +32,10 @@
 #include "exchange-autoconfig-wizard.h"
 
+#ifdef G_OS_WIN32
+/* Used by exchange-autoconfig-wizard.c. Just use the compile-time paths here */
+const char *_exchange_storage_gladedir = CONNECTOR_GLADEDIR;
+const char *_exchange_storage_imagesdir = CONNECTOR_IMAGESDIR;
+#endif
+
 int
 main (int argc, char **argv)


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