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
Родитель 3732603b0e
Коммит 6857cbf218
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);

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

@ -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);
@ -768,6 +778,7 @@ var MessageWindowController =
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;
}