Fixing bug 496434 - Mailnews shutdown service doesn't respect restarting flags.
authorNick Kreeger <nick.kreeger@park.edu>
Thu, 18 Jun 2009 23:55:20 -0700
changeset 2888 72f343ec0f8642948207fd7dd777f845404b88f9
parent 2885 1ba2d6e21cbf9446c547d04779e0f4e374d28b7d
child 2889 56d5e9e1c5d7609fb538f1fdf1ed498fdc16419d
push idunknown
push userunknown
push dateunknown
bugs496434
Fixing bug 496434 - Mailnews shutdown service doesn't respect restarting flags. r=Standard8 sr=bienvenu
mailnews/base/src/nsMsgMailSession.cpp
mailnews/base/src/nsMsgMailSession.h
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -522,17 +522,18 @@ nsMsgMailSession::GetDataFilesDir(const 
   return rv;
 }
 
 /********************************************************************************/
 
 NS_IMPL_ISUPPORTS3(nsMsgShutdownService, nsIMsgShutdownService, nsIUrlListener, nsIObserver)
 
 nsMsgShutdownService::nsMsgShutdownService()
-: mProcessedShutdown(PR_FALSE),
+: mQuitMode(nsIAppStartup::eAttemptQuit),
+  mProcessedShutdown(PR_FALSE),
   mQuitForced(PR_FALSE),
   mReadyToQuit(PR_FALSE)
 {
   nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
   if (observerService)
   {
     observerService->AddObserver(this, "quit-application-requested", PR_FALSE);
     observerService->AddObserver(this, "quit-application-granted", PR_FALSE);
@@ -600,17 +601,17 @@ void nsMsgShutdownService::AttemptShutdo
     PR_CNotifyAll(this);
     PR_CExitMonitor(this);
   }
   else
   {
     nsCOMPtr<nsIAppStartup> appStartup =
       do_GetService(NS_APPSTARTUP_CONTRACTID);
     NS_ENSURE_TRUE(appStartup, );
-    NS_ENSURE_SUCCESS(appStartup->Quit(nsIAppStartup::eAttemptQuit), );
+    NS_ENSURE_SUCCESS(appStartup->Quit(mQuitMode), );
   }
 }
 
 NS_IMETHODIMP nsMsgShutdownService::SetShutdownListener(nsIWebProgressListener *inListener)
 {
   NS_ENSURE_TRUE(mMsgProgress, NS_ERROR_FAILURE);
   mMsgProgress->RegisterListener(inListener);
   return NS_OK;
@@ -702,16 +703,22 @@ NS_IMETHODIMP nsMsgShutdownService::Obse
         NS_ENSURE_TRUE(internalDomWin, NS_ERROR_FAILURE);  // bail if we don't get a window.
       }
     }
 
     if (!mQuitForced)
     {
       nsCOMPtr<nsISupportsPRBool> stopShutdown = do_QueryInterface(aSubject);
       stopShutdown->SetData(PR_TRUE);
+
+      // If the attempted quit was a restart, be sure to restart the app once
+      // the tasks have been run. This is usually the case when addons or
+      // updates are going to be installed.
+      if (nsDependentString(aData).EqualsLiteral("restart"))
+        mQuitMode |= nsIAppStartup::eRestart;
     }
 
     mMsgProgress->OpenProgressDialog(internalDomWin, topMsgWindow, 
                                      "chrome://messenger/content/shutdownWindow.xul", 
                                      PR_FALSE, nsnull);
 
     if (mQuitForced)
     {
--- a/mailnews/base/src/nsMsgMailSession.h
+++ b/mailnews/base/src/nsMsgMailSession.h
@@ -123,14 +123,15 @@ public:
 protected:
   nsresult ProcessNextTask();
   void AttemptShutdown();
   
 private:
   nsCOMArray<nsIMsgShutdownTask> mShutdownTasks;
   nsCOMPtr<nsIMsgProgress>       mMsgProgress;
   PRUint32                       mTaskIndex;
+  PRUint32                       mQuitMode;
   PRPackedBool mProcessedShutdown;
   PRPackedBool mQuitForced;
   PRPackedBool mReadyToQuit;
 };
 
 #endif /* nsMsgMailSession_h__ */