[evolution-kolab/ek-wip-porting-imapx: 8/12] CamelKolabStream: build fixes, error handling fixes
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting-imapx: 8/12] CamelKolabStream: build fixes, error handling fixes
- Date: Wed, 30 Nov 2011 11:27:32 +0000 (UTC)
commit 090cd533bf1914267fe61fa92f1cb7f929aa53fd
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Wed Nov 30 11:55:35 2011 +0100
CamelKolabStream: build fixes, error handling fixes
* constructors for I/O streams (HTTP, File) now take
a GError** argument
* removed use of CamelException, using GError instead
src/camel/camel-kolab-stream.c | 61 +++++++++++++++++++++++++---------------
src/camel/camel-kolab-stream.h | 13 +++-----
2 files changed, 43 insertions(+), 31 deletions(-)
---
diff --git a/src/camel/camel-kolab-stream.c b/src/camel/camel-kolab-stream.c
index b0153ae..5ee824c 100644
--- a/src/camel/camel-kolab-stream.c
+++ b/src/camel/camel-kolab-stream.c
@@ -38,15 +38,25 @@
/*----------------------------------------------------------------------------*/
CamelStream*
-camel_kolab_stream_new_filestream (const gchar* filename,
+camel_kolab_stream_new_filestream (const gchar *filename,
const gint flags,
- const mode_t mode)
+ const mode_t mode,
+ GError **err)
{
- CamelStream* stream = NULL;
+ CamelStream *stream = NULL;
+ GError *tmp_err = NULL;
+
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
stream = camel_stream_fs_new_with_name (filename,
- flags,
- mode);
+ flags,
+ mode,
+ &tmp_err);
+
+ if (tmp_err != NULL) {
+ g_propagate_error (err, tmp_err);
+ return NULL;
+ }
if (stream == NULL)
g_debug ("%s: CamelStreamFs is NULL", __func__);
@@ -55,24 +65,23 @@ camel_kolab_stream_new_filestream (const gchar* filename,
}
CamelStream*
-camel_kolab_stream_new_httpstream (CamelSession* session,
- const gchar* url_string)
+camel_kolab_stream_new_httpstream (CamelSession *session,
+ const gchar *url_string,
+ GError **err)
{
- CamelURL* url;
- CamelStream* stream = NULL;
- CamelException ex;
-
- camel_exception_init (&ex);
+ CamelURL *url = NULL;
+ CamelStream *stream = NULL;
+ GError *tmp_err = NULL;
- url = camel_url_new (url_string, NULL);
- if (camel_exception_is_set (&ex) ) {
+ url = camel_url_new (url_string, &tmp_err);
+ if (tmp_err != NULL) {
g_debug ("%s: CamelURL is NULL", __func__);
goto done;
}
stream = camel_http_stream_new(CAMEL_HTTP_METHOD_GET,
- session,
- url);
+ session,
+ url);
if (stream == NULL) {
g_debug ("%s: CamelHttpStream is NULL", __func__);
goto done;
@@ -80,22 +89,26 @@ camel_kolab_stream_new_httpstream (CamelSession* session,
/* TODO use better agent version string here */
camel_http_stream_set_user_agent((CamelHttpStream *)stream,
- "CamelHttpStream/1.0 Evolution-kolab/" VERSION);
+ "CamelHttpStream/1.0 Evolution-kolab/" VERSION);
done:
- camel_url_free (url);
- camel_exception_free (&ex);
+ if (url != NULL)
+ camel_url_free (url);
+ if (tmp_err != NULL) {
+ g_propagate_error (err, tmp_err);
+ return NULL;
+ }
return stream;
}
CamelStream*
-camel_kolab_stream_new_memstream (GByteArray* buffer)
+camel_kolab_stream_new_memstream (GByteArray *buffer)
{
/* caution: CamelStreamMem behaves differently
* compared to the other CamelStream classes,
* type-wise ...
*/
- CamelStreamMem* stream = (CamelStreamMem*)camel_stream_mem_new ();
+ CamelStreamMem *stream = (CamelStreamMem*)camel_stream_mem_new ();
if (buffer != NULL)
camel_stream_mem_set_byte_array (stream, buffer);
@@ -103,9 +116,11 @@ camel_kolab_stream_new_memstream (GByteArray* buffer)
return (CamelStream*)stream;
}
-void camel_kolab_stream_free (CamelStream* stream)
+void camel_kolab_stream_free (CamelStream *stream)
{
if (stream == NULL)
return;
- camel_object_unref (stream);
+ g_object_unref (stream);
}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/camel/camel-kolab-stream.h b/src/camel/camel-kolab-stream.h
index a774194..6ee7d05 100644
--- a/src/camel/camel-kolab-stream.h
+++ b/src/camel/camel-kolab-stream.h
@@ -37,14 +37,11 @@
/*----------------------------------------------------------------------------*/
-CamelStream* camel_kolab_stream_new_filestream (const gchar*,
- const gint flags,
- const mode_t);
-CamelStream* camel_kolab_stream_new_httpstream (CamelSession*,
- const gchar*);
-CamelStream* camel_kolab_stream_new_memstream (GByteArray*);
-
-void camel_kolab_stream_free (CamelStream*);
+CamelStream* camel_kolab_stream_new_filestream (const gchar *filename, const gint flags, const mode_t mode, GError **err);
+CamelStream* camel_kolab_stream_new_httpstream (CamelSession *session, const gchar *url_string, GError **err);
+CamelStream* camel_kolab_stream_new_memstream (GByteArray *buffer);
+
+void camel_kolab_stream_free (CamelStream *stream);
/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]