evolution-exchange r1645 - in trunk: . camel storage



Author: tml
Date: Thu May  8 02:39:04 2008
New Revision: 1645
URL: http://svn.gnome.org/viewvc/evolution-exchange?rev=1645&view=rev

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

	* 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.

	* camel/camel-exchange-store.c (exchange_connect)
	* storage/exchange-component.c (config_listener_account_created):
	Construct the path to the socket in the same way in these two
	functions. Use g_get_tmp_dir() instead of hardcoding /tmp. Use
	g_build_filename().

	* camel/camel-exchange-store.c (exchange_get_folder): Use
	g_file_test() instead of access().

	* storage/exchange-component.c
	(default_linestatus_notify_handler): Use guint instead of uint.



Modified:
   trunk/ChangeLog
   trunk/camel/camel-exchange-store.c
   trunk/storage/exchange-component.c

Modified: trunk/camel/camel-exchange-store.c
==============================================================================
--- trunk/camel/camel-exchange-store.c	(original)
+++ trunk/camel/camel-exchange-store.c	Thu May  8 02:39:04 2008
@@ -27,11 +27,13 @@
 
 #include <glib/gi18n-lib.h>
 
+#include <camel/camel-session.h>
+#include <camel/camel-url.h>
+#include <libedataserver/e-data-server-util.h>
+
 #include "camel-exchange-store.h"
 #include "camel-exchange-folder.h"
 #include "camel-exchange-summary.h"
-#include <camel/camel-session.h>
-#include <camel/camel-url.h>
 
 #define SUBFOLDER_DIR_NAME     "subfolders"
 #define SUBFOLDER_DIR_NAME_LEN 10
@@ -320,29 +322,6 @@
 
 #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)
 {
@@ -388,7 +367,7 @@
 exchange_connect (CamelService *service, CamelException *ex)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service);
-	char *real_user, *socket_path;
+	char *real_user, *socket_path, *dot_exchange_username, *user_at_host;
 	gchar *password = NULL;
 	guint32 connect_status;
 	gboolean online_mode = FALSE;
@@ -407,10 +386,15 @@
 			real_user++;
 		else
 			real_user = service->url->user;
-		socket_path = g_strdup_printf ("/tmp/.exchange-%s/%s %s",
-					       g_get_user_name (),
-					       real_user, service->url->host);
-		e_filename_make_safe (strchr (socket_path + 5, '/') + 1);
+		dot_exchange_username = g_strdup_printf (".exchange-%s", g_get_user_name ());
+		user_at_host = g_strdup_printf ("%s %s", real_user, service->url->host);
+		e_filename_make_safe (user_at_host);
+		socket_path = g_build_filename (g_get_tmp_dir (),
+						dot_exchange_username,
+						user_at_host,
+						NULL);
+		g_free (dot_exchange_username);
+		g_free (user_at_host);
 
 		exch->stub = camel_stub_new (socket_path, _("Evolution Exchange backend process"), ex);
 		g_free (socket_path);
@@ -505,7 +489,7 @@
 	folder_dir = exchange_path_to_physical (exch->storage_path, folder_name);
 
 	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,
 					      _("No such folder %s"), folder_name);

Modified: trunk/storage/exchange-component.c
==============================================================================
--- trunk/storage/exchange-component.c	(original)
+++ trunk/storage/exchange-component.c	Thu May  8 02:39:04 2008
@@ -21,6 +21,8 @@
 #include "config.h"
 #endif
 
+#include <libedataserver/e-data-server-util.h>
+
 #include "exchange-component.h"
 #include "shell/e-component-view.h"
 
@@ -44,7 +46,6 @@
 
 #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);
 static void ex_migrate_esources (ExchangeComponent *component,
@@ -314,30 +315,6 @@
 	}
 }
 
-/* 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,
 		ExchangeComponentAccount *baccount)
@@ -387,17 +364,21 @@
 	ExchangeComponent *component = user_data;
 	ExchangeComponentPrivate *priv = component->priv;
 	ExchangeComponentAccount *baccount;
-	char *path, *account_filename;
+	char *path, *dot_exchange_username, *account_filename;
 
 	baccount = g_new0 (ExchangeComponentAccount, 1);
 	baccount->account = g_object_ref (account);
 
+	dot_exchange_username = g_strdup_printf (".exchange-%s", g_get_user_name ());
+
 	account_filename = strrchr (account->storage_dir, '/') + 1;
 	e_filename_make_safe (account_filename);
 
-	path = g_strdup_printf ("/tmp/.exchange-%s/%s",
-				g_get_user_name (),
-				account_filename);
+	path = g_build_filename (g_get_tmp_dir (),
+				 dot_exchange_username,
+				 account_filename,
+				 NULL);
+	g_free (dot_exchange_username);
 	baccount->msl = mail_stub_listener_new (path);
 	g_signal_connect (baccount->msl, "new_connection",
 			  G_CALLBACK (new_connection), baccount);
@@ -427,7 +408,7 @@
 }
 
 static void
-default_linestatus_notify_handler (ExchangeComponent *component, uint status)
+default_linestatus_notify_handler (ExchangeComponent *component, guint status)
 {
 	CORBA_Environment ev;
 



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