Closed Bug 1164817 Opened 5 years ago Closed 5 years ago

.eml files should be opened in a mail message window and not in a browser window

Categories

(SeaMonkey :: OS Integration, defect)

SeaMonkey 2.33 Branch
defect
Not set

Tracking

(seamonkey2.35 affected, seamonkey2.36 affected, seamonkey2.37 affected, seamonkey2.38 affected, seamonkey2.39 fixed)

RESOLVED FIXED
seamonkey2.39
Tracking Status
seamonkey2.35 --- affected
seamonkey2.36 --- affected
seamonkey2.37 --- affected
seamonkey2.38 --- affected
seamonkey2.39 --- fixed

People

(Reporter: daliv.tyw, Assigned: philip.chee)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1
Build ID: 20150321194901

Steps to reproduce:

save mail with attacchment
open produced .eml file



Actual results:

opened in browser.
attachments is not accessible


Expected results:

opened in mail component as from mail component:
file -> open -> saved mesage
patch for files inside omni.ja :

--- components\nsMailNewsCommandLineHandler.js	Fri Jan 01 00:00:00 2010
+++ components\nsMailNewsCommandLineHandler.js	Thu May 14 21:06:12 2015
@@ -8,6 +8,7 @@ const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/FileUtils.jsm");
 
 const MAPI_STARTUP_ARG = "MapiStartup";
 const MESSAGE_ID_PARAM = "?messageid=";
@@ -106,6 +109,17 @@ var nsMailNewsCommandLineHandler =
             null);
       }
       aCommandLine.preventDefault = true;
+    } else {
+		if (mailURL.toLowerCase().endsWith(".eml") || mailURL.toLowerCase().endsWith(".msg")) {
+			var url = Services.io.newFileURI(new FileUtils.File(mailURL));
+			var uri = url.QueryInterface(Components.interfaces.nsIURL).QueryInterface(Components.interfaces.nsIFileURL);;
+			uri.query = "?type=application/x-message-display";
+			Services.ww.openWindow(null,
+				"chrome://messenger/content/messageWindow.xul",
+				"_blank", "all,chrome,dialog=no,status,toolbar",
+				uri);
+			cmdLine.preventDefault = true;
+		}
     }
 
     // -MapiStartup

and then
seamonkey -mail "path\filename.EML" 
seamonkey -mail "path\filename.msg" 
opens email in normal way ...

so next - for windows clients set registry:
HKEY_CURRENT_USER\Software\Classes\SeaMonkeyEML\shell\open\command
"C:\Program Files (x86)\SeaMonkey\seamonkey.exe" -mail "%1"
and .eml files opens by double-click ...

currently not ideal mod - have one problem: opens additional browser window ... currently not found how to prevent ...
corrected patch - opens one window as expected ... (but can't correct post here ... unpractical)

--- components\nsMailNewsCommandLineHandler.js	Fri Jan 01 00:00:00 2010
+++ components\nsMailNewsCommandLineHandler.js	Thu May 14 21:06:12 2015
@@ -8,6 +8,7 @@ const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/FileUtils.jsm");
 
 const MAPI_STARTUP_ARG = "MapiStartup";
 const MESSAGE_ID_PARAM = "?messageid=";
@@ -106,6 +109,17 @@ var nsMailNewsCommandLineHandler =
             null);
       }
       aCommandLine.preventDefault = true;
+    } else {
+		if (mailURL.toLowerCase().endsWith(".eml") || mailURL.toLowerCase().endsWith(".msg")) {
+			var url = Services.io.newFileURI(new FileUtils.File(mailURL));
+			var uri = url.QueryInterface(Components.interfaces.nsIURL).QueryInterface(Components.interfaces.nsIFileURL);;
+			uri.query = "?type=application/x-message-display";
+			Services.ww.openWindow(null,
+				"chrome://messenger/content/messageWindow.xul",
+				"_blank", "all,chrome,dialog=no,status,toolbar",
+				uri);
+			aCommandLine.preventDefault = true;
+		}
     }
 
     // -MapiStartup
You can use the attachment link in the attachment box above to attach your patch.

--- components\nsMailNewsCommandLineHandler.js	Fri Jan 01 00:00:00 2010
+++ components\nsMailNewsCommandLineHandler.js	Thu May 14 21:06:12 2015
@@ -8,6 +8,7 @@ const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/FileUtils.jsm");
 
 const MAPI_STARTUP_ARG = "MapiStartup";
 const MESSAGE_ID_PARAM = "?messageid=";
@@ -106,6 +109,17 @@ var nsMailNewsCommandLineHandler =
             null);
       }
       aCommandLine.preventDefault = true;
+    } else {
+		if (mailURL.toLowerCase().endsWith(".eml") || mailURL.toLowerCase().endsWith(".msg")) {
+			var url = Services.io.newFileURI(new FileUtils.File(mailURL));
+			var uri = url.QueryInterface(Components.interfaces.nsIURL).QueryInterface(Components.interfaces.nsIFileURL);;
+			uri.query = "?type=application/x-message-display";
+			Services.ww.openWindow(null,
+				"chrome://messenger/content/messageWindow.xul",
+				"_blank", "all,chrome,dialog=no,status,toolbar",
+				uri);
+			aCommandLine.preventDefault = true;
+		}
     }
 
     // -MapiStartup

> +    } else {
> +		if (mailURL.toLowerCase().endsWith(".eml") || mailURL.toLowerCase().endsWith(".msg")) {
Use    } else if (.....)

> +			var url = Services.io.newFileURI(new FileUtils.File(mailURL));
> +			var uri = url.QueryInterface(Components.interfaces.nsIURL).QueryInterface(Components.interfaces.nsIFileURL);;
url is already a nsIFileURL so you just need to QI nsIURL

To Neil: does this seem a reasonable approach?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(neil)
want more optimization - so:

--- nsMailNewsCommandLineHandler.js	Fri Jan 01 00:00:00 2010
+++ nsMailNewsCommandLineHandler.js	Sat May 16 22:03:21 2015
@@ -8,6 +8,7 @@ const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/FileUtils.jsm");
 
 const MAPI_STARTUP_ARG = "MapiStartup";
 const MESSAGE_ID_PARAM = "?messageid=";
@@ -106,6 +109,17 @@ var nsMailNewsCommandLineHandler =
             null);
       }
       aCommandLine.preventDefault = true;
+    } else {
+		let mailURLlc = mailURL.toLowerCase();
+		if (mailURLlc.endsWith(".eml") || mailURLlc.endsWith(".msg")) {
+			var uri = Services.io.newFileURI(new FileUtils.File(mailURL)).QueryInterface(Components.interfaces.nsIFileURL);
+			uri.query = "?type=application/x-message-display";
+			Services.ww.openWindow(null,
+				"chrome://messenger/content/messageWindow.xul",
+				"_blank", "all,chrome,dialog=no,status,toolbar",
+				uri);
+			aCommandLine.preventDefault = true;
+		}
     }
 
     // -MapiStartup
For review purposes please generate a patch with more context. For example -U8 -p

Please do not add your patch as a comment. Instead use the attachment function at the top of this page to upload your patch as an attachment.

Please do not use tabs for indentation. Use spaces. Mozilla style is to use two space indentation.
as requested with -U8
without tabs - with 2x spaces
Comment on attachment 8607205 [details] [diff] [review]
*.eml open handler patch (spaces idented)

Flagging this patch for review. => Neil
Attachment #8607205 - Flags: review?(neil)
(In reply to DaLiV from comment #1)
> so next - for windows clients set registry:
> HKEY_CURRENT_USER\Software\Classes\SeaMonkeyEML\shell\open\command
> "C:\Program Files (x86)\SeaMonkey\seamonkey.exe" -mail "%1"
> and .eml files opens by double-click ...

Thanks for working on this, but I'd prefer a solution that used a different command name to open a message file, rather than overloading the -mail command.
Flags: needinfo?(neil)
(In reply to neil@parkwaycc.co.uk from comment #9)
> (In reply to DaLiV from comment #1)
> > so next - for windows clients set registry:
> > HKEY_CURRENT_USER\Software\Classes\SeaMonkeyEML\shell\open\command
> > "C:\Program Files (x86)\SeaMonkey\seamonkey.exe" -mail "%1"
> > and .eml files opens by double-click ...
> 
> Thanks for working on this, but I'd prefer a solution that used a different
> command name to open a message file, rather than overloading the -mail
> command.

Any suggestions? What does Thunderbird use?
(In reply to Philip Chee from comment #10)
> (In reply to comment #9)
> > (In reply to DaLiV from comment #1)
> > > so next - for windows clients set registry:
> > > HKEY_CURRENT_USER\Software\Classes\SeaMonkeyEML\shell\open\command
> > > "C:\Program Files (x86)\SeaMonkey\seamonkey.exe" -mail "%1"
> > > and .eml files opens by double-click ...
> > 
> > Thanks for working on this, but I'd prefer a solution that used a different
> > command name to open a message file, rather than overloading the -mail
> > command.
> 
> Any suggestions? What does Thunderbird use?

It doesn't, it assumes that any file you pass (optionally using -file) is a compose attachment unless it ends in .vcf or .eml (or some other special cases).
Ah I just realized that nsMailNewsCommandLineHandler.js is shared mailnews code which means Thunderbird uses it too. We don't want to affect Thunderbird so we can't change this unilaterally. The SeaMonkey specific nsBrowserContentHandler.js looks to be the file we need to change. Already in that file we handle "openurl" and "openfile". By analogy I propose "openeml"
(In reply to Philip Chee from comment #12)
> Ah I just realized that nsMailNewsCommandLineHandler.js is shared mailnews
> code which means Thunderbird uses it too. We don't want to affect
> Thunderbird so we can't change this unilaterally.
Ah yes, I meant to mention that too.

> The SeaMonkey specific
> nsBrowserContentHandler.js looks to be the file we need to change.
Not ideal, since that file's for opening browser windows (it doesn't do editor or mail windows).

> Already in that file we handle "openurl" and "openfile".
> By analogy I propose "openeml"
That's for -remote, which doesn't really apply here.
mailURL already analyzing in that part of code - and file:// is also one type of URL ... strange if You can't see that, and want make new code anywhere else ...
OS: Unspecified → All
Hardware: Unspecified → All
Summary: eml not opening in mail component → .eml files should be opened in a mail message window and not in a browser window
Attached patch Untested WIP patch (obsolete) — Splinter Review
Untested patch based on version from DaLiV
Attachment #8612946 - Flags: feedback?(neil)
Comment on attachment 8612946 [details] [diff] [review]
Untested WIP patch

Aha, I see what we can do.

In the existing handler, we simply bail for an unrecognised URL. I think what we should do is:
* If we find an nsIMsgMessageUrl then open it with MailUtils as before
* If we don't find a URL then try to resolve the file to a URL.
* If we have a URL then try to open it with messageWindow.xul
Note: I think resolveFile can throw.
Attachment #8612946 - Flags: feedback?(neil) → feedback-
Attachment #8607205 - Flags: review?(neil) → review-
> In the existing handler, we simply bail for an unrecognised URL. I think what we should do is:
> * If we find an nsIMsgMessageUrl then open it with MailUtils as before
> * If we don't find a URL then try to resolve the file to a URL.
> * If we have a URL then try to open it with messageWindow.xul
> Note: I think resolveFile can throw.
Done and Done.
(Patch works after I remembered to -purgecaches)
Assignee: nobody → philip.chee
Attachment #8612946 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8634927 - Flags: review?
Attachment #8634927 - Flags: review? → review?(neil)
Comment on attachment 8634927 [details] [diff] [review]
Patch v1.0 Proposed fix.

>+      else if (AppConstants.MOZ_APP_NAME == "seamonkey" &&
...
>+        Services.console.logStringMessage("Unrecognized URL: " + mailURL);
Please get feedback from Thunderbird that they are happy with these changes.
Attachment #8634927 - Flags: review?(neil) → review+
Target Milestone: --- → seamonkey2.39
Duplicate of this bug: 707631
(In reply to neil@parkwaycc.co.uk from bug 707631 comment #25 )
> We'd also have to associate .eml files with the mail handler...

(In reply to DaLiV from comment #1)
> so next - for windows clients set registry:
> HKEY_CURRENT_USER\Software\Classes\SeaMonkeyEML\shell\open\command
> "C:\Program Files (x86)\SeaMonkey\seamonkey.exe" -mail "%1"
> and .eml files opens by double-click ...
> 
Would .msg files also need this?
Component: General → OS Integration
Flags: needinfo?(philip.chee)
Blocks: 707631
(In reply to Ian Neal from comment #20)
> Would .msg files also need this?
Maybe. Let's discuss this over in Bug 707631
Oops forgot to add the changeset.
http://hg.mozilla.org/comm-central/rev/3f93350ebfbd
Flags: needinfo?(philip.chee)
> Would .msg files also need this?

sure .msg can redirect to the SeaMonkeyEML ... eml is set-up by default for mozilla at install time ... 

can add into registry:

[HKEY_CLASSES_ROOT\.msg]
@="SeaMonkeyEML"
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.