diff --git a/mail/locales/en-US/chrome/messenger/messenger.properties b/mail/locales/en-US/chrome/messenger/messenger.properties index 0861d44420..6814a15f00 100644 --- a/mail/locales/en-US/chrome/messenger/messenger.properties +++ b/mail/locales/en-US/chrome/messenger/messenger.properties @@ -465,6 +465,11 @@ emptyTrashDontAsk=Don't ask me again. junkAnalysisPercentComplete=Junk analysis %S complete processingJunkMessages=Processing Junk Messages +# Messenger bootstrapping messages +fileNotFoundTitle = File Not Found +#LOCALIZATION NOTE(fileNotFoundMsg): %S is the filename +fileNotFoundMsg = The file %S does not exist. + # second person direct object pronoun; used in the collapsed header view if # the user is in the To or Cc field of a message headerFieldYou=You diff --git a/mailnews/base/src/nsMessengerBootstrap.cpp b/mailnews/base/src/nsMessengerBootstrap.cpp index a23155ae76..45a78d6f84 100644 --- a/mailnews/base/src/nsMessengerBootstrap.cpp +++ b/mailnews/base/src/nsMessengerBootstrap.cpp @@ -26,6 +26,7 @@ * Pierre Phaneuf * David Bienvenu * Siddharth Agarwal + * Magnus Melin * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -54,6 +55,8 @@ #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsIWindowWatcher.h" +#include "nsIPromptService.h" +#include "nsIStringBundle.h" #include "nsString.h" #include "nsIURI.h" #include "nsIDialogParamBlock.h" @@ -105,7 +108,7 @@ nsMessengerBootstrap::Handle(nsICommandLine* aCmdLine) aCmdLine->SetPreventDefault(PR_TRUE); } #endif - + nsAutoString mailUrl; // -mail or -mail PRBool flag = PR_FALSE; rv = aCmdLine->HandleFlagWithParam(NS_LITERAL_STRING("mail"), PR_FALSE, mailUrl); @@ -162,7 +165,6 @@ nsMessengerBootstrap::Handle(nsICommandLine* aCmdLine) scriptableURL->SetData((mailUrl)); argsArray->AppendElement(scriptableURL); } - wwatch->OpenWindow(nsnull, "chrome://messenger/content/", "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar,dialog=no", argsArray, getter_AddRefs(opened)); aCmdLine->SetPreventDefault(PR_TRUE); @@ -188,11 +190,39 @@ nsMessengerBootstrap::Handle(nsICommandLine* aCmdLine) if (StringEndsWith(arg, NS_LITERAL_STRING(".eml"), nsCaseInsensitiveStringComparator())) { - nsCOMPtr 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 file; + rv = aCmdLine->ResolveFile(arg, getter_AddRefs(file)); + PRBool fileExists = PR_FALSE; + if (file) // Absolute paths always resolve, check if it exists too. + file->Exists(&fileExists); + + // If we couldn't resolve, or the file does not exist - shown an alert. + if (NS_FAILED(rv) || !fileExists) + { + nsCOMPtr bs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr bundle; + rv = bs->CreateBundle("chrome://messenger/locale/messenger.properties", + getter_AddRefs(bundle)); + NS_ENSURE_SUCCESS(rv, rv); + + nsAutoString title; + rv = bundle->GetStringFromName(NS_LITERAL_STRING("fileNotFoundTitle").get(), + getter_Copies(title)); + NS_ENSURE_SUCCESS(rv, rv); + + nsAutoString msg; + const PRUnichar *formatStrings[1] = { arg.get() }; + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("fileNotFoundMsg").get(), + formatStrings, 1, getter_Copies(msg)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr promptService(do_GetService("@mozilla.org/embedcomp/prompt-service;1", &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + promptService->Alert(nsnull, title.get(), msg.get()); + return NS_OK; + } nsCOMPtr uri; NS_NewFileURI(getter_AddRefs(uri), file); diff --git a/suite/locales/en-US/chrome/mailnews/messenger.properties b/suite/locales/en-US/chrome/mailnews/messenger.properties index 13cb7cfc78..c3e5f7472a 100644 --- a/suite/locales/en-US/chrome/mailnews/messenger.properties +++ b/suite/locales/en-US/chrome/mailnews/messenger.properties @@ -421,3 +421,8 @@ emptyTrashDontAsk=Don't ask me again. # junkCommands.js junkAnalysisPercentComplete=Junk analysis %S complete processingJunkMessages=Processing Junk Messages + +# Messenger bootstrapping messages +fileNotFoundTitle = File Not Found +#LOCALIZATION NOTE(fileNotFoundMsg): %S is the filename +fileNotFoundMsg = The file %S does not exist.