Part of bug 440794, when sending in background fix sending more than one email in the same session. r/sr=bienvenu
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 21 Apr 2009 09:33:22 +0100
changeset 2438 2e28575d773cbca49421940a672d4c8fe5cb9dbe
parent 2437 f02f2adc5f62d7b8d12b30454b2112c04cfeff93
child 2439 557a2e8aab9544ef076061b3c148db0ff4834af8
push id1980
push userbugzilla@standard8.plus.com
push dateTue, 21 Apr 2009 08:34:43 +0000
treeherdercomm-central@557a2e8aab95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs440794
Part of bug 440794, when sending in background fix sending more than one email in the same session. r/sr=bienvenu
mailnews/compose/src/nsMsgSendLater.cpp
mailnews/compose/src/nsMsgSendLater.h
--- a/mailnews/compose/src/nsMsgSendLater.cpp
+++ b/mailnews/compose/src/nsMsgSendLater.cpp
@@ -72,16 +72,17 @@ NS_IMPL_ISUPPORTS6(nsMsgSendLater,
                    nsIRequestObserver,
                    nsIStreamListener,
                    nsIObserver,
                    nsIMsgShutdownTask)
 
 nsMsgSendLater::nsMsgSendLater()
 {
   mSendingMessages = PR_FALSE;
+  mTimerSet = PR_FALSE;
   mTotalSentSuccessfully = 0;
   mTotalSendCount = 0;
   mLeftoverBuffer = nsnull;
 
   m_to = nsnull;
   m_bcc = nsnull;
   m_fcc = nsnull;
   m_newsgroups = nsnull;
@@ -153,16 +154,17 @@ nsMsgSendLater::Init()
 
 NS_IMETHODIMP
 nsMsgSendLater::Observe(nsISupports *aSubject, const char* aTopic,
                         const PRUnichar *aData)
 {
   if (aSubject == mTimer && !strcmp(aTopic, "timer-callback"))
   {
     mTimer->Cancel();
+    mTimerSet = PR_FALSE;
     // If we've already started a send since the timer fired, don't start
     // another
     if (!mSendingMessages)
       InternalSendMessages(PR_FALSE, nsnull);
   }
   else if (!strcmp(aTopic, "quit-application"))
   {
     // We're shutting down. Unsubscribe from the unsentFolder notifications
@@ -1336,17 +1338,17 @@ nsMsgSendLater::GetIdentityFromKey(const
   NS_ENSURE_SUCCESS(rv,rv);
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgSendLater::OnItemAdded(nsIMsgFolder *aParentItem, nsISupports *aItem)
 {
   // No need to trigger if timer is already set
-  if (mTimer)
+  if (mTimerSet)
     return NS_OK;
 
   // XXX only trigger for non-queued headers
 
   // Items from this function return NS_OK because the callee won't care about
   // the result anyway.
   nsresult rv;
   if (!mTimer)
@@ -1354,16 +1356,18 @@ nsMsgSendLater::OnItemAdded(nsIMsgFolder
     mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
     NS_ENSURE_SUCCESS(rv, NS_OK);
   }
 
   rv = mTimer->Init(static_cast<nsIObserver*>(this), kInitialMessageSendTime,
                     nsITimer::TYPE_ONE_SHOT);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
+  mTimerSet = PR_TRUE;
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgSendLater::OnItemRemoved(nsIMsgFolder *aParentItem, nsISupports *aItem)
 {
   return NS_OK;
 }
--- a/mailnews/compose/src/nsMsgSendLater.h
+++ b/mailnews/compose/src/nsMsgSendLater.h
@@ -118,18 +118,19 @@ public:
  
   // Private Information
 private:
   nsresult GetIdentityFromKey(const char *aKey, nsIMsgIdentity **aIdentity);
   nsresult InternalSendMessages(PRBool aUserInitiated,
                                 nsIMsgIdentity *aIdentity);
 
   nsTObserverArray<nsCOMPtr<nsIMsgSendLaterListener> > mListenerArray;
-  nsCOMPtr<nsIMsgDBHdr>      mMessage;
+  nsCOMPtr<nsIMsgDBHdr> mMessage;
   nsCOMPtr<nsITimer> mTimer;
+  PRBool mTimerSet;
   nsCOMPtr<nsIUrlListener> mShutdownListener;
 
   //
   // File output stuff...
   //
   nsCOMPtr<nsIFile>         mTempFile;
   nsCOMPtr<nsIOutputStream> mOutFile;