fix bug 257735, wrong error message when error saving to draft folder, and retry saves to sent folder, r=standard8
authorDavid Bienvenu <bienvenu@nventure.com>
Fri, 14 Jan 2011 13:09:51 -0800
changeset 6959 d3121c483250becfb0d69689b527179867fe36aa
parent 6958 95805deaae99505aad06c9191f1d42c4c02fb5f7
child 6960 cc7fcc38e0f28752e75faeb66b8721e32582da26
push idunknown
push userunknown
push dateunknown
reviewersstandard8
bugs257735
fix bug 257735, wrong error message when error saving to draft folder, and retry saves to sent folder, r=standard8
mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
mailnews/compose/src/nsComposeStrings.h
mailnews/compose/src/nsMsgPrompts.cpp
mailnews/compose/src/nsMsgPrompts.h
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsMsgSend.h
suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
--- a/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
+++ b/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
@@ -194,19 +194,16 @@ 12564=The author of this message has req
 
 ## @name NS_MSG_UNDISCLOSED_RECIPIENTS
 ## LOCALIZATION NOTE: this string must be using only US_ASCII characters
 12566=undisclosed-recipients
 
 ## @name NS_MSG_ERROR_ATTACHING_FILE
 12570=There was an error attaching %S. Please check if you have access to the file.
 
-## @name NS_MSG_ERROR_DOING_FCC
-12571=There was an error copying the message to the Sent folder. Retry?
-
 ## @name NS_ERROR_SMTP_GREETING
 12572=An error occurred sending mail: The mail server sent an incorrect greeting:  %s.
 
 ## @name NS_ERROR_SENDING_RCPT_COMMAND
 12575=An error occurred while sending mail. The mail server responded:  %1$s. Please check the message recipient %2$s and try again.
 
 ## @name NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS
 12582=An error occurred sending mail: Unable to establish a secure link with SMTP server %S using STARTTLS since it doesn't advertise that feature. Switch off STARTTLS for that server or contact your service provider.
@@ -363,8 +360,12 @@ smtpEnterPasswordPrompt=Enter your passw
 ## words %1$S and %2$S. Place the word %1$S where the host name should appear,
 ## and %2$S where the user name should appear.
 smtpEnterPasswordPromptWithUsername=Enter your password for %2$S on %1$S:
 smtpEnterPasswordPromptTitle=SMTP Server Password Required
 
 # LOCALIZATION NOTE (removeAttachmentMsgs): Semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/Localization_and_Plurals
 removeAttachmentMsgs=Remove Attachment;Remove Attachments
+
+## LOCALIZATION NOTE(errorSavingMsg): Do not translate the word %S. It
+## will be replaced with the name of the folder the message is being saved to.
+errorSavingMsg=There was an error saving the message to %S. Retry?
--- a/mailnews/compose/src/nsComposeStrings.h
+++ b/mailnews/compose/src/nsComposeStrings.h
@@ -63,17 +63,16 @@
 #define NS_MSG_ASK_TO_COMEBACK_TO_COMPOSE           12561
 #define NS_MSG_GENERIC_FAILURE_EXPLANATION          12562
 #define NS_MSG_ERROR_READING_FILE                   NS_MSG_GENERATE_FAILURE(12563)
 #define NS_MSG_FOLLOWUPTO_ALERT                     12564
 
 #define NS_MSG_UNDISCLOSED_RECIPIENTS               12566
 
 #define NS_MSG_ERROR_ATTACHING_FILE                 NS_MSG_GENERATE_FAILURE(12570)
-#define NS_MSG_ERROR_DOING_FCC                      12571
 
 #define NS_ERROR_SMTP_GREETING                      NS_MSG_GENERATE_FAILURE(12572)
 
 #define NS_ERROR_SENDING_RCPT_COMMAND               NS_MSG_GENERATE_FAILURE(12575)
 
 #define NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS      NS_MSG_GENERATE_FAILURE(12582)
 
 #define NS_ERROR_SMTP_PASSWORD_UNDEFINED            NS_MSG_GENERATE_FAILURE(12584)
--- a/mailnews/compose/src/nsMsgPrompts.cpp
+++ b/mailnews/compose/src/nsMsgPrompts.cpp
@@ -122,31 +122,16 @@ nsMsgDisplayMessageByString(nsIPrompt * 
   }
 
   if (prompt)
     rv = prompt->Alert(windowTitle, msg);
   return NS_OK;
 }
 
 nsresult
-nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer, const PRUnichar * windowTitle)
-{
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsString msg;
-  bundle->GetStringFromID(msgID, getter_Copies(msg));
-  return nsMsgAskBooleanQuestionByString(aPrompt, msg.get(), answer, windowTitle);
-}
-
-nsresult
 nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer, const PRUnichar * windowTitle)
 {
   nsresult rv;
   PRInt32 result;
   nsCOMPtr<nsIPrompt> dialog = aPrompt;
 
   if ((!msg) || (!*msg))
     return NS_ERROR_INVALID_ARG;
--- a/mailnews/compose/src/nsMsgPrompts.h
+++ b/mailnews/compose/src/nsMsgPrompts.h
@@ -44,12 +44,11 @@
 
 class nsIPrompt;
 
 nsresult      nsMsgGetMessageByID(PRInt32 aMsgID, nsString& aResult);
 nsresult      nsMsgBuildMessageWithFile(nsIFile * aFile, nsString& aResult);
 nsresult      nsMsgBuildMessageWithTmpFile(nsIFile * aFile, nsString& aResult);
 nsresult      nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID, const PRUnichar * windowTitle = nsnull);
 nsresult      nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg, const PRUnichar * windowTitle = nsnull);
-nsresult      nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer, const PRUnichar * windowTitle = nsnull);
 nsresult      nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer, const PRUnichar * windowTitle = nsnull);
 
 #endif /* _nsMsgPrompts_H_ */
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -4162,23 +4162,38 @@ nsMsgComposeAndSend::NotifyListenerOnSto
 
   SetStatusMessage(msg);
   nsCOMPtr<nsIPrompt> prompt;
   GetDefaultPrompt(getter_AddRefs(prompt));
 
   if (NS_FAILED(aStatus))
   {
     PRBool retry = PR_FALSE;
-    nsMsgAskBooleanQuestionByID(prompt, NS_MSG_ERROR_DOING_FCC, &retry, nsnull /* what title */);
-    if (retry)
+    nsresult rv;
+    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
+    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundle> bundle;
+    rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsString msg;
+    const PRUnichar *formatStrings[] = { mSavedToFolderName.get() };
+
+    rv = bundle->FormatStringFromName(NS_LITERAL_STRING("errorSavingMsg").get(),
+                                      formatStrings, 1,
+                                      getter_Copies(msg));
+    if (NS_SUCCEEDED(rv))
     {
-      mSendProgress = nsnull; // this was cancelled, so we need to clear it.
-      return DoFcc();
+      nsMsgAskBooleanQuestionByString(prompt, msg.get(), &retry, nsnull);
+      if (retry)
+      {
+        mSendProgress = nsnull; // this was cancelled, so we need to clear it.
+        return SendToMagicFolder(m_deliver_mode);
+      }
     }
-
   }
   // Ok, now to support a second copy operation, we need to figure
   // out which copy request just finished. If the user has requested
   // a second copy operation, then we need to fire that off, but if they
   // just wanted a single copy operation, we can tell everyone we are done
   // and move on with life. Only do the second copy if the first one worked.
   //
   if ( NS_SUCCEEDED(aStatus) && (mNeedToPerformSecondFCC) )
@@ -4467,17 +4482,16 @@ nsMsgComposeAndSend::MimeDoFCC(nsIFile  
   nsresult      status = NS_OK;
   char          *ibuffer = 0;
   PRInt32       ibuffer_size = TEN_K;
   char          *obuffer = 0;
   PRUint32      n;
   PRBool        folderIsLocal = PR_TRUE;
   nsCString     turi;
   PRUnichar     *printfString = nsnull;
-  nsString folderName;
   nsString msg;
   nsCOMPtr<nsIMsgFolder> folder;
 
   // Before continuing, just check the user has not cancel the operation
   if (mSendProgress)
   {
     PRBool canceled = PR_FALSE;
     mSendProgress->GetProcessCanceledByUser(&canceled);
@@ -4572,20 +4586,20 @@ nsMsgComposeAndSend::MimeDoFCC(nsIFile  
   {
     nsCOMPtr<nsIRDFService> rdfService = do_GetService(kRDFServiceCID);
     if (rdfService)
     {
       nsCOMPtr<nsIRDFResource> res;
       rdfService->GetResource(turi, getter_AddRefs(res));
       nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(res);
       if (folder)
-        folder->GetName(folderName);
+        folder->GetName(mSavedToFolderName);
     }
-    if (!folderName.IsEmpty())
-      printfString = nsTextFormatter::smprintf(msg.get(), folderName.get());
+    if (!mSavedToFolderName.IsEmpty())
+      printfString = nsTextFormatter::smprintf(msg.get(), mSavedToFolderName.get());
     else
       printfString = nsTextFormatter::smprintf(msg.get(), "?");
     if (printfString)
     {
       SetStatusMessage(nsDependentString(printfString));
       PR_Free(printfString);
     }
   }
--- a/mailnews/compose/src/nsMsgSend.h
+++ b/mailnews/compose/src/nsMsgSend.h
@@ -307,17 +307,18 @@ public:
   PRUint32                  mMessageWarningSize; // Warn if a message is over this size!
 
   PRBool                    m_dont_deliver_p;    // If set, we just return the nsIFile of the file
                                                  // created, instead of actually delivering message.
   nsMsgDeliverMode          m_deliver_mode;      // nsMsgDeliverNow, nsMsgQueueForLater, nsMsgSaveAsDraft,
                                                  // nsMsgSaveAsTemplate and nsMsgSendUnsent
   nsCOMPtr<nsIMsgDBHdr>     mMsgToReplace;       // If the mode is nsMsgSaveAsDraft, this is the message it will
                                                  // replace
-
+  nsString mSavedToFolderName; // Name of folder we're saving to, used when
+                               // displaying error on save.
   // These are needed for callbacks to the FE...
   nsCOMPtr<nsIDOMWindowInternal>  mParentWindow;
   nsCOMPtr<nsIMsgProgress>        mSendProgress;
   nsCOMPtr<nsIMsgSendListener>    mListener;
   nsCOMPtr<nsIMsgStatusFeedback>  mStatusFeedback;
   nsCOMPtr<nsIRequest>      mRunningRequest;
   PRBool                    mSendMailAlso;
   nsCOMPtr<nsIFile>         mReturnFile;     // a holder for file spec's to be returned to caller
--- a/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
+++ b/suite/locales/en-US/chrome/mailnews/compose/composeMsgs.properties
@@ -194,19 +194,16 @@ 12564=The author of this message has req
 
 ## @name NS_MSG_UNDISCLOSED_RECIPIENTS
 ## LOCALIZATION NOTE: this string must be using only US_ASCII characters
 12566=undisclosed-recipients
 
 ## @name NS_MSG_ERROR_ATTACHING_FILE
 12570=There was an error attaching %S. Please check if you have access to the file.
 
-## @name NS_MSG_ERROR_DOING_FCC
-12571=There was an error copying the message to the Sent folder. Retry?
-
 ## @name NS_ERROR_SMTP_GREETING
 12572=An error occurred sending mail: The mail server sent an incorrect greeting:  %s.
 
 ## @name NS_ERROR_SENDING_RCPT_COMMAND
 12575=An error occurred while sending mail. The mail server responded:  %1$s. Please check the message recipient %2$s and try again.
 
 ## @name NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS
 12582=An error occurred sending mail: Unable to establish a secure link with SMTP server %S using STARTTLS since it doesn't advertise that feature. Switch off STARTTLS for that server or contact your service provider.
@@ -336,8 +333,12 @@ renameAttachmentMessage=New attachment n
 ## LOCALIZATION NOTE(smtpEnterPasswordPrompt): Do not translate the
 ## word $S. Place the word $S where the host name should appear.
 smtpEnterPasswordPrompt=Enter your password for %S:
 ## LOCALIZATION NOTE(smtpEnterPasswordPromptWithUsername): Do not translate the
 ## words %1$S and %2$S. Place the word %1$S where the host name should appear,
 ## and %2$S where the user name should appear.
 smtpEnterPasswordPromptWithUsername=Enter your password for %2$S on %1$S:
 smtpEnterPasswordPromptTitle=SMTP Server Password Required
+
+## LOCALIZATION NOTE(errorSavingMsg): Do not translate the word %S. It
+## will be replaced with the name of the folder the message is being saved to.
+errorSavingMsg=There was an error saving the message to %S. Retry?