[evolution-kolab/ek-wip-porting: 4/6] libekolabutil: build fixes



commit e6f86ddf5beb4fbf303dbc84237258c05aef9c01
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Thu Nov 24 14:33:52 2011 +0100

    libekolabutil: build fixes
    
    * remove all camel header file includes from camel-system-headers.h
      but the single camel.h file
    * include our camel-system-headers.h instead of a multitude of camel
      headers (which is no longer possible)
    * commented out Camel authentication stuff (details no longer live
      in CamelURL, but in CamelSettings), rewrite of HTTP auth pending
    * fixed CamelType (now GType)
    * fixed CamelException (now GError, removed conversion functions)
    * commented out libsoup stuff in HTTP utils (we use libcurl for
      time being to support certificate based client auth via NSS and
      PKCS #11)

 src/camel/camel-kolab-session.h             |   11 ++---
 src/camel/camel-kolab-stream.h              |    9 ++--
 src/libekolabutil/camel-system-headers.h    |    3 +-
 src/libekolabutil/kolab-util-cal-freebusy.c |   21 ++++++----
 src/libekolabutil/kolab-util-camel.c        |   43 ++++++++++++--------
 src/libekolabutil/kolab-util-error.c        |   58 ---------------------------
 src/libekolabutil/kolab-util-error.h        |   10 -----
 src/libekolabutil/kolab-util-http.c         |   50 +++++++++++++++--------
 8 files changed, 82 insertions(+), 123 deletions(-)
---
diff --git a/src/camel/camel-kolab-session.h b/src/camel/camel-kolab-session.h
index 3f89a5c..d73daa7 100644
--- a/src/camel/camel-kolab-session.h
+++ b/src/camel/camel-kolab-session.h
@@ -11,12 +11,12 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with main.c; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
@@ -50,8 +50,7 @@
 
 #include <glib.h>
 
-#include <camel/camel-types.h>
-#include <camel/camel-session.h>
+#include <libekolabutil/camel-system-headers.h>
 
 /*----------------------------------------------------------------------------*/
 
@@ -75,10 +74,10 @@ typedef struct _CamelKolabSession {
 typedef struct _CamelKolabSessionClass {
         CamelSessionClass parent_class;
 	/* TODO check what else is needed here */
-	
+
 } CamelKolabSessionClass;
 
-CamelType camel_kolab_session_get_type (void);
+GType camel_kolab_session_get_type (void);
 
 CamelKolabSession* camel_kolab_session_new (void);
 gboolean camel_kolab_session_bringup (CamelKolabSession *self, GError **err);
diff --git a/src/camel/camel-kolab-stream.h b/src/camel/camel-kolab-stream.h
index bd25c11..05ea061 100644
--- a/src/camel/camel-kolab-stream.h
+++ b/src/camel/camel-kolab-stream.h
@@ -11,17 +11,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with main.c; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 
 #ifndef _CAMEL_KOLAB_STREAM_H_
@@ -30,10 +30,9 @@
 /*----------------------------------------------------------------------------*/
 
 #include <glib.h>
-
 #include <sys/types.h>
 
-#include <camel/camel-types.h>
+#include <libekolabutil/camel-system-headers.h>
 
 /*----------------------------------------------------------------------------*/
 
diff --git a/src/libekolabutil/camel-system-headers.h b/src/libekolabutil/camel-system-headers.h
index 1d2cd80..1ce7149 100644
--- a/src/libekolabutil/camel-system-headers.h
+++ b/src/libekolabutil/camel-system-headers.h
@@ -34,6 +34,7 @@
 /*----------------------------------------------------------------------------*/
 
 #include <camel/camel.h>
+#if 0
 #include <camel/camel-object.h>
 #include <camel/camel-url.h>
 #include <camel/camel-exception.h>
@@ -47,7 +48,7 @@
 #include <camel/camel-multipart.h>
 #include <camel/camel-mime-utils.h>
 #include <camel/camel-mime-message.h>
-
+#endif
 
 #if 0
 #include <camel/camel-sasl.h>
diff --git a/src/libekolabutil/kolab-util-cal-freebusy.c b/src/libekolabutil/kolab-util-cal-freebusy.c
index 225ace1..922b671 100644
--- a/src/libekolabutil/kolab-util-cal-freebusy.c
+++ b/src/libekolabutil/kolab-util-cal-freebusy.c
@@ -12,17 +12,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 /** @file */
 
@@ -62,7 +62,7 @@ kolab_cal_util_fb_new_ecalcomp_from_request (KolabHttpJob *job,
 	gssize nbytes;
 	ECalComponent *ecalcomp = NULL;
 	GError *tmp_err = NULL;
-	
+
 	/* preconditions */
 	g_assert (job != NULL);
 	g_assert (job->buffer == NULL);
@@ -95,13 +95,19 @@ kolab_cal_util_fb_new_ecalcomp_from_request (KolabHttpJob *job,
 	g_free (url_string);
 	camel_url_set_user (camel_url, job->url->user);
 	/* TODO authmech ? */
+
+	/* FIXME camel authentication stuff has moved to CamelSettings */
+	g_warning ("%s: Camel authentication not yet ported", __func__);
+#if 0
 	camel_url_set_passwd (camel_url, job->url->passwd);
+#endif
+
 	camel_url_set_port (camel_url, job->url->port);
 	if (job->url->query) camel_url_set_query (camel_url, job->url->query);
 	if (job->url->fragment) camel_url_set_fragment (camel_url, job->url->fragment);
 	camel_url_free (job->url);
 	job->url = camel_url;
-	
+
 	job->buffer = g_byte_array_new ();
 	g_assert (job->buffer != NULL);
 
@@ -116,7 +122,7 @@ kolab_cal_util_fb_new_ecalcomp_from_request (KolabHttpJob *job,
 	                                                              &tmp_err);
 	if ((ecalcomp == NULL) && (tmp_err != NULL))
 		g_propagate_error (err, tmp_err);
-		
+
 	g_byte_array_unref (job->buffer);
 	job->buffer = NULL;
 	g_free (servername);
@@ -128,7 +134,7 @@ kolab_cal_util_fb_new_ecalcomp_from_request (KolabHttpJob *job,
 }
 
 void
-kolab_cal_util_fb_ecalcomp_free (ECalComponent *ecalcomp) 
+kolab_cal_util_fb_ecalcomp_free (ECalComponent *ecalcomp)
 {
 	/* this function could be removed */
 	if (ecalcomp == NULL)
@@ -136,5 +142,4 @@ kolab_cal_util_fb_ecalcomp_free (ECalComponent *ecalcomp)
 	g_object_unref (ecalcomp);
 }
 
-
 /*----------------------------------------------------------------------------*/
diff --git a/src/libekolabutil/kolab-util-camel.c b/src/libekolabutil/kolab-util-camel.c
index a6fd9bb..7950907 100644
--- a/src/libekolabutil/kolab-util-camel.c
+++ b/src/libekolabutil/kolab-util-camel.c
@@ -11,17 +11,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 
 #include <e-util/e-util.h>
@@ -38,16 +38,14 @@ gboolean
 kolab_util_camel_init (GError **err)
 {
 	static gboolean is_initialized = FALSE;
-	
+
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	if (is_initialized == TRUE)
 		return TRUE;
-	
+
 	/* GLib must be initialized first */
 	kolab_util_glib_init ();
-	
-	camel_type_init ();
 
 	/* init Camel subsystem */
 	if (camel_init (e_get_user_data_dir (), TRUE) != 0) {
@@ -63,7 +61,7 @@ kolab_util_camel_init (GError **err)
 	camel_provider_init ();
 
 	is_initialized = TRUE;
-	
+
 	g_debug ("%s: camel system initialized", __func__);
 
 	return TRUE;
@@ -85,30 +83,39 @@ kolab_util_camel_get_storage_path (CamelService *service,
                                    GError **err)
 {
 	gchar *store_path = NULL;
-	CamelException *ex = NULL;
-	
+	CamelURL *url = NULL;
+
 	g_assert (CAMEL_IS_SERVICE (service));
 	g_assert (CAMEL_IS_SESSION (session));
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
+	/* FIXME Rework the whole CamelURL / CamelSettings / CamelService
+	 *	 stuff according to mbarnes' changes
+	 */
+	url = camel_service_new_camel_url (service);
+	g_assert (url != NULL);
+	g_assert (url->path != NULL);
+	store_path = g_strdup (url->path);
+	camel_url_free (url);
+
+#if 0
 	if (service->url->path != NULL)
 		return g_strdup (service->url->path);
 
-	ex = camel_exception_new ();
 	store_path = camel_session_get_storage_path (session,
 	                                             service,
-	                                             ex);
-	if (camel_exception_is_set (ex)) {
+	                                             &tmp_err);
+	if (tmp_err != NULL) {
 		g_warning ("%s: %s",
 		           __func__,
-		           camel_exception_get_description (ex));
-		camel_exception_free (ex);
+		           tmp_err->message);
+		g_error_free (tmp_err);
+		tmp_err = NULL;
 		if (store_path != NULL) {
 			g_free (store_path);
 			store_path = NULL;
 		}
 	}
-	camel_exception_free (ex);
 	if (store_path == NULL)
 		store_path = camel_session_get_storage_path (session,
 		                                             service,
@@ -119,8 +126,10 @@ kolab_util_camel_get_storage_path (CamelService *service,
 			     KOLAB_CAMEL_KOLAB_ERROR_DB,
 			     "%s: could get Camel storage path",
 			     __func__);
-		
+
 	}
+#endif
+
 	return store_path;
 }
 
diff --git a/src/libekolabutil/kolab-util-error.c b/src/libekolabutil/kolab-util-error.c
index c3e4caa..2dc02b9 100644
--- a/src/libekolabutil/kolab-util-error.c
+++ b/src/libekolabutil/kolab-util-error.c
@@ -75,62 +75,4 @@ kolab_util_error_quark (void)
 }
 
 /*----------------------------------------------------------------------------*/
-/* CamelException <-> GError */
-
-CamelException*
-kolab_camelexception_new_from_gerror (const GError *err)
-{
-	CamelException *ex = camel_exception_new ();
-	
-	if (err != NULL) {
-		camel_exception_set (ex,
-		                     KOLAB_CAMEL_ERROR_GENERIC,
-		                     err->message);
-	}
-	return ex;
-}
-
-GError*
-kolab_gerror_new_from_camelexception (CamelException *ex,
-                                      GQuark error_quark)
-{
-	GError *err = NULL;
-	
-	if (camel_exception_is_set (ex)) {
-		err = g_error_new (error_quark,
-		                   KOLAB_CAMEL_ERROR_GENERIC,
-		                   "%s",
-		                   camel_exception_get_description (ex));
-	}
-	return err;
-}
-
-void
-kolab_gerror_propagate_from_camelexception (GError **err,
-                                            CamelException *ex,
-                                            GQuark error_quark)
-{
-	GError *tmp_err = NULL;
-
-	g_assert (err == NULL || *err == NULL);
-
-	if (!camel_exception_is_set (ex))
-		return;
-
-	tmp_err = kolab_gerror_new_from_camelexception (ex,
-	                                                error_quark);
-	camel_exception_free (ex);
-	g_propagate_error (err, tmp_err);	
-}
-
-void
-kolab_camelexception_propagate_from_gerror (CamelException *ex, GError *err)
-{
-	CamelException *tmp_ex;
-
-	tmp_ex = kolab_camelexception_new_from_gerror (err);
-	camel_exception_xfer (ex, tmp_ex);
-}
-
-/*----------------------------------------------------------------------------*/
 
diff --git a/src/libekolabutil/kolab-util-error.h b/src/libekolabutil/kolab-util-error.h
index 15d6b4d..df15d7c 100644
--- a/src/libekolabutil/kolab-util-error.h
+++ b/src/libekolabutil/kolab-util-error.h
@@ -73,16 +73,6 @@ typedef enum {
 GQuark kolab_util_error_quark (void) G_GNUC_CONST;
 
 /*----------------------------------------------------------------------------*/
-/* CamelException <-> GErorr conversion */
-
-/* converts bewtween GError and CamelException (obsolete when ported to 2.32+) */
-CamelException *kolab_camelexception_new_from_gerror (const GError *err);
-GError *kolab_gerror_new_from_camelexception (CamelException *ex, GQuark error_quark);
-/* propagates a CamelException to a GError and vice versa */
-void kolab_gerror_propagate_from_camelexception (GError **err, CamelException *ex, GQuark error_quark);
-void kolab_camelexception_propagate_from_gerror (CamelException *ex, GError *err);
-
-/*----------------------------------------------------------------------------*/
 
 /*----------------------------------------------------------------------------*/
 
diff --git a/src/libekolabutil/kolab-util-http.c b/src/libekolabutil/kolab-util-http.c
index f72a42b..5c5aab1 100644
--- a/src/libekolabutil/kolab-util-http.c
+++ b/src/libekolabutil/kolab-util-http.c
@@ -12,17 +12,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 
 /*
@@ -65,7 +65,7 @@
 
 /* TEMPORARY */
 /* TODO: move to config file, since this is configurable */
-#define KOLAB_UTIL_HTTP_CURL_DEBUG 0		/* 1 or 0 */ 
+#define KOLAB_UTIL_HTTP_CURL_DEBUG 0		/* 1 or 0 */
 #define KOLAB_UTIL_HTTP_CURL_SSL_VERIFY_PEER 1L /* 1L or 0L */
 #define KOLAB_UTIL_HTTP_CURL_SSL_VERIFY_HOST 2L /* 2L, 1L or 0L */
 #define KOLAB_UTIL_HTTP_CURL_FOLLOW_REDIRECTS 1 /* 1 or 0 */
@@ -95,12 +95,12 @@ typedef enum {
 /*----------------------------------------------------------------------------*/
 
 /*TODO get rid of these globals if possible */
-static SoupSession *kolab_soup_session = NULL;
+/* static SoupSession *kolab_soup_session = NULL; */
 static CURL *kolab_curl_handle = NULL;
 
 /*----------------------------------------------------------------------------*/
 /* LibSoup */
-
+#if 0
 static void
 kolab_util_http_soup_authenticate (SoupSession *session,
                                    SoupMessage *msg,
@@ -127,6 +127,7 @@ kolab_util_http_soup_authenticate (SoupSession *session,
 static gssize
 kolab_util_http_soup_get (const KolabHttpJob *job, GError **error)
 {
+	g_error ("%s: not implemented.", __func__);
 	SoupMessage *msg = NULL;
 	CamelStream *mem = NULL;
 	guint status = 0;
@@ -177,7 +178,7 @@ kolab_util_http_soup_get (const KolabHttpJob *job, GError **error)
 			error_code = KOLAB_UTIL_HTTP_ERROR_CLIENT_ERROR;
 		else /* if (status > 100) */
 			/* 1xx informational and 2xx is considered success, then why are we here? */
-			error_code = KOLAB_UTIL_HTTP_ERROR_UNKNOWN_ERROR; 
+			error_code = KOLAB_UTIL_HTTP_ERROR_UNKNOWN_ERROR;
 
 		g_set_error (error,
 		             KOLAB_UTIL_HTTP_ERROR,
@@ -187,6 +188,7 @@ kolab_util_http_soup_get (const KolabHttpJob *job, GError **error)
 
 	return nbytes;
 }
+#endif
 
 /*----------------------------------------------------------------------------*/
 /* LibCurl */
@@ -251,7 +253,7 @@ kolab_util_http_curl_set_genopts (void)
 	                             CURLOPT_SSL_VERIFYHOST,
 	                             KOLAB_UTIL_HTTP_CURL_SSL_VERIFY_HOST);
 	if (curlcode) return curlcode;
-	 
+
 	/* TODO more here
 	 * - HTTP options (referrers, encoding, follow, user-agent...)
 	 */
@@ -265,15 +267,15 @@ kolab_util_http_curl_set_jobopts (const KolabHttpJob *job)
 	CURLcode curlcode;
 	gchar *usrpwd = NULL;
 	gchar *url_string;
-	
+
 	/* buffer to write answer data to */
 	curlcode = curl_easy_setopt (kolab_curl_handle,
 	                             CURLOPT_WRITEDATA,
 	                             (void*)job->buffer);
 	if (curlcode)
 		return curlcode;
-	
-	url_string = camel_url_to_string (job->url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_AUTH);
+
+	url_string = camel_url_to_string (job->url, CAMEL_URL_HIDE_AUTH);
 	curlcode = curl_easy_setopt (kolab_curl_handle,
 	                             CURLOPT_URL,
 	                             url_string);
@@ -287,6 +289,9 @@ kolab_util_http_curl_set_jobopts (const KolabHttpJob *job)
 
 	/* set username/password for basic auth */
 	if (job->url->user != NULL) {
+		/* FIXME get password from CamelSettings (change KolabHttpJob) */
+		g_warning ("%s: FIXME get password from CamelSettings", __func__);
+#if 0
 		if (job->url->passwd != NULL)
 			usrpwd = g_strconcat (job->url->user,
 			                      ":",
@@ -295,6 +300,7 @@ kolab_util_http_curl_set_jobopts (const KolabHttpJob *job)
 		else
 			g_debug ("%s: username given but password not set",
 			         __func__);
+#endif
 	}
 	if (usrpwd != NULL) {
 		curlcode = curl_easy_setopt (kolab_curl_handle,
@@ -308,8 +314,8 @@ kolab_util_http_curl_set_jobopts (const KolabHttpJob *job)
 	 * - SSL options (cert, cert key, ... maybe better done in genopts)
 	 * - Proxy usage and auth
 	 */
-	
-	/* CURLOPT_SSLCERT (nss): provide a nickname for certificate. In this 
+
+	/* CURLOPT_SSLCERT (nss): provide a nickname for certificate. In this
 	 * case, we don't supply a nickname and expect the nss to do "the right
 	 * thing".
 	 */
@@ -359,7 +365,7 @@ kolab_util_http_curl_get (KolabHttpJob *job, GError **error)
 		             KOLAB_UTIL_HTTP_ERROR,
 		             error_code,
 		             "Access to %s failed in libcurl with CURLcode: %u",
-		             camel_url_to_string (job->url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_AUTH), curlcode);
+		             camel_url_to_string (job->url, CAMEL_URL_HIDE_AUTH), curlcode);
 	}
 	else {
 		nbytes = (gssize)job->buffer->len;
@@ -393,14 +399,16 @@ kolab_util_http_init (void)
 	glong curl_global_flags;
 	static gboolean http_is_initialized = FALSE;
 
-	if (http_is_initialized == TRUE) 
+	if (http_is_initialized == TRUE)
 		return;
+#if 0
 	/* libsoup */
-	kolab_soup_session = (SoupSession*)soup_session_sync_new ();	
+	kolab_soup_session = (SoupSession*)soup_session_sync_new ();
 	g_assert (kolab_soup_session != NULL);
+#endif
 
 	/* libcurl */
-	
+
 	/* CURL_GLOBAL_ALL will also init SSL,
 	 * which we want to leave to Camel...
 	 * CURL_GLOBAL_NOTHING should init libcurl,
@@ -436,8 +444,10 @@ kolab_util_http_shutdown (void)
 	curl_easy_cleanup (kolab_curl_handle);
 	curl_global_cleanup ();
 
+#if 0
 	/* libsoup */
 	g_object_unref (kolab_soup_session);
+#endif
 }
 
 /*----------------------------------------------------------------------------*/
@@ -457,6 +467,9 @@ kolab_util_http_get (KolabHttpJob *job, GError **error)
 {
 	gssize nbytes = -1;
 
+	nbytes = kolab_util_http_curl_get (job, error);
+
+#if 0
 	/* TODO change this to conditional compilation once
 	 *      things have settled.
 	 *      We keep this for now to make sure all variants
@@ -475,6 +488,7 @@ kolab_util_http_get (KolabHttpJob *job, GError **error)
 			/* can't happen */
 			g_assert_not_reached();
 	}
+#endif
 
 	return nbytes;
 }
@@ -497,7 +511,7 @@ kolab_util_http_new_hostname_from_url (const gchar *url_string)
 	CamelURL *url = NULL;
 	gchar *hostname = NULL;
 	CamelException *ex = NULL;
-	
+
 	g_assert (url_string != NULL);
 
 	ex = camel_exception_new ();



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