[evolution/email-factory-3-4: 4/38] Add operate on folder mail ops.



commit 8e4cf280cad6104cd7360a884c340ab4c2a9884f
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Mon Oct 31 11:40:33 2011 +0530

    Add operate on folder mail ops.

 libemail-engine/mail-ops.c |   68 ++++++++++++++++++++++++++++++++++++++++++++
 libemail-engine/mail-ops.h |    5 +++
 2 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index a12a63a..766c70e 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -1678,3 +1678,71 @@ mail_disconnect_store (CamelStore *store)
 	return id;
 }
 
+/* Multi Operation holder */
+
+
+struct _multi_op_folder_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	gboolean ret;
+	gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error);	
+	void (*done) (gboolean success, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+multi_op_folder_desc (struct _multi_op_folder_msg *m)
+{
+	gchar *res;
+
+	res = g_strdup_printf(_("Operating on Folder '%s'"), camel_folder_get_full_name (m->folder));
+
+	return res;
+}
+
+static void
+multi_op_folder_exec (struct _multi_op_folder_msg *m)
+{
+	m->ret = m->do_op (m->folder, m->data, &m->base.error);
+}
+
+static void
+multi_op_folder_done (struct _multi_op_folder_msg *m)
+{
+	if (m->done)
+		m->done(m->ret, m->data, m->base.error);
+}
+
+static void
+multi_op_folder_free (struct _multi_op_folder_msg *m)
+{
+	g_object_unref (m->folder);
+}
+
+static MailMsgInfo multi_op_folder = {
+	sizeof (struct _multi_op_folder_msg),
+	(MailMsgDescFunc) multi_op_folder_desc,
+	(MailMsgExecFunc) multi_op_folder_exec,
+	(MailMsgDoneFunc) multi_op_folder_done,
+	(MailMsgFreeFunc) multi_op_folder_free
+};
+
+void
+mail_operate_on_folder(CamelFolder *folder, 
+		       gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error),
+		       void (*done) (gboolean ret, gpointer data, GError *error), 
+		       gpointer data)
+{
+	struct _multi_op_folder_msg *m;
+
+	m = mail_msg_new(&multi_op_folder);
+	m->folder= folder;
+	g_object_ref (folder);
+	m->data = data;
+	m->do_op = do_op;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
+
diff --git a/libemail-engine/mail-ops.h b/libemail-engine/mail-ops.h
index 63d8528..958b110 100644
--- a/libemail-engine/mail-ops.h
+++ b/libemail-engine/mail-ops.h
@@ -97,6 +97,11 @@ void mail_execute_shell_command (CamelFilterDriver *driver, gint argc, gchar **a
 
 gint mail_disconnect_store (CamelStore *store);
 
+void mail_operate_on_folder			(CamelFolder *folder, 
+		       	    			gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error),
+		            			void (*done) (gboolean ret, gpointer data, GError *error), 
+		            			gpointer data);
+
 G_END_DECLS
 
 #endif /* MAIL_OPS_H */



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