[evolution-ews/gnome-3-6] Bug #686228 - Cannot fetch list of addressbooks



commit e28cb2f5395579c7d68ac293bfda1105f118e74c
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 24 15:29:31 2012 +0200

    Bug #686228 - Cannot fetch list of addressbooks

 src/server/e-ews-connection.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index ff95c71..886ec11 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -2185,6 +2185,30 @@ e_ews_autodiscover_ws_url (CamelEwsSettings *settings,
 	}
 }
 
+static gboolean
+has_suffix_icmp (const gchar *text,
+		 const gchar *suffix)
+{
+	gint ii, tlen, slen;
+
+	g_return_val_if_fail (text != NULL, FALSE);
+	g_return_val_if_fail (suffix != NULL, FALSE);
+
+	tlen = strlen (text);
+	slen = strlen (suffix);
+
+	if (!*text || !*suffix || tlen < slen)
+		return FALSE;
+
+	for (ii = 0; ii < slen; ii++) {
+		if (g_ascii_tolower (text[tlen - ii - 1]) != 
+		    g_ascii_tolower (suffix[slen - ii - 1]))
+			break;
+	}
+
+	return ii == slen;
+}
+
 gboolean
 e_ews_autodiscover_ws_url_finish (CamelEwsSettings *settings,
                                   GAsyncResult *result,
@@ -2208,7 +2232,20 @@ e_ews_autodiscover_ws_url_finish (CamelEwsSettings *settings,
 	g_warn_if_fail (ad->oab_url != NULL);
 
 	camel_ews_settings_set_hosturl (settings, ad->as_url);
-	camel_ews_settings_set_oaburl (settings, ad->oab_url);
+
+	if (!has_suffix_icmp (ad->oab_url, "oab.xml")) {
+		gchar *tmp;
+
+		if (g_str_has_suffix (ad->oab_url, "/"))
+			tmp = g_strconcat (ad->oab_url, "oab.xml", NULL);
+		else
+			tmp = g_strconcat (ad->oab_url, "/", "oab.xml", NULL);
+
+		camel_ews_settings_set_oaburl (settings, tmp);
+		g_free (tmp);
+	} else {
+		camel_ews_settings_set_oaburl (settings, ad->oab_url);
+	}
 
 	return TRUE;
 }



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