allow thunderbird to open .eml files from the command line 242959 sr=mscott, a=chofmann

This commit is contained in:
bienvenu%nventure.com 2005-06-01 21:00:21 +00:00
Родитель 1134b6e059
Коммит d578f3c197
4 изменённых файлов: 112 добавлений и 62 удалений

Просмотреть файл

@ -672,6 +672,9 @@ function CreateBareDBView(originalView, msgFolder, viewType, viewFlags, sortType
case nsMsgViewType.eShowVirtualFolderResults:
dbviewContractId += "xfvf";
break;
case nsMsgViewType.eShowSearch:
dbviewContractId += "search";
break;
case nsMsgViewType.eShowAllThreads:
default:
if (sortType == nsMsgViewSortType.byThread || sortType == nsMsgViewSortType.byId
@ -685,7 +688,7 @@ function CreateBareDBView(originalView, msgFolder, viewType, viewFlags, sortType
break;
}
// dump ("contract id = " + dbviewContractId + "original view = " + originalView + "\n");
// dump ("contract id = " + dbviewContractId + "original view = " + originalView + "\n");
if (!originalView)
gDBView = Components.classes[dbviewContractId].createInstance(Components.interfaces.nsIMsgDBView);

Просмотреть файл

@ -252,19 +252,19 @@ function OnLoadMessageWindow()
function delayedOnLoadMessageWindow()
{
HideMenus();
HideMenus();
ShowMenus();
AddMailOfflineObserver();
CreateMailWindowGlobals();
CreateMessageWindowGlobals();
verifyAccounts(null);
CreateMailWindowGlobals();
CreateMessageWindowGlobals();
verifyAccounts(null);
InitMsgWindow();
InitMsgWindow();
messenger.SetWindow(window, msgWindow);
InitializeDataSources();
// FIX ME - later we will be able to use onload from the overlay
OnLoadMsgHeaderPane();
messenger.SetWindow(window, msgWindow);
InitializeDataSources();
// FIX ME - later we will be able to use onload from the overlay
OnLoadMsgHeaderPane();
try {
var nsIFolderListener = Components.interfaces.nsIFolderListener;
@ -278,9 +278,9 @@ function delayedOnLoadMessageWindow()
var folder = null;
var messageUri;
var loadCustomMessage = false; //set to true when either loading a message/rfc822 attachment or a .eml file
if (window.arguments)
{
if (window.arguments[0])
if (window.arguments)
{
if (window.arguments[0])
{
try
{
@ -300,20 +300,20 @@ function delayedOnLoadMessageWindow()
}
if (!gCurrentMessageUri)
gCurrentMessageUri = window.arguments[0];
gCurrentMessageUri = window.arguments[0];
}
else
gCurrentMessageUri = null;
else
gCurrentMessageUri = null;
if (window.arguments[1])
gCurrentFolderUri = window.arguments[1];
else
if (window.arguments[1])
gCurrentFolderUri = window.arguments[1];
else
gCurrentFolderUri = folder ? folder.URI : null;
if (window.arguments[2])
originalView = window.arguments[2];
}
}
CreateView(originalView);
@ -332,7 +332,10 @@ function delayedOnLoadMessageWindow()
function OnLoadMessageWindowDelayed(loadCustomMessage)
{
if (loadCustomMessage)
{
gDBView.suppressMsgDisplay = false;
gDBView.loadMessageByUrl(gCurrentMessageUri);
}
else
{
var msgKey = extractMsgKeyFromURI(gCurrentMessageUri);
@ -382,6 +385,13 @@ function CreateView(originalView)
dbFolderInfo = null;
}
}
else
{
// this is a hack to make opening a stand-alone msg window on a
// .eml file work. We use a search view since its much more tolerant
// of not having a folder.
viewType = nsMsgViewType.eShowSearch;
}
// create a db view
CreateBareDBView(originalView, msgFolder, viewType, viewFlags, sortType, sortOrder);
@ -525,12 +535,12 @@ function InitializeDataSources()
function GetSelectedMsgFolders()
{
var folderArray = new Array(1);
var msgFolder = GetLoadedMsgFolder();
if (msgFolder)
folderArray[0] = msgFolder;
var folderArray = new Array(1);
var msgFolder = GetLoadedMsgFolder();
if (msgFolder)
folderArray[0] = msgFolder;
return folderArray;
return folderArray;
}
function GetFirstSelectedMessage()
@ -591,14 +601,14 @@ function GetLoadedMessage()
//Clear everything related to the current message. called after load start page.
function ClearMessageSelection()
{
gCurrentMessageUri = null;
gCurrentFolderUri = null;
gCurrentMessageUri = null;
gCurrentFolderUri = null;
UpdateMailToolbar("clear msg, std alone window");
}
function GetCompositeDataSource(command)
{
return gCompositeDataSource;
return gCompositeDataSource;
}
function SetNextMessageAfterDelete()
@ -712,38 +722,38 @@ function MsgDeleteMessageFromMessageWindow(reallyDelete, fromToolbar)
var MessageWindowController =
{
supportsCommand: function(command)
{
switch ( command )
{
case "cmd_reply":
case "button_reply":
case "cmd_replySender":
case "cmd_replyGroup":
case "cmd_replyall":
case "button_replyall":
case "cmd_forward":
case "button_forward":
case "cmd_forwardInline":
case "cmd_forwardAttachment":
case "cmd_editAsNew":
case "cmd_delete":
{
switch ( command )
{
case "cmd_reply":
case "button_reply":
case "cmd_replySender":
case "cmd_replyGroup":
case "cmd_replyall":
case "button_replyall":
case "cmd_forward":
case "button_forward":
case "cmd_forwardInline":
case "cmd_forwardAttachment":
case "cmd_editAsNew":
case "cmd_delete":
case "cmd_undo":
case "cmd_redo":
case "cmd_killThread":
case "cmd_watchThread":
case "button_delete":
case "button_delete":
case "button_junk":
case "cmd_shiftDelete":
case "cmd_saveAsFile":
case "cmd_saveAsTemplate":
case "cmd_viewPageSource":
case "cmd_shiftDelete":
case "cmd_saveAsFile":
case "cmd_saveAsTemplate":
case "cmd_viewPageSource":
case "cmd_getMsgsForAuthAccounts":
case "button_mark":
case "cmd_markAsRead":
case "cmd_markAllRead":
case "cmd_markThreadAsRead":
case "cmd_markAsRead":
case "cmd_markAllRead":
case "cmd_markThreadAsRead":
case "cmd_markReadByDate":
case "cmd_markAsFlagged":
case "cmd_markAsFlagged":
case "cmd_label0":
case "cmd_label1":
case "cmd_label2":
@ -751,23 +761,24 @@ var MessageWindowController =
case "cmd_label4":
case "cmd_label5":
case "button_file":
case "cmd_file":
case "cmd_file":
case "cmd_markAsJunk":
case "cmd_markAsNotJunk":
case "cmd_recalculateJunkScore":
case "cmd_applyFilters":
case "cmd_runJunkControls":
case "cmd_deleteJunk":
case "cmd_nextMsg":
case "cmd_nextMsg":
case "button_next":
case "button_previous":
case "cmd_nextUnreadMsg":
case "cmd_nextFlaggedMsg":
case "cmd_nextUnreadThread":
case "cmd_previousMsg":
case "cmd_previousUnreadMsg":
case "cmd_previousFlaggedMsg":
case "cmd_nextUnreadMsg":
case "cmd_nextFlaggedMsg":
case "cmd_nextUnreadThread":
case "cmd_previousMsg":
case "cmd_previousUnreadMsg":
case "cmd_previousFlaggedMsg":
return !(gDBView.keyForFirstSelectedMessage == nsMsgKey_None);
case "cmd_getNextNMessages":
case "cmd_find":
case "cmd_findAgain":

Просмотреть файл

@ -60,13 +60,14 @@ interface nsMsgViewSortOrder
const nsMsgViewSortOrderValue descending = 2;
};
[scriptable, uuid(dac950b0-1dd1-11b2-be06-d4c2003a6927)]
[scriptable, uuid(f28a1cdf-06c3-4e98-8f66-f49991670071)]
interface nsMsgViewType {
const nsMsgViewTypeValue eShowAllThreads = 0;
const nsMsgViewTypeValue eShowThreadsWithUnread = 2;
const nsMsgViewTypeValue eShowWatchedThreadsWithUnread = 3;
const nsMsgViewTypeValue eShowQuickSearchResults = 4;
const nsMsgViewTypeValue eShowVirtualFolderResults = 5;
const nsMsgViewTypeValue eShowSearch = 6;
};
[scriptable, uuid(64852276-1dd2-11b2-8103-afe12002c053)]

Просмотреть файл

@ -55,9 +55,11 @@
#include "nsString.h"
#include "nsIURI.h"
#include "nsIDialogParamBlock.h"
#ifdef MOZ_XUL_APP
#include "nsICommandLine.h"
#include "nsILocalFile.h"
#include "nsNetUtil.h"
#include "nsIFileURL.h"
#endif
NS_IMPL_THREADSAFE_ADDREF(nsMessengerBootstrap)
@ -114,8 +116,41 @@ nsMessengerBootstrap::Handle(nsICommandLine* aCmdLine)
wwatch->OpenWindow(nsnull, "chrome://messenger/content/", "_blank",
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar,dialog=no", argsArray, getter_AddRefs(opened));
aCmdLine->SetPreventDefault(PR_TRUE);
return NS_OK;
}
PRInt32 numArgs;
aCmdLine->GetLength(&numArgs);
if (numArgs > 0)
{
nsAutoString arg;
aCmdLine->GetArgument(0, arg);
if (StringEndsWith(arg, NS_LITERAL_STRING(".eml")))
{
nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
NS_ENSURE_TRUE(file, NS_ERROR_FAILURE);
rv = file->InitWithPath(arg);
NS_ENSURE_SUCCESS(rv, rv);
// should we check that the file exists, or looks like a mail message?
nsCOMPtr<nsIURI> uri;
NS_NewFileURI(getter_AddRefs(uri), file);
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
NS_ENSURE_TRUE(fileURL, NS_ERROR_FAILURE);
// create scriptable versions of our strings that we can store in our nsISupportsArray....
nsCOMPtr<nsISupportsString> scriptableURL (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(scriptableURL, NS_ERROR_FAILURE);
fileURL->SetQuery(NS_LITERAL_CSTRING("?type=x-message-display"));
wwatch->OpenWindow(nsnull, "chrome://messenger/content/messageWindow.xul", "_blank",
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar,dialog=no", fileURL, getter_AddRefs(opened));
aCmdLine->SetPreventDefault(PR_TRUE);
}
return NS_OK;
}
return NS_OK;
}