[evolution-data-server] Bug 609390 - search folders don't work in imapx



commit a82c1572616c55d5d66a053e451d133aca6aeb08
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Tue Feb 9 21:46:48 2010 +0530

    Bug 609390 -  search folders don't work in imapx

 camel/providers/imapx/camel-imapx-provider.c |   55 +++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-provider.c b/camel/providers/imapx/camel-imapx-provider.c
index 7bd8fda..3b4bd25 100644
--- a/camel/providers/imapx/camel-imapx-provider.c
+++ b/camel/providers/imapx/camel-imapx-provider.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#include <string.h>
 #include "camel/camel-provider.h"
 #include "camel/camel-session.h"
 #include "camel/camel-url.h"
@@ -35,6 +36,9 @@
 
 #include "camel-imapx-store.h"
 
+static guint imapx_url_hash (gconstpointer key);
+static gint  imapx_url_equal (gconstpointer a, gconstpointer b);
+
 CamelProviderConfEntry imapx_conf_entries[] = {
 		{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
 	  N_("Checking for New Mail") },
@@ -115,8 +119,8 @@ void
 camel_imapx_module_init(void)
 {
 	imapx_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imapx_store_get_type();
-	imapx_provider.url_hash = camel_url_hash;
-	imapx_provider.url_equal = camel_url_equal;
+	imapx_provider.url_hash = imapx_url_hash;
+	imapx_provider.url_equal = imapx_url_equal;
 	imapx_provider.authtypes = camel_sasl_authtype_list(FALSE);
 	imapx_provider.authtypes = g_list_prepend(imapx_provider.authtypes, &camel_imapx_password_authtype);
 	imapx_provider.translation_domain = GETTEXT_PACKAGE;
@@ -133,3 +137,50 @@ camel_provider_module_init(void)
 {
 	camel_imapx_module_init();
 }
+
+static void
+imapx_add_hash (guint *hash, gchar *s)
+{
+	if (s)
+		*hash ^= g_str_hash(s);
+}
+
+static guint
+imapx_url_hash (gconstpointer key)
+{
+	const CamelURL *u = (CamelURL *)key;
+	guint hash = 0;
+
+	imapx_add_hash (&hash, u->user);
+	imapx_add_hash (&hash, u->host);
+	hash ^= u->port;
+
+	return hash;
+}
+
+static gint
+imapx_check_equal (gchar *s1, gchar *s2)
+{
+	if (s1 == NULL) {
+		if (s2 == NULL)
+			return TRUE;
+		else
+			return FALSE;
+	}
+
+	if (s2 == NULL)
+		return FALSE;
+
+	return strcmp (s1, s2) == 0;
+}
+
+static gint
+imapx_url_equal (gconstpointer a, gconstpointer b)
+{
+	const CamelURL *u1 = a, *u2 = b;
+
+	return imapx_check_equal (u1->protocol, u2->protocol)
+		&& imapx_check_equal (u1->user, u2->user)
+		&& imapx_check_equal (u1->host, u2->host)
+		&& u1->port == u2->port;
+}



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