[evolution-kolab] ECalBackendKolab: extended the free/busy getter



commit 26d154c796af31d463284fa0f81507807afea0d6
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Oct 24 17:54:34 2012 +0200

    ECalBackendKolab: extended the free/busy getter
    
    * have the free/busy getter retrieve XFB first
    * if that fails, fall back to retrieving SFB

 src/calendar/kolab-util-calendar.c |   81 ++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 18 deletions(-)
---
diff --git a/src/calendar/kolab-util-calendar.c b/src/calendar/kolab-util-calendar.c
index 3822b03..811509a 100644
--- a/src/calendar/kolab-util-calendar.c
+++ b/src/calendar/kolab-util-calendar.c
@@ -144,6 +144,7 @@ util_calendar_create_pfb_trigger (KolabSettingsHandler *ksettings,
 static KolabUtilHttpJob*
 util_calendar_create_xfb_request (KolabSettingsHandler *ksettings,
                                   gchar *query,
+                                  gboolean extended,
                                   GError **error)
 {
 	KolabUtilHttpJob *job = NULL;
@@ -154,21 +155,60 @@ util_calendar_create_xfb_request (KolabSettingsHandler *ksettings,
 	g_assert (query != NULL);
 	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-	path = g_strdup_printf ("/freebusy/%s.ifb", query);
+	if (extended)
+		path = g_strdup_printf ("/freebusy/%s.xfb", query);
+	else
+		path = g_strdup_printf ("/freebusy/%s.ifb", query);
 
 	job = util_calendar_create_http_request (ksettings,
 	                                         path,
 	                                         &tmp_err);
 	g_free (path);
+
 	if (tmp_err != NULL) {
 		g_propagate_error (error, tmp_err);
-		g_warning ("%s()[%u] call to kolab_util_calendar_create_http_request() returned NULL!",
-		           __func__, __LINE__);
 		return NULL;
 	}
+
 	return job;
 } /* util_calendar_create_xfb_request () */
 
+static KolabUtilHttpJob*
+util_calendar_retrieve_xfb (KolabSettingsHandler *ksettings,
+                            gchar *query,
+                            gboolean extended,
+                            GError **error)
+{
+	KolabUtilHttpJob *job = NULL;
+	GError *tmp_err = NULL;
+
+	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
+	g_assert (query != NULL);
+	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+	job = util_calendar_create_xfb_request (ksettings,
+	                                        query,
+	                                        extended,
+	                                        &tmp_err);
+	if (job == NULL)
+		goto exit;
+
+	job->buffer = g_byte_array_new ();
+	(void) kolab_util_http_get (job, &tmp_err);
+
+ exit:
+
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
+		if (job != NULL) {
+			kolab_util_http_job_free (job);
+			job = NULL;
+		}
+	}
+
+	return job;
+} /* util_calendar_retrieve_xfb */
+
 /*----------------------------------------------------------------------------*/
 /* public API */
 
@@ -354,25 +394,30 @@ kolab_util_calendar_retrieve_xfb (KolabSettingsHandler *ksettings,
 	g_assert (query != NULL);
 	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-	job = util_calendar_create_xfb_request (ksettings,
-	                                        (gchar *) query,
-	                                        &tmp_err);
-	if (job == NULL) {
-		g_propagate_error (error, tmp_err);
-		g_warning ("%s()[%u] error creating job, giving up on %s.",
-		           __func__, __LINE__, (gchar *) query);
-		return NULL;
-	}
+	job = util_calendar_retrieve_xfb (ksettings,
+	                                  query,
+	                                  TRUE, /* try XFB */
+	                                  &tmp_err);
+	if (job != NULL)
+		goto done;
 
-	job->buffer = g_byte_array_new ();
-	(void)kolab_util_http_get (job, &tmp_err);
 	if (tmp_err != NULL) {
-		/* might happen, perhaps the server did not know about the user. */
-		kolab_util_http_job_free (job);
-		g_propagate_error (error, tmp_err);
-		return NULL;
+		g_warning ("%s()[%u] %s",
+		           __func__, __LINE__, tmp_err->message);
+		g_error_free (tmp_err);
+		tmp_err = NULL;
 	}
 
+	job = util_calendar_retrieve_xfb (ksettings,
+	                                  query,
+	                                  FALSE, /* try SFB */
+	                                  &tmp_err);
+
+	if (tmp_err != NULL)
+		g_propagate_error (error, tmp_err);
+
+ done:
+
 	return job;
 } /* kolab_util_calendar_retrieve_xfb () */
 



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