fix imap assertions when retrying url, r=standard8, sr=neil, 455966
authorDavid Bienvenu <bienvenu@nventure.com>
Tue, 28 Oct 2008 08:13:15 -0700
changeset 741 aa3428e96c984d5ebd0b140d36d1c9c103ee5f2a
parent 740 6442d905c13d89db08b401ce3d9e1784ab28a326
child 742 a8d4959143e5b61e86b1d5f0cee1d1dd01c62560
push idunknown
push userunknown
push dateunknown
reviewersstandard8, neil, 455966
bugs455966
fix imap assertions when retrying url, r=standard8, sr=neil, 455966
mailnews/imap/public/nsIImapServerSink.idl
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapProtocol.cpp
--- a/mailnews/imap/public/nsIImapServerSink.idl
+++ b/mailnews/imap/public/nsIImapServerSink.idl
@@ -37,35 +37,42 @@
 
 #include "nsISupports.idl"
 #include "MailNewsTypes2.idl"
 
 interface nsIMsgWindow;
 interface nsIMsgMailNewsUrl;
 interface nsIImapProtocol;
 interface nsIImapUrl;
+interface nsIImapMockChannel;
 
-[scriptable, uuid(8255E06F-C296-40d0-B924-ECAE5F5291C6)]
+[scriptable, uuid(1851b9f0-f1b3-4f01-b1ba-9525997cf7ca)]
 interface nsIImapServerSink : nsISupports {
   /* returns true if it's a new mailbox */
   boolean possibleImapMailbox(in ACString folderPath, in wchar hierarchyDelim, in long boxFlags);
   boolean folderNeedsACLInitialized(in ACString folderPath);
   void addFolderRights(in ACString folderPath, in ACString userName, in ACString rights);
   void refreshFolderRights(in ACString folderPath);
   void discoveryDone();
   void onlineFolderDelete(in ACString aFolderName);
   void onlineFolderCreateFailed(in ACString aFolderName);
   void onlineFolderRename(in nsIMsgWindow msgWindow, in ACString oldName, in ACString newName);
   boolean folderIsNoSelect(in ACString aFolderName);
   void setFolderAdminURL(in ACString aFolderName, in ACString adminUrl);
   boolean folderVerifiedOnline(in ACString aFolderName);
 
   void setCapability(in unsigned long capability);
   boolean loadNextQueuedUrl(in nsIImapProtocol aProtocol);
-  void retryUrl(in nsIImapUrl aImapUrl);
+  /*
+   * Retry the current url
+   * 
+   * @param  aImapUrl - url to retry
+   * @param  aChannel - channel to associate with the url 
+   */
+  void retryUrl(in nsIImapUrl aImapUrl, in nsIImapMockChannel aChannel);
   // if previous url failed, this gives server chance to abort urls with same mock channel
   void abortQueuedUrls(); 
   AString getImapStringByID(in long aMsgId);
   AString formatStringWithHostNameByID(in long aMsgId);
   void fEAlert(in AString aString, in nsIMsgWindow aMsgWindow);
   void fEAlertFromServer(in ACString aString, in nsIMsgWindow aMsgWindow);
   void commitNamespaces();
   void promptForPassword(out ACString aString, in nsIMsgWindow aMsgWindow);
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -442,20 +442,21 @@ nsImapIncomingServer::GetImapConnectionA
     PRBool urlRun;
     rv = LoadNextQueuedUrl(nsnull, &urlRun);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsImapIncomingServer::RetryUrl(nsIImapUrl *aImapUrl)
+nsImapIncomingServer::RetryUrl(nsIImapUrl *aImapUrl, nsIImapMockChannel *aChannel)
 {
   nsresult rv;
   // Get current thread envent queue
+  aImapUrl->SetMockChannel(aChannel);
   nsCOMPtr <nsIImapProtocol> protocolInstance;
   nsImapProtocol::LogImapUrl("creating protocol instance to retry queued url", aImapUrl);
   rv = GetImapConnection(NS_GetCurrentThread(), aImapUrl, getter_AddRefs(protocolInstance));
   if (NS_SUCCEEDED(rv) && protocolInstance)
   {
     nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
     if (NS_SUCCEEDED(rv) && url)
     {
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -1656,27 +1656,27 @@ PRBool nsImapProtocol::ProcessCurrentURL
         m_useIdle = PR_FALSE;
     }
   }
   return anotherUrlRun;
 }
 
 PRBool nsImapProtocol::RetryUrl()
 {
+  nsAutoCMonitor mon(this);
   nsCOMPtr <nsIImapUrl> kungFuGripImapUrl = m_runningUrl;
   nsCOMPtr <nsIImapMockChannel> saveMockChannel;
   m_runningUrl->GetMockChannel(getter_AddRefs(saveMockChannel));
   ReleaseUrlState(PR_TRUE);
   nsresult rv;
   nsCOMPtr<nsIImapIncomingServer> imapServer  = do_QueryReferent(m_server, &rv);
-  kungFuGripImapUrl->SetMockChannel(saveMockChannel);
   if (NS_SUCCEEDED(rv))
     imapServer->RemoveConnection(this);
   if (m_imapServerSink)
-    m_imapServerSink->RetryUrl(kungFuGripImapUrl);
+    m_imapServerSink->RetryUrl(kungFuGripImapUrl, saveMockChannel);
   return (m_imapServerSink != nsnull); // we're running a url (the same url)
 }
 
 // ignoreBadAndNOResponses --> don't throw a error dialog if this command results in a NO or Bad response
 // from the server..in other words the command is "exploratory" and we don't really care if it succeeds or fails.
 void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString, PRBool aIgnoreBadAndNOResponses)
 {
     if (commandString)