[evolution/express2-daemon: 5/9] Emit draft specific events and add 'Pin to Myzone' menu item.



commit 9d87ae3c7e82a3e0cf7f63208071273faf2a5863
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Thu Jun 17 09:00:20 2010 +0530

    Emit draft specific events and add 'Pin to Myzone' menu item.

 mail/e-mail-backend.c    |    2 +-
 mail/e-mail-reader.c     |   63 +++++++++++++++++++++++++++++++++++++++++++++-
 mail/em-composer-utils.c |   45 ++++++++++++++++++++++++++++++++-
 3 files changed, 107 insertions(+), 3 deletions(-)
---
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 734fefb..08be1fa 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -352,7 +352,7 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 			g_return_if_reached ();
 
 	target = em_event_target_new_folder (
-		event, folder_uri, new_messages,
+		event, folder, folder_uri, new_messages,
 		msg_uid, msg_sender, msg_subject);
 
 	folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index b5bcd15..c3e1e5c 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -46,6 +46,7 @@
 #include "mail/em-utils.h"
 #include "mail/mail-autofilter.h"
 #include "mail/mail-config.h"
+#include "mail/mail-folder-cache.h"
 #include "mail/mail-ops.h"
 #include "mail/mail-mt.h"
 #include "mail/mail-vfolder.h"
@@ -120,6 +121,55 @@ mail_reader_get_private (GObject *object)
 }
 
 static void
+action_mail_pin_myzone_cb (GtkAction *action,
+                           EMailReader *reader)
+{
+	EShellBackend *shell_backend;
+	CamelMessageInfo *info;
+	CamelFolder *folder;
+	GPtrArray *uids;
+	const gchar *address;
+	EMEvent *event = em_event_peek ();
+	EMEventTargetFolder *target;
+	char *uri;
+
+	folder = e_mail_reader_get_folder (reader);
+	shell_backend = e_mail_reader_get_shell_backend (reader);
+	uids = e_mail_reader_get_selected_uids (reader);
+
+	if (uids->len != 1)
+		goto exit;
+
+	info = camel_folder_get_message_info (folder, uids->pdata[0]);
+	if (info == NULL)
+		goto exit;
+
+	address = camel_message_info_from (info);
+	if (address == NULL || *address == '\0')
+		goto exit;
+	
+	uri = mail_folder_cache_get_folder_uri (mail_folder_cache_get_default(), folder);
+	
+	target = em_event_target_new_folder (event, folder, uri, 1,
+			uids->pdata[0], camel_message_info_from(info), camel_message_info_subject(info));
+	
+	/** @Event: mail.note
+	 *  @Title: Mail Pin to Myzone
+	 *  @Target: EMEventTargetFolder
+	 *
+	 * mail.note is emitted whenever a message wants to be pinned to Myzone.
+	 */
+	e_event_emit (
+		(EEvent *) event, "mail.note",
+		(EEventTarget *) target);
+
+	g_free (uri);
+	camel_message_info_free(info);
+exit:
+	em_utils_uids_free (uids);
+}
+
+static void
 action_mail_add_sender_cb (GtkAction *action,
                            EMailReader *reader)
 {
@@ -1145,6 +1195,13 @@ static GtkActionEntry mail_reader_entries[] = {
 	  N_("Add sender to address book"),
 	  G_CALLBACK (action_mail_add_sender_cb) },
 
+	{ "mail-pin-myzone",
+	  NULL,
+	  N_("Pin to Myzone"),
+	  NULL,
+	  N_("Pin to Myzone"),
+	  G_CALLBACK (action_mail_pin_myzone_cb) },	
+
 	{ "mail-check-for-junk",
 	  "mail-mark-junk",
 	  N_("Check for _Junk"),
@@ -1572,7 +1629,11 @@ static EPopupActionEntry mail_reader_popup_entries[] = {
 
 	{ "mail-popup-copy",
 	  NULL,
-	  "mail-copy" },
+	  "mail-copy" }, 
+
+	{ "mail-popup-pin-myzone",
+	  NULL,
+	  "mail-pin-myzone" }, 
 
 	{ "mail-popup-delete",
 	  NULL,
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 25e1761..f4d3e3f 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -38,6 +38,7 @@
 #include "mail-config.h"
 #include "mail-session.h"
 #include "mail-send-recv.h"
+#include "mail-folder-cache.h"
 
 #include "e-util/e-account-utils.h"
 #include "e-util/e-alert-dialog.h"
@@ -581,6 +582,10 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i
 {
 	struct _save_draft_info *sdi = user_data;
 	struct emcs_t *emcs;
+	EMEvent *event = em_event_peek ();
+	EMEventTargetFolder *target;
+	CamelMessageInfo *minfo;
+	char *uri;
 
 	if (!ok)
 		goto done;
@@ -595,6 +600,25 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i
 		camel_folder_set_message_flags (emcs->drafts_folder, emcs->drafts_uid,
 						CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN,
 						CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN);
+
+		minfo = camel_folder_summary_uid (emcs->drafts_folder->summary, emcs->drafts_uid);
+		uri = mail_folder_cache_get_folder_uri (mail_folder_cache_get_default(), emcs->drafts_folder);
+		target = em_event_target_new_folder (event, emcs->drafts_folder, uri, 1,
+			emcs->drafts_uid, camel_message_info_to(minfo), camel_message_info_subject(minfo));
+
+		/** @Event: draft.deleted
+		 * @Title: Draft deleted
+		 * @Target: EMEventTargetFolder
+		 *
+		 * draft.deleted is emitted whenever a draft is delted.
+		 */
+		e_event_emit (
+			(EEvent *) event, "draft.deleted",
+			(EEventTarget *) target);
+		g_free(uri);
+	
+		camel_message_info_free (minfo);
+
 		camel_object_unref (emcs->drafts_folder);
 		emcs->drafts_folder = NULL;
 		g_free (emcs->drafts_uid);
@@ -618,7 +642,26 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i
 
 	if (e_msg_composer_is_exiting (sdi->composer))
 		gtk_widget_destroy (GTK_WIDGET (sdi->composer));
-
+	
+	minfo = camel_folder_summary_uid (folder->summary, appended_uid);
+	uri = mail_folder_cache_get_folder_uri (mail_folder_cache_get_default(), folder);
+	target = em_event_target_new_folder (
+		event, folder, uri, 1,
+		appended_uid, camel_message_info_to(minfo), camel_message_info_subject(minfo));
+
+	/** @Event: draft.saved
+	 * @Title: Draft saved
+	 * @Target: EMEventTargetFolder
+	 *
+	 * draft.saved is emitted whenever a draft is saved.
+	 */
+	e_event_emit (
+		(EEvent *) event, "draft.saved",
+		(EEventTarget *) target);
+	
+	g_free(uri);
+	camel_message_info_free (minfo);
+	
  done:
 	g_object_unref (sdi->composer);
 	if (sdi->emcs)



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