[evolution-kolab/ek-wip-porting] kolab-util-calendar: fixed password handling



commit f8ee189f467ff2635b14865ab7eb7300f54f98b9
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Mar 19 12:03:24 2012 +0100

    kolab-util-calendar: fixed password handling
    
    * set the password for the PFB request on the
      KolabUtilHttpJob directly from KolabSettingsHandler
    * CamelURL does no longer carry auth information

 src/calendar/kolab-util-calendar.c |   96 +++++++++++++++++-------------------
 1 files changed, 46 insertions(+), 50 deletions(-)
---
diff --git a/src/calendar/kolab-util-calendar.c b/src/calendar/kolab-util-calendar.c
index 003dd7d..46ec86e 100644
--- a/src/calendar/kolab-util-calendar.c
+++ b/src/calendar/kolab-util-calendar.c
@@ -47,8 +47,8 @@ kolab_util_calendar_create_http_request (KolabSettingsHandler *ksettings,
 	const gchar *user = NULL;
 	const gchar *passwd = NULL;
 	guint tls_variant = KOLAB_TLS_VARIANT_DEFAULT;
-	GError *tmp_error = NULL;
 	KolabUtilHttpJob *job = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
 	g_assert (path != NULL);
@@ -56,21 +56,21 @@ kolab_util_calendar_create_http_request (KolabSettingsHandler *ksettings,
 
 	url = kolab_settings_handler_get_char_field (ksettings,
 	                                             KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_URI,
-	                                             &tmp_error);
+	                                             &tmp_err);
 	if (url == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
 	tls_variant = kolab_settings_handler_get_uint_field (ksettings,
 	                                                     KOLAB_SETTINGS_HANDLER_UINT_FIELD_TLS_VARIANT,
-	                                                     &tmp_error);
-	if (error != NULL) {
-		g_propagate_error (error, tmp_error);
+	                                                     &tmp_err);
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
-	uri = camel_url_new (url, &tmp_error);
-	if (tmp_error != NULL) {
-		g_propagate_error (error, tmp_error);
+	uri = camel_url_new (url, &tmp_err);
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
 	if (uri == NULL) {
@@ -87,29 +87,25 @@ kolab_util_calendar_create_http_request (KolabSettingsHandler *ksettings,
 	camel_url_set_path (uri, path);
 	user = kolab_settings_handler_get_char_field (ksettings,
 	                                              KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_NAME,
-	                                              &tmp_error);
+	                                              &tmp_err);
 	if (user == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		camel_url_free (uri);
 		return NULL;
 	}
 	camel_url_set_user (uri, user);
 	passwd = kolab_settings_handler_get_char_field (ksettings,
 	                                                KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD,
-	                                                &tmp_error);
+	                                                &tmp_err);
 	if (passwd == NULL) {
-		g_propagate_error (error, tmp_error);
-		camel_url_free (uri);
-		return NULL;
+		g_warning ("%s()[%u]: no password supplied! (%s)",
+		           __func__, __LINE__, tmp_err->message);
+		g_error_free (tmp_err);
 	}
 
-	/* FIXME CamelURL does no longer carry auth details */
-	g_error ("%s: FIXME CamelURL does no longer carry auth details",
-	         __func__);
-	/* camel_url_set_passwd (uri, passwd); */
-
 	job = kolab_util_http_job_new ();
 	job->url = uri;
+	job->passwd = g_strdup (passwd); /* no longer carried by CamelURL */
 
 	return job;
 } /* kolab_util_calendar_create_http_request () */
@@ -123,7 +119,7 @@ kolab_util_calendar_create_pfb_trigger (KolabSettingsHandler *ksettings,
 	gchar *path = NULL;
 	const gchar *username = NULL;
 	gint source_offset = 0;
-	GError *tmp_error = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
 	g_assert (sourcename != NULL);
@@ -131,9 +127,9 @@ kolab_util_calendar_create_pfb_trigger (KolabSettingsHandler *ksettings,
 
 	username = kolab_settings_handler_get_char_field (ksettings,
 	                                                  KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_NAME,
-	                                                  &tmp_error);
-	if (tmp_error != NULL) {
-		g_propagate_error (error, tmp_error);
+	                                                  &tmp_err);
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
 
@@ -144,10 +140,10 @@ kolab_util_calendar_create_pfb_trigger (KolabSettingsHandler *ksettings,
 
 	job = kolab_util_calendar_create_http_request (ksettings,
 	                                               path,
-	                                               &tmp_error);
+	                                               &tmp_err);
 	g_free (path);
 	if (job == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
 	return job;
@@ -160,7 +156,7 @@ kolab_util_calendar_create_xfb_request (KolabSettingsHandler *ksettings,
 {
 	KolabUtilHttpJob *job = NULL;
 	gchar *path = NULL;
-	GError *tmp_error = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
 	g_assert (query != NULL);
@@ -170,10 +166,10 @@ kolab_util_calendar_create_xfb_request (KolabSettingsHandler *ksettings,
 
 	job = kolab_util_calendar_create_http_request (ksettings,
 	                                               path,
-	                                               &tmp_error);
+	                                               &tmp_err);
 	g_free (path);
 	if (job == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		g_warning ("%s()[%u] call to kolab_util_calendar_create_http_request() returned NULL!",
 		           __func__, __LINE__);
 		return NULL;
@@ -242,7 +238,7 @@ kolab_util_calendar_toggle_pfb_trigger (KolabSettingsHandler *ksettings,
 	 * If an error occured, internal_state is set to false as indicator.
 	 */
 	KolabUtilHttpJob *job = NULL;
-	GError *tmp_error = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
 	g_assert (sourcename != NULL);
@@ -250,19 +246,19 @@ kolab_util_calendar_toggle_pfb_trigger (KolabSettingsHandler *ksettings,
 
 	job = kolab_util_calendar_create_pfb_trigger (ksettings,
 	                                              sourcename,
-	                                              &tmp_error);
+	                                              &tmp_err);
 	if (job == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		g_warning ("%s()[%u] error: could not create F/B toggle, giving up on %s.",
 		           __func__, __LINE__, sourcename);
 		return FALSE;
 	}
 	job->buffer = g_byte_array_new ();
-	(void)kolab_util_http_get (job, &tmp_error);
+	(void)kolab_util_http_get (job, &tmp_err);
 	kolab_util_http_job_free (job);
 
-	if (tmp_error != NULL) {
-		g_propagate_error (error, tmp_error);
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
 		return FALSE;
 	}
 	return TRUE;
@@ -274,7 +270,7 @@ kolab_util_calendar_retrieve_xfb (KolabSettingsHandler *ksettings,
                                   GError **error)
 {
 	KolabUtilHttpJob *job = NULL;
-	GError *tmp_error = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_SETTINGS_HANDLER (ksettings));
 	g_assert (query != NULL);
@@ -282,20 +278,20 @@ kolab_util_calendar_retrieve_xfb (KolabSettingsHandler *ksettings,
 
 	job = kolab_util_calendar_create_xfb_request (ksettings,
 	                                              (gchar *) query,
-	                                              &tmp_error);
+	                                              &tmp_err);
 	if (job == NULL) {
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		g_warning ("%s()[%u] error creating job, giving up on %s.",
 		           __func__, __LINE__, (gchar *) query);
 		return NULL;
 	}
 
 	job->buffer = g_byte_array_new ();
-	(void)kolab_util_http_get (job, &tmp_error);
-	if (tmp_error != NULL) {
+	(void)kolab_util_http_get (job, &tmp_err);
+	if (tmp_err != NULL) {
 		/* might happen, perhaps the server did not now about the user. */
 		kolab_util_http_job_free (job);
-		g_propagate_error (error, tmp_error);
+		g_propagate_error (error, tmp_err);
 		return NULL;
 	}
 
@@ -317,7 +313,7 @@ kolab_util_calendar_store (ECalComponent *ecalcomp,
 	KolabMailAccessOpmodeID mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
 	gboolean do_trigger = FALSE;
 	gboolean ok = FALSE;
-	GError *tmp_error = NULL;
+	GError *tmp_err = NULL;
 
 	g_assert (E_IS_CAL_COMPONENT (ecalcomp));
 	/* ecaltz may be NULL */
@@ -342,13 +338,13 @@ kolab_util_calendar_store (ECalComponent *ecalcomp,
 	                                      kmh,
 	                                      sourcename,
 	                                      cancellable,
-	                                      &tmp_error);
+	                                      &tmp_err);
 	if (! ok)
 		goto cleanup;
 
 	mode = kolab_mail_access_get_opmode (koma,
-	                                     &tmp_error);
-	if (tmp_error != NULL)
+	                                     &tmp_err);
+	if (tmp_err != NULL)
 		goto cleanup;
 	if (mode < KOLAB_MAIL_ACCESS_OPMODE_ONLINE) {
 		/* In OFFLINE state, the triggers are generated during
@@ -359,19 +355,19 @@ kolab_util_calendar_store (ECalComponent *ecalcomp,
 
 	do_trigger = kolab_mail_access_source_fbtrigger_needed (koma,
 	                                                        sourcename,
-	                                                        &tmp_error);
-	if (tmp_error != NULL)
+	                                                        &tmp_err);
+	if (tmp_err != NULL)
 		goto cleanup;
 
 	if (do_trigger == TRUE)
 		(void) kolab_util_calendar_toggle_pfb_trigger (ksettings,
 		                                               sourcename,
-		                                               &tmp_error);
+		                                               &tmp_err);
  cleanup:
 	g_object_unref (ksettings);
 	g_free (sourcename);
-	if (tmp_error != NULL) {
-		g_propagate_error (error, tmp_error);
+	if (tmp_err != NULL) {
+		g_propagate_error (error, tmp_err);
 		return FALSE;
 	}
 	return TRUE;



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