[Evolution-hackers] Re: [evolution-patches] Patch for the receipt bounty (#127534)



On Mon, 4 Apr 2005, Not Zed wrote:

Could you please address these issues, then send the final patch to the
list?  I don't see any reason why it shouldn't go in after that
(although, i will actually have to test that it works first ;-).

OK, here it is.

--
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
I know KUNG FU, KARATE and 47 other dangerous words.
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.501
diff -u -u -r1.501 e-msg-composer.c
--- composer/e-msg-composer.c	15 Mar 2005 21:04:24 -0000	1.501
+++ composer/e-msg-composer.c	5 Apr 2005 19:23:15 -0000
@@ -463,6 +463,15 @@
 					 composer->extra_hdr_names->pdata[i],
 					 composer->extra_hdr_values->pdata[i]);
 	}
+
+	/* Message Disposition Notification */
+	if (composer->request_receipt) {
+		char *mdn_address = hdrs->account->id->reply_to;
+		if (!mdn_address || !*mdn_address)
+			mdn_address = hdrs->account->id->address;
+		
+		camel_medium_add_header (CAMEL_MEDIUM (new), "Disposition-Notification-To", mdn_address);
+	}
 	
 	if (composer->mime_body) {
 		plain_encoding = CAMEL_TRANSFER_ENCODING_7BIT;
@@ -1928,6 +1937,19 @@
 }
 
 static void
+menu_insert_receipt_cb (BonoboUIComponent           *component,
+			const char                  *path,
+			Bonobo_UIComponent_EventType type,
+			const char                  *state,
+			gpointer                     user_data)
+{
+	if (type != Bonobo_UIComponent_STATE_CHANGED)
+		return;
+	
+	e_msg_composer_set_request_receipt (E_MSG_COMPOSER (user_data), atoi (state));
+}
+
+static void
 menu_changed_charset_cb (BonoboUIComponent           *component,
 			 const char                  *path,
 			 Bonobo_UIComponent_EventType type,
@@ -2228,6 +2250,14 @@
 	bonobo_ui_component_add_listener (
 		composer->uic, "ViewBCC",
 		menu_view_bcc_cb, composer);
+
+	/* Insert/Request Receipt */
+	bonobo_ui_component_set_prop (
+		composer->uic, "/commands/RequestReceipt",
+		"state", composer->request_receipt ? "1" : "0", NULL);
+	bonobo_ui_component_add_listener (
+		composer->uic, "RequestReceipt",
+		menu_insert_receipt_cb, composer);
 	
 	/* Security -> PGP Sign */
 	bonobo_ui_component_set_prop (
@@ -5406,6 +5437,47 @@
 	e_msg_composer_hdrs_set_visible (E_MSG_COMPOSER_HDRS (composer->hdrs),
 					 e_msg_composer_get_visible_flags (composer));
 }
+
+
+
+/**
+ * e_msg_composer_get_request_receipt
+ * @composer: A message composer widget
+ * 
+ * Get the status of the "Request receipt" flag.
+ * 
+ * Return value: The status of the "Request receipt" flag.
+ **/
+gboolean
+e_msg_composer_get_request_receipt (EMsgComposer *composer)
+{
+	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+	
+	return composer->request_receipt;
+}
+
+
+/**
+ * e_msg_composer_set_request_receipt:
+ * @composer: A message composer widget
+ * @state: whether to request or not a receipt
+ *
+ * If set, a message delivery notification request will be sent to the recipient
+ */
+void
+e_msg_composer_set_request_receipt (EMsgComposer *composer, gboolean request_receipt)
+{
+	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+	
+	if ((composer->request_receipt && request_receipt) ||
+	    (!composer->request_receipt && !request_receipt))
+		return;
+	
+	composer->request_receipt = request_receipt;
+	bonobo_ui_component_set_prop (composer->uic, "/commands/RequestReceipt",
+				      "state", composer->request_receipt ? "1" : "0", NULL);
+}
+
 
 
 EDestination **
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.91
diff -u -u -r1.91 e-msg-composer.h
--- composer/e-msg-composer.h	27 Jul 2004 16:52:17 -0000	1.91
+++ composer/e-msg-composer.h	5 Apr 2005 19:23:16 -0000
@@ -101,6 +101,7 @@
 	guint32 view_bcc               : 1;
 	guint32 view_cc                : 1;
 	guint32 view_subject           : 1;
+	guint32 request_receipt        : 1;
 	guint32 has_changed            : 1;
 	guint32 autosaved              : 1;
 	
@@ -191,6 +192,10 @@
 gboolean                 e_msg_composer_get_view_bcc                     (EMsgComposer      *composer);
 void                     e_msg_composer_set_view_bcc                     (EMsgComposer      *composer,
 									  gboolean           view_bcc);
+
+gboolean                 e_msg_composer_get_request_receipt              (EMsgComposer *composer);
+void                     e_msg_composer_set_request_receipt              (EMsgComposer *composer,
+									  gboolean      request_receipt);
 
 EDestination           **e_msg_composer_get_recipients                   (EMsgComposer *composer);
 EDestination           **e_msg_composer_get_to                           (EMsgComposer *composer);
Index: e-util/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.530
diff -u -u -r1.530 ChangeLog
--- e-util/ChangeLog	16 Mar 2005 06:50:11 -0000	1.530
+++ e-util/ChangeLog	5 Apr 2005 19:23:18 -0000
@@ -365,6 +365,10 @@
 	* e-icon-factory.c (icon_foreach_remove): We must return TRUE here
 	so that things actually get removed from the list
 
+2004-08-07  ERDI Gergo  <cactus cactus rulez org>
+
+	* e-account.h: Added new receipt_policy field to services
+
 2004-08-05  Rodrigo Moya <rodrigo novell com>
 
 	* e-icon-factory.c (e_icon_factory_init): connect to "changed"
Index: e-util/e-account.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account.c,v
retrieving revision 1.14
diff -u -u -r1.14 e-account.c
--- e-util/e-account.c	4 Mar 2005 03:07:18 -0000	1.14
+++ e-util/e-account.c	5 Apr 2005 19:23:22 -0000
@@ -265,6 +265,56 @@
 	return res;
 }
 
+static EAccountReceiptPolicy
+str_to_receipt_policy (const char *str)
+{
+	if (!strcmp (str, "ask"))
+		return E_ACCOUNT_RECEIPT_ASK;
+	if (!strcmp (str, "always"))
+		return E_ACCOUNT_RECEIPT_ALWAYS;
+
+	return E_ACCOUNT_RECEIPT_NEVER;
+}
+
+static char*
+receipt_policy_to_str (EAccountReceiptPolicy val)
+{
+	char *ret = 0;
+	
+	switch (val) {
+	case E_ACCOUNT_RECEIPT_NEVER:
+		ret = "never";
+		break;
+	case E_ACCOUNT_RECEIPT_ASK:
+		ret = "ask";
+		break;
+	case E_ACCOUNT_RECEIPT_ALWAYS:
+		ret = "always";
+		break;
+	}
+
+	return ret;
+}
+
+static gboolean
+xml_set_receipt_policy (xmlNodePtr node, const char *name, EAccountReceiptPolicy *val)
+{
+	EAccountReceiptPolicy new_val;
+	char *buf;
+
+	if ((buf = xmlGetProp (node, name))) {
+		new_val = str_to_receipt_policy (buf);
+		xmlFree (buf);
+
+		if (new_val != *val) {
+			*val = new_val;
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
 static gboolean
 xml_set_content (xmlNodePtr node, char **val)
 {
@@ -387,7 +437,7 @@
 	
 	changed |= xml_set_prop (node, "name", &account->name);
 	changed |= xml_set_bool (node, "enabled", &account->enabled);
-
+	
 	for (node = node->children; node; node = node->next) {
 		if (!strcmp (node->name, "identity")) {
 			changed |= xml_set_identity (node, account->id);
@@ -405,6 +455,8 @@
 		} else if (!strcmp (node->name, "auto-bcc")) {
 			changed |= xml_set_bool (node, "always", &account->always_bcc);
 			changed |= xml_set_content (node, &account->bcc_addrs);
+		} else if (!strcmp (node->name, "receipt-policy")) {
+			changed |= xml_set_receipt_policy (node, "policy", &account->receipt_policy);
 		} else if (!strcmp (node->name, "pgp")) {
 			changed |= xml_set_bool (node, "encrypt-to-self", &account->pgp_encrypt_to_self);
 			changed |= xml_set_bool (node, "always-trust", &account->pgp_always_trust);
@@ -494,6 +546,8 @@
 	g_free (dest->bcc_addrs);
 	dest->bcc_addrs = g_strdup (src->bcc_addrs);
 	
+	dest->receipt_policy = src->receipt_policy;
+	
 	g_free (dest->pgp_key);
 	dest->pgp_key = g_strdup (src->pgp_key);
 	dest->pgp_encrypt_to_self = src->pgp_encrypt_to_self;
@@ -578,6 +632,9 @@
 	if (account->bcc_addrs)
 		xmlNewTextChild (node, NULL, "recipients", account->bcc_addrs);
 
+	node = xmlNewChild (root, NULL, "receipt-policy", NULL);
+	xmlSetProp (node, "policy", receipt_policy_to_str (account->receipt_policy));
+	
 	node = xmlNewChild (root, NULL, "pgp", NULL);
 	xmlSetProp (node, "encrypt-to-self", account->pgp_encrypt_to_self ? "true" : "false");
 	xmlSetProp (node, "always-trust", account->pgp_always_trust ? "true" : "false");
@@ -708,6 +765,8 @@
 	{ /* E_ACCOUNT_BCC_ALWAYS */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, always_bcc) },
 	{ /* E_ACCOUNT_BCC_ADDRS */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, bcc_addrs) },
 
+	{ /* E_ACCOUNT_RECEIPT_POLICY */ 0, TYPE_INT, G_STRUCT_OFFSET(EAccount, receipt_policy) },
+	
 	{ /* E_ACCOUNT_PGP_KEY */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, pgp_key) },
 	{ /* E_ACCOUNT_PGP_ENCRYPT_TO_SELF */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_encrypt_to_self) },
 	{ /* E_ACCOUNT_PGP_ALWAYS_SIGN */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_always_sign) },
Index: e-util/e-account.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account.h,v
retrieving revision 1.8
diff -u -u -r1.8 e-account.h
--- e-util/e-account.h	20 Sep 2004 05:59:54 -0000	1.8
+++ e-util/e-account.h	5 Apr 2005 19:23:22 -0000
@@ -55,6 +55,8 @@
 	E_ACCOUNT_BCC_ALWAYS,
 	E_ACCOUNT_BCC_ADDRS,
 
+	E_ACCOUNT_RECEIPT_POLICY,
+	
 	E_ACCOUNT_PGP_KEY,
 	E_ACCOUNT_PGP_ENCRYPT_TO_SELF,
 	E_ACCOUNT_PGP_ALWAYS_SIGN,
@@ -82,6 +84,12 @@
 	char *sig_uid;
 } EAccountIdentity;
 
+typedef enum _EAccountReceiptPolicy {
+	E_ACCOUNT_RECEIPT_NEVER,
+	E_ACCOUNT_RECEIPT_ASK,
+	E_ACCOUNT_RECEIPT_ALWAYS
+} EAccountReceiptPolicy;
+
 typedef struct _EAccountService {
 	char *url;
 	gboolean keep_on_server;
@@ -108,6 +116,8 @@
 	char *cc_addrs;
 	gboolean always_bcc;
 	char *bcc_addrs;
+
+	EAccountReceiptPolicy receipt_policy;
 
 	char *pgp_key;
 	gboolean pgp_encrypt_to_self;
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3615
diff -u -u -r1.3615 ChangeLog
--- mail/ChangeLog	4 Apr 2005 20:53:21 -0000	1.3615
+++ mail/ChangeLog	5 Apr 2005 19:23:35 -0000
@@ -1,3 +1,16 @@
+2005-03-31  ERDI Gergo  <cactus cactus rulez org>
+
+	* mail-errors.xml: Added new dialog for receipt requests
+
+	* em-composer-utils.c (em_utils_guess_account): Made guess_account
+	public, to be callable from em-folder-view
+	(em_utils_send_receipt): New function to send an RFC
+	2298-compliant message delivery notification
+
 2005-04-04  Rodney Dawes  <dobey novell com>
 
 	* em-folder-view.c (emfv_popup_items): Add Mark as Read/Unread back
Index: mail/em-account-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-account-editor.c,v
retrieving revision 1.24
diff -u -u -r1.24 em-account-editor.c
--- mail/em-account-editor.c	2 Mar 2005 05:23:45 -0000	1.24
+++ mail/em-account-editor.c	5 Apr 2005 19:23:39 -0000
@@ -724,6 +724,65 @@
 }
 
 static void
+emae_receipt_policy_changed(GtkComboBox *dropdown, EMAccountEditor *emae)
+{
+	int id = gtk_combo_box_get_active(dropdown);
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	EAccountReceiptPolicy policy;
+
+	if (id != -1) {
+		model = gtk_combo_box_get_model(dropdown);
+		if (gtk_tree_model_iter_nth_child(model, &iter, NULL, id)) {
+			gtk_tree_model_get(model, &iter, 1, &policy, -1);
+			e_account_set_int (emae->account, E_ACCOUNT_RECEIPT_POLICY, policy);
+		}
+	}
+
+}
+
+static GtkWidget *
+emae_setup_receipt_policy (EMAccountEditor *emae, GladeXML *xml)
+{
+	GtkComboBox *dropdown = (GtkComboBox *)glade_xml_get_widget(xml, "receipt_policy_dropdown");
+	GtkListStore *store;
+	int i = 0, active = 0;
+	GtkTreeIter iter;
+	EAccountReceiptPolicy current = emae->account->receipt_policy;
+
+	static struct {
+		EAccountReceiptPolicy policy;
+		char *label;			
+	} receipt_policies[] = {
+		{ E_ACCOUNT_RECEIPT_NEVER,  N_("Never") },
+		{ E_ACCOUNT_RECEIPT_ALWAYS, N_("Always") },
+		{ E_ACCOUNT_RECEIPT_ASK,    N_("Ask for each message") }
+	};
+
+	gtk_widget_show((GtkWidget *)dropdown);
+
+	store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
+
+	for (i = 0; i < 3; ++i) {
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter,
+				    0, _(receipt_policies[i].label),
+				    1, receipt_policies[i].policy,
+				    -1);
+		if (current == receipt_policies[i].policy)
+			active = i;		
+	}
+	
+	gtk_combo_box_set_model(dropdown, (GtkTreeModel *)store);
+	gtk_combo_box_set_active(dropdown, active);
+
+	g_signal_connect(dropdown, "changed", G_CALLBACK(emae_receipt_policy_changed), emae);
+	gtk_widget_set_sensitive((GtkWidget *)dropdown, e_account_writable(emae->account, E_ACCOUNT_RECEIPT_POLICY));
+
+	return (GtkWidget *)dropdown;
+}
+
+static void
 emae_account_entry_changed(GtkEntry *entry, EMAccountEditor *emae)
 {
 	int item = GPOINTER_TO_INT(g_object_get_data((GObject *)entry, "account-item"));
@@ -2081,6 +2140,9 @@
 	gtk_widget_set_sensitive((GtkWidget *)gui->restore_folders_button,
 				 e_account_writable(emae->account, E_ACCOUNT_SENT_FOLDER_URI)
 				 || e_account_writable(emae->account, E_ACCOUNT_DRAFTS_FOLDER_URI));
+
+	/* Receipt policy */
+	emae_setup_receipt_policy (emae, xml);
 	
 	w = glade_xml_get_widget(xml, item->label);
 	gtk_notebook_append_page((GtkNotebook *)parent, w, gtk_label_new(_("Defaults")));
Index: mail/em-composer-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-composer-utils.c,v
retrieving revision 1.34
diff -u -u -r1.34 em-composer-utils.c
--- mail/em-composer-utils.c	4 Mar 2005 03:15:37 -0000	1.34
+++ mail/em-composer-utils.c	5 Apr 2005 19:23:42 -0000
@@ -50,9 +50,10 @@
 #include "e-util/e-account-list.h"
 
 #include <camel/camel-string-utils.h>
+#include <camel/camel-stream-mem.h>
 #include <camel/camel-nntp-address.h>
 
-static EAccount *guess_account (CamelMimeMessage *message, CamelFolder *folder);
+static EAccount * guess_account (CamelMimeMessage *message, CamelFolder *folder);
 
 struct emcs_t {
 	unsigned int ref_count;
@@ -190,6 +191,7 @@
 		if (emcs && emcs->folder) {
 			/* set any replied flags etc */
 			camel_folder_set_message_flags (emcs->folder, emcs->uid, emcs->flags, emcs->set);
+			camel_folder_set_message_user_flag (emcs->folder, emcs->uid, "receipt-handled", TRUE);
 			camel_object_unref (emcs->folder);
 			emcs->folder = NULL;
 			g_free (emcs->uid);
@@ -1064,6 +1066,174 @@
 	g_return_if_fail (uid != NULL);
 	
 	mail_get_message (folder, uid, redirect_msg, NULL, mail_thread_new);
+}
+
+
+static gboolean
+em_utils_ask_receipt (CamelFolder *folder, CamelMimeMessage *message)
+{
+	/* Check the account's receipt policy settings, and pop up a
+	 * dialog if the policy is ASK */
+	
+	EAccount *account = guess_account (message, folder);
+	
+	if (account->receipt_policy == E_ACCOUNT_RECEIPT_ASK) {
+		const char *receipt_address = camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To");
+		const char *subject = camel_mime_message_get_subject (message);
+		
+		return (e_error_run (NULL, "mail:ask-receipt", receipt_address, subject) == GTK_RESPONSE_YES);
+	}
+	
+	return (account->receipt_policy == E_ACCOUNT_RECEIPT_ALWAYS);	
+}
+
+void
+em_utils_handle_receipt (CamelFolder *folder, const char *uid)
+{
+	CamelMimeMessage *message = camel_folder_get_message (folder, uid, NULL);
+	
+	g_return_if_fail (message);
+
+	if (camel_folder_get_message_user_flag (folder, uid, "receipt-handled"))
+		return;
+	camel_folder_set_message_user_flag (folder, uid, "receipt-handled", TRUE);
+	
+	if (!camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To"))
+		return;
+	
+	if (em_utils_ask_receipt (folder, message))
+		em_utils_send_receipt (folder, message);
+}
+
+static void
+em_utils_receipt_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info,
+		       int queued, const char *appended_uid, void *data)
+{
+	camel_message_info_free (info);
+	mail_send ();
+}
+
+
+void
+em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message)
+{
+	/* See RFC #2298 for a description of message receipts */
+
+	EAccount *account = guess_account (message, folder);
+
+	CamelMimeMessage *receipt = camel_mime_message_new ();
+	CamelMultipart *body = camel_multipart_new ();
+	CamelMimePart *part;
+	CamelDataWrapper *receipt_text, *receipt_data;
+	CamelContentType *type;
+	CamelInternetAddress *addr;
+	CamelStream *stream;	
+	CamelFolder *out_folder;
+	CamelMessageInfo *info;
+	const char *message_id = camel_medium_get_header (CAMEL_MEDIUM (message), "Message-ID");
+	const char *message_date = camel_medium_get_header (CAMEL_MEDIUM (message), "Date");
+	const char *message_subject = camel_mime_message_get_subject (message);
+	const char *receipt_address = camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To");
+	char *fake_msgid;
+	char *hostname;
+	char *self_address, *receipt_subject;
+	char *ua, *recipient;
+
+	if (!receipt_address)
+		return;
+	
+	/* Collect information for the receipt */
+
+	/* We use camel_header_msgid_generate () to get a canonical
+	 * hostname, then skip the part leading to '@' */
+	fake_msgid = camel_header_msgid_generate ();
+	for (hostname = fake_msgid; hostname && *hostname != '@'; ++hostname);
+	++hostname;
+
+	self_address = account->id->address;
+
+	if (!message_id)
+		message_id = "";
+	if (!message_date)
+		message_date ="";
+	
+	/* Create toplevel container */
+	camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (body),
+					  "multipart/report;"
+					  "report-type=\"disposition-notification\"");
+	camel_multipart_set_boundary (body, NULL);	
+	
+	/* Create textual receipt */
+	receipt_text = camel_data_wrapper_new ();
+	type = camel_content_type_new ("text", "plain");
+	camel_content_type_set_param (type, "format", "flowed");
+	camel_data_wrapper_set_mime_type_field (receipt_text, type);
+	camel_content_type_unref (type);
+	stream = camel_stream_mem_new ();
+	camel_stream_printf (stream,
+			     "Your message to %s about \"%s\" on %s has been read.",
+			     self_address, message_subject, message_date);
+	camel_data_wrapper_construct_from_stream (receipt_text, stream);
+	camel_object_unref (stream);
+	
+	part = camel_mime_part_new ();
+	camel_medium_set_content_object (CAMEL_MEDIUM (part), receipt_text);
+	camel_object_unref (receipt_text);
+	camel_multipart_add_part (body, part);
+	camel_object_unref (part);	
+	
+	/* Create the machine-readable receipt */
+	receipt_data = camel_data_wrapper_new ();
+	type = camel_content_type_new ("message", "disposition-notification");
+	camel_data_wrapper_set_mime_type_field (receipt_data, type);
+	camel_content_type_unref (type);
+	stream = camel_stream_mem_new ();
+	part = camel_mime_part_new ();
+
+	ua = g_strdup_printf ("%s; %s", hostname, "Evolution " VERSION SUB_VERSION " " VERSION_COMMENT);
+	recipient = g_strdup_printf ("rfc822; %s", self_address);	
+
+	camel_medium_add_header (CAMEL_MEDIUM (part), "Reporting-UA", ua);
+	camel_medium_add_header (CAMEL_MEDIUM (part), "Final-Recipient", recipient);
+	camel_medium_add_header (CAMEL_MEDIUM (part), "Original-Message-ID", message_id);
+	camel_medium_add_header (CAMEL_MEDIUM (part), "Disposition", "manual-action/MDN-sent-manually; displayed");
+
+	g_free (ua);
+	g_free (recipient);
+	g_free (fake_msgid);
+	
+	camel_data_wrapper_construct_from_stream (receipt_data, stream);
+	camel_object_unref (stream);
+	camel_medium_set_content_object (CAMEL_MEDIUM (part), receipt_data);
+	camel_object_unref (receipt_data);
+	camel_multipart_add_part (body, part);
+	camel_object_unref (part);	
+	
+	/* Finish creating the message */
+	camel_medium_set_content_object (CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
+	camel_object_unref (body);
+	
+	receipt_subject = g_strdup_printf ("Delivery Notification for: \"%s\"", message_subject);
+	camel_mime_message_set_subject (receipt, receipt_subject);
+	g_free (receipt_subject);
+	
+	addr = camel_internet_address_new ();
+	camel_address_decode (CAMEL_ADDRESS (addr), self_address);
+	camel_mime_message_set_recipients (receipt, CAMEL_RECIPIENT_TYPE_TO, addr);
+	camel_object_unref (addr);
+	
+	addr = camel_internet_address_new ();
+	camel_address_decode (CAMEL_ADDRESS (addr), receipt_address);
+	camel_mime_message_set_from (receipt, addr);
+	camel_object_unref (addr);
+
+	camel_medium_set_header (CAMEL_MEDIUM (receipt), "Return-Path", "<>");
+
+	/* Send the receipt */
+	out_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
+	info = camel_message_info_new (NULL);
+	camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+	mail_append_mail (out_folder, receipt, info, em_utils_receipt_done, 0);
 }
 
 /* Replying to messages... */
Index: mail/em-composer-utils.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-composer-utils.h,v
retrieving revision 1.7
diff -u -u -r1.7 em-composer-utils.h
--- mail/em-composer-utils.h	28 Jul 2004 14:38:50 -0000	1.7
+++ mail/em-composer-utils.h	5 Apr 2005 19:23:43 -0000
@@ -34,6 +34,7 @@
 struct _CamelMimeMessage;
 struct _EMsgComposer;
 struct _EMFormat;
+struct _EAccount;
 
 void em_composer_utils_setup_callbacks (struct _EMsgComposer *composer, struct _CamelFolder *folder, const char *uid,
 					guint32 flags, guint32 set, struct _CamelFolder *drafts, const char *drafts_uid);
@@ -62,6 +63,9 @@
 
 void em_utils_redirect_message (struct _CamelMimeMessage *message);
 void em_utils_redirect_message_by_uid (struct _CamelFolder *folder, const char *uid);
+
+void em_utils_handle_receipt (struct _CamelFolder *folder, const char *uid);
+void em_utils_send_receipt   (struct _CamelFolder *folder, struct _CamelMimeMessage *message);
 
 enum {
 	REPLY_MODE_SENDER,
Index: mail/em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.113
diff -u -u -r1.113 em-folder-view.c
--- mail/em-folder-view.c	4 Apr 2005 20:53:21 -0000	1.113
+++ mail/em-folder-view.c	5 Apr 2005 19:23:47 -0000
@@ -64,6 +64,7 @@
 #include <bonobo/bonobo-ui-util.h>
 
 #include "widgets/misc/e-charset-picker.h"
+#include "widgets/misc/e-error.h"
 
 #include <e-util/e-dialog-utils.h>
 #include <e-util/e-icon-factory.h>
@@ -125,6 +126,8 @@
 static void emfv_on_url_cb(GObject *emitter, const char *url, EMFolderView *emfv);
 static void emfv_on_url(EMFolderView *emfv, const char *uri, const char *nice_uri);
 
+static void emfv_set_seen (EMFolderView *emfv, const char *uid);
+
 static gboolean emfv_popup_menu (GtkWidget *widget);
 
 static const EMFolderViewEnable emfv_enable_map[];
@@ -441,6 +444,7 @@
 		em_folder_view_set_folder((EMFolderView *)emmb, emfv->folder, emfv->folder_uri);
 		em_folder_view_set_message((EMFolderView *)emmb, views->pdata[i], FALSE);
 		gtk_widget_show(emmb->window);
+		em_utils_handle_receipt (emfv->folder, uids->pdata[i]);
 		g_free(views->pdata[i]);
 	}
 	g_ptr_array_free(views, TRUE);
@@ -2101,7 +2105,7 @@
 	MessageList *list = emfv->list;
 	
 	if (mst->uid && list->cursor_uid && !strcmp (mst->uid, list->cursor_uid))
-		camel_folder_set_message_flags (emfv->folder, mst->uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+		emfv_set_seen (emfv, mst->uid);
 	
 	return FALSE;
 }
@@ -2147,7 +2151,7 @@
 			emfv->priv->seen_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, emfv->mark_seen_timeout,
 								 (GSourceFunc)do_mark_seen, mst, (GDestroyNotify)mst_free);
 		} else {
-			camel_folder_set_message_flags(emfv->folder, uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+			emfv_set_seen (emfv, uid);
 		}
 	}
 	
@@ -2419,6 +2423,19 @@
 		gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time);
 
 	return TRUE;
+}
+
+static void
+emfv_set_seen(EMFolderView *emfv, const char *uid)
+{
+	guint32 old_flags = camel_folder_get_message_flags(emfv->folder, uid);
+
+	/* If we're setting the SEEN flag on a message, handle receipt
+	 * requests */
+	if (!(old_flags & CAMEL_MESSAGE_SEEN))
+		em_utils_handle_receipt(emfv->folder, uid);
+	
+	camel_folder_set_message_flags(emfv->folder, uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
 }
 
 /* keep these two tables in sync */
Index: mail/mail-config.glade
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.glade,v
retrieving revision 1.158
diff -u -u -r1.158 mail-config.glade
--- mail/mail-config.glade	30 Mar 2005 07:57:45 -0000	1.158
+++ mail/mail-config.glade	5 Apr 2005 19:24:01 -0000
@@ -3056,6 +3056,120 @@
 	      <property name="fill">False</property>
 	    </packing>
 	  </child>
+
+	  <child>
+	    <widget class="GtkVBox" id="vbox205">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">6</property>
+
+	      <child>
+		<widget class="GtkLabel" id="label578">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Message Receipts&lt;/span&gt;</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">True</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkHBox" id="hbox231">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">12</property>
+
+		  <child>
+		    <widget class="GtkLabel" id="label581">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox232">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">12</property>
+
+		      <child>
+			<widget class="GtkLabel" id="label583">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">Send message receipts:</property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkComboBox" id="receipt_policy_dropdown">
+			  <property name="visible">True</property>
+			  <property name="items" translatable="yes"></property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">True</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">True</property>
+	      <property name="fill">True</property>
+	    </packing>
+	  </child>
 	</widget>
 	<packing>
 	  <property name="tab_expand">False</property>
Index: mail/mail-errors.xml
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-errors.xml,v
retrieving revision 1.13
diff -u -u -r1.13 mail-errors.xml
--- mail/mail-errors.xml	1 Apr 2005 00:43:27 -0000	1.13
+++ mail/mail-errors.xml	5 Apr 2005 19:24:02 -0000
@@ -347,5 +347,12 @@
 </secondary>
 </error>
 
+  <error id="ask-receipt" type="question" default="GTK_RESPONSE_NO">
+    <primary>Receipt requested</primary>
+    <secondary>Send message receipt to {0} about message &quot;{1}&quot;?</secondary>
+    <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+    <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+  </error>
+
 </error-list>
 
Index: ui/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ui/ChangeLog,v
retrieving revision 1.408
diff -u -u -r1.408 ChangeLog
--- ui/ChangeLog	14 Feb 2005 15:55:00 -0000	1.408
+++ ui/ChangeLog	5 Apr 2005 19:24:04 -0000
@@ -1,3 +1,8 @@
+2004-03-31  ERDI Gergo  <cactus cactus rulez org>
+
+	* evolution-message-composer.xml: Added new menu item for
+	requesting message receipts when composing a new message
+
 2005-02-14  Rodney Dawes  <dobey novell com>
 
 	* evolution-mail-list.xml:
Index: ui/evolution-message-composer.xml
===================================================================
RCS file: /cvs/gnome/evolution/ui/evolution-message-composer.xml,v
retrieving revision 1.44
diff -u -u -r1.44 evolution-message-composer.xml
--- ui/evolution-message-composer.xml	4 Jan 2005 19:43:20 -0000	1.44
+++ ui/evolution-message-composer.xml	5 Apr 2005 19:24:04 -0000
@@ -31,6 +31,10 @@
 		pixtype="stock" pixname="gtk-delete"
 		_tip="Delete all but signature"/>
 
+		<cmd name="RequestReceipt" _label="Request Receipt"
+		     _tip="Check to get delivery notification when your message is read"
+		     type="toggle" state="0"/>
+		
 		<cmd name="FormatHtml" _label="HT_ML" _tip="Send the mail in HTML format"
 		type="toggle" state="0"/> 
 		
@@ -132,6 +136,8 @@
 	                <menuitem name="FileAttach" verb=""
 	                _label="_Attachment..." pixtype="pixbuf"/>
                 	<placeholder name="Component"/>
+			<separator f="" name="emailcomposer"/>
+			<menuitem name="RequestReceipt" verb=""/>
                 </submenu>
 		
                 <submenu name="Security" _label="_Security">


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