[evolution-rss] Bug 712709 - Adapt to evolution-data-server/evolution 3.11.2 changes
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-rss] Bug 712709 - Adapt to evolution-data-server/evolution 3.11.2 changes
- Date: Fri, 29 Nov 2013 21:45:03 +0000 (UTC)
commit a9805199c18b1a8b6b2c48d83b3c78be21b2ab91
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 29 18:01:12 2013 +0100
Bug 712709 - Adapt to evolution-data-server/evolution 3.11.2 changes
src/parser.c | 5 ++
src/rss-cache.c | 8 +---
src/rss-cache.h | 14 +++++-
src/rss-config-factory.c | 5 ++-
src/rss-evo-common.c | 4 ++
src/rss-image.c | 106 +++++++++++++++++++++++++++++++++++++++++++---
src/rss-image.h | 5 +-
src/rss.c | 4 ++
8 files changed, 133 insertions(+), 18 deletions(-)
---
diff --git a/src/parser.c b/src/parser.c
index d3b3ed6..ef20856 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -25,11 +25,16 @@
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/debugXML.h>
+
+#if EVOLUTION_VERSION >= 31102
+#include <libemail-engine/libemail-engine.h>
+#else
#if EVOLUTION_VERSION >= 30305
#include <libemail-engine/mail-ops.h>
#else
#include <mail/mail-ops.h>
#endif
+#endif
#if EVOLUTION_VERSION >= 30505
#include <mail/e-mail-reader-utils.h>
#endif
diff --git a/src/rss-cache.c b/src/rss-cache.c
index b075659..65f926d 100644
--- a/src/rss-cache.c
+++ b/src/rss-cache.c
@@ -98,12 +98,6 @@ rss_cache_get_path(int create, const char *key)
return real;
}
-CamelStream*
-rss_cache_get(gchar *url)
-{
- return camel_data_cache_get(cache, HTTP_CACHE_PATH, url, NULL);
-}
-
#if DATASERVER_VERSION <= 2025004
#define CAMEL_DATA_CACHE_BITS (6)
#define CAMEL_DATA_CACHE_MASK ((1<<CAMEL_DATA_CACHE_BITS)-1)
@@ -145,7 +139,7 @@ rss_cache_get_filename(gchar *url)
#endif
}
-CamelStream*
+RssCacheStream *
rss_cache_add(gchar *url)
{
return camel_data_cache_add(cache, HTTP_CACHE_PATH, url, NULL);
diff --git a/src/rss-cache.h b/src/rss-cache.h
index eabee01..845178c 100644
--- a/src/rss-cache.h
+++ b/src/rss-cache.h
@@ -17,14 +17,24 @@
* 02110-1301 USA
*/
+#ifndef RSS_CACHE_H
+#define RSS_CACHE_H
+
#if (DATASERVER_VERSION >= 2031001)
#include <camel/camel.h>
#else
#include <camel/camel-data-cache.h>
#endif
+#if (DATASERVER_VERSION >= 3011002)
+#define RssCacheStream GIOStream
+#else
+#define RssCacheStream CamelStream
+#endif
+
void rss_cache_init(void);
-CamelStream *rss_cache_get(gchar *url);
gchar *rss_cache_get_filename(gchar *url);
char* rss_cache_get_path(int create, const char *path);
-CamelStream* rss_cache_add(gchar *url);
+RssCacheStream *rss_cache_add(gchar *url);
+
+#endif /* RSS_CACHE_H */
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 84a1d6e..7105d01 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -46,6 +46,9 @@
#endif
#include <mail/em-folder-selector.h>
+#if EVOLUTION_VERSION >= 31102
+#include <libemail-engine/libemail-engine.h>
+#else
#if EVOLUTION_VERSION >= 30305
#include <libemail-engine/e-mail-folder-utils.h>
#else
@@ -53,7 +56,7 @@
#include <mail/e-mail-folder-utils.h>
#endif
#endif
-
+#endif
#include <mail/em-utils.h>
#include <shell/e-shell.h>
diff --git a/src/rss-evo-common.c b/src/rss-evo-common.c
index 2f893df..0145b8c 100644
--- a/src/rss-evo-common.c
+++ b/src/rss-evo-common.c
@@ -26,6 +26,9 @@
#if (EVOLUTION_VERSION < 30303)
#include <mail/e-mail-local.h>
#endif
+#if EVOLUTION_VERSION >= 31102
+#include <libemail-engine/libemail-engine.h>
+#else
#if EVOLUTION_VERSION >= 30305
#include <libemail-engine/e-mail-folder-utils.h>
#else
@@ -33,6 +36,7 @@
#include <mail/e-mail-folder-utils.h>
#endif
#endif
+#endif
#include <mail/e-mail-reader.h>
#include <mail/em-folder-utils.h>
diff --git a/src/rss-image.c b/src/rss-image.c
index 12ab7fc..9dfb636 100644
--- a/src/rss-image.c
+++ b/src/rss-image.c
@@ -303,7 +303,7 @@ finish_image_feedback (SoupMessage *msg, FEED_IMAGE *user_data)
finish_image_feedback (SoupSession *soup_sess, SoupMessage *msg, FEED_IMAGE *user_data)
#endif
{
- CamelStream *stream = NULL;
+ RssCacheStream *stream = NULL;
gchar *mime_type;
d("finish_image_feedback()");
stream = rss_cache_add(user_data->url);
@@ -337,9 +337,9 @@ finish_image_feedback (SoupSession *soup_sess, SoupMessage *msg, FEED_IMAGE *use
void
#if LIBSOUP_VERSION < 2003000
-finish_image (SoupMessage *msg, CamelStream *user_data)
+finish_image (SoupMessage *msg, RssCacheStream *user_data)
#else
-finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
+finish_image (SoupSession *soup_sess, SoupMessage *msg, RssCacheStream *user_data)
#endif
{
d("CODE:%d\n", msg->status_code);
@@ -362,6 +362,19 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
msg->response.length);
#else
if (msg->response_body->data) {
+#if (DATASERVER_VERSION >= 3011002)
+ GOutputStream *out;
+
+ out = g_io_stream_get_output_stream (user_data);
+ g_output_stream_write_all (out,
+ msg->response_body->data,
+ msg->response_body->length,
+ NULL,
+ NULL,
+ NULL);
+ g_output_stream_flush (out, NULL, NULL);
+ g_output_stream_close (out, NULL, NULL);
+#else
#if (DATASERVER_VERSION >= 2033001)
camel_stream_write (user_data,
msg->response_body->data,
@@ -377,6 +390,7 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
camel_stream_close(user_data, NULL);
#endif
#endif
+#endif
#if (DATASERVER_VERSION >= 2031001)
g_object_unref(user_data);
#else
@@ -384,6 +398,19 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
#endif
}
} else {
+#if (DATASERVER_VERSION >= 3011002)
+ GOutputStream *out;
+
+ out = g_io_stream_get_output_stream (user_data);
+ g_output_stream_write_all (out,
+ msg->response_body->data,
+ msg->response_body->length,
+ NULL,
+ NULL,
+ NULL);
+ g_output_stream_flush (out, NULL, NULL);
+ g_output_stream_close (out, NULL, NULL);
+#else
#if (DATASERVER_VERSION >= 2033001)
camel_stream_write (user_data, pixfilebuf, pixfilelen, NULL, NULL);
camel_stream_close (user_data, NULL, NULL);
@@ -391,6 +418,73 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
camel_stream_write(user_data, pixfilebuf, pixfilelen, NULL);
camel_stream_close(user_data, NULL);
#endif
+#endif
+
+#if (DATASERVER_VERSION >= 2031001)
+ g_object_unref(user_data);
+#else
+ camel_object_unref(user_data);
+#endif
+ }
+}
+
+static void
+#if LIBSOUP_VERSION < 2003000
+finish_image_camel (SoupMessage *msg, CamelStream *user_data)
+#else
+finish_image_camel (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
+#endif
+{
+ d("CODE:%d\n", msg->status_code);
+ // we might need to handle more error codes here
+ if (503 != msg->status_code && //handle this timedly fasion
+ 404 != msg->status_code && //NOT FOUND
+ 400 != msg->status_code && //bad request
+ 2 != msg->status_code && //STATUS_CANT_RESOLVE
+ 1 != msg->status_code && //TIMEOUT (CANCELLED) ?
+ 7 != msg->status_code && // STATUS_IO_ERROR
+#if LIBSOUP_VERSION < 2003000
+ msg->response.length) { //ZERO SIZE
+#else
+ msg->response_body->length) { //ZERO SIZE
+#endif
+#if LIBSOUP_VERSION < 2003000
+ if (msg->response.body) {
+ camel_stream_write(user_data,
+ msg->response.body,
+ msg->response.length);
+#else
+ if (msg->response_body->data) {
+#if (DATASERVER_VERSION >= 2033001)
+ camel_stream_write (user_data,
+ msg->response_body->data,
+ msg->response_body->length,
+ NULL,
+ NULL);
+ camel_stream_close(user_data, NULL, NULL);
+#else
+ camel_stream_write (user_data,
+ msg->response_body->data,
+ msg->response_body->length,
+ NULL);
+ camel_stream_close(user_data, NULL);
+#endif
+#endif
+#if (DATASERVER_VERSION >= 2031001)
+ g_object_unref(user_data);
+#else
+ camel_object_unref(user_data);
+#endif
+ }
+ } else {
+#if (DATASERVER_VERSION >= 2033001)
+ camel_stream_write (user_data, pixfilebuf, pixfilelen, NULL, NULL);
+ camel_stream_close (user_data, NULL, NULL);
+#else
+ camel_stream_write(user_data, pixfilebuf, pixfilelen, NULL);
+ camel_stream_close(user_data, NULL);
+#endif
+
#if (DATASERVER_VERSION >= 2031001)
g_object_unref(user_data);
#else
@@ -412,7 +506,7 @@ finish_create_icon (SoupSession *soup_sess, SoupMessage *msg, FEED_IMAGE *user_d
CamelStream *feed_fs = camel_stream_fs_new_with_name(
user_data->img_file,
O_RDWR|O_CREAT, 0666, NULL);
- finish_image(soup_sess, msg, feed_fs);
+ finish_image_camel(soup_sess, msg, feed_fs);
display_folder_icon(evolution_store, user_data->key);
}
g_free(user_data->key);
@@ -428,7 +522,7 @@ finish_create_icon_stream (
SoupSession *soup_sess, SoupMessage *msg, FEED_IMAGE *user_data)
#endif
{
- finish_image(soup_sess, msg, user_data->feed_fs);
+ finish_image_camel(soup_sess, msg, user_data->feed_fs);
display_folder_icon(evolution_store, user_data->key);
g_free(user_data->key);
g_free(user_data);
@@ -768,7 +862,7 @@ fetch_image_redraw(gchar *url, gchar *link, gpointer data)
1,
&err);
} else {
- CamelStream *stream = rss_cache_add(intern);
+ RssCacheStream *stream = rss_cache_add(intern);
fetch_unblocking(tmpurl,
textcb,
NULL,
diff --git a/src/rss-image.h b/src/rss-image.h
index 739c413..72e6853 100644
--- a/src/rss-image.h
+++ b/src/rss-image.h
@@ -19,6 +19,7 @@
#include <mail/e-mail-reader.h>
+#include <rss-cache.h>
typedef struct _FEED_IMAGE {
gchar *img_file;
@@ -51,10 +52,10 @@ gchar *verify_image(gchar *uri, EMailDisplay *format);
void
#if LIBSOUP_VERSION < 2003000
-finish_image (SoupMessage *msg, CamelStream *user_data);
+finish_image (SoupMessage *msg, RssCacheStream *user_data);
#else
finish_image (SoupSession *soup_sess,
- SoupMessage *msg, CamelStream *user_data);
+ SoupMessage *msg, RssCacheStream *user_data);
#endif
void
#if LIBSOUP_VERSION < 2003000
diff --git a/src/rss.c b/src/rss.c
index 1dcf192..5ebf5e1 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -67,6 +67,9 @@ int rss_verbose_debug = 0;
#include <mail/e-mail-reader-utils.h>
#endif
+#if EVOLUTION_VERSION >= 31102
+#include <libemail-engine/libemail-engine.h>
+#else
#if EVOLUTION_VERSION >= 30305
#include <libemail-engine/mail-tools.h>
#include <libemail-engine/mail-ops.h>
@@ -82,6 +85,7 @@ int rss_verbose_debug = 0;
#include <mail/e-mail-session.h>
#endif
#endif
+#endif
#if (EVOLUTION_VERSION > 30501)
#include <em-format/e-mail-formatter.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]