[Evolution-hackers] [Fwd: Beginning MDN Support]



Sent this on Friday but my list subscription had not activated yet.
--- Begin Message ---
Hi,

Firstly, congratulations on your latest wonderful release.

I'm new to this list but I was reading a rather heated thread on the
users list regarding "return receipts" and thought that I might have a
shot at implementing support for this.

So far I have trivially added support for requesting the Message
Disposition Notification's in the first place.  This takes the form of
an "MDN Request" toggle option on the "Security" menu of the composition
window.  When true at build_message time the extra header "Disposition-
Notification-To:" is set to the same value as the "From:" header.

When loading a draft message (e_msg_composer_new_with_message) the
simple presence of this header triggers the setting of the mdn_request
field of the new composer object back to true.

I have not exhaustively tested this but a Mozilla Thunderbird understood
what I was asking for and sent me a MDN back.  This is only a first
attempt and I expect to find many issues I have overlooked but I thought
you might like some input at this stage.  Feel free to correct me on any
point and suggest alternative strings and/or UI structure.

Regarding the more difficult generation of the MDNs, when a request
comes in I was thinking of tending away from the user interfaces I have
seen for this before.  Instead I was thinking of putting a tool bar
button that shows a dialogue with tabs for the possible disposition
types "displayed", "dispatched", "processed", "deleted", "denied" and
"failed" (probably with the exception of "failed", though).

Each tab would have a description the type for the user to choose.  The
default tab would be whatever Lookout uses when it asks to send a read
receipt (probably "displayed") and each would have a send button.  Bear
in mind here that I have not read the IMAP-specific RFC yet.

I, personally, would hope to just never push that tool bar button but if
you have to for whatever reason it is there for you to do so.

Comments, suggestions, bugs and flames all welcome,

James Ascroft-Leigh

PNG image

diff -r -u evolution-2.0.0/composer/e-msg-composer.c evolution-2.0.0-jwal/composer/e-msg-composer.c
--- evolution-2.0.0/composer/e-msg-composer.c	2004-08-13 17:27:16 +0100
+++ evolution-2.0.0-jwal/composer/e-msg-composer.c	2004-09-17 19:19:05 +0100
@@ -437,7 +437,13 @@
 					 composer->extra_hdr_names->pdata[i],
 					 composer->extra_hdr_values->pdata[i]);
 	}
-	
+
+	if (e_msg_composer_get_mdn_request (composer)) {
+		camel_medium_add_header (CAMEL_MEDIUM (new),
+					"Disposition-Notification-To",
+					camel_medium_get_header (CAMEL_MEDIUM (new), "From"));
+	}
+
 	if (composer->mime_body) {
 		plain_encoding = CAMEL_TRANSFER_ENCODING_7BIT;
 		for (i = 0; composer->mime_body[i]; i++) {
@@ -1830,6 +1836,20 @@
 	e_msg_composer_set_smime_encrypt (E_MSG_COMPOSER (composer), atoi (state));
 }
 
+static void
+menu_security_mdn_request_cb (BonoboUIComponent           *component,
+			      const char                  *path,
+			      Bonobo_UIComponent_EventType type,
+			      const char                  *state,
+			      gpointer                     composer)
+
+{
+	if (type != Bonobo_UIComponent_STATE_CHANGED)
+		return;
+	
+	e_msg_composer_set_mdn_request (E_MSG_COMPOSER (composer), atoi (state));
+}
+
 
 static void
 menu_view_from_cb (BonoboUIComponent           *component,
@@ -2255,7 +2275,16 @@
 		composer->uic, "SecuritySMimeEncrypt",
 		menu_security_smime_encrypt_cb, composer);
 	
-	/* View -> Attachments */
+	/* Security -> MDN Request */
+	bonobo_ui_component_set_prop (
+		composer->uic, "/commands/SecurityMDNRequest",
+		"state", e_msg_composer_get_mdn_request (composer) ? "1" : "0", NULL);
+
+	bonobo_ui_component_add_listener (
+		composer->uic, "SecurityMDNRequest",
+		menu_security_mdn_request_cb, composer);
+	
+		/* View -> Attachments */
 	bonobo_ui_component_add_listener (
 		composer->uic, "ViewAttach",
 		menu_view_attachments_activate_cb, composer);
@@ -3865,6 +3894,12 @@
 		to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
 		cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
 		bcc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC);
+
+		if (camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To")) {
+			e_msg_composer_set_mdn_request (new, TRUE);
+		} else {
+			e_msg_composer_set_mdn_request (new, FALSE);
+		}
 		
 		len = CAMEL_ADDRESS (to)->addresses->len;
 		for (i = 0; i < len; i++) {
@@ -4035,6 +4070,8 @@
 	bonobo_ui_component_set_prop (composer->uic, "/menu/Edit", "sensitive", "0", NULL);
 	bonobo_ui_component_set_prop (composer->uic, "/menu/Format", "sensitive", "0", NULL);
 	bonobo_ui_component_set_prop (composer->uic, "/menu/Insert", "sensitive", "0", NULL);
+
+	/* TODO: MDN: Ask hackers whether MDN preferences should be disabled here */
 }
 
 /**
@@ -4881,6 +4918,46 @@
 
 
 /**
+ * e_msg_composer_set_mdn_request:
+ * @composer: A message composer widget
+ * @mdn_request: Whether the composer should include the Disposition-Notification-To: header
+ * 
+ * Set the status of the "MDN Request" toggle item.  The user can override it.
+ **/
+void
+e_msg_composer_set_mdn_request (EMsgComposer *composer, gboolean mdn_request)
+{
+	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+	if (composer->mdn_request && mdn_request)
+		return;
+	if (!composer->mdn_request && !mdn_request)
+		return;
+	
+	composer->mdn_request = mdn_request;
+	e_msg_composer_set_changed (composer);
+	
+	bonobo_ui_component_set_prop (composer->uic, "/commands/SecurityMDNRequest",
+				      "state", composer->mdn_request ? "1" : "0", NULL);
+}
+
+/**
+ * e_msg_composer_get_mdn_request:
+ * @composer: A message composer widget
+ * 
+ * Get the status of the "MDN Request" flag.
+ * 
+ * Return value: The status of the "MDN Request" flag.
+ **/
+gboolean
+e_msg_composer_get_mdn_request (EMsgComposer *composer)
+{
+	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+	
+	return composer->mdn_request;
+}
+
+/**
  * e_msg_composer_get_view_from:
  * @composer: A message composer widget
  * 
diff -r -u evolution-2.0.0/composer/e-msg-composer.h evolution-2.0.0-jwal/composer/e-msg-composer.h
--- evolution-2.0.0/composer/e-msg-composer.h	2004-07-27 17:52:17 +0100
+++ evolution-2.0.0-jwal/composer/e-msg-composer.h	2004-09-17 14:15:42 +0100
@@ -94,6 +94,7 @@
 	guint32 pgp_encrypt            : 1;
 	guint32 smime_sign             : 1;
 	guint32 smime_encrypt          : 1;
+	guint32 mdn_request            : 1;
 	guint32 view_from              : 1;
 	guint32 view_replyto           : 1;
 	guint32 view_to                : 1;
diff -r -u evolution-2.0.0/ui/evolution-message-composer.xml evolution-2.0.0-jwal/ui/evolution-message-composer.xml
--- evolution-2.0.0/ui/evolution-message-composer.xml	2004-05-25 21:54:01 +0100
+++ evolution-2.0.0-jwal/ui/evolution-message-composer.xml	2004-09-17 13:48:11 +0100
@@ -73,6 +73,10 @@
                 <cmd name="SecuritySMimeEncrypt" _label="S/MIME Encrypt" 
                 _tip="Encrypt this message with your S/MIME Encryption Cetificate"
 		type="toggle" state="0" hidden="1"/>
+		
+                <cmd name="SecurityMDNRequest" _label="_MDN Request" 
+                _tip="Request that all recipients respond with a Message Disposition Notification"
+		type="toggle" state="0"/>
 
 	</commands>
 	
@@ -139,6 +143,7 @@
                         <menuitem name="SecurityPGPEncrypt" verb="" _label="PGP Encrypt"/>
                         <menuitem name="SecuritySMimeSign" verb="" _label="S/MIME Sign"/>
                         <menuitem name="SecuritySMimeEncrypt" verb="" _label="S/MIME Encrypt"/>
+                        <menuitem name="SecurityMDNRequest" verb="" _label="_MDN Request"/>
                 </submenu>
 		
 	</menu>

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---


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