aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-11-02 21:39:37 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-11-02 21:39:37 +0800
commit428b0a481bc6ec47b4f5c73260034f30d1a93fd1 (patch)
tree403be24cd23845fa6b92d7b2c0f073352c0fd55f
parent9a721740008ab29f7c1f40a9c6466a03a8b80c3f (diff)
downloadgsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar.gz
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar.bz2
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar.lz
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar.xz
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.tar.zst
gsoc2013-evolution-428b0a481bc6ec47b4f5c73260034f30d1a93fd1.zip
Adapt to CamelDataCache API changes.
-rw-r--r--mail/e-http-request.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/mail/e-http-request.c b/mail/e-http-request.c
index 996a993804..afad8cbdd0 100644
--- a/mail/e-http-request.c
+++ b/mail/e-http-request.c
@@ -55,24 +55,34 @@ struct _EHTTPRequestPrivate {
G_DEFINE_TYPE (EHTTPRequest, e_http_request, SOUP_TYPE_REQUEST)
static gssize
-copy_stream_to_stream (CamelStream *input,
+copy_stream_to_stream (GIOStream *file_io_stream,
GMemoryInputStream *output,
GCancellable *cancellable)
{
+ GInputStream *input_stream;
gchar *buff;
gssize read_len = 0;
gssize total_len = 0;
+ const gsize buff_size = 4096;
- g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, cancellable, NULL);
+ g_seekable_seek (
+ G_SEEKABLE (file_io_stream), 0,
+ G_SEEK_SET, cancellable, NULL);
- buff = g_malloc (4096);
- while ((read_len = camel_stream_read (input, buff, 4096, cancellable, NULL)) > 0) {
+ input_stream = g_io_stream_get_input_stream (file_io_stream);
- g_memory_input_stream_add_data (output, buff, read_len, g_free);
+ buff = g_malloc (buff_size);
+ read_len = g_input_stream_read (
+ input_stream, buff, buff_size, cancellable, NULL);
+ while (read_len > 0) {
+ g_memory_input_stream_add_data (
+ output, buff, read_len, g_free);
total_len += read_len;
- buff = g_malloc (4096);
+ buff = g_malloc (buff_size);
+ read_len = g_input_stream_read (
+ input_stream, buff, buff_size, cancellable, NULL);
}
/* Free the last unused buffer */
@@ -160,7 +170,7 @@ handle_http_request (GSimpleAsyncResult *res,
GSettings *settings;
const gchar *user_cache_dir;
CamelDataCache *cache;
- CamelStream *cache_stream;
+ GIOStream *cache_stream;
GHashTable *query;
gint uri_len;
@@ -224,8 +234,7 @@ handle_http_request (GSimpleAsyncResult *res,
/* Found item in cache! */
cache_stream = camel_data_cache_get (cache, "http", uri_md5, NULL);
- if (cache_stream) {
-
+ if (cache_stream != NULL) {
gssize len;
stream = g_memory_input_stream_new ();
@@ -336,7 +345,7 @@ handle_http_request (GSimpleAsyncResult *res,
SoupSession *session;
SoupMessage *message;
- CamelStream *cache_stream;
+ GIOStream *cache_stream;
GError *error;
GMainContext *context;
EProxy *proxy;
@@ -374,18 +383,26 @@ handle_http_request (GSimpleAsyncResult *res,
/* Write the response body to cache */
error = NULL;
- cache_stream = camel_data_cache_add (cache, "http", uri_md5, &error);
+ cache_stream = camel_data_cache_add (
+ cache, "http", uri_md5, &error);
if (error != NULL) {
g_warning (
"Failed to create cache file for '%s': %s",
uri, error->message);
g_clear_error (&error);
} else {
- camel_stream_write (
- cache_stream, message->response_body->data,
- message->response_body->length, cancellable, &error);
+ GOutputStream *output_stream;
+
+ output_stream =
+ g_io_stream_get_output_stream (cache_stream);
+
+ g_output_stream_write_all (
+ output_stream,
+ message->response_body->data,
+ message->response_body->length,
+ NULL, cancellable, &error);
- camel_stream_close (cache_stream, cancellable, NULL);
+ g_io_stream_close (cache_stream, NULL, NULL);
g_object_unref (cache_stream);
if (error != NULL) {