[evolution-rss] adapt to camel sync changes



commit 4a6e10c6de75b2117db1f422f5029aca951fcd8e
Author: Lucian Langa <lucilanga gnome org>
Date:   Thu Sep 30 22:15:58 2010 +0300

    adapt to camel sync changes

 src/dbus.c               |    8 ++-
 src/notification.c       |    7 ++
 src/parser.c             |    5 ++
 src/rss-config-factory.c |   29 +++++++++-
 src/rss-image.c          |   24 +++++++-
 src/rss.c                |  141 +++++++++++++++++++++++++++++++++++++++++++--
 src/rss.h                |    4 +
 7 files changed, 205 insertions(+), 13 deletions(-)
---
diff --git a/src/dbus.c b/src/dbus.c
index c51675c..e3def2b 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -129,12 +129,16 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *user_da
 				if (rf->treeview)
 					store_redraw(GTK_TREE_VIEW(rf->treeview));
 				save_gconf_feed();
+#if (DATASERVER_VERSION >= 2033001)
+				camel_operation_pop_message (NULL);
+#else
 				camel_operation_end(NULL);
+#endif
 			}
 
 
-    //  dbus_message_unref(reply);
- //     return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
+//  dbus_message_unref(reply);
+//     return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
 
 			//dbus_free (s);
 		} else {
diff --git a/src/notification.c b/src/notification.c
index 9a2a543..19f96f8 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -258,8 +258,15 @@ taskbar_op_new(gchar *message)
 	shell = e_shell_get_default ();
 	shell_backend = e_shell_get_backend_by_name (shell, "mail");
 
+#if EVOLUTION_VERSION >= 23300
+	activity = e_activity_new ();
+	e_activity_set_primary_text (activity, message);
+	/* does this even makes sense */
+	e_activity_set_cancellable (activity, NULL);
+#else
 	activity = e_activity_new (message);
 	e_activity_set_allow_cancel (activity, TRUE);
+#endif
 	e_activity_set_percent (activity, 0.0);
 	e_shell_backend_add_activity (shell_backend, activity);
 
diff --git a/src/parser.c b/src/parser.c
index 76d87f6..e6a2899 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1092,7 +1092,12 @@ void
 refresh_mail_folder(CamelFolder *mail_folder)
 {
 	mail_refresh_folder(mail_folder, NULL, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+		camel_folder_synchronize (mail_folder, FALSE, G_PRIORITY_DEFAULT,
+			NULL, NULL, NULL);
+#else
 	camel_folder_sync(mail_folder, FALSE, NULL);
+#endif
 	camel_folder_thaw(mail_folder);
 }
 
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 6848cda..fd8df60 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -1015,7 +1015,13 @@ rss_delete_rec (CamelStore *store, CamelFolderInfo *fi, GError **error)
 
 		d("deleting folder '%s'\n", fi->full_name);
 
-		if (!(folder = camel_store_get_folder (store, fi->full_name, 0, error)))
+#if (DATASERVER_VERSION >= 2033001)
+		if (!(folder = camel_store_get_folder_sync (store, fi->full_name,
+			0, NULL, error)))
+#else
+		if (!(folder = camel_store_get_folder (store, fi->full_name,
+			0, error)))
+#endif
 			return;
 
 			uids = camel_folder_get_uids (folder);
@@ -1028,12 +1034,20 @@ rss_delete_rec (CamelStore *store, CamelFolderInfo *fi, GError **error)
 
 			camel_folder_free_uids (folder, uids);
 
-			camel_folder_sync (folder, TRUE, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+			camel_folder_synchronize_sync (folder, TRUE, NULL, NULL);
+#else
+			camel_folder_synch (folder, TRUE, NULL);
+#endif
 			camel_folder_thaw (folder);
 
 		d("do camel_store_delete_folder()\n");
 
+#if (DATASERVER_VERSION >= 2033001)
+		camel_store_delete_folder_sync (store, fi->full_name, NULL, error);
+#else
 		camel_store_delete_folder (store, fi->full_name, error);
+#endif
 		if (error != NULL)
 			return;
 
@@ -1052,10 +1066,17 @@ rss_delete_folders (CamelStore *store,
 	CamelFolderInfo *fi = NULL;
 
 	d("camel_store_get_folder_info() %s\n", full_name);
+#if (DATASERVER_VERSION >= 2033001)
+	fi = camel_store_get_folder_info_sync (
+		store,
+		full_name,
+		flags, NULL, error);
+#else
 	fi = camel_store_get_folder_info (
 		store,
 		full_name,
 		flags, error);
+#endif
 	if (!fi || error != NULL)
 		return;
 
@@ -1546,7 +1567,11 @@ process_dialog_edit(add_feed *feed, gchar *url, gchar *feed_name)
 				gchar *b = g_build_path(
 						G_DIR_SEPARATOR_S,
 						dir, feed->feed_name, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+				camel_store_rename_folder_sync (store, a, b, NULL, &error);
+#else
 				camel_store_rename_folder (store, a, b, &error);
+#endif
 				if (error != NULL) {
 					e_alert_run_dialog_for_args(
 						GTK_WINDOW(rf->preferences),
diff --git a/src/rss-image.c b/src/rss-image.c
index 710a8f9..78480e4 100644
--- a/src/rss-image.c
+++ b/src/rss-image.c
@@ -317,12 +317,21 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *user_data)
 				msg->response.length);
 #else
 		if (msg->response_body->data) {
-			camel_stream_write(user_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);
-#endif
 			camel_stream_close(user_data, NULL);
+#endif
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 			g_object_unref(user_data);
 #else
@@ -330,8 +339,13 @@ finish_image (SoupSession *soup_sess, SoupMessage *msg, CamelStream *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
@@ -407,9 +421,15 @@ display_folder_icon(GtkTreeStore *tree_store, gchar *key)
 					"%s" G_DIR_SEPARATOR_S "%s",
 					get_main_folder(),
 					lookup_feed_folder(name));
+#if (DATASERVER_VERSION >= 2033001)
+		rss_folder = camel_store_get_folder_sync (
+					store,
+					full_name, 0, NULL, NULL);
+#else
 		rss_folder = camel_store_get_folder (
 					store,
 					full_name, 0, NULL);
+#endif
 		if (!rss_folder) {
 			g_free(full_name);
 			result = FALSE;
diff --git a/src/rss.c b/src/rss.c
index 7b4956b..5c9b3b3 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -492,7 +492,11 @@ browser_stream_write(CamelStream *stream, gchar *base)
 	GString *str = g_string_new(NULL);
 	gchar *line;
 	CamelStream *in = camel_stream_buffer_new(stream, CAMEL_STREAM_BUFFER_READ);
+#if (DATASERVER_VERSION >= 2033001)
+	while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)in, NULL,  NULL))) {
+#else
 	while ((line = camel_stream_buffer_read_line((CamelStreamBuffer *)in, NULL))) {
+#endif
 		gchar *tmp = line;
 		g_string_append(str, line);
 		g_free(tmp);
@@ -916,7 +920,11 @@ rss_select_folder(gchar *folder_name)
 	shell_sidebar  = e_shell_view_get_shell_sidebar(rss_shell_view);
 	g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
 	store = rss_component_peek_local_store();
+#if (DATASERVER_VERSION >= 2033001)
+	fold = camel_store_get_folder_sync (store, folder_name, 0, NULL, NULL);
+#else
 	fold = camel_store_get_folder (store, folder_name, 0, NULL);
+#endif
 	if (!fold) return;
 	uri = mail_tools_folder_to_url (fold);
 	em_folder_tree_set_selected(folder_tree, uri, 0);
@@ -1107,7 +1115,11 @@ rss_browser_update_content (
 						d("cache read\n");
 						fi->create = 0;
 						browser_stream_write(stream, po->website);
-						camel_stream_close(stream, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+						camel_stream_close (stream, NULL, NULL);
+#else
+						camel_stream_close (stream, NULL);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 						g_object_unref(stream);
 #else
@@ -2296,10 +2308,17 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t)	//camelmimepart
 		mcontent = camel_medium_get_content_object(
 				CAMEL_MEDIUM(t->part));
 #endif
-		camel_data_wrapper_write_to_stream(
+#if DATASERVER_VERSION >= 233001
+		camel_data_wrapper_write_to_stream_sync (
+			mcontent,
+			(CamelStream *)stream,
+			NULL, NULL);
+#else
+		camel_data_wrapper_write_to_stream (
 			mcontent,
 			(CamelStream *)stream,
 			NULL);
+#endif
 		g_byte_array_append (buffer, (unsigned char *)"", 1);
 //#ifdef EVOLUTION_2_12	//aparently this ("?" char parsing) is fixed in 2.12
 //		//then again this does not work in evo > 2.12 perhaps is gtkhtml related
@@ -2495,15 +2514,25 @@ render_body:	if (category)
 	}
 
 	//this is required for proper charset rendering when html
-	camel_data_wrapper_construct_from_stream(dw, fstream, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+	camel_data_wrapper_construct_from_stream_sync (dw, fstream, NULL, NULL);
+#else
+	camel_data_wrapper_construct_from_stream (dw, fstream, NULL);
+#endif
 #if EVOLUTION_VERSION >= 23100
 	camel_medium_set_content((CamelMedium *)part, dw);
 #else
 	camel_medium_set_content_object((CamelMedium *)part, dw);
 #endif
+#if EVOLUTION_VERSION >= 23300
+	em_format_format_text((EMFormat *)t->format,
+				(CamelStream *)t->stream,
+				(CamelDataWrapper *)part, NULL);
+#else
 	em_format_format_text((EMFormat *)t->format,
 				(CamelStream *)t->stream,
 				(CamelDataWrapper *)part);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 	g_object_unref(dw);
 	g_object_unref(part);
@@ -3644,7 +3673,11 @@ finish_website (SoupSession *soup_sess, SoupMessage *msg, gpointer user_data)
 		g_free(tmsg);
 		if (ub->create) {
 			//stream remove
-			camel_stream_close(ub->stream, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+			camel_stream_close (ub->stream, NULL, NULL);
+#else
+			camel_stream_close (ub->stream, NULL);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 			g_object_unref(ub->stream);
 #else
@@ -3653,8 +3686,13 @@ finish_website (SoupSession *soup_sess, SoupMessage *msg, gpointer user_data)
 		}
 	} else {
 		if (ub->create) {
+#if (DATASERVER_VERSION >= 2033001)
+			camel_stream_write(ub->stream, response->str, strlen(response->str), NULL, NULL);
+			camel_stream_close(ub->stream, NULL, NULL);
+#else
 			camel_stream_write(ub->stream, response->str, strlen(response->str), NULL);
 			camel_stream_close(ub->stream, NULL);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 			g_object_unref(ub->stream);
 #else
@@ -4083,7 +4121,11 @@ check_feed_folder(gchar *folder_name)
 	d("main_folder:%s\n", main_folder);
 	d("real_folder:%s\n", real_folder);
 	d("real_name:%s\n", real_name);
+#if (DATASERVER_VERSION >= 2033001)
+	mail_folder = camel_store_get_folder_sync (store, real_name, 0, NULL, NULL);
+#else
 	mail_folder = camel_store_get_folder (store, real_name, 0, NULL);
+#endif
 	base_folder = main_folder;
 	if (mail_folder == NULL) {
 		sanitize_path_separator(real_folder);
@@ -4093,11 +4135,20 @@ check_feed_folder(gchar *folder_name)
 				if (path[i] == NULL)
 					break;
 				if (path[i] && strlen(path[i])) {
+#if (DATASERVER_VERSION >= 2033001)
+					camel_store_create_folder_sync (
+						store,
+						base_folder,
+						path[i],
+						NULL,
+						NULL);
+#else
 					camel_store_create_folder (
 						store,
 						base_folder,
 						path[i],
 						NULL);
+#endif
 					base_folder = g_strconcat(
 							base_folder,
 							"/",
@@ -4107,10 +4158,18 @@ check_feed_folder(gchar *folder_name)
 			} while (NULL != path[++i]);
 			g_strfreev(path);
 		}
+#if (DATASERVER_VERSION >= 2033001)
+		mail_folder = camel_store_get_folder_sync (store,
+				real_name,
+				0,
+				NULL,
+				NULL);
+#else
 		mail_folder = camel_store_get_folder (store,
 				real_name,
 				0,
 				NULL);
+#endif
 	}
 	g_free(real_name);
 	return mail_folder;
@@ -4593,6 +4652,23 @@ check_folders(void)
 	CamelStore *store = rss_component_peek_local_store();
 	CamelFolder *mail_folder, *old_folder;
 
+#if (DATASERVER_VERSION >= 2033001)
+	/*FIXME block*/
+	mail_folder = camel_store_get_folder_sync (
+			store, lookup_main_folder(), 0, NULL, NULL);
+	old_folder = camel_store_get_folder_sync (
+			store, OLD_FEEDS_FOLDER, 0, NULL, NULL);
+	if (old_folder) {
+		camel_store_rename_folder_sync(
+			store, OLD_FEEDS_FOLDER,
+			lookup_main_folder(), NULL, NULL);
+	} else if (mail_folder == NULL) {
+		camel_store_create_folder_sync (
+			store, NULL,
+			lookup_main_folder(), NULL, NULL);
+		return;
+	}
+#else
 	mail_folder = camel_store_get_folder (
 			store, lookup_main_folder(), 0, NULL);
 	old_folder = camel_store_get_folder (
@@ -4607,6 +4683,7 @@ check_folders(void)
 			lookup_main_folder(), NULL);
 		return;
 	}
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 	g_object_unref (mail_folder);
 #else
@@ -4718,6 +4795,7 @@ my_op_status(CamelOperation *op, const char *what, int pc, void *data)
 	g_print("OP STATUS\n");
 	g_print("CANCEL!!!!\n");
 
+#if (DATASERVER_VERSION < 2033001)
 	switch (pc) {
 	case CAMEL_OPERATION_START:
 		pc = 0;
@@ -4726,6 +4804,7 @@ my_op_status(CamelOperation *op, const char *what, int pc, void *data)
 		pc = 100;
 		break;
 	}
+#endif
 
 	set_send_status(info, what, pc);
 }
@@ -4784,7 +4863,13 @@ org_gnome_evolution_rss(void *ep, EMPopupTargetSelect *t)
 //
 	info->uri = g_strdup("feed"); //g_stddup
 
+#if (DATASERVER_VERSION >= 2033001)
+	info->cancel = camel_operation_new ();
+	g_signal_connect(info->cancel, "status",
+		G_CALLBACK(my_op_status), info);
+#else
 	info->cancel = camel_operation_new (my_op_status, info);
+#endif
 	info->state = SEND_ACTIVE;
 //        info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info);
 //
@@ -5269,7 +5354,12 @@ create_mail(create_feed *CF)
 	stream = camel_stream_mem_new ();
 	// w/out an format argument this throws and seg fault
 	camel_stream_printf (stream, "%s", CF->body);
+#if (DATASERVER_VERSION >= 2033001)
+	/*FIXME may block */
+	camel_data_wrapper_construct_from_stream_sync (rtext, stream, NULL, NULL);
+#else
 	camel_data_wrapper_construct_from_stream (rtext, stream, NULL);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 	g_object_unref (stream);
 #else
@@ -5360,7 +5450,13 @@ create_mail(create_feed *CF)
 		camel_medium_set_content_object(CAMEL_MEDIUM(new), CAMEL_DATA_WRAPPER(rtext));
 #endif
 
-	camel_folder_append_message(mail_folder, new, info, &appended_uid, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+	camel_folder_append_message_sync (mail_folder, new, info,
+			&appended_uid, NULL, NULL);
+#else
+	camel_folder_append_message (mail_folder, new, info,
+			&appended_uid, NULL);
+#endif
 
 	/* no point in filtering mails at import time as it just
 	 * wastes time, user can setup his own afterwards
@@ -5427,7 +5523,13 @@ file_to_message(const char *filename)
 	if (!file)
 		return NULL;
 
-	camel_data_wrapper_construct_from_stream(content, (CamelStream *)file, NULL);
+#if (DATASERVER_VERSION >= 2033001)
+	camel_data_wrapper_construct_from_stream_sync (content,
+		(CamelStream *)file, NULL, NULL);
+#else
+	camel_data_wrapper_construct_from_stream(content,
+		(CamelStream *)file, NULL);
+#endif
 #if (DATASERVER_VERSION >= 2031001)
 	g_object_unref((CamelObject *)file);
 #else
@@ -5851,7 +5953,11 @@ get_feed_age(RDF *r, gpointer name)
 			"%s" G_DIR_SEPARATOR_S "%s",
 			lookup_main_folder(),
 			real_folder);
+#if (DATASERVER_VERSION >= 2033001)
+	if (!(folder = camel_store_get_folder_sync (store, real_name, 0, NULL, NULL)))
+#else
 	if (!(folder = camel_store_get_folder (store, real_name, 0, NULL)))
+#endif
 		goto fail;
 	time (&now);
 
@@ -5868,7 +5974,13 @@ get_feed_age(RDF *r, gpointer name)
 		for (i = 0; i < uids->len; i++) {
 			el = NULL;
 			match = FALSE;
-			message = camel_folder_get_message(folder, uids->pdata[i], NULL);
+#if (DATASERVER_VERSION >= 2033001)
+			message = camel_folder_get_message_sync (folder,
+				uids->pdata[i], NULL, NULL);
+#else
+			message = camel_folder_get_message (folder,
+				uids->pdata[i], NULL);
+#endif
 			if (message == NULL)
 				break;
 			feedid  = (gchar *)camel_medium_get_header (
@@ -5914,7 +6026,12 @@ get_feed_age(RDF *r, gpointer name)
 				gtk_main_iteration ();
 		}
 		camel_folder_free_uids (folder, uids);
+#if (DATASERVER_VERSION >= 2033001)
+		camel_folder_synchronize (folder, FALSE, G_PRIORITY_DEFAULT,
+			NULL, NULL, NULL);
+#else
 		camel_folder_sync (folder, FALSE, NULL);
+#endif
 		camel_folder_thaw(folder);
 	}
 	if (del_feed == 2) {
@@ -5944,7 +6061,12 @@ get_feed_age(RDF *r, gpointer name)
 				gtk_main_iteration ();
 		}
 		camel_folder_free_uids (folder, uids);
+#if (DATASERVER_VERSION >= 2033001)
+		camel_folder_synchronize (folder, FALSE, G_PRIORITY_DEFAULT,
+			NULL, NULL, NULL);
+#else
 		camel_folder_sync (folder, FALSE, NULL);
+#endif
 		camel_folder_thaw(folder);
 		//need to find a better expunde method
 		//camel_folder_expunge (folder, NULL);
@@ -5960,7 +6082,12 @@ get_feed_age(RDF *r, gpointer name)
 			i++;
 		}
 		//too heavy to sync with expunge
+#if (DATASERVER_VERSION >= 2033001)
+		camel_folder_synchronize (folder, FALSE, G_PRIORITY_DEFAULT,
+			NULL, NULL, NULL);
+#else
 		camel_folder_sync (folder, FALSE, NULL);
+#endif
 		camel_folder_thaw(folder);
 		//need to find a better expunde method
 		//camel_folder_expunge (folder, NULL);
diff --git a/src/rss.h b/src/rss.h
index 6e82bc1..5228d45 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -277,7 +277,11 @@ typedef enum {
 
 struct _send_info {
 	send_info_t type;               /* 0 = fetch, 1 = send */
+#if (DATASERVER_VERSION >= 2033001)
+	GCancellable *cancel;
+#else
 	CamelOperation *cancel;
+#endif
 	char *uri;
 	int keep;
 	send_state_t state;



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