Closed Bug 209403 Opened 21 years ago Closed 21 years ago

Mail Compose Window needs to support mailto urls...

Categories

(MailNews Core :: Composition, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 236774
mozilla1.7alpha

People

(Reporter: mscott, Assigned: mscott)

References

Details

Attachments

(2 files)

If Mozilla/Mail or Thunderbird is your default mail client and you click on a
mailto url from another browser (like firebird), we bring up an empty compose
window, ignoring the mailto url.

The cmd line handler service brings up messenger chrome and packages the mailto
url as an argument to the window. The existing compose window code only looks at
the passed in argument if it is a nsIMsgComposeParams object. It ignores it if
it is a mailto url.

We already have code as part of another routine in nsMsgComposeService which
knows how to take a mailto url and turn its contents into a nsIMsgComposeParams
object. 

The fix involves refactoring that code into a method which can be called through
xpconnect. And then the onload handler needs to be modified to check if window
argument is a mailto ur.
Pull out a bunch of code in OpenWindowWithURI that was parsing a mailto url and
turning it into a nsIMsgComposeParams object and make it a stand alone routine.
This is the change I've made in thunderbird to make the compose window smart
enough to handle a mailto url as a window argument. This patch applies cleanly
to mozilla mail as well so I can check it into both places.
Attachment #125642 - Flags: superreview?(sspitzer)
Attachment #125643 - Flags: superreview?(sspitzer)
Comment on attachment 125642 [details] [diff] [review]
patch to refactor some code into a getMsgParamsForMailto routine

r/sr=sspitzer, with two nits / suggestions:

1)

+	   *aParams = pMsgComposeParams;
+	   NS_ADDREF(*aParams);

you can do:

NS_ADDREF(*aParams = pMsgComposeParams);

2)

+  // if we got here we must have encountered an error
+  *aParams = NULL;

you want nsnull instead of NULL, right?
Attachment #125642 - Flags: superreview?(sspitzer)
Attachment #125642 - Flags: superreview+
Attachment #125642 - Flags: review+
Comment on attachment 125643 [details] [diff] [review]
patch to make mail compose window handle a mailto argument

r/sr=sspitzer, with a few nits / comments:

1)

+  // see if the string is a mailto url....do this by checking the first 7
characters of the string
+  var protocol = mailtoUrl.substr(0, 7);
+  if (protocol.toLowerCase() === "mailto:")
+  {

I think I got this trick from neil.  instead do:

+ if (mailtoUrl.search(/(^mailto:)/i) == 0)
+ {

2)

+    // if it is a mailto url, turn the mailto url into a MsgComposeParams
object....
+    var ioService =
Components.classes["@mozilla.org/network/io-service;1"].getService(Components.i
nterfaces.nsIIOService);

I think you've got gIOService in scope already, so you don't need to do this.

See
http://lxr.mozilla.org/mozilla/source/mailnews/compose/resources/content/MsgCom
poseCommands.js#106

3)

this new way (of doing <app>.exe -compose <mailto:url>) will work around a
problem we have with doing <app>.exe <mailto:url>, 
where you get a blank browser window and a compose window.

see http://bugzilla.mozilla.org/show_bug.cgi?id=58826

once your fix lands, we should log bugs about fixing the help text for
-compose.

we also might have some other places we could (or should) fix, to do it this
way.  maybe the x-remote code (maybe not, I'm not sure off the top of my head)
Attachment #125643 - Flags: superreview?(sspitzer)
Attachment #125643 - Flags: superreview+
Attachment #125643 - Flags: review+
see also bug #133362, which might just be a dup of this one. 
*** Bug 133362 has been marked as a duplicate of this bug. ***
>I think I got this trick from neil.  instead do:
>
>+ if (mailtoUrl.search(/(^mailto:)/i) == 0)

It's better, but I would do this:

if (/^mailto:/i.test(mailtoUrl))
This bug has become a lot more urgent suddenly, because 
  mozilla -mail mailto:bob@x.com
no longer opens a compose window at all (as of 1.5RC1 at the latest, also in 1.
6a); see bug 220306.  This means *no* external program can open a compose window 
unless they're willing to parse out the parts of the URL into the argument 
string.
The second patch in this bug needs a simple back port to seamonkey and then we
can close it out. I still don't think mozilla -compose mailto:foo@foo.com will
work yet like it does in thunderbird 'cause of
http://bugzilla.mozilla.org/show_bug.cgi?id=220306#c7
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.7alpha
Has this bug been superceded by bug 236774?
thanks Mike, I forgot about this bug. Duping it against the one I'm actively
getting a r/sr for. 

*** This bug has been marked as a duplicate of 236774 ***
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: