Closed Bug 321890 Opened 20 years ago Closed 18 years ago

Enhancements to GenericSendMessage

Categories

(Thunderbird :: Message Compose Window, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: patrick, Assigned: patrick)

References

Details

Attachments

(1 file, 3 obsolete files)

GenericSendMessage as it is now dispatches an event for preprocessing of messages just before the message is sent. While this is certainly a good step into a pluggable sending architecture, at least for Enigmail, two things are missing for the event handler: 1. the event handler needs to know the value of msgType (e.g. make it a global variable or add it to gMsgCompose.compFields) 2. the event handler should be able to cancel message sending e.g. in case something goes wrong or in case the user aborts sending. This may just be my ignorance, but I couldn't find a way how to abort message sending -- not even throwing an exception stopped the operation.
QA Contact: message-compose
I have created a very minimal patch that adds msgType and cancelSendMessage directly as variables to the event. I don't know if that's according to the usual programming style; otherwise I'd be glad to accept any input for how to do it in a better way. In order to cancel sending the message in this solution from within the event handling, you' have to do: event.stopPropagation(); event.cancelSendMessage=true;
Assignee: mscott → patrick.brunschwig
Status: NEW → ASSIGNED
Attachment #275655 - Flags: review?(bienvenu)
Comment on attachment 275655 [details] [diff] [review] patch adding msgType and cancelSendMessage to the event I don't know if there's any prior art here, but it seems OK to me. Requesting sr from Scott.
Attachment #275655 - Flags: superreview?(mscott)
Attachment #275655 - Flags: review?(bienvenu)
Attachment #275655 - Flags: review+
Neil might have opinions on whether this is the best approach.
I'm not sure what the best way to expose the message send type is but expando properties on DOM events aren't pinned and could be deleted at any time. Since the event has been created as cancelable the way to cancel it is to call event.preventDefault() on it or return false from an event listener and make GenericSendMessage use event.getPreventDefault() to see if it was cancelled.
Attached patch New patch, using UIEvent (obsolete) — Splinter Review
Neil, thanks for your input. The main problem regarding event cancellation was that 'Event' was used (which does not provide the getPreventDefault method), instead of 'UIEvent'. Concerning the msgType, I'm adding it now as attribute to the event target XUL element.
Attachment #275655 - Attachment is obsolete: true
Attachment #275940 - Flags: review?(bienvenu)
Attachment #275655 - Flags: superreview?(mscott)
Comment on attachment 275940 [details] [diff] [review] New patch, using UIEvent looks ok to me, but could you lose the extra braces here: + if (event.getPreventDefault()) { + throw Components.results.NS_ERROR_ABORT; + } Is it possible that we might want to set the msgtype attribute when the msg window is created, instead of right before it's sent? I wonder if other extensions might care earlier...
Attachment #275940 - Flags: superreview?(neil)
Attachment #275940 - Flags: review?(bienvenu)
Attachment #275940 - Flags: review+
Comment on attachment 275940 [details] [diff] [review] New patch, using UIEvent never mind about setting the msgType earlier - Neil corrected my thinking there.
Comment on attachment 275940 [details] [diff] [review] New patch, using UIEvent Looks good to me.
Attachment #275940 - Flags: superreview?(neil) → superreview+
Keywords: checkin-needed
Whiteboard: checkin to mail/ and mailnews/
Patrick, can you make a patch against CVS for both the thunderbird and seamonkey files? It's a lot easier for contributors with CVS access to do a fly-by checkin if they can easily apply it. Thanks again for the patch...
Here is the patch again, this time for Seamonkey and Thunderbird together. I found that on Seamonkey the "compose-send-message" event is issued much earlier than on Thunderbird. I couldn't find a reason why, but for the sake of consistency it should be issued at the same time on both products -- especially regarding the comment just above the event creation (on Thunderbird).
Attachment #275940 - Attachment is obsolete: true
Attachment #276759 - Flags: review?(bienvenu)
Keywords: checkin-needed
Whiteboard: checkin to mail/ and mailnews/
Comment on attachment 276759 [details] [diff] [review] Patch for Thunderbird and Seamonkey so, the TB change is fine, but for SM, you'll want someone like Neil to make sure that moving the call is OK with him.
Attachment #276759 - Flags: review?(bienvenu) → review+
Attachment #276759 - Flags: superreview?(neil)
Comment on attachment 276759 [details] [diff] [review] Patch for Thunderbird and Seamonkey >+ document.getElementById("msgcomposeWindow").dispatchEvent(event); This line shouldn't have been copied. sr=me with it removed.
Attachment #276759 - Flags: superreview?(neil) → superreview+
Attached patch final patchSplinter Review
Ah, right Neil, I have overlooked that line. Here we are then!
Attachment #276759 - Attachment is obsolete: true
mail/components/compose/content/MsgComposeCommands.js 1.116 mailnews/compose/resources/content/MsgComposeCommands.js 1.399
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: