fix gug 704707, don't need event target when running imap urls, along with a bunch of fixes for issues with test that this change exposed r=neil, sr=standard8
authorDavid Bienvenu <bienvenu@nventure.com>
Tue, 10 Jan 2012 07:37:22 -0800
changeset 10390 25d62c5e3121d290269118ad0aba11f3c40c652c
parent 10389 b43c074160f0a71b1d0fd519cc7896b20b1c8a9e
child 10391 fa7ba14da2071c0739f4196551b183f4ea5bcd18
push id402
push userbugzilla@standard8.plus.com
push dateTue, 13 Mar 2012 21:17:18 +0000
treeherdercomm-beta@d080a8ebf16a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil, standard8
bugs704707
fix gug 704707, don't need event target when running imap urls, along with a bunch of fixes for issues with test that this change exposed r=neil, sr=standard8
mailnews/base/test/unit/test_imapPump.js
mailnews/base/util/nsImapMoveCoalescer.cpp
mailnews/imap/public/nsIImapIncomingServer.idl
mailnews/imap/public/nsIImapProtocol.idl
mailnews/imap/public/nsIImapService.idl
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapIncomingServer.h
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapMailFolder.h
mailnews/imap/src/nsImapOfflineSync.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapProtocol.h
mailnews/imap/src/nsImapService.cpp
mailnews/imap/src/nsImapService.h
mailnews/imap/src/nsImapUndoTxn.cpp
mailnews/imap/src/nsImapUndoTxn.h
mailnews/imap/test/unit/test_filterCustomHeaders.js
mailnews/imap/test/unit/test_imapCopyTimeout.js
mailnews/imap/test/unit/test_imapHighWater.js
mailnews/imap/test/unit/test_imapMove.js
mailnews/imap/test/unit/test_mailboxes.js
mailnews/imap/test/unit/test_preserveDataOnMove.js
mailnews/imap/test/unit/test_saveImapDraft.js
mailnews/imap/test/unit/test_saveTemplate.js
mailnews/local/src/nsLocalUndoTxn.cpp
mailnews/test/resources/IMAPpump.js
mailnews/test/resources/messageInjection.js
--- a/mailnews/base/test/unit/test_imapPump.js
+++ b/mailnews/base/test/unit/test_imapPump.js
@@ -39,16 +39,18 @@
 // async support 
 load("../../../resources/logHelper.js");
 load("../../../resources/mailTestUtils.js");
 load("../../../resources/asyncTestUtils.js");
 
 // IMAP pump
 load("../../../resources/IMAPpump.js");
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 // Globals
 
 // Messages to load must have CRLF line endings, that is Windows style
 const gMessage = "bugmail10"; // message file used as the test message
 
 setupIMAPPump();
 
 // Definition of tests
@@ -73,16 +75,17 @@ function loadImapMessage()
 // Cleanup at end
 function endTest()
 {
   teardownIMAPPump();
 }
 
 function run_test()
 {
+  Services.prefs.setBoolPref("mail.server.server1.autosync_offline_stores", false);
   async_run_tests(tests);
 }
 
 /*
  * helper functions
  */
 
 // given a test file, return the file uri spec
--- a/mailnews/base/util/nsImapMoveCoalescer.cpp
+++ b/mailnews/base/util/nsImapMoveCoalescer.cpp
@@ -244,18 +244,17 @@ NS_IMETHODIMP nsMoveCoalescerCopyListene
       PRUint32 folderFlags;
       m_destFolder->GetFlags(&folderFlags);
       if (!(folderFlags & (nsMsgFolderFlags::Junk | nsMsgFolderFlags::Trash)))
       {
         nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv); 
         NS_ENSURE_SUCCESS(rv, rv);
         nsCOMPtr <nsIURI> url;
         nsCOMPtr <nsIUrlListener> listener = do_QueryInterface(m_coalescer);
-        nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-        rv = imapService->SelectFolder(thread, m_destFolder, listener, nsnull, getter_AddRefs(url));
+        rv = imapService->SelectFolder(m_destFolder, listener, nsnull, getter_AddRefs(url));
       }
     }
     else // give junk filters a chance to run on new msgs in destination local folder
     {
       bool filtersRun;
       m_destFolder->CallFilterPlugins(nsnull, &filtersRun);
     }
   }
--- a/mailnews/imap/public/nsIImapIncomingServer.idl
+++ b/mailnews/imap/public/nsIImapIncomingServer.idl
@@ -35,32 +35,31 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 interface nsIUrlListener;
 interface nsIURI;
 interface nsIImapUrl;
-interface nsIEventTarget;
 interface nsIImapProtocol;
 interface nsIMsgFolder;
 interface nsIMsgWindow;
 
 typedef long nsMsgImapDeleteModel;
 
 [scriptable, uuid(bbfc33de-fe89-11d3-a564-0060b0fc04b7)]
 interface nsMsgImapDeleteModels
 {
   const long IMAPDelete = 0;    /* delete with a big red x */
   const long MoveToTrash = 1;   /* delete moves message to the trash */
   const long DeleteNoTrash = 2; /* delete is shift delete - don't create or use trash */
 };
 
-[scriptable, uuid(d4f8f5c7-d413-4c11-b886-abed7f7265a6)]
+[scriptable, uuid(3f02221b-d556-48ef-8b4f-7e50bfe9813d)]
 interface nsIImapIncomingServer : nsISupports {
 
   attribute long maximumConnectionsNumber;
   attribute long timeOutLimits;
   attribute ACString adminUrl;
   attribute ACString serverDirectory;
   attribute long capabilityPref;
   /// RFC 2971 ID response stored as a pref
@@ -99,19 +98,18 @@ interface nsIImapIncomingServer : nsISup
   attribute AString trashFolderName;
 
   attribute boolean downloadBodiesOnGetNewMail;
   attribute boolean autoSyncOfflineStores;
 
   /// Max age of messages we will autosync to, or keep in offline store.
   attribute long autoSyncMaxAgeDays;
 
-  void GetImapConnectionAndLoadUrl(in nsIEventTarget aClientEventTarget,
-                                           in nsIImapUrl aImapUrl,
-                                           in nsISupports aConsumer);
+  void GetImapConnectionAndLoadUrl(in nsIImapUrl aImapUrl,
+                                   in nsISupports aConsumer);
 
   void RemoveConnection(in nsIImapProtocol aImapConnection);
   void ResetNamespaceReferences();
   void pseudoInterruptMsgLoad(in nsIMsgFolder aImapFolder, in nsIMsgWindow aMsgWindow, out boolean interrupted);
   void ResetConnection(in ACString folderName);
   void CloseConnectionForFolder(in nsIMsgFolder aMsgFolder);
   void reDiscoverAllFolders();
   nsIURI subscribeToFolder(in AString name, in boolean subscribe);
--- a/mailnews/imap/public/nsIImapProtocol.idl
+++ b/mailnews/imap/public/nsIImapProtocol.idl
@@ -36,24 +36,23 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 #include "nsIStreamListener.idl"
 
 interface nsIUrlListener;
 interface nsIURI;
 interface nsIImapUrl;
-interface nsIEventTarget;
 interface nsIImapProtocol;
 interface nsIImapIncomingServer;
 interface nsIMsgFolder;
 interface nsIImapHostSessionList;
 interface nsIMsgWindow;
 
-[scriptable, uuid(1c3bbfa9-69f7-4716-8986-2dba10cefb09)]
+[scriptable, uuid(177f4140-37ad-4828-880c-42d4ee5d2015)]
 interface nsIImapProtocol : nsISupports {
   void LoadImapUrl(in nsIURI aUrl, in nsISupports aConsumer);
 
   /**
    * IsBusy returns true if the connection is currently processing a url
    * and false otherwise.
    */
   void IsBusy(out boolean aIsConnectionBusy,
@@ -64,22 +63,21 @@ interface nsIImapProtocol : nsISupports 
    * if it can process this url. I decided to push the semantics about
    * whether a connection can handle a url down into the connection level
    * instead of in the connection cache.
    */
   void CanHandleUrl(in nsIImapUrl aImapUrl, out boolean aCanRunUrl,
                     out boolean hasToWait);
 
   /**
-   * Right now, initialize requires the event queue of the UI thread,
-   * or more importantly the event queue of the consumer of the imap
-   * protocol data. The protocol also needs a host session list.
+   * Initialize a protocol object.
+   * @param aHostSessionList host session list service
+   * @param aServer imap server the protocol object will be talking to
    */
-  void Initialize(in nsIImapHostSessionList aHostSessionList, in nsIImapIncomingServer aServer,
-                  in nsIEventTarget aSinkEventTarget);
+  void Initialize(in nsIImapHostSessionList aHostSessionList, in nsIImapIncomingServer aServer);
 
   void NotifyBodysToDownload(out unsigned long keys, in unsigned long count);
   // methods to get data from the imap parser flag state.
   void GetFlagsForUID(in unsigned long uid, out boolean foundIt, out unsigned short flags, out string customFlags);
   void GetSupportedUserFlags(out unsigned short flags);
 
   void GetRunningImapURL(out nsIImapUrl aImapUrl);
 
--- a/mailnews/imap/public/nsIImapService.idl
+++ b/mailnews/imap/public/nsIImapService.idl
@@ -46,50 +46,45 @@
 
 #include "nsISupports.idl"
 #include "nsIImapUrl.idl"
 
 interface nsIImapProtocol;
 interface nsIImapMessageSink;
 interface nsIUrlListener;
 interface nsIURI;
-interface nsIEventTarget;
 interface nsIFile;
 interface nsIMsgFolder;
 interface nsIMsgWindow;
 interface nsIImapIncomingServer;
 interface nsICacheSession;
 
-[scriptable, uuid(7ff02a19-f402-436a-a6cc-c4c454f0b86f)]
+[scriptable, uuid(aba44b3d-7a0f-4987-8794-96d2de66d966)]
 interface nsIImapService : nsISupports
 {
   // You can pass in null for the url listener and the url if you don't require either.....
-  // aClientEventTarget is the event queue of the event sinks. We post events into this queue.
-  void selectFolder(in nsIEventTarget aClientEventTarget,
-                    in nsIMsgFolder aImapMailFolder,
+  void selectFolder(in nsIMsgFolder aImapMailFolder,
                     in nsIUrlListener aUrlListener,
                     in nsIMsgWindow   aMsgWindow,
                     out nsIURI aURL);
 
   /**
    * Select the folder on the imap server without doing a sync of flags or
    * headers. This is used for offline playback, where we don't want to
    * download hdrs we don't have, because they may have been offline deleted.
    *
-   * @param aClientEventTarget  the event target of the ui thread
    * @param aImapMailFolder     the folder to select
    * @param aUrlListener        url listener, can be null
    * @param aMsgWindow          msg window url is running in, can be null
    *
    * @returns the url created to run the lite select in.
    */
-  nsIURI liteSelectFolder(in nsIEventTarget aClientEventTarget,
-                        in nsIMsgFolder aImapMailFolder,
-                        in nsIUrlListener aUrlListener,
-                        in nsIMsgWindow aMsgWindow);
+  nsIURI liteSelectFolder(in nsIMsgFolder aImapMailFolder,
+                          in nsIUrlListener aUrlListener,
+                          in nsIMsgWindow aMsgWindow);
 
   void addImapFetchToUrl(in nsIURI aURL,
                          in nsIMsgFolder aImapMailFolder,
                          in ACString aMessageIdentifierList,
                          in ACString aAdditionalHeader);
 
   void fetchMessage(in nsIImapUrl aUrl,
                     in nsImapState aImapAction,
@@ -97,228 +92,199 @@ interface nsIImapService : nsISupports
                     in nsIImapMessageSink aImapMessageSink,
                     in nsIMsgWindow aMsgWindow,
                     in nsISupports aConsumer,
                     in ACString aMessageIdentifierList,
                     in boolean convertDataToText,
                     in ACString additionalHeader,
                     out nsIURI aOutURL);
 
-  void noop(in nsIEventTarget aClientEventTarget,
-            in nsIMsgFolder aImapMailFolder,
+  void noop(in nsIMsgFolder aImapMailFolder,
             in nsIUrlListener aUrlListener,
             out nsIURI aURL);
 
-  void getHeaders(in nsIEventTarget aClientEventTarget,
-                  in nsIMsgFolder aImapMailFolder,
+  void getHeaders(in nsIMsgFolder aImapMailFolder,
                   in nsIUrlListener aUrlListener,
                   out nsIURI aURL,
                   in ACString aMessageIdentifierList,
                   in boolean aMessageIdsAreUID);
 
-  nsIURI getBodyStart(in nsIEventTarget aClientEventTarget,
-                  in nsIMsgFolder aImapMailFolder,
-                  in nsIUrlListener aUrlListener,
-                  in ACString aMessageIdentifierList,
-                  in long numBytes);
+  nsIURI getBodyStart(in nsIMsgFolder aImapMailFolder,
+                      in nsIUrlListener aUrlListener,
+                      in ACString aMessageIdentifierList,
+                      in long numBytes);
 
   /**
    * Issue an EXPUNGE on the target folder.
    *
-   * @param aClientEventTarget  the event target of the ui thread
    * @param aImapMailFolder     the folder to expunge
    * @param aUrlListener        url listener, can be null
    * @param aMsgWindow          msg window url is running in, can be null
    *
    * @returns the url created to run the expunge.
    */
-  void expunge(in nsIEventTarget aClientEventTarget,
-               in nsIMsgFolder aImapMailFolder,
+  void expunge(in nsIMsgFolder aImapMailFolder,
                in nsIUrlListener aUrlListener,
                in nsIMsgWindow aMsgWindow,
                out nsIURI aURL);
 
   /**
    * Issue a STATUS on the target folder.
    *
-   * @param aClientEventTarget  the event target of the ui thread
    * @param aImapMailFolder     the folder to expunge
    * @param aUrlListener        url listener, can be null
    *
    * @returns the url created to run the status.
    */
-  nsIURI updateFolderStatus(in nsIEventTarget aClientEventTarget,
-                            in nsIMsgFolder aImapMailFolder,
+  nsIURI updateFolderStatus(in nsIMsgFolder aImapMailFolder,
                             in nsIUrlListener aUrlListener);
 
   /**
    * Verify that we can login.
    *
    * @param aImapMailFolder - any old imap folder - we just need it to
    *                          set url sinks.
    * @param aMsgWindow    - nsIMsgWindow to use for notification callbacks.
    * @return - the url that we run.
    */
   nsIURI verifyLogon(in nsIMsgFolder aImapMailFolder,
                      in nsIUrlListener aUrlListener,
                      in nsIMsgWindow aMsgWindow);
 
-  void biff(in nsIEventTarget aClientEventTarget,
-            in nsIMsgFolder aImapMailFolder,
+  void biff(in nsIMsgFolder aImapMailFolder,
             in nsIUrlListener aUrlListener,
             out nsIURI aURL,
             in unsigned long aUidHighWater);
 
-  void deleteMessages(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aImapMailFolder,
+  void deleteMessages(in nsIMsgFolder aImapMailFolder,
                       in nsIUrlListener aUrlListener,
                       out nsIURI aURL,
                       in ACString aMessageIdentifierList,
                       in boolean aMessageIdsAreUID);
 
-  void deleteAllMessages(in nsIEventTarget aClientEventTarget,
-                         in nsIMsgFolder aImapMailFolder,
+  void deleteAllMessages(in nsIMsgFolder aImapMailFolder,
                          in nsIUrlListener aUrlListener,
                          out nsIURI aURL);
 
-  void addMessageFlags(in nsIEventTarget aClientEventTarget,
-                         in nsIMsgFolder aImapMailFolder,
-                         in nsIUrlListener aUrlListener,
-                         out nsIURI aURL,
-                         in ACString aMessageIdentifierList,
-                         in imapMessageFlagsType aFlags,
-                         in boolean aMessageIdsAreUID);
+  void addMessageFlags(in nsIMsgFolder aImapMailFolder,
+                       in nsIUrlListener aUrlListener,
+                       out nsIURI aURL,
+                       in ACString aMessageIdentifierList,
+                       in imapMessageFlagsType aFlags,
+                       in boolean aMessageIdsAreUID);
 
-  void subtractMessageFlags(in nsIEventTarget aClientEventTarget,
-                            in nsIMsgFolder aImapMailFolder,
+  void subtractMessageFlags(in nsIMsgFolder aImapMailFolder,
                             in nsIUrlListener aUrlListener,
                             out nsIURI aURL,
                             in ACString aMessageIdentifierList,
                             in imapMessageFlagsType aFlags,
                             in boolean aMessageIdsAreUID);
 
-  void setMessageFlags(in nsIEventTarget aClientEventTarget,
-                       in nsIMsgFolder aImapMailFolder,
+  void setMessageFlags(in nsIMsgFolder aImapMailFolder,
                        in nsIUrlListener aUrlListener,
                        out nsIURI aURL,
                        in ACString aMessageIdentifierList,
                        in imapMessageFlagsType aFlags,
                        in boolean aMessageIdsAreUID);
 
-  void discoverAllFolders(in nsIEventTarget aClientEventTarget,
-                          in nsIMsgFolder aImapMailFolder,
+  void discoverAllFolders(in nsIMsgFolder aImapMailFolder,
                           in nsIUrlListener aUrlListener,
                           in nsIMsgWindow aMsgWindow,
                           out nsIURI aURL);
 
-  void discoverAllAndSubscribedFolders(in nsIEventTarget aClientEventTarget,
-                                       in nsIMsgFolder aImapMailFolder,
+  void discoverAllAndSubscribedFolders(in nsIMsgFolder aImapMailFolder,
                                        in nsIUrlListener aUrlListener,
                                        out nsIURI aURL);
-  void discoverChildren(in nsIEventTarget aClientEventTarget,
-                        in nsIMsgFolder aImapMailFolder,
+
+  void discoverChildren(in nsIMsgFolder aImapMailFolder,
                         in nsIUrlListener aUrlListener,
                         in ACString folderPath,
                         out nsIURI aURL);
 
-  void onlineMessageCopy(in nsIEventTarget aClientEventTarget,
-                         in nsIMsgFolder aSrcFolder,
+  void onlineMessageCopy(in nsIMsgFolder aSrcFolder,
                          in ACString aMessageIds,
                          in nsIMsgFolder aDstFolder,
                          in boolean aIdsAreUids,
                          in boolean aIsMove,
                          in nsIUrlListener aUrlListener,
                          out nsIURI aURL,
                          in nsISupports aCopyState,
                          in nsIMsgWindow aWindow);
 
 
-  void appendMessageFromFile(in nsIEventTarget aClientEventTarget,
-                             in nsIFile aFile,
+  void appendMessageFromFile(in nsIFile aFile,
                              in nsIMsgFolder aDstFolder,
                              in ACString aMessageId,
                              in boolean idsAreUids,
                              in boolean aInSelectedState,
                              in nsIUrlListener aUrlListener,
                              out nsIURI aURL,
                              in nsISupports aCopyState,
                              in nsIMsgWindow aMsgWindow);
 
   void downloadMessagesForOffline(in ACString aMessageIds, in nsIMsgFolder aSrcFolder,
                       in nsIUrlListener aListener, in nsIMsgWindow   aMsgWindow);
 
-  nsIURI moveFolder(in nsIEventTarget aClientEventTarget,
-                    in nsIMsgFolder aSrcFolder,
+  nsIURI moveFolder(in nsIMsgFolder aSrcFolder,
                     in nsIMsgFolder aDstFolder,
                     in nsIUrlListener aUrlListener,
                     in nsIMsgWindow msgWindow);
 
-  nsIURI renameLeaf(in nsIEventTarget aClientEventTarget,
-                    in nsIMsgFolder aSrcFolder,
+  nsIURI renameLeaf(in nsIMsgFolder aSrcFolder,
                     in AString aLeafName,
                     in nsIUrlListener aUrlListener,
                     in nsIMsgWindow msgWindow);
 
-  nsIURI deleteFolder(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aFolder,
+  nsIURI deleteFolder(in nsIMsgFolder aFolder,
                       in nsIUrlListener aUrlListener,
                       in nsIMsgWindow aMsgWindow);
 
-  nsIURI createFolder(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aParentFolder,
+  nsIURI createFolder(in nsIMsgFolder aParentFolder,
                       in AString aLeafName,
                       in nsIUrlListener aUrlListener);
 
-  nsIURI listFolder(in nsIEventTarget aClientEventTarget,
-                    in nsIMsgFolder aMailFolder,
+  nsIURI listFolder(in nsIMsgFolder aMailFolder,
                     in nsIUrlListener aUrlListener);
 
-  nsIURI subscribeFolder(in nsIEventTarget aClientEventTarget,
-                         in nsIMsgFolder aMailFolder,
+  nsIURI subscribeFolder(in nsIMsgFolder aMailFolder,
                          in AString mailboxName,
                          in nsIUrlListener aUrlListener);
 
-  nsIURI unsubscribeFolder(in nsIEventTarget aClientEventTarget,
-                           in nsIMsgFolder aMailFolder,
+  nsIURI unsubscribeFolder(in nsIMsgFolder aMailFolder,
                            in AString mailboxName,
                            in nsIUrlListener aUrlListener);
 
   // this method will first check if the folder exists but is
   // not subscribed to, in which case it will subscribe to the folder.
   // otherwise, it will try to create the folder. It will try to do this
   // with one url.
-  nsIURI ensureFolderExists(in nsIEventTarget aClientEventTarget,
-                            in nsIMsgFolder aParentFolder,
+  nsIURI ensureFolderExists(in nsIMsgFolder aParentFolder,
                             in AString aLeafName,
                             in nsIUrlListener aUrlListener);
 
 
-  nsIURI getFolderAdminUrl(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aMailFolder,
-                      in nsIMsgWindow   aMsgWindow,
-                      in nsIUrlListener aUrlListener);
+  nsIURI getFolderAdminUrl(in nsIMsgFolder aMailFolder,
+                           in nsIMsgWindow   aMsgWindow,
+                           in nsIUrlListener aUrlListener);
 
-  nsIURI issueCommandOnMsgs(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aMailFolder,
-                      in nsIMsgWindow aMsgWindow,
-                      in ACString aCommand,
-                      in ACString aMessageIdentifierList);
+  nsIURI issueCommandOnMsgs(in nsIMsgFolder aMailFolder,
+                            in nsIMsgWindow aMsgWindow,
+                            in ACString aCommand,
+                            in ACString aMessageIdentifierList);
 
-  nsIURI fetchCustomMsgAttribute(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aMailFolder,
-                      in nsIMsgWindow aMsgWindow,
-                      in ACString aAttribute,
-                      in ACString aMessageIdentifierList);
+  nsIURI fetchCustomMsgAttribute(in nsIMsgFolder aMailFolder,
+                                 in nsIMsgWindow aMsgWindow,
+                                 in ACString aAttribute,
+                                 in ACString aMessageIdentifierList);
 
-  nsIURI storeCustomKeywords(in nsIEventTarget aClientEventTarget,
-                      in nsIMsgFolder aMailFolder,
-                      in nsIMsgWindow aMsgWindow,
-                      in ACString flagsToAdd,
-                      in ACString flagsToSubtract,
-                      in ACString aMessageIdentifierList);
+  nsIURI storeCustomKeywords(in nsIMsgFolder aMailFolder,
+                             in nsIMsgWindow aMsgWindow,
+                             in ACString flagsToAdd,
+                             in ACString flagsToSubtract,
+                             in ACString aMessageIdentifierList);
 
   void getListOfFoldersOnServer(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow);
   void getListOfFoldersWithPath(in nsIImapIncomingServer aServer, in nsIMsgWindow aMsgWindow, in ACString folderPath);
 
   nsISupports playbackAllOfflineOperations(in nsIMsgWindow aMsgWindow, in nsIUrlListener aListener);
   void downloadAllOffineImapFolders(in nsIMsgWindow aMsgWindow, in nsIUrlListener aListener);
 
   readonly attribute nsICacheSession cacheSession;
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -436,23 +436,22 @@ nsImapIncomingServer::SetIsAOLServer(boo
   if (aBool)
     m_capability |= kAOLImapCapability;
   else
     m_capability &= ~kAOLImapCapability;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventTarget * aClientEventTarget,
-                                                  nsIImapUrl* aImapUrl,
+nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIImapUrl* aImapUrl,
                                                   nsISupports* aConsumer)
 {
   nsCOMPtr<nsIImapProtocol> aProtocol;
 
-  nsresult rv = GetImapConnection(aClientEventTarget, aImapUrl, getter_AddRefs(aProtocol));
+  nsresult rv = GetImapConnection(aImapUrl, getter_AddRefs(aProtocol));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(aImapUrl, &rv);
   if (aProtocol)
   {
     rv = aProtocol->LoadImapUrl(mailnewsurl, aConsumer);
     // *** jt - in case of the time out situation or the connection gets
     // terminated by some unforseen problems let's give it a second chance
@@ -460,17 +459,17 @@ nsImapIncomingServer::GetImapConnectionA
     if (NS_FAILED(rv))
     {
       NS_ASSERTION(false, "shouldn't get an error loading url");
       rv = aProtocol->LoadImapUrl(mailnewsurl, aConsumer);
     }
   }
   else
   {   // unable to get an imap connection to run the url; add to the url
-    // queue
+     // queue
     nsImapProtocol::LogImapUrl("queuing url", aImapUrl);
     PR_CEnterMonitor(this);
     m_urlQueue.AppendObject(aImapUrl);
     m_urlConsumers.AppendElement((void*)aConsumer);
     NS_IF_ADDREF(aConsumer);
     PR_CExitMonitor(this);
     // let's try running it now - maybe the connection is free now.
     bool urlRun;
@@ -506,17 +505,17 @@ NS_IMETHODIMP
 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);
   nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-  rv = GetImapConnection(thread, aImapUrl, getter_AddRefs(protocolInstance));
+  rv = GetImapConnection(aImapUrl, getter_AddRefs(protocolInstance));
   if (NS_SUCCEEDED(rv) && protocolInstance)
   {
     nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
     if (NS_SUCCEEDED(rv) && url)
     {
       nsImapProtocol::LogImapUrl("retrying  url", aImapUrl);
       rv = protocolInstance->LoadImapUrl(url, nsnull); // ### need to save the display consumer.
       NS_ASSERTION(NS_SUCCEEDED(rv), "failed running queued url");
@@ -526,16 +525,19 @@ nsImapIncomingServer::RetryUrl(nsIImapUr
 }
 
 // checks to see if there are any queued urls on this incoming server,
 // and if so, tries to run the oldest one. Returns true if the url is run
 // on the passed in protocol connection.
 NS_IMETHODIMP
 nsImapIncomingServer::LoadNextQueuedUrl(nsIImapProtocol *aProtocol, bool *aResult)
 {
+  if (WeAreOffline())
+    return NS_MSG_ERROR_OFFLINE;
+
   nsresult rv = NS_OK;
   bool urlRun = false;
   bool keepGoing = true;
   nsCOMPtr <nsIImapProtocol>  protocolInstance ;
 
   MutexAutoLock mon(mLock);
   PRInt32 cnt = m_urlQueue.Count();
 
@@ -552,17 +554,17 @@ nsImapIncomingServer::LoadNextQueuedUrl(
       NS_ENSURE_SUCCESS(rv, rv);
       // if we didn't doom the url, lets run it.
       if (!removeUrlFromQueue)
       {
         nsISupports *aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
         NS_IF_ADDREF(aConsumer);
 
         nsImapProtocol::LogImapUrl("creating protocol instance to play queued url", aImapUrl);
-        rv = GetImapConnection(nsnull, aImapUrl, getter_AddRefs(protocolInstance));
+        rv = GetImapConnection(aImapUrl, getter_AddRefs(protocolInstance));
         if (NS_SUCCEEDED(rv) && protocolInstance)
         {
           nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
           if (NS_SUCCEEDED(rv) && url)
           {
             nsImapProtocol::LogImapUrl("playing queued url", aImapUrl);
             rv = protocolInstance->LoadImapUrl(url, aConsumer);
             NS_ASSERTION(NS_SUCCEEDED(rv), "failed running queued url");
@@ -712,19 +714,18 @@ nsImapIncomingServer::ConnectionTimeOut(
         aProtocol->TellThreadToDie(false);
         retVal = true;
       }
   }
   return retVal;
 }
 
 nsresult
-nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
-                                           nsIImapUrl * aImapUrl,
-                                           nsIImapProtocol ** aImapConnection)
+nsImapIncomingServer::GetImapConnection(nsIImapUrl * aImapUrl,
+                                        nsIImapProtocol ** aImapConnection)
 {
   nsresult rv = NS_OK;
   bool canRunUrlImmediately = false;
   bool canRunButBusy = false;
   nsCOMPtr<nsIImapProtocol> connection;
   nsCOMPtr<nsIImapProtocol> freeConnection;
   bool isBusy = false;
   bool isInboxConnection = false;
@@ -838,19 +839,19 @@ nsImapIncomingServer::GetImapConnection(
   else if (userCancelled)
   {
     rv = NS_BINDING_ABORTED;  // user cancelled
   }
   // CanHandleUrl will pretend that some types of urls require a selected state url
   // (e.g., a folder delete or msg append) but we shouldn't create new connections
   // for these types of urls if we have a free connection. So we check the actual
   // required state here.
-  else if (cnt < maxConnections && aEventTarget
+  else if (cnt < maxConnections
       && (!freeConnection || requiredState == nsIImapUrl::nsImapSelectedState))
-    rv = CreateProtocolInstance(aEventTarget, aImapConnection);
+    rv = CreateProtocolInstance(aImapConnection);
   else if (freeConnection)
   {
     *aImapConnection = freeConnection;
     NS_IF_ADDREF(*aImapConnection);
   }
   else // cannot get anyone to handle the url queue it
   {
     if (cnt >= maxConnections)
@@ -858,18 +859,17 @@ nsImapIncomingServer::GetImapConnection(
       // caller will queue the url
   }
 
   PR_CExitMonitor(this);
   return rv;
 }
 
 nsresult
-nsImapIncomingServer::CreateProtocolInstance(nsIEventTarget *aEventTarget,
-                                             nsIImapProtocol ** aImapConnection)
+nsImapIncomingServer::CreateProtocolInstance(nsIImapProtocol ** aImapConnection)
 {
   // create a new connection and add it to the connection cache
   // we may need to flag the protocol connection as busy so we don't get
   // a race condition where someone else goes through this code
 
   PRInt32 authMethod;
   GetAuthMethod(&authMethod);
   nsresult rv;
@@ -890,17 +890,17 @@ nsImapIncomingServer::CreateProtocolInst
   }
   nsIImapProtocol * protocolInstance;
   rv = CallCreateInstance(kImapProtocolCID, &protocolInstance);
   if (NS_SUCCEEDED(rv) && protocolInstance)
   {
     nsCOMPtr<nsIImapHostSessionList> hostSession =
       do_GetService(kCImapHostSessionListCID, &rv);
     if (NS_SUCCEEDED(rv))
-      rv = protocolInstance->Initialize(hostSession, this, aEventTarget);
+      rv = protocolInstance->Initialize(hostSession, this);
   }
 
   // take the protocol instance and add it to the connectionCache
   if (protocolInstance)
     m_connectionCache.AppendObject(protocolInstance);
   *aImapConnection = protocolInstance; // this is already ref counted.
   return rv;
 }
@@ -991,17 +991,17 @@ nsImapIncomingServer::PerformExpand(nsIM
   rv = GetRootFolder(getter_AddRefs(rootMsgFolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!rootMsgFolder) return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-  rv = imapService->DiscoverAllFolders(thread, rootMsgFolder,
+  rv = imapService->DiscoverAllFolders(rootMsgFolder,
                                        this, aMsgWindow, nsnull);
   return rv;
 }
 
 NS_IMETHODIMP
 nsImapIncomingServer::VerifyLogon(nsIUrlListener *aUrlListener,
                                   nsIMsgWindow *aMsgWindow, nsIURI **aURL)
 {
@@ -2565,19 +2565,19 @@ nsImapIncomingServer::SubscribeToFolder(
 
   nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
 
   nsAutoString unicodeName;
   rv = CopyMUTF7toUTF16(folderCName, unicodeName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (subscribe)
-    rv = imapService->SubscribeFolder(thread, msgFolder, unicodeName, nsnull, aUri);
+    rv = imapService->SubscribeFolder(msgFolder, unicodeName, nsnull, aUri);
   else
-    rv = imapService->UnsubscribeFolder(thread, msgFolder, unicodeName, nsnull, nsnull);
+    rv = imapService->UnsubscribeFolder(msgFolder, unicodeName, nsnull, nsnull);
   return rv;
 }
 
 NS_IMETHODIMP
 nsImapIncomingServer::SetDoingLsub(bool doingLsub)
 {
   mDoingLsub = doingLsub;
   return NS_OK;
--- a/mailnews/imap/src/nsImapIncomingServer.h
+++ b/mailnews/imap/src/nsImapIncomingServer.h
@@ -45,17 +45,16 @@
 #include "nsIImapServerSink.h"
 #include "nsIStringBundle.h"
 #include "nsISubscribableServer.h"
 #include "nsIUrlListener.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsCOMArray.h"
 #include "mozilla/Mutex.h"
 
-class nsIEventTarget;
 class nsIRDFService;
 
 /* get some implementation from nsMsgIncomingServer */
 class nsImapIncomingServer : public nsMsgIncomingServer,
                              public nsIImapIncomingServer,
                              public nsIImapServerSink,
                              public nsISubscribableServer,
                              public nsIUrlListener
@@ -114,21 +113,19 @@ protected:
   bool AllDescendentsAreNoSelect(nsIMsgFolder *parentFolder);
 
   nsresult GetStringBundle();
   nsString GetImapStringByName(const nsString &aName);
   static nsresult AlertUser(const nsAString& aString, nsIMsgMailNewsUrl *aUrl);
 
 private:
   nsresult SubscribeToFolder(const PRUnichar *aName, bool subscribe);
-  nsresult GetImapConnection (nsIEventTarget* aEventTarget,
-                                   nsIImapUrl* aImapUrl,
-                                   nsIImapProtocol** aImapConnection);
-  nsresult CreateProtocolInstance(nsIEventTarget *aEventTarget,
-                                           nsIImapProtocol ** aImapConnection);
+  nsresult GetImapConnection(nsIImapUrl* aImapUrl,
+                             nsIImapProtocol** aImapConnection);
+  nsresult CreateProtocolInstance(nsIImapProtocol ** aImapConnection);
   nsresult CreateHostSpecificPrefName(const char *prefPrefix, nsCAutoString &prefName);
 
   nsresult DoomUrlIfChannelHasError(nsIImapUrl *aImapUrl, bool *urlDoomed);
   bool ConnectionTimeOut(nsIImapProtocol* aImapConnection);
   nsresult GetFormattedStringFromID(const nsAString& aValue, PRInt32 aID, nsAString& aResult);
   nsresult GetPrefForServerAttribute(const char *prefSuffix, bool *prefValue);
   bool CheckSpecialFolder(nsIRDFService *rdf, nsCString &folderUri,
                             PRUint32 folderFlag, nsCString &existingUri);
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -230,17 +230,16 @@ nsImapMailFolder::nsImapMailFolder() :
     m_folderQuotaMaxKB(0),
     m_compactingOfflineStore(false),
     m_expunging(false),
     m_applyIncomingFilters(false),
     m_filterListRequiresBody(false)
 {
   MOZ_COUNT_CTOR(nsImapMailFolder); // double count these for now.
 
-  m_thread = do_GetCurrentThread();
   m_moveCoalescer = nsnull;
   m_boxFlags = 0;
   m_uidValidity = kUidUnknown;
   m_numServerRecentMessages = 0;
   m_numServerUnseenMessages = 0;
   m_numServerTotalMessages = 0;
   m_nextUID = nsMsgKey_None;
   m_hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
@@ -845,17 +844,17 @@ NS_IMETHODIMP nsImapMailFolder::UpdateFo
     selectFolder = false;
   // don't run select if we can't select the folder...
   if (NS_SUCCEEDED(rv) && !m_urlRunning && selectFolder)
   {
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr <nsIURI> url;
-    rv = imapService->SelectFolder(m_thread, this, m_urlListener, aMsgWindow, getter_AddRefs(url));
+    rv = imapService->SelectFolder(this, m_urlListener, aMsgWindow, getter_AddRefs(url));
     if (NS_SUCCEEDED(rv))
     {
       m_urlRunning = true;
       m_updatingFolder = true;
     }
     if (url)
     {
       nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(url, &rv);
@@ -910,17 +909,17 @@ NS_IMETHODIMP nsImapMailFolder::CreateSu
   {
     ThrowAlertMsg("folderExists", msgWindow);
     return NS_MSG_FOLDER_EXISTS;
   }
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  return imapService->CreateFolder(m_thread, this, folderName, this, nsnull);
+  return imapService->CreateFolder(this, folderName, this, nsnull);
 }
 
 NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const nsACString& folderName,
                                                           char hierarchyDelimiter,
                                                           PRInt32 flags,
                                                           bool suppressNotification)
 {
   nsresult rv = NS_OK;
@@ -1044,17 +1043,17 @@ NS_IMETHODIMP nsImapMailFolder::CreateCl
   return rv;
 }
 
 NS_IMETHODIMP nsImapMailFolder::List()
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  return imapService->ListFolder(m_thread, this, this, nsnull);
+  return imapService->ListFolder(this, this, nsnull);
 }
 
 NS_IMETHODIMP nsImapMailFolder::RemoveSubFolder (nsIMsgFolder *which)
 {
   nsresult rv;
   nsCOMPtr<nsIMutableArray> folders(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_TRUE(folders, rv);
   nsCOMPtr<nsISupports> folderSupport = do_QueryInterface(which, &rv);
@@ -1098,17 +1097,17 @@ NS_IMETHODIMP nsImapMailFolder::CreateSt
   if (msgParent)
   {
     nsString folderName;
     GetName(folderName);
     nsresult rv;
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr <nsIURI> uri;
-    imapService->EnsureFolderExists(m_thread, msgParent, folderName, urlListener, getter_AddRefs(uri));
+    imapService->EnsureFolderExists(msgParent, folderName, urlListener, getter_AddRefs(uri));
   }
   return rv;
 }
 
 
 NS_IMETHODIMP nsImapMailFolder::GetVerifiedAsOnlineFolder(bool *aVerifiedAsOnlineFolder)
 {
   NS_ENSURE_ARG_POINTER(aVerifiedAsOnlineFolder);
@@ -1382,17 +1381,17 @@ NS_IMETHODIMP nsImapMailFolder::MarkPend
 
 NS_IMETHODIMP nsImapMailFolder::Expunge(nsIUrlListener *aListener,
                                         nsIMsgWindow *aMsgWindow)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return imapService->Expunge(m_thread, this, aListener, aMsgWindow, nsnull);
+  return imapService->Expunge(this, aListener, aMsgWindow, nsnull);
 }
 
 NS_IMETHODIMP nsImapMailFolder::CompactAll(nsIUrlListener *aListener,
                                                nsIMsgWindow *aMsgWindow,
                                                bool aCompactOfflineAlso)
 {
   nsresult rv;
   nsCOMPtr<nsIMutableArray> folderArray, offlineFolderArray;
@@ -1443,17 +1442,17 @@ NS_IMETHODIMP nsImapMailFolder::CompactA
 
 NS_IMETHODIMP nsImapMailFolder::UpdateStatus(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr <nsIURI> uri;
-  rv = imapService->UpdateFolderStatus(m_thread, this, aListener, getter_AddRefs(uri));
+  rv = imapService->UpdateFolderStatus(this, aListener, getter_AddRefs(uri));
   if (uri && !aMsgWindow)
   {
     nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(uri, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     // if no msg window, we won't put up error messages (this is almost certainly a biff-inspired status)
     mailNewsUrl->SetSuppressErrorMsgs(true);
   }
   return rv;
@@ -1570,21 +1569,21 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTra
                                           nsnull, nsnull, nsnull, nsnull, &dummyValue, &dlgResult);
           }
           if (NS_SUCCEEDED(rv) && dlgResult == 1)
             return NS_BINDING_ABORTED;
         }
       }
     }
     if (aListener)
-      rv = imapService->DeleteAllMessages(m_thread, trashFolder, aListener, nsnull);
+      rv = imapService->DeleteAllMessages(trashFolder, aListener, nsnull);
     else
     {
       nsCOMPtr<nsIUrlListener> urlListener = do_QueryInterface(trashFolder);
-      rv = imapService->DeleteAllMessages(m_thread, trashFolder, urlListener, nsnull);
+      rv = imapService->DeleteAllMessages(trashFolder, urlListener, nsnull);
     }
     // return an error if this failed. We want the empty trash on exit code
     // to know if this fails so that it doesn't block waiting for empty trash to finish.
     if (NS_FAILED(rv))
       return rv;
 
     if (hasSubfolders)
     {
@@ -1698,17 +1697,17 @@ NS_IMETHODIMP nsImapMailFolder::Rename (
   }
   nsCOMPtr <nsIImapIncomingServer> incomingImapServer;
   GetImapIncomingServer(getter_AddRefs(incomingImapServer));
   if (incomingImapServer)
     RecursiveCloseActiveConnections(incomingImapServer);
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  return imapService->RenameLeaf(m_thread, this, newName, this, msgWindow, nsnull);
+  return imapService->RenameLeaf(this, newName, this, msgWindow, nsnull);
 }
 
 NS_IMETHODIMP nsImapMailFolder::RecursiveCloseActiveConnections(nsIImapIncomingServer *incomingImapServer)
 {
   NS_ENSURE_ARG(incomingImapServer);
 
   nsCOMPtr<nsIMsgImapMailFolder> folder;
   PRInt32 count = mSubFolders.Count();
@@ -2302,17 +2301,17 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMe
 
   if ((NS_SUCCEEDED(rv) && deleteImmediatelyNoTrash) || deleteModel == nsMsgImapDeleteModels::IMAPDelete )
   {
     if (allowUndo)
     {
       //need to take care of these two delete models
       nsRefPtr<nsImapMoveCopyMsgTxn> undoMsgTxn = new nsImapMoveCopyMsgTxn;
       if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(this, &srcKeyArray, messageIds.get(), nsnull,
-                                                      true, isMove, m_thread)))
+                                                    true, isMove)))
         return NS_ERROR_OUT_OF_MEMORY;
 
       undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
       // we're adding this undo action before the delete is successful. This is evil,
       // but 4.5 did it as well.
       nsCOMPtr <nsITransactionManager> txnMgr;
       if (msgWindow)
         msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
@@ -2535,34 +2534,32 @@ nsImapMailFolder::DeleteSubFolders(nsIAr
   {
     for (i = 0; i < folderCount; i++)
     {
       curFolder = do_QueryElementAt(foldersRemaining, i, &rv);
       if (NS_SUCCEEDED(rv))
       {
         urlListener = do_QueryInterface(curFolder);
         if (deleteNoTrash)
-          rv = imapService->DeleteFolder(m_thread,
-                                         curFolder,
+          rv = imapService->DeleteFolder(curFolder,
                                          urlListener,
                                          msgWindow,
                                          nsnull);
         else
         {
           bool confirm = false;
           bool match = false;
           rv = curFolder->MatchOrChangeFilterDestination(nsnull, false, &match);
           if (match)
           {
             curFolder->ConfirmFolderDeletionForFilter(msgWindow, &confirm);
             if (!confirm)
               return NS_OK;
           }
-          rv = imapService->MoveFolder(m_thread,
-                                       curFolder,
+          rv = imapService->MoveFolder(curFolder,
                                        trashFolder,
                                        urlListener,
                                        msgWindow,
                                        nsnull);
         }
       }
     }
   }
@@ -3408,18 +3405,17 @@ NS_IMETHODIMP nsImapMailFolder::EndCopy(
     m_copyState->m_tmpFile = tmpFile;
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));
     nsCOMPtr<nsISupports> copySupport;
     if (m_copyState)
       copySupport = do_QueryInterface(m_copyState);
-    rv = imapService->AppendMessageFromFile(m_thread,
-                                            m_copyState->m_tmpFile,
+    rv = imapService->AppendMessageFromFile(m_copyState->m_tmpFile,
                                             this, EmptyCString(), true,
                                             m_copyState->m_selectedState,
                                             urlListener, nsnull,
                                             copySupport,
                                             m_copyState->m_msgWindow);
   }
   if (NS_FAILED(rv) || !copySucceeded)
     PR_LOG(IMAP, PR_LOG_ALWAYS, ("EndCopy failed:%lx\n", rv));
@@ -3821,26 +3817,26 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFil
 }
 
 NS_IMETHODIMP nsImapMailFolder::SetImapFlags(const char *uids, PRInt32 flags, nsIURI **url)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  return imapService->SetMessageFlags(m_thread, this, this, url, nsCAutoString(uids), flags, true);
+  return imapService->SetMessageFlags(this, this, url, nsCAutoString(uids), flags, true);
 }
 
 // "this" is the parent folder
 NS_IMETHODIMP nsImapMailFolder::PlaybackOfflineFolderCreate(const nsAString& aFolderName, nsIMsgWindow *aWindow, nsIURI **url)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  return imapService->CreateFolder(m_thread, this, aFolderName, this, url);
+  return imapService->CreateFolder(this, aFolderName, this, url);
 }
 
 NS_IMETHODIMP 
 nsImapMailFolder::ReplayOfflineMoveCopy(nsMsgKey *aMsgKeys, PRUint32 aNumKeys,
                                         bool isMove, nsIMsgFolder *aDstFolder,
                                         nsIUrlListener *aUrlListener, nsIMsgWindow *aWindow)
 {
   nsresult rv;
@@ -3901,17 +3897,17 @@ nsImapMailFolder::ReplayOfflineMoveCopy(
     // the offline move/copy.
   }
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr <nsIURI> resultUrl;
   nsCAutoString uids;
   AllocateUidStringFromKeys(aMsgKeys, aNumKeys, uids);
-  rv = imapService->OnlineMessageCopy(m_thread, this, uids, aDstFolder,
+  rv = imapService->OnlineMessageCopy(this, uids, aDstFolder,
                                       true, isMove, aUrlListener,
                                       getter_AddRefs(resultUrl), nsnull, aWindow);
   if (resultUrl)
   {
     nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(resultUrl, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr <nsIUrlListener> folderListener = do_QueryInterface(aDstFolder);
     if (folderListener)
@@ -3943,20 +3939,20 @@ NS_IMETHODIMP nsImapMailFolder::StoreIma
   nsresult rv;
   if (!WeAreOffline())
   {
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCAutoString msgIds;
     AllocateUidStringFromKeys(keys, numKeys, msgIds);
     if (addFlags)
-      imapService->AddMessageFlags(m_thread, this, aUrlListener ? aUrlListener : this,
+      imapService->AddMessageFlags(this, aUrlListener ? aUrlListener : this,
                                    nsnull, msgIds, flags, true);
     else
-      imapService->SubtractMessageFlags(m_thread, this, aUrlListener ? aUrlListener : this,
+      imapService->SubtractMessageFlags(this, aUrlListener ? aUrlListener : this,
                                         nsnull, msgIds, flags, true);
   }
   else
   {
     GetDatabase();
     if (mDatabase)
     {
       PRUint32 total = numKeys;
@@ -3979,17 +3975,17 @@ NS_IMETHODIMP nsImapMailFolder::StoreIma
 }
 
 NS_IMETHODIMP nsImapMailFolder::LiteSelect(nsIUrlListener *aUrlListener,
                                            nsIMsgWindow *aMsgWindow)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
-  return imapService->LiteSelectFolder(m_thread, this, aUrlListener,
+  return imapService->LiteSelectFolder(this, aUrlListener,
                                        aMsgWindow, nsnull);
 }
 
 nsresult nsImapMailFolder::GetFolderOwnerUserName(nsACString& userName)
 {
   if ((mFlags & nsMsgFolderFlags::ImapPersonal) ||
     !(mFlags & (nsMsgFolderFlags::ImapPublic | nsMsgFolderFlags::ImapOtherUser)))
   {
@@ -4078,17 +4074,17 @@ NS_IMETHODIMP nsImapMailFolder::FolderPr
           return extProtService->LoadUrl(uri);
       }
     }
   }
   else
   {
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
-    rv = imapService->GetFolderAdminUrl(m_thread, this, window, this, nsnull);
+    rv = imapService->GetFolderAdminUrl(this, window, this, nsnull);
     if (NS_SUCCEEDED(rv))
       m_urlRunning = true;
   }
   return rv;
 }
 
 NS_IMETHODIMP nsImapMailFolder::GetHasAdminUrl(bool *aBool)
 {
@@ -4123,26 +4119,26 @@ NS_IMETHODIMP nsImapMailFolder::GetHdrPa
 
   // this is used to issue an arbitrary imap command on the passed in msgs.
   // It assumes the command needs to be run in the selected state.
 NS_IMETHODIMP nsImapMailFolder::IssueCommandOnMsgs(const nsACString& command, const char *uids, nsIMsgWindow *aWindow, nsIURI **url)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  return imapService->IssueCommandOnMsgs(m_thread, this, aWindow, command, nsDependentCString(uids), url);
+  return imapService->IssueCommandOnMsgs(this, aWindow, command, nsDependentCString(uids), url);
 }
 
 NS_IMETHODIMP nsImapMailFolder::FetchCustomMsgAttribute(const nsACString& attribute, const char *uids, nsIMsgWindow *aWindow, nsIURI **url)
 {
   nsresult rv;
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  return imapService->FetchCustomMsgAttribute(m_thread, this, aWindow, attribute, nsDependentCString(uids), url);
+  return imapService->FetchCustomMsgAttribute(this, aWindow, attribute, nsDependentCString(uids), url);
 }
 
 nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
                                                    nsIMsgDatabase *sourceDB,
                                                    const nsACString& destFolderUri,
                                                    nsIMsgFilter *filter,
                                                    nsIMsgWindow *msgWindow)
 {
@@ -4568,17 +4564,17 @@ NS_IMETHODIMP nsImapMailFolder::Download
       return rv;
     }
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Selecting the folder with nsIImapUrl::shouldStoreMsgOffline true will
     // cause us to fetch any message bodies we don't have.
     m_urlListener = listener;
-    rv = imapService->SelectFolder(m_thread, this, this, msgWindow,
+    rv = imapService->SelectFolder(this, this, msgWindow,
                                    getter_AddRefs(runningURI));
     if (NS_SUCCEEDED(rv))
     {
       nsCOMPtr<nsIImapUrl> imapUrl(do_QueryInterface(runningURI));
       if (imapUrl)
         imapUrl->SetStoreResultsOffline(true);
       m_urlRunning = true;
     }
@@ -4736,17 +4732,17 @@ nsImapMailFolder::OnlineCopyCompleted(ns
     if (NS_FAILED(rv)) return rv;
     if (action != nsIImapUrl::nsImapOnlineToOfflineMove)
       return NS_ERROR_FAILURE; // don't assert here...
     nsCString messageIds;
     rv = imapUrl->GetListOfMessageIds(messageIds);
     if (NS_FAILED(rv)) return rv;
     nsCOMPtr<nsIImapService> imapService =  do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
-    return imapService->AddMessageFlags(m_thread, this, nsnull, nsnull,
+    return imapService->AddMessageFlags(this, nsnull, nsnull,
                                       messageIds,
                                       kImapMsgDeletedFlag,
                                       true);
   }
   /* unhandled copystate */
   else if (m_copyState) // whoops, this is the wrong folder - should use the source folder
   {
     nsCOMPtr<nsIMsgFolder> srcFolder;
@@ -6862,17 +6858,17 @@ nsImapMailFolder::CopyMessagesWithStream
   {
     nsCAutoString messageIds;
     nsTArray<nsMsgKey> srcKeyArray;
     rv = BuildIdsAndKeyArray(messages, messageIds, srcKeyArray);
 
     nsRefPtr<nsImapMoveCopyMsgTxn> undoMsgTxn = new nsImapMoveCopyMsgTxn;
 
     if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(srcFolder, &srcKeyArray, messageIds.get(), this,
-                                true, isMove, m_thread)))
+                                true, isMove)))
       return NS_ERROR_OUT_OF_MEMORY;
 
     if (isMove)
     {
       if (mFlags & nsMsgFolderFlags::Trash)
         undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
       else
         undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
@@ -7196,17 +7192,17 @@ nsresult nsImapMailFolder::CopyMessagesO
               sourceOp->AddMessageCopyOperation(folderURI.get()); // offline copy
 
             nsTArray<nsMsgKey> srcKeyArray;
 
             srcKeyArray.AppendElement(originalKey);
             sourceOp->GetOperation(&opType);
             nsRefPtr<nsImapOfflineTxn> undoMsgTxn = new
               nsImapOfflineTxn(srcFolder, &srcKeyArray, messageId.get(), this, 
-                               isMove, opType, message, m_thread);
+                               isMove, opType, message);
             if (undoMsgTxn)
             {
               if (isMove)
               {
                 undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
                 nsCOMPtr<nsIMsgImapMailFolder> srcIsImap(do_QueryInterface(srcFolder));
                 // remember this undo transaction so we can hook up the result
                 // msg ids in the undo transaction.
@@ -7284,17 +7280,17 @@ nsresult nsImapMailFolder::CopyMessagesO
                 SetFlag(nsMsgFolderFlags::OfflineEvents);
                 destOp->SetSourceFolderURI(originalSrcFolderURI.get());
                 destOp->SetSrcMessageKey(originalKey);
                 {
                   nsTArray<nsMsgKey> keyArray;
                   keyArray.AppendElement(fakeBase + sourceKeyIndex);
                   nsRefPtr<nsImapOfflineTxn> undoMsgTxn = new
                     nsImapOfflineTxn(this, &keyArray, nsnull, this, isMove, nsIMsgOfflineImapOperation::kAddedHeader,
-                      newMailHdr, m_thread);
+                      newMailHdr);
                   if (undoMsgTxn && txnMgr)
                      txnMgr->DoTransaction(undoMsgTxn);
                 }
               }
             }
             else
               stopit = NS_ERROR_FAILURE;
           }
@@ -7305,18 +7301,17 @@ nsresult nsImapMailFolder::CopyMessagesO
           {
             nsTArray<nsMsgKey> srcKeyArray;
             srcKeyArray.AppendElement(msgKey);
             nsOfflineImapOperationType opType = nsIMsgOfflineImapOperation::kDeletedMsg;
             if (!deleteToTrash)
               opType = nsIMsgOfflineImapOperation::kMsgMarkedDeleted;
             srcKeyArray.AppendElement(msgKey);
             nsRefPtr<nsImapOfflineTxn> undoMsgTxn = new
-              nsImapOfflineTxn(srcFolder, &srcKeyArray, messageId.get(), this, isMove, opType, mailHdr,
-                m_thread);
+              nsImapOfflineTxn(srcFolder, &srcKeyArray, messageId.get(), this, isMove, opType, mailHdr);
             if (undoMsgTxn)
             {
               if (isMove)
               {
                 if (mFlags & nsMsgFolderFlags::Trash)
                   undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
                 else
                   undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
@@ -7595,27 +7590,26 @@ nsImapMailFolder::CopyMessages(nsIMsgFol
     if (NS_FAILED(rv)) goto done;
 
     m_copyState->m_curIndex = m_copyState->m_totalCount;
 
     if (isMove)
       srcFolder->EnableNotifications(allMessageCountNotifications, false, true/* dbBatching*/);  //disable message count notification
 
     copySupport = do_QueryInterface(m_copyState);
-    rv = imapService->OnlineMessageCopy(m_thread,
-                                        srcFolder, messageIds,
+    rv = imapService->OnlineMessageCopy(srcFolder, messageIds,
                                         this, true, isMove,
                                         urlListener, nsnull,
                                         copySupport, msgWindow);
     if (NS_SUCCEEDED(rv) && m_copyState->m_allowUndo)
     {
       nsRefPtr<nsImapMoveCopyMsgTxn> undoMsgTxn = new nsImapMoveCopyMsgTxn;
       if (!undoMsgTxn || NS_FAILED(undoMsgTxn->Init(srcFolder, &srcKeyArray,
                                    messageIds.get(), this,
-                                   true, isMove, m_thread)))
+                                   true, isMove)))
         return NS_ERROR_OUT_OF_MEMORY;
 
       if (isMove)
       {
         if (mFlags & nsMsgFolderFlags::Trash)
           undoMsgTxn->SetTransactionType(nsIMessenger::eDeleteMsg);
         else
           undoMsgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
@@ -7692,19 +7686,17 @@ nsImapFolderCopyState::StartNextCopy()
 {
   nsresult rv;
   // first make sure dest folder exists.
   nsCOMPtr <nsIImapService> imapService = do_GetService (NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsString folderName;
   m_curSrcFolder->GetName(folderName);
 
-  nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-  return imapService->EnsureFolderExists(thread,
-                                         m_curDestParent,
+  return imapService->EnsureFolderExists(m_curDestParent,
                                          folderName,
                                          this, nsnull);
 }
 
 nsresult nsImapFolderCopyState::AdvanceToNextFolder(nsresult aStatus)
 {
   nsresult rv;
   m_childIndex++;
@@ -7974,18 +7966,17 @@ nsImapMailFolder::CopyFolder(nsIMsgFolde
         }
       }
       rv = InitCopyState(srcSupport, nsnull, false, nsnull,
                          false, 0, EmptyCString(), listener, 
                          msgWindow, false);
       if (NS_FAILED(rv))
         return OnCopyCompleted(srcSupport, rv);
 
-      rv = imapService->MoveFolder(m_thread,
-                                   srcFolder,
+      rv = imapService->MoveFolder(srcFolder,
                                    this,
                                    this,
                                    msgWindow,
                                    nsnull);
     }
   }
   else // copying folder (should only be across server?)
   {
@@ -8051,18 +8042,17 @@ nsImapMailFolder::CopyFileMessage(nsIFil
       copySupport = do_QueryInterface(m_copyState);
     if (!isDraftOrTemplate)
     {
       m_copyState->m_totalCount = 1;
       // This makes the IMAP APPEND set the INTERNALDATE for the msg copy
       // we make when detaching/deleting attachments to the original msg date.
       m_copyState->m_message = msgToReplace;
     }
-    rv = imapService->AppendMessageFromFile(m_thread, file, this,
-                                            messageId,
+    rv = imapService->AppendMessageFromFile(file, this, messageId,
                                             true, isDraftOrTemplate,
                                             urlListener, nsnull,
                                             copySupport,
                                             msgWindow);
     if (NS_FAILED(rv))
       return OnCopyCompleted(srcSupport, rv);
 
     return rv;
@@ -8621,19 +8611,17 @@ NS_IMETHODIMP nsImapMailFolder::PerformE
   nsCOMPtr<nsIImapIncomingServer> imapServer;
   rv = GetImapIncomingServer(getter_AddRefs(imapServer));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = imapServer->GetUsingSubscription(&usingSubscription);
   if (NS_SUCCEEDED(rv) && !usingSubscription)
   {
     nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = imapService->DiscoverChildren(m_thread, this, this,
-                                       m_onlineFolderName,
-                                       nsnull);
+    rv = imapService->DiscoverChildren( this, this, m_onlineFolderName, nsnull);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsImapMailFolder::RenameClient(nsIMsgWindow *msgWindow, nsIMsgFolder *msgFolder, const nsACString& oldName, const nsACString& newName)
 {
   nsresult rv;
   nsCOMPtr<nsILocalFile> pathFile;
@@ -8940,17 +8928,17 @@ nsImapMailFolder::StoreCustomKeywords(ns
       mDatabase->Commit(nsMsgDBCommitType::kLargeCommit); // flush offline ops
       return rv;
     }
   }
   nsCOMPtr<nsIImapService> imapService(do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   nsCAutoString msgIds;
   AllocateUidStringFromKeys(aKeysToStore, aNumKeys, msgIds);
-  return imapService->StoreCustomKeywords(m_thread, this, aMsgWindow, aFlagsToAdd,
+  return imapService->StoreCustomKeywords(this, aMsgWindow, aFlagsToAdd,
                                           aFlagsToSubtract, msgIds, _retval);
 }
 
 NS_IMETHODIMP nsImapMailFolder::NotifyIfNewMail()
 {
   return PerformBiffNotifications();
 }
 
@@ -9272,17 +9260,17 @@ NS_IMETHODIMP nsImapMailFolder::FetchMsg
     }
   }
   if (!keysToFetchFromServer.IsEmpty())
   {
     PRUint32 msgCount = keysToFetchFromServer.Length();
     nsCAutoString messageIds;
     AllocateImapUidString(keysToFetchFromServer.Elements(), msgCount,
                          nsnull, messageIds);
-    rv = imapService->GetBodyStart(m_thread, this, aUrlListener,
+    rv = imapService->GetBodyStart(this, aUrlListener,
                                    messageIds, 2048, nsnull);
     *aAsyncResults = true; // the preview text will be available async...
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapMailFolder::AddKeywordsToMessages(nsIArray *aMessages, const nsACString& aKeywords)
 {
--- a/mailnews/imap/src/nsImapMailFolder.h
+++ b/mailnews/imap/src/nsImapMailFolder.h
@@ -54,17 +54,16 @@
 #include "nsIMsgFilterHitNotify.h"
 #include "nsIMsgFilterList.h"
 #include "prmon.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIImapMailFolderSink.h"
 #include "nsIImapServerSink.h"
 #include "nsIMsgFilterPlugin.h"
-#include "nsIEventTarget.h"
 #include "nsIThread.h"
 #include "nsDataHashtable.h"
 #include "nsIMutableArray.h"
 #include "nsITimer.h"
 #include "nsCOMArray.h"
 #include "nsAutoSyncState.h"
 
 class nsImapMoveCoalescer;
@@ -479,17 +478,16 @@ protected:
   // folder total and unread counts.
   PRInt32 m_numServerRecentMessages;
   PRInt32 m_numServerUnseenMessages;
   PRInt32 m_numServerTotalMessages;
   // if server supports UIDNEXT, we store it here.
   PRInt32 m_nextUID;
 
   PRInt32  m_nextMessageByteLength;
-  nsCOMPtr<nsIThread> m_thread;
   nsCOMPtr<nsIUrlListener> m_urlListener;
   bool m_urlRunning;
 
   // undo move/copy transaction support
   nsRefPtr<nsMsgTxn> m_pendingUndoTxn;
   nsRefPtr<nsImapMailCopyState> m_copyState;
   char m_hierarchyDelimiter;
   PRInt32 m_boxFlags;
--- a/mailnews/imap/src/nsImapOfflineSync.cpp
+++ b/mailnews/imap/src/nsImapOfflineSync.cpp
@@ -1043,43 +1043,24 @@ nsresult nsImapOfflineSync::ProcessNextO
     {
       m_currentServer = nsnull;
       AdvanceToNextFolder();
     }
     if (m_singleFolderToUpdate)
     {
       m_singleFolderToUpdate->ClearFlag(nsMsgFolderFlags::OfflineEvents);
       m_singleFolderToUpdate->UpdateFolder(m_window);
-      // do we have to do anything? Old code would do a start update...
-    }
-    else
-    {
+      nsCOMPtr<nsIMsgImapMailFolder> imapFolder(do_QueryInterface(m_singleFolderToUpdate));
+      if (imapFolder)
+      {
+        nsCOMPtr<nsIUrlListener> saveListener = m_listener;
+//        m_listener = nsnull;
+//        imapFolder->UpdateFolderWithListener(m_window, saveListener);
+      }
     }
-    
-    //		MSG_FolderIterator *updateFolderIterator = m_singleFolderToUpdate ? (MSG_FolderIterator *) 0 : m_folderIterator;
-    
-    
-    // we are done playing commands back, now queue up the sync with each imap folder
-    // If we're using the iterator, m_currentFolder will be set correctly
-    //			nsIMsgFolder * folder = m_singleFolderToUpdate ? m_singleFolderToUpdate : m_currentFolder;
-    //			while (folder)
-    //			{            
-    //				bool loadingFolder = m_workerPane->GetLoadingImapFolder() == folder;
-    //				if ((folder->GetType() == FOLDER_IMAPMAIL) && (deletedAllOfflineEventsInFolder == folder || (folder->GetFolderPrefFlags() & nsMsgFolderFlags::Offline)
-    //					|| loadingFolder) 
-    //					&& !(folder->GetFolderPrefFlags() & MSG_FOLDER_PREF_IMAPNOSELECT) )
-    //				{
-    //					bool lastChance = ((deletedAllOfflineEventsInFolder == folder) && m_singleFolderToUpdate) || loadingFolder;
-    // if deletedAllOfflineEventsInFolder == folder and we're only updating one folder, then we need to update newly selected folder
-    // I think this also means that we're really opening the folder...so we tell StartUpdate that we're loading a folder.
-    //					if (!updateFolderIterator || !(imapMail->GetFlags() & nsMsgFolderFlags::Inbox))		// avoid queueing the inbox twice
-    //						imapMail->StartUpdateOfNewlySelectedFolder(m_workerPane, lastChance, queue, nsnsnull, false, false);
-    //				}
-    //				folder= m_singleFolderToUpdate ? (MSG_FolderInfo *)nsnull : updateFolderIterator->Next();
-    //       }
   }
   // if we get here, then I *think* we're done. Not sure, though.
 #ifdef DEBUG_bienvenu
   printf("done with offline imap sync\n");
 #endif
   nsCOMPtr <nsIUrlListener> saveListener = m_listener;
   m_listener = nsnull;
 
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -515,37 +515,37 @@ nsresult nsImapProtocol::Configure(PRInt
   m_chunkStartSize = m_chunkSize = ChunkSize;
   m_chunkThreshold = ChunkThreshold;
   m_fetchByChunks = FetchByChunks;
 
   return NS_OK;
 }
 
 
-nsresult nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList, nsIImapIncomingServer *aServer,
-                                    nsIEventTarget * aSinkEventTarget)
-{
-  NS_PRECONDITION(aSinkEventTarget && aHostSessionList,
-             "oops...trying to initialize with a null sink event target!");
-  if (!aSinkEventTarget || !aHostSessionList || !aServer)
+NS_IMETHODIMP
+nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList,
+                           nsIImapIncomingServer *aServer)
+{
+  NS_PRECONDITION(aHostSessionList && aServer,
+     "oops...trying to initialize with a null host session list or server!");
+  if (!aHostSessionList || !aServer)
     return NS_ERROR_NULL_POINTER;
 
   nsresult rv = m_downloadLineCache->GrowBuffer(kDownLoadCacheSize);
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_flagState = new nsImapFlagAndUidState(kImapFlagAndUidStateSize);
   if (!m_flagState)
     return NS_ERROR_OUT_OF_MEMORY;
 
   aServer->GetUseIdle(&m_useIdle);
   aServer->GetUseCondStore(&m_useCondStore);
   aServer->GetUseCompressDeflate(&m_useCompressDeflate);
   NS_ADDREF(m_flagState);
 
-  m_sinkEventTarget = aSinkEventTarget;
   m_hostSessionList = aHostSessionList; // no ref count...host session list has life time > connection
   m_parser.SetHostSessionList(aHostSessionList);
   m_parser.SetFlagState(m_flagState);
 
   // one of the initializations that should be done in UI thread
   nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
 
   // Now initialize the thread for the connection
@@ -1054,17 +1054,16 @@ NS_IMETHODIMP nsImapProtocol::Run()
     m_runningUrl.swap(doomed);
     NS_ProxyRelease(thread, doomed);
   }
 
   // close streams via UI thread if it's not already done
   if (m_imapProtocolSink)
     m_imapProtocolSink->CloseStreams();
 
-  m_sinkEventTarget = nsnull;
   m_imapMailFolderSink = nsnull;
   m_imapMessageSink = nsnull;
 
   // shutdown this thread, but do it from the main thread
   nsCOMPtr<nsIRunnable> ev = new nsImapThreadShutdownEvent(m_iThread);
   if (NS_FAILED(NS_DispatchToMainThread(ev)))
     NS_WARNING("Failed to dispatch nsImapThreadShutdownEvent");
   m_iThread = nsnull;
@@ -9146,19 +9145,18 @@ nsresult nsImapMockChannel::ReadFromImap
 
   // loading the url consists of asking the server to add the url to it's imap event queue....
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = mailnewsUrl->GetServer(getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIImapIncomingServer> imapServer (do_QueryInterface(server, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
   // Assume AsyncRead is always called from the UI thread.....
-  return imapServer->GetImapConnectionAndLoadUrl(thread, imapUrl, nsnull);
+  return imapServer->GetImapConnectionAndLoadUrl(imapUrl, nsnull);
 }
 
 // for messages stored in our offline cache, we have special code to handle that...
 // If it's in the local cache, we return true and we can abort the download because
 // this method does the rest of the work.
 bool nsImapMockChannel::ReadFromLocalCache()
 {
   nsresult rv = NS_OK;
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -38,17 +38,16 @@
 
 #ifndef nsImapProtocol_h___
 #define nsImapProtocol_h___
 
 #include "nsIImapProtocol.h"
 #include "nsIImapUrl.h"
 
 #include "nsMsgProtocol.h"
-#include "nsIEventTarget.h"
 #include "nsIStreamListener.h"
 #include "nsIAsyncOutputStream.h"
 #include "nsIAsyncInputStream.h"
 #include "nsImapCore.h"
 #include "nsStringGlue.h"
 #include "nsIProgressEventSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -370,17 +369,16 @@ private:
 
   nsCOMPtr<nsIAsyncInputStream>   m_channelInputStream;
   nsCOMPtr<nsIAsyncOutputStream>  m_channelOutputStream;
   nsCOMPtr<nsIImapMockChannel>    m_mockChannel;   // this is the channel we should forward to people
   //nsCOMPtr<nsIRequest> mAsyncReadRequest; // we're going to cancel this when we're done with the conn.
 
 
   // ******* Thread support *******
-  nsCOMPtr<nsIEventTarget> m_sinkEventTarget;
   nsCOMPtr<nsIThread>      m_iThread;
   PRThread     *m_thread;
   mozilla::ReentrantMonitor m_dataAvailableMonitor;   // used to notify the arrival of data from the server
   mozilla::ReentrantMonitor m_urlReadyToRunMonitor;   // used to notify the arrival of a new url to be processed
   mozilla::ReentrantMonitor m_pseudoInterruptMonitor;
   mozilla::ReentrantMonitor m_dataMemberMonitor;
   mozilla::ReentrantMonitor m_threadDeathMonitor;
   mozilla::ReentrantMonitor m_waitForBodyIdsMonitor;
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -201,23 +201,21 @@ nsresult nsImapService::GetFolderName(ns
     if (NS_SUCCEEDED(rv))
       onlineName.Adopt(escapedOnlineName);
   }
   // need to escape everything else
   MsgEscapeString(onlineName, nsINetUtil::ESCAPE_URL_PATH, aFolderName);
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::SelectFolder(nsIEventTarget *aClientEventTarget, 
-                                          nsIMsgFolder *aImapMailFolder, 
-                                          nsIUrlListener *aUrlListener, 
+NS_IMETHODIMP nsImapService::SelectFolder(nsIMsgFolder *aImapMailFolder,
+                                          nsIUrlListener *aUrlListener,
                                           nsIMsgWindow *aMsgWindow,
                                           nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   if (WeAreOffline())
     return NS_MSG_ERROR_OFFLINE;
 
   bool canOpenThisFolder = true;
   nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(aImapMailFolder);
   if (imapFolder)
@@ -250,34 +248,32 @@ NS_IMETHODIMP nsImapService::SelectFolde
     {
       nsCAutoString folderName;
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append("/select>");
       urlSpec.Append(hierarchyDelimiter);
       urlSpec.Append(folderName);
       rv = mailNewsUrl->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   } // if we have a url to run....
 
   return rv;
 }
 
 // lite select, used to verify UIDVALIDITY while going on/offline
-NS_IMETHODIMP nsImapService::LiteSelectFolder(nsIEventTarget *aClientEventTarget,
-                                              nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::LiteSelectFolder(nsIMsgFolder *aImapMailFolder,
                                               nsIUrlListener *aUrlListener,
                                               nsIMsgWindow *aMsgWindow,
                                               nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/liteselect>", nsIImapUrl::nsImapLiteSelectFolder, aMsgWindow, aURL);
 }
 
 NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, 
                                           nsIURI **aURL, 
                                           nsIMsgWindow *aMsgWindow) 
 {
   nsresult rv = NS_OK;
@@ -693,19 +689,17 @@ nsresult nsImapService::FetchMimePart(ns
       else // do what we used to do before
       {
         // I'd like to get rid of this code as I believe that we always get a docshell
         // or stream listener passed into us in this method but i'm not sure yet...
         // I'm going to use an assert for now to figure out if this is ever getting called
 #if defined(DEBUG_mscott) || defined(DEBUG_bienvenu)
         NS_ERROR("oops...someone still is reaching this part of the code");
 #endif
-        nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-        rv = GetImapConnectionAndLoadUrl(thread, aImapUrl,
-                                         aDisplayConsumer, aURL);
+        rv = GetImapConnectionAndLoadUrl(aImapUrl, aDisplayConsumer, aURL);
       }
     }
   }
   return rv;
 }
 
 //
 // rhp: Right now, this is the same as simple DisplayMessage, but it will change
@@ -861,20 +855,18 @@ NS_IMETHODIMP nsImapService::Search(nsIM
     // escape aSearchUri so that IMAP special characters (i.e. '\')
     // won't be replaced with '/' in NECKO.
     // it will be unescaped in nsImapUrl::ParseUrl().
     nsCString escapedSearchUri;
 
     MsgEscapeString(nsDependentCString(aSearchUri), nsINetUtil::ESCAPE_XALPHAS, escapedSearchUri);
     urlSpec.Append(escapedSearchUri);
     rv = mailNewsUrl->SetSpec(urlSpec);
-    if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-      rv = GetImapConnectionAndLoadUrl(thread, imapUrl, nsnull, nsnull);
-    }
+    if (NS_SUCCEEDED(rv))
+      rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, nsnull);
   }
   return rv;
 }
 
 // just a helper method to break down imap message URIs....
 nsresult nsImapService::DecomposeImapURI(const nsACString &aMessageURI, 
                                          nsIMsgFolder **aFolder, 
                                          nsACString &aMsgKey)
@@ -1136,18 +1128,17 @@ nsresult nsImapService::GetMessageFromUr
     else // do what we used to do before
     {
       // I'd like to get rid of this code as I believe that we always get a docshell
       // or stream listener passed into us in this method but i'm not sure yet...
       // I'm going to use an assert for now to figure out if this is ever getting called
 #if defined(DEBUG_mscott) || defined(DEBUG_bienvenu)
       NS_ERROR("oops...someone still is reaching this part of the code");
 #endif
-      nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-      rv = GetImapConnectionAndLoadUrl(thread, aImapUrl,
+      rv = GetImapConnectionAndLoadUrl(aImapUrl,
                                        aDisplayConsumer, aURL);
     }
   }
   return rv;
 }
 
 // this method streams a message to the passed in consumer, with an optional stream converter
 // and additional header (e.g., "header=filter")
@@ -1403,27 +1394,25 @@ nsresult nsImapService::CreateStartOfIma
   }
   return rv;
 }
 
 /* fetching the headers of RFC822 messages */
 /* imap4://HOST>header><UID/SEQUENCE>>MAILBOXPATH>x */
 /*   'x' is the message UID or sequence number list */
 /* will not affect the 'SEEN' flag */
-NS_IMETHODIMP nsImapService::GetHeaders(nsIEventTarget *aClientEventTarget, 
-                                        nsIMsgFolder *aImapMailFolder, 
+NS_IMETHODIMP nsImapService::GetHeaders(nsIMsgFolder *aImapMailFolder, 
                                         nsIUrlListener *aUrlListener, 
                                         nsIURI **aURL,
                                         const nsACString &messageIdentifierList,
                                         bool messageIdsAreUID)
 {
   // create a protocol instance to handle the request.
   // NOTE: once we start working with multiple connections, this step will be much more complicated...but for now
   // just create a connection and process the request.
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
 
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), aImapMailFolder, 
                                      aUrlListener, urlSpec, hierarchyDelimiter);
@@ -1445,36 +1434,34 @@ NS_IMETHODIMP nsImapService::GetHeaders(
 
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(messageIdentifierList);
       rv = uri->SetSpec(urlSpec);
 
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
 
 /* peeking at the start of msg bodies */
 /* imap4://HOST>header><UID>>MAILBOXPATH>x>n */
 /*   'x' is the message UID */
 /*   'n' is the number of bytes to fetch */
 /* will not affect the 'SEEN' flag */
-NS_IMETHODIMP nsImapService::GetBodyStart(nsIEventTarget *aClientEventTarget, 
-                                          nsIMsgFolder *aImapMailFolder, 
+NS_IMETHODIMP nsImapService::GetBodyStart(nsIMsgFolder *aImapMailFolder, 
                                           nsIUrlListener *aUrlListener, 
                                           const nsACString &messageIdentifierList,
                                           PRInt32 numBytes,
                                           nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   nsresult rv;
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), aImapMailFolder, 
@@ -1497,31 +1484,29 @@ NS_IMETHODIMP nsImapService::GetBodyStar
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(messageIdentifierList);
       urlSpec.Append(">");
       urlSpec.AppendInt(numBytes);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
-nsresult nsImapService::FolderCommand(nsIEventTarget *aClientEventTarget,
-                                      nsIMsgFolder *imapMailFolder,
+nsresult nsImapService::FolderCommand(nsIMsgFolder *imapMailFolder,
                                       nsIUrlListener *urlListener,
                                       const char *aCommand,
                                       nsImapAction imapAction,
                                       nsIMsgWindow *msgWindow,
                                       nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(imapMailFolder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(imapMailFolder);
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl),
                                      imapMailFolder, urlListener, urlSpec, hierarchyDelimiter);
@@ -1539,18 +1524,17 @@ nsresult nsImapService::FolderCommand(ns
       urlSpec.Append(aCommand);
       urlSpec.Append(hierarchyDelimiter);
 
       nsCString folderName;
       GetFolderName(imapMailFolder, folderName);
       urlSpec.Append(folderName);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsImapService::VerifyLogon(nsIMsgFolder *aFolder, nsIUrlListener *aUrlListener,
                            nsIMsgWindow *aMsgWindow, nsIURI **aURL)
@@ -1566,74 +1550,64 @@ nsImapService::VerifyLogon(nsIMsgFolder 
     nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
 
     nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
     mailNewsUrl->SetSuppressErrorMsgs(true);
     mailNewsUrl->SetMsgWindow(aMsgWindow);
     rv = SetImapUrlSink(aFolder, imapUrl);
     urlSpec.Append("/verifyLogon");
     rv = uri->SetSpec(urlSpec);
-    if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-      rv = GetImapConnectionAndLoadUrl(thread, imapUrl, nsnull, nsnull);
-    }
+    if (NS_SUCCEEDED(rv))
+      rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, nsnull);
     if (aURL)
       uri.forget(aURL);
   }
   return rv;
 }
 
 // Noop, used to update a folder (causes server to send changes).
-NS_IMETHODIMP nsImapService::Noop(nsIEventTarget *aClientEventTarget, 
-                                  nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::Noop(nsIMsgFolder *aImapMailFolder,
                                   nsIUrlListener *aUrlListener, 
                                   nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/selectnoop>", nsIImapUrl::nsImapSelectNoopFolder, nsnull, aURL);
 }
     
 // FolderStatus, used to update message counts
-NS_IMETHODIMP nsImapService::UpdateFolderStatus(nsIEventTarget *aClientEventTarget, 
-                                                nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::UpdateFolderStatus(nsIMsgFolder *aImapMailFolder,
                                                 nsIUrlListener *aUrlListener, 
                                                 nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/folderstatus>", nsIImapUrl::nsImapFolderStatus, nsnull, aURL);
 }
 
 // Expunge, used to "compress" an imap folder,removes deleted messages.
-NS_IMETHODIMP nsImapService::Expunge(nsIEventTarget *aClientEventTarget,
-                                     nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::Expunge(nsIMsgFolder *aImapMailFolder,
                                      nsIUrlListener *aUrlListener,
                                      nsIMsgWindow *aMsgWindow,
                                      nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/Expunge>", nsIImapUrl::nsImapExpungeFolder, aMsgWindow, aURL);
 }
 
 /* old-stle biff that doesn't download headers */
-NS_IMETHODIMP nsImapService::Biff(nsIEventTarget *aClientEventTarget, 
-                                  nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::Biff(nsIMsgFolder *aImapMailFolder,
                                   nsIUrlListener *aUrlListener, 
                                   nsIURI **aURL,
                                   PRUint32 uidHighWater)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   // static const char *formatString = "biff>%c%s>%ld";
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl),
@@ -1651,55 +1625,51 @@ NS_IMETHODIMP nsImapService::Biff(nsIEve
 
       nsCString folderName;
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.AppendInt(uidHighWater);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::DeleteFolder(nsIEventTarget *aClientEventTarget,
-                                          nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::DeleteFolder(nsIMsgFolder *aImapMailFolder,
                                           nsIUrlListener *aUrlListener,
                                           nsIMsgWindow *aMsgWindow,
                                           nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   // If it's an aol server then use 'deletefolder' url to 
   // remove all msgs first and then remove the folder itself.
   bool removeFolderAndMsgs = false;
   nsCOMPtr<nsIMsgIncomingServer> server;
   if (NS_SUCCEEDED(aImapMailFolder->GetServer(getter_AddRefs(server))) && server)
   {
     nsCOMPtr <nsIImapIncomingServer> imapServer = do_QueryInterface(server);
     if (imapServer) 
       imapServer->GetIsAOLServer(&removeFolderAndMsgs);
   }
   
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        removeFolderAndMsgs ? "/deletefolder>" : "/delete>", 
                        nsIImapUrl::nsImapDeleteFolder, aMsgWindow, aURL);
 }
 
-NS_IMETHODIMP nsImapService::DeleteMessages(nsIEventTarget *aClientEventTarget, 
-                                            nsIMsgFolder *aImapMailFolder, 
+NS_IMETHODIMP nsImapService::DeleteMessages(nsIMsgFolder *aImapMailFolder, 
                                             nsIUrlListener *aUrlListener, 
                                             nsIURI **aURL,
                                             const nsACString &messageIdentifierList,
                                             bool messageIdsAreUID)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   // create a protocol instance to handle the request.
   // NOTE: once we start working with multiple connections, this step will be much more complicated...but for now
   // just create a connection and process the request.
   nsresult rv;
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
@@ -1723,90 +1693,80 @@ NS_IMETHODIMP nsImapService::DeleteMessa
 
       nsCString folderName;
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(messageIdentifierList);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
 // Delete all messages in a folder, used to empty trash
-NS_IMETHODIMP nsImapService::DeleteAllMessages(nsIEventTarget *aClientEventTarget, 
-                                               nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::DeleteAllMessages(nsIMsgFolder *aImapMailFolder,
                                                nsIUrlListener *aUrlListener, 
                                                nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                       "/deleteallmsgs>", nsIImapUrl::nsImapSelectNoopFolder, nsnull, aURL);
 }
 
-NS_IMETHODIMP nsImapService::AddMessageFlags(nsIEventTarget *aClientEventTarget,
-                                             nsIMsgFolder *aImapMailFolder, 
-                                             nsIUrlListener *aUrlListener, 
+NS_IMETHODIMP nsImapService::AddMessageFlags(nsIMsgFolder *aImapMailFolder,
+                                             nsIUrlListener *aUrlListener,
                                              nsIURI **aURL,
                                              const nsACString &messageIdentifierList,
                                              imapMessageFlagsType flags,
                                              bool messageIdsAreUID)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return DiddleFlags(aClientEventTarget, aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
+  return DiddleFlags(aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
                      "addmsgflags", flags, messageIdsAreUID);
 }
 
-NS_IMETHODIMP nsImapService::SubtractMessageFlags(nsIEventTarget *aClientEventTarget,
-                                                  nsIMsgFolder *aImapMailFolder, 
-                                                  nsIUrlListener *aUrlListener, 
+NS_IMETHODIMP nsImapService::SubtractMessageFlags(nsIMsgFolder *aImapMailFolder,
+                                                  nsIUrlListener *aUrlListener,
                                                   nsIURI **aURL,
                                                   const nsACString &messageIdentifierList,
                                                   imapMessageFlagsType flags,
                                                   bool messageIdsAreUID)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return DiddleFlags(aClientEventTarget, aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
+  return DiddleFlags(aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
                      "subtractmsgflags", flags, messageIdsAreUID);
 }
 
-NS_IMETHODIMP nsImapService::SetMessageFlags(nsIEventTarget *aClientEventTarget,
-                                             nsIMsgFolder *aImapMailFolder, 
-                                             nsIUrlListener *aUrlListener, 
+NS_IMETHODIMP nsImapService::SetMessageFlags(nsIMsgFolder *aImapMailFolder,
+                                             nsIUrlListener *aUrlListener,
                                              nsIURI **aURL,
                                              const nsACString &messageIdentifierList,
                                              imapMessageFlagsType flags,
                                              bool messageIdsAreUID)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return DiddleFlags(aClientEventTarget, aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
+  return DiddleFlags(aImapMailFolder, aUrlListener, aURL, messageIdentifierList,
                      "setmsgflags", flags, messageIdsAreUID);
 }
 
-nsresult nsImapService::DiddleFlags(nsIEventTarget *aClientEventTarget, 
-                                    nsIMsgFolder *aImapMailFolder, 
+nsresult nsImapService::DiddleFlags(nsIMsgFolder *aImapMailFolder,
                                     nsIUrlListener *aUrlListener,
                                     nsIURI **aURL,
                                     const nsACString &messageIdentifierList,
                                     const char *howToDiddle,
                                     imapMessageFlagsType flags,
                                     bool messageIdsAreUID)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   // create a protocol instance to handle the request.
   // NOTE: once we start working with multiple connections, 
   //       this step will be much more complicated...but for now
   // just create a connection and process the request.
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
@@ -1833,17 +1793,17 @@ nsresult nsImapService::DiddleFlags(nsIE
       GetFolderName(aImapMailFolder, folderName);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(messageIdentifierList);
       urlSpec.Append('>');
       urlSpec.AppendInt(flags);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
 nsresult nsImapService::SetImapUrlSink(nsIMsgFolder *aMsgFolder, nsIImapUrl *aImapUrl)
 {
   NS_ENSURE_ARG_POINTER(aMsgFolder);
@@ -1870,23 +1830,21 @@ nsresult nsImapService::SetImapUrlSink(n
     aImapUrl->SetImapMessageSink(imapMessageSink);
   
   nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
   mailnewsUrl->SetFolder(aMsgFolder);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsImapService::DiscoverAllFolders(nsIEventTarget *aClientEventTarget,
-                                                nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::DiscoverAllFolders(nsIMsgFolder *aImapMailFolder,
                                                 nsIUrlListener *aUrlListener,
                                                 nsIMsgWindow *aMsgWindow,
                                                 nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), aImapMailFolder, 
                                      aUrlListener, urlSpec, hierarchyDelimiter);
@@ -1899,28 +1857,26 @@ NS_IMETHODIMP nsImapService::DiscoverAll
       nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
       nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(imapUrl);
       if (mailnewsurl)
         mailnewsurl->SetMsgWindow(aMsgWindow);
       urlSpec.Append("/discoverallboxes");
       nsCOMPtr <nsIURI> url = do_QueryInterface(imapUrl, &rv);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::DiscoverAllAndSubscribedFolders(nsIEventTarget *aClientEventTarget,
-                                                             nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::DiscoverAllAndSubscribedFolders(nsIMsgFolder *aImapMailFolder,
                                                              nsIUrlListener *aUrlListener,
                                                              nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   nsCOMPtr<nsIImapUrl> aImapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(aImapUrl), aImapMailFolder,
                                      aUrlListener, urlSpec, hierarchyDelimiter);
@@ -1928,29 +1884,27 @@ NS_IMETHODIMP nsImapService::DiscoverAll
   {
     rv = SetImapUrlSink(aImapMailFolder, aImapUrl);
     if (NS_SUCCEEDED(rv))
     {
       nsCOMPtr<nsIURI> uri = do_QueryInterface(aImapUrl);
       urlSpec.Append("/discoverallandsubscribedboxes");
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, aImapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(aImapUrl, nsnull, aURL);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::DiscoverChildren(nsIEventTarget *aClientEventTarget,
-                                              nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::DiscoverChildren(nsIMsgFolder *aImapMailFolder,
                                               nsIUrlListener *aUrlListener,
                                               const nsACString &folderPath,
                                               nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
   nsCOMPtr<nsIImapUrl> aImapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aImapMailFolder);
   nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(aImapUrl), aImapMailFolder, 
                                      aUrlListener, urlSpec, hierarchyDelimiter);
@@ -1971,37 +1925,35 @@ NS_IMETHODIMP nsImapService::DiscoverChi
         // obj if it's not kOnlineHierarchySeparatorUnknown (ie, '^').
         char uriDelimiter;
         nsresult rv1 = aImapUrl->GetOnlineSubDirSeparator(&uriDelimiter);
         if (NS_SUCCEEDED (rv1) && hierarchyDelimiter != kOnlineHierarchySeparatorUnknown &&
             uriDelimiter != hierarchyDelimiter)
           aImapUrl->SetOnlineSubDirSeparator(hierarchyDelimiter);
 
         if (NS_SUCCEEDED(rv))
-          rv = GetImapConnectionAndLoadUrl(aClientEventTarget, aImapUrl, nsnull, aURL);
+          rv = GetImapConnectionAndLoadUrl(aImapUrl, nsnull, aURL);
       }
       else
         rv = NS_ERROR_FAILURE;
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::OnlineMessageCopy(nsIEventTarget *aClientEventTarget,
-                                               nsIMsgFolder *aSrcFolder,
+NS_IMETHODIMP nsImapService::OnlineMessageCopy(nsIMsgFolder *aSrcFolder,
                                                const nsACString &messageIds,
                                                nsIMsgFolder *aDstFolder,
                                                bool idsAreUids,
                                                bool isMove,
                                                nsIUrlListener *aUrlListener,
                                                nsIURI **aURL,
                                                nsISupports *copyState,
                                                nsIMsgWindow *aMsgWindow)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aSrcFolder);
   NS_ENSURE_ARG_POINTER(aDstFolder);
 
   nsresult rv;
   nsCOMPtr<nsIMsgIncomingServer> srcServer;
   nsCOMPtr<nsIMsgIncomingServer> dstServer;
 
   rv = aSrcFolder->GetServer(getter_AddRefs(srcServer));
@@ -2055,17 +2007,17 @@ NS_IMETHODIMP nsImapService::OnlineMessa
     urlSpec.Append('>');
     urlSpec.Append(hierarchyDelimiter);
     folderName.Adopt(strdup(""));
     GetFolderName(aDstFolder, folderName);
     urlSpec.Append(folderName);
 
     rv = uri->SetSpec(urlSpec);
     if (NS_SUCCEEDED(rv))
-      rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+      rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
   }
   return rv;
 }
 
 nsresult nsImapService::OfflineAppendFromFile(nsIFile *aFile,
                                               nsIURI *aUrl,
                                               nsIMsgFolder* aDstFolder,
                                               const nsACString &messageId,  // to be replaced
@@ -2186,28 +2138,26 @@ nsresult nsImapService::OfflineAppendFro
   if (destDB)
     destDB->Close(true);
   return rv;
 }
 
 /* append message from file url */
 /* imap://HOST>appendmsgfromfile>DESTINATIONMAILBOXPATH */
 /* imap://HOST>appenddraftfromfile>DESTINATIONMAILBOXPATH>UID>messageId */
-NS_IMETHODIMP nsImapService::AppendMessageFromFile(nsIEventTarget *aClientEventTarget,
-                                                   nsIFile *aFile,
+NS_IMETHODIMP nsImapService::AppendMessageFromFile(nsIFile *aFile,
                                                    nsIMsgFolder *aDstFolder,
                                                    const nsACString &messageId,  // to be replaced
                                                    bool idsAreUids,
                                                    bool inSelectedState,       // needs to be in
                                                    nsIUrlListener *aListener,
                                                    nsIURI **aURL,
                                                    nsISupports *aCopyState,
                                                    nsIMsgWindow *aMsgWindow)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aFile);
   NS_ENSURE_ARG_POINTER(aDstFolder);
 
   nsresult rv;
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(aDstFolder);
@@ -2252,23 +2202,22 @@ NS_IMETHODIMP nsImapService::AppendMessa
     
     rv = uri->SetSpec(urlSpec);
     if (WeAreOffline())
     {
       // handle offline append to drafts or templates folder here.
       return OfflineAppendFromFile(aFile, uri, aDstFolder, messageId, inSelectedState, aListener, aURL, aCopyState);
     }
     if (NS_SUCCEEDED(rv))
-      rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+      rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
   }
   return rv;
 }
 
-nsresult nsImapService::GetImapConnectionAndLoadUrl(nsIEventTarget *aClientEventTarget,
-                                                    nsIImapUrl *aImapUrl,
+nsresult nsImapService::GetImapConnectionAndLoadUrl(nsIImapUrl *aImapUrl,
                                                     nsISupports *aConsumer,
                                                     nsIURI **aURL)
 {
   NS_ENSURE_ARG_POINTER(aImapUrl);
 
   bool isValidUrl;
   aImapUrl->GetValidUrl(&isValidUrl);
   if (!isValidUrl)
@@ -2296,29 +2245,27 @@ nsresult nsImapService::GetImapConnectio
     nsCOMPtr<nsIURI> msgUrlUri = do_QueryInterface(msgUrl);
     msgUrlUri.swap(*aURL);
   }
 
   if (NS_SUCCEEDED(rv) && aMsgIncomingServer)
   {
     nsCOMPtr<nsIImapIncomingServer> aImapServer(do_QueryInterface(aMsgIncomingServer, &rv));
     if (NS_SUCCEEDED(rv) && aImapServer)
-      rv = aImapServer->GetImapConnectionAndLoadUrl(aClientEventTarget, aImapUrl, aConsumer);
+      rv = aImapServer->GetImapConnectionAndLoadUrl(aImapUrl, aConsumer);
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::MoveFolder(nsIEventTarget *aClientEventTarget,
-                                        nsIMsgFolder *srcFolder,
+NS_IMETHODIMP nsImapService::MoveFolder(nsIMsgFolder *srcFolder,
                                         nsIMsgFolder *dstFolder, 
                                         nsIUrlListener *urlListener, 
                                         nsIMsgWindow *msgWindow, 
                                         nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(srcFolder);
   NS_ENSURE_ARG_POINTER(dstFolder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
 
   char default_hierarchyDelimiter = GetHierarchyDelimiter(dstFolder);
@@ -2346,40 +2293,36 @@ NS_IMETHODIMP nsImapService::MoveFolder(
       {
         urlSpec.Append(hierarchyDelimiter);
         urlSpec.Append(folderName);
       }
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
       {
         GetFolderName(srcFolder, folderName);
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
       }
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::RenameLeaf(nsIEventTarget *aClientEventTarget,
-                                        nsIMsgFolder *srcFolder,
+NS_IMETHODIMP nsImapService::RenameLeaf(nsIMsgFolder *srcFolder,
                                         const nsAString &newLeafName, 
                                         nsIUrlListener *urlListener,
                                         nsIMsgWindow *msgWindow, 
                                         nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(srcFolder);
-  
+
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
-  nsresult rv;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(srcFolder);
-  rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), srcFolder, 
+  nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), srcFolder, 
                             urlListener, urlSpec, hierarchyDelimiter);
   if (NS_SUCCEEDED(rv))
   {
     rv = SetImapUrlSink(srcFolder, imapUrl);
     if (NS_SUCCEEDED(rv))
     {
       nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
       nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
@@ -2408,30 +2351,27 @@ NS_IMETHODIMP nsImapService::RenameLeaf(
       MsgEscapeString(utfNewName, nsINetUtil::ESCAPE_URL_PATH, escapedNewName);
       nsCString escapedSlashName;
       rv = nsImapUrl::EscapeSlashes(escapedNewName.get(), getter_Copies(escapedSlashName));
       NS_ENSURE_SUCCESS(rv, rv);
       urlSpec.Append(escapedSlashName);
 
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
     } // if (NS_SUCCEEDED(rv))
   } // if (NS_SUCCEEDED(rv) && imapUrl)
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::CreateFolder(nsIEventTarget *aClientEventTarget,
-                                          nsIMsgFolder *parent,
+NS_IMETHODIMP nsImapService::CreateFolder(nsIMsgFolder *parent,
                                           const nsAString &newFolderName,
-                                          nsIUrlListener *urlListener, 
+                                          nsIUrlListener *urlListener,
                                           nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(parent);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(parent);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), parent, 
@@ -2461,30 +2401,27 @@ NS_IMETHODIMP nsImapService::CreateFolde
       rv = CopyUTF16toMUTF7(PromiseFlatString(newFolderName), utfNewName);
       NS_ENSURE_SUCCESS(rv, rv);
       nsCString escapedFolderName;
       MsgEscapeString(utfNewName, nsINetUtil::ESCAPE_URL_PATH, escapedFolderName);
       urlSpec.Append(escapedFolderName);
 
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
     } // if (NS_SUCCEEDED(rv))
   } // if (NS_SUCCEEDED(rv) && imapUrl)
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::EnsureFolderExists(nsIEventTarget *aClientEventTarget,
-                                                nsIMsgFolder *parent,
+NS_IMETHODIMP nsImapService::EnsureFolderExists(nsIMsgFolder *parent,
                                                 const nsAString &newFolderName, 
                                                 nsIUrlListener *urlListener, 
                                                 nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(parent);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
 
   char hierarchyDelimiter = GetHierarchyDelimiter(parent);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), parent, urlListener, urlSpec, hierarchyDelimiter);
@@ -2507,32 +2444,29 @@ NS_IMETHODIMP nsImapService::EnsureFolde
       nsCAutoString utfNewName; 
       CopyUTF16toMUTF7(PromiseFlatString(newFolderName), utfNewName);
       nsCString escapedFolderName;
       MsgEscapeString(utfNewName, nsINetUtil::ESCAPE_URL_PATH, escapedFolderName);
       urlSpec.Append(escapedFolderName);
 
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
     } // if (NS_SUCCEEDED(rv))
   } // if (NS_SUCCEEDED(rv) && imapUrl)
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::ListFolder(nsIEventTarget *aClientEventTarget,
-                                        nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::ListFolder(nsIMsgFolder *aImapMailFolder,
                                         nsIUrlListener *aUrlListener,
                                         nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/listfolder>", nsIImapUrl::nsImapListFolder, nsnull, aURL);
 }
 
 NS_IMETHODIMP nsImapService::GetScheme(nsACString &aScheme)
 {
   aScheme.Assign("imap");
   return NS_OK; 
 }
@@ -3068,18 +3002,17 @@ NS_IMETHODIMP nsImapService::GetListOfFo
     else
       changedStr.Append(tokenStr);
 
     if (slashPos > 0 ) 
       changedStr.Append(remStr);
 
     rv = rootMsgFolder->FindSubFolder(changedStr, getter_AddRefs(msgFolder));
   }
-  nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-  return DiscoverChildren(thread, msgFolder, listener, folderPath, nsnull);
+  return DiscoverChildren(msgFolder, listener, folderPath, nsnull);
 }
 
 NS_IMETHODIMP nsImapService::GetListOfFoldersOnServer(nsIImapIncomingServer *aServer, 
                                                       nsIMsgWindow *aMsgWindow)
 {
   nsresult rv;
 
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(aServer);
@@ -3091,40 +3024,35 @@ NS_IMETHODIMP nsImapService::GetListOfFo
 
   NS_ENSURE_SUCCESS(rv, rv);
   if (!rootMsgFolder) 
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIUrlListener> listener = do_QueryInterface(aServer, &rv);
   NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && listener, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-  return DiscoverAllAndSubscribedFolders(thread, rootMsgFolder, listener, nsnull);
+  return DiscoverAllAndSubscribedFolders(rootMsgFolder, listener, nsnull);
 } 
 
-NS_IMETHODIMP nsImapService::SubscribeFolder(nsIEventTarget *aClientEventTarget,
-                                             nsIMsgFolder *aFolder,
+NS_IMETHODIMP nsImapService::SubscribeFolder(nsIMsgFolder *aFolder,
                                              const nsAString &aFolderName, 
                                              nsIUrlListener *urlListener, 
                                              nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
-
-  return ChangeFolderSubscription(aClientEventTarget, aFolder, aFolderName, 
+
+  return ChangeFolderSubscription(aFolder, aFolderName, 
                                   "/subscribe>", urlListener, url);
 }
 
-nsresult nsImapService::ChangeFolderSubscription(nsIEventTarget *aClientEventTarget,
-                                                 nsIMsgFolder *folder,
+nsresult nsImapService::ChangeFolderSubscription(nsIMsgFolder *folder,
                                                  const nsAString &folderName, 
                                                  const char *command,
                                                  nsIUrlListener *urlListener, 
                                                  nsIURI **url)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(folder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
   char hierarchyDelimiter = GetHierarchyDelimiter(folder);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), folder, urlListener,
                             urlSpec, hierarchyDelimiter);
@@ -3139,56 +3067,49 @@ nsresult nsImapService::ChangeFolderSubs
       nsCAutoString utfFolderName;
       rv = CopyUTF16toMUTF7(PromiseFlatString(folderName), utfFolderName);
       NS_ENSURE_SUCCESS(rv, rv);
       nsCString escapedFolderName;
       MsgEscapeString(utfFolderName, nsINetUtil::ESCAPE_URL_PATH, escapedFolderName);
       urlSpec.Append(escapedFolderName);
       rv = uri->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl,
-                                         nsnull, url);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, url);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::UnsubscribeFolder(nsIEventTarget *aClientEventTarget,
-                                               nsIMsgFolder *aFolder,
+NS_IMETHODIMP nsImapService::UnsubscribeFolder(nsIMsgFolder *aFolder,
                                                const nsAString &aFolderName, 
                                                nsIUrlListener *aUrlListener, 
                                                nsIURI **aUrl)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
-
-  return ChangeFolderSubscription(aClientEventTarget, aFolder, aFolderName,
+
+  return ChangeFolderSubscription(aFolder, aFolderName,
                                   "/unsubscribe>", aUrlListener, aUrl);
 }
 
-NS_IMETHODIMP nsImapService::GetFolderAdminUrl(nsIEventTarget *aClientEventTarget,
-                                               nsIMsgFolder *aImapMailFolder,
+NS_IMETHODIMP nsImapService::GetFolderAdminUrl(nsIMsgFolder *aImapMailFolder,
                                                nsIMsgWindow *aMsgWindow,
                                                nsIUrlListener *aUrlListener,
                                                nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(aImapMailFolder);
 
-  return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
+  return FolderCommand(aImapMailFolder, aUrlListener,
                        "/refreshfolderurls>", nsIImapUrl::nsImapRefreshFolderUrls, aMsgWindow, aURL);
 }
 
-NS_IMETHODIMP nsImapService::IssueCommandOnMsgs(nsIEventTarget *aClientEventTarget,
-                                                nsIMsgFolder *anImapFolder,
+NS_IMETHODIMP nsImapService::IssueCommandOnMsgs(nsIMsgFolder *anImapFolder,
                                                 nsIMsgWindow *aMsgWindow,
                                                 const nsACString &aCommand,
                                                 const nsACString &uids,
                                                 nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(anImapFolder);
   NS_ENSURE_ARG_POINTER(aMsgWindow);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
   char hierarchyDelimiter = GetHierarchyDelimiter(anImapFolder);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), anImapFolder, nsnull, urlSpec, hierarchyDelimiter);
@@ -3213,31 +3134,29 @@ NS_IMETHODIMP nsImapService::IssueComman
       urlSpec.Append(uidString);
       urlSpec.Append(">");
       urlSpec.Append(hierarchyDelimiter);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(uids);
       rv = mailNewsUrl->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   } // if we have a url to run....
 
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::FetchCustomMsgAttribute(nsIEventTarget *aClientEventTarget,
-                                                     nsIMsgFolder *anImapFolder,
+NS_IMETHODIMP nsImapService::FetchCustomMsgAttribute(nsIMsgFolder *anImapFolder,
                                                      nsIMsgWindow *aMsgWindow,
                                                      const nsACString &aAttribute,
                                                      const nsACString &uids,
                                                      nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(anImapFolder);
   NS_ENSURE_ARG_POINTER(aMsgWindow);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
   char hierarchyDelimiter = GetHierarchyDelimiter(anImapFolder);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), anImapFolder, 
@@ -3260,32 +3179,30 @@ NS_IMETHODIMP nsImapService::FetchCustom
       urlSpec.Append(hierarchyDelimiter);
       urlSpec.Append(folderName);
       urlSpec.Append(">");
       urlSpec.Append(uids);
       urlSpec.Append(">");
       urlSpec.Append(aAttribute);
       rv = mailNewsUrl->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   } // if we have a url to run....
 
   return rv;
 }
 
-NS_IMETHODIMP nsImapService::StoreCustomKeywords(nsIEventTarget *aClientEventTarget,
-                                                 nsIMsgFolder *anImapFolder,
+NS_IMETHODIMP nsImapService::StoreCustomKeywords(nsIMsgFolder *anImapFolder,
                                                  nsIMsgWindow *aMsgWindow,
                                                  const nsACString &flagsToAdd,
                                                  const nsACString &flagsToSubtract,
                                                  const nsACString &uids,
                                                  nsIURI **aURL)
 {
-  NS_ENSURE_ARG_POINTER(aClientEventTarget);
   NS_ENSURE_ARG_POINTER(anImapFolder);
 
   nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
   nsresult rv;
   char hierarchyDelimiter = GetHierarchyDelimiter(anImapFolder);
   rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), anImapFolder, nsnull, urlSpec, hierarchyDelimiter);
 
@@ -3309,17 +3226,17 @@ NS_IMETHODIMP nsImapService::StoreCustom
       urlSpec.Append(">");
       urlSpec.Append(uids);
       urlSpec.Append(">");
       urlSpec.Append(flagsToAdd);
       urlSpec.Append(">");
       urlSpec.Append(flagsToSubtract);
       rv = mailNewsUrl->SetSpec(urlSpec);
       if (NS_SUCCEEDED(rv))
-        rv = GetImapConnectionAndLoadUrl(aClientEventTarget, imapUrl, nsnull, aURL);
+        rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, aURL);
     }
   } // if we have a url to run....
 
   return rv;
 }
 
 
 NS_IMETHODIMP nsImapService::DownloadMessagesForOffline(const nsACString &messageIds, 
--- a/mailnews/imap/src/nsImapService.h
+++ b/mailnews/imap/src/nsImapService.h
@@ -90,50 +90,46 @@ protected:
 
   nsresult CreateStartOfImapUrl(const nsACString &aImapURI,  // a RDF URI for the current message/folder, can be empty
                                 nsIImapUrl  **imapUrl,
                                 nsIMsgFolder *aImapFolder,
                                 nsIUrlListener *aUrlListener,
                                 nsACString &urlSpec,
                                 char &hierarchyDelimiter);
 
-  nsresult GetImapConnectionAndLoadUrl(nsIEventTarget *aClientEventTarget, 
-                                       nsIImapUrl *aImapUrl,
+  nsresult GetImapConnectionAndLoadUrl(nsIImapUrl *aImapUrl,
                                        nsISupports *aConsumer,
                                        nsIURI **aURL);
 
   nsresult SetImapUrlSink(nsIMsgFolder *aMsgFolder, nsIImapUrl *aImapUrl);
 
   nsresult FetchMimePart(nsIImapUrl *aImapUrl,
                          nsImapAction aImapAction,
                          nsIMsgFolder *aImapMailFolder, 
                          nsIImapMessageSink *aImapMessage,
                          nsIURI **aURL,
                          nsISupports *aDisplayConsumer, 
                          const nsACString &messageIdentifierList,
                          const nsACString &mimePart);
 
-  nsresult FolderCommand(nsIEventTarget *clientEventTarget, 
-                         nsIMsgFolder *imapMailFolder,
+  nsresult FolderCommand(nsIMsgFolder *imapMailFolder,
                          nsIUrlListener *urlListener,
                          const char *aCommand,
                          nsImapAction imapAction,
                          nsIMsgWindow *msgWindow,
                          nsIURI **url);
 
-  nsresult ChangeFolderSubscription(nsIEventTarget *eventTarget, 
-                                    nsIMsgFolder *folder,
-                                    const nsAString &folderName, 
+  nsresult ChangeFolderSubscription(nsIMsgFolder *folder,
+                                    const nsAString &folderName,
                                     const char *aCommand,
                                     nsIUrlListener *urlListener,
                                     nsIURI **url);
 
-  nsresult DiddleFlags(nsIEventTarget *aClientEventTarget,
-                       nsIMsgFolder *aImapMailFolder, 
-                       nsIUrlListener *aUrlListener, 
+  nsresult DiddleFlags(nsIMsgFolder *aImapMailFolder,
+                       nsIUrlListener *aUrlListener,
                        nsIURI **aURL,
                        const nsACString &messageIdentifierList,
                        const char *howToDiddle,
                        imapMessageFlagsType flags,
                        bool messageIdsAreUID);
 
   nsresult OfflineAppendFromFile(nsIFile *aFile,
                                  nsIURI *aUrl,
--- a/mailnews/imap/src/nsImapUndoTxn.cpp
+++ b/mailnews/imap/src/nsImapUndoTxn.cpp
@@ -55,27 +55,25 @@
 nsImapMoveCopyMsgTxn::nsImapMoveCopyMsgTxn() :
     m_idsAreUids(false), m_isMove(false), m_srcIsPop3(false)
 {
 }
 
 nsresult
 nsImapMoveCopyMsgTxn::Init(nsIMsgFolder* srcFolder, nsTArray<nsMsgKey>* srcKeyArray, 
                            const char* srcMsgIdString, nsIMsgFolder* dstFolder,
-                           bool idsAreUids, bool isMove,
-                           nsIEventTarget* eventTarget)
+                           bool idsAreUids, bool isMove)
 {
   nsresult rv;
   m_srcHdrs = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
   m_srcMsgIdString = srcMsgIdString;
   m_idsAreUids = idsAreUids;
   m_isMove = isMove;
   m_srcFolder = do_GetWeakReference(srcFolder);
   m_dstFolder = do_GetWeakReference(dstFolder);
-  m_eventTarget = eventTarget;
   m_srcKeyArray = *srcKeyArray;
   m_dupKeyArray = *srcKeyArray;
   nsCString uri;
   rv = srcFolder->GetURI(uri);
   nsCString protocolType(uri);
   protocolType.SetLength(protocolType.FindChar(':'));
   nsCOMPtr<nsIMsgDatabase> srcDB;
   rv = srcFolder->GetMsgDatabase(getter_AddRefs(srcDB));
@@ -150,18 +148,17 @@ nsImapMoveCopyMsgTxn::UndoTransaction(vo
         return rv;
       nsCOMPtr<nsIUrlListener> srcListener = do_QueryInterface(srcFolder, &rv);
       if (NS_FAILED(rv)) 
         return rv;
       m_onStopListener =   do_GetWeakReference(srcListener);
 
       // ** make sure we are in the selected state; use lite select
       // folder so we won't hit performance hard
-      rv = imapService->LiteSelectFolder(m_eventTarget, srcFolder,
-        srcListener, nsnull, nsnull);
+      rv = imapService->LiteSelectFolder(srcFolder, srcListener, nsnull, nsnull);
       if (NS_FAILED(rv)) 
         return rv;
       bool deletedMsgs = true; //default is true unless imapDelete model
       nsMsgImapDeleteModel deleteModel;
       rv = GetImapDeleteModel(srcFolder, &deleteModel);
 
       // protect against a bogus undo txn without any source keys
       // see bug #179856 for details
@@ -170,53 +167,53 @@ nsImapMoveCopyMsgTxn::UndoTransaction(vo
         return NS_ERROR_UNEXPECTED;
 
       if (!m_srcMsgIdString.IsEmpty())
       {
         if (NS_SUCCEEDED(rv) && deleteModel == nsMsgImapDeleteModels::IMAPDelete)
           CheckForToggleDelete(srcFolder, m_srcKeyArray[0], &deletedMsgs);
 
         if (deletedMsgs)
-          rv = imapService->SubtractMessageFlags(m_eventTarget, srcFolder, 
+          rv = imapService->SubtractMessageFlags(srcFolder,
                                                  this, nsnull,
                                                  m_srcMsgIdString, 
                                                  kImapMsgDeletedFlag,
                                                  m_idsAreUids);
         else
-          rv = imapService->AddMessageFlags(m_eventTarget, srcFolder,
+          rv = imapService->AddMessageFlags(srcFolder,
                                             srcListener, nsnull,
                                             m_srcMsgIdString,
                                             kImapMsgDeletedFlag,
                                             m_idsAreUids);
         if (NS_FAILED(rv)) 
           return rv;
 
         finishInOnStopRunningUrl = true;
         if (deleteModel != nsMsgImapDeleteModels::IMAPDelete)
-          rv = imapService->GetHeaders(m_eventTarget, srcFolder,
-                                srcListener, nsnull, m_srcMsgIdString, true);
+          rv = imapService->GetHeaders(srcFolder, srcListener, nsnull,
+                                       m_srcMsgIdString, true);
       }
     }
   }
   if (!finishInOnStopRunningUrl && !m_dstMsgIdString.IsEmpty())
   {
     nsCOMPtr<nsIMsgFolder> dstFolder = do_QueryReferent(m_dstFolder, &rv);
     if (NS_FAILED(rv) || !dstFolder)
       return rv;
 
     nsCOMPtr<nsIUrlListener> dstListener;
 
     dstListener = do_QueryInterface(dstFolder, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     // ** make sure we are in the selected state; use lite select folder
     // so we won't potentially download a bunch of headers.
-    rv = imapService->LiteSelectFolder(m_eventTarget, dstFolder,
+    rv = imapService->LiteSelectFolder(dstFolder,
       dstListener, nsnull, nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = imapService->AddMessageFlags(m_eventTarget, dstFolder, dstListener,
+    rv = imapService->AddMessageFlags(dstFolder, dstListener,
                                       nsnull, m_dstMsgIdString, 
                                       kImapMsgDeletedFlag, m_idsAreUids);
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsImapMoveCopyMsgTxn::RedoTransaction(void)
@@ -250,60 +247,58 @@ nsImapMoveCopyMsgTxn::RedoTransaction(vo
       if (m_srcKeyArray.IsEmpty())
         return NS_ERROR_UNEXPECTED;
       
       if (NS_SUCCEEDED(rv) && deleteModel == nsMsgImapDeleteModels::IMAPDelete)
         rv = CheckForToggleDelete(srcFolder, m_srcKeyArray[0], &deletedMsgs);
       
       // Make sure we are in the selected state; use lite select
       // folder so performance won't suffer.
-      rv = imapService->LiteSelectFolder(m_eventTarget, srcFolder,
-        srcListener, nsnull, nsnull);
+      rv = imapService->LiteSelectFolder(srcFolder, srcListener, nsnull, nsnull);
       NS_ENSURE_SUCCESS(rv, rv);
       if (deletedMsgs)
       {
-        rv = imapService->SubtractMessageFlags(m_eventTarget, srcFolder,
-                                                srcListener, nsnull,
-                                                m_srcMsgIdString,
-                                                kImapMsgDeletedFlag,
-                                                m_idsAreUids);
+        rv = imapService->SubtractMessageFlags(srcFolder,
+                                               srcListener, nsnull,
+                                               m_srcMsgIdString,
+                                               kImapMsgDeletedFlag,
+                                               m_idsAreUids);
       }
       else
       {
-        rv = imapService->AddMessageFlags(m_eventTarget, srcFolder,
+        rv = imapService->AddMessageFlags(srcFolder,
                                           srcListener, nsnull, m_srcMsgIdString,
                                           kImapMsgDeletedFlag, m_idsAreUids);
       }
     }
   }
   if (!m_dstMsgIdString.IsEmpty())
   {
     nsCOMPtr<nsIMsgFolder> dstFolder = do_QueryReferent(m_dstFolder, &rv);
     if (NS_FAILED(rv) || !dstFolder) return rv;
 
     nsCOMPtr<nsIUrlListener> dstListener;
 
     dstListener = do_QueryInterface(dstFolder, &rv); 
     NS_ENSURE_SUCCESS(rv, rv);
     // ** make sure we are in the selected state; use lite select
     // folder so we won't hit performance hard
-    rv = imapService->LiteSelectFolder(m_eventTarget, dstFolder,
-      dstListener, nsnull, nsnull);
+    rv = imapService->LiteSelectFolder(dstFolder, dstListener, nsnull, nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = imapService->SubtractMessageFlags(m_eventTarget, dstFolder,
-                                           dstListener, nsnull, 
+    rv = imapService->SubtractMessageFlags(dstFolder,
+                                           dstListener, nsnull,
                                            m_dstMsgIdString,
                                            kImapMsgDeletedFlag,
                                            m_idsAreUids);
     NS_ENSURE_SUCCESS(rv, rv);
     nsMsgImapDeleteModel deleteModel;
     rv = GetImapDeleteModel(dstFolder, &deleteModel);
     if (NS_FAILED(rv) || deleteModel == nsMsgImapDeleteModels::MoveToTrash)
     {
-      rv = imapService->GetHeaders(m_eventTarget, dstFolder, dstListener, 
+      rv = imapService->GetHeaders(dstFolder, dstListener, 
                                    nsnull, m_dstMsgIdString, true);
     }
   }
   return rv;
 }
 
 nsresult
 nsImapMoveCopyMsgTxn::SetCopyResponseUid(const char* aMsgIdString)
@@ -450,26 +445,25 @@ NS_IMETHODIMP nsImapMoveCopyMsgTxn::OnSt
     {
       PRInt32 extraStatus;
       imapUrl->GetExtraStatus(&extraStatus);
       if (extraStatus != nsIImapUrl::ImapStatusNone)
       {
         // If subtracting the deleted flag didn't work, try
         // moving the message back from the target folder to the src folder
         if (!m_dstMsgIdString.IsEmpty())
-          imapService->OnlineMessageCopy(m_eventTarget,
-                                       dstFolder,
-                                       m_dstMsgIdString,
-                                       srcFolder,
-                                       true,
-                                       true,
-                                       nsnull, /* listener */
-                                       nsnull,
-                                       nsnull,
-                                       nsnull);
+          imapService->OnlineMessageCopy(dstFolder,
+                                         m_dstMsgIdString,
+                                         srcFolder,
+                                         true,
+                                         true,
+                                         nsnull, /* listener */
+                                         nsnull,
+                                         nsnull,
+                                         nsnull);
         else
         {
           // server doesn't support COPYUID, so we're going to update the dest
           // folder, and when that's done, use the db to find the messages
           // to move back, looking them up by message-id.
           nsCOMPtr<nsIMsgImapMailFolder> imapDest = do_QueryInterface(dstFolder);
           if (imapDest)
             imapDest->UpdateFolderWithListener(nsnull, this);
@@ -478,21 +472,20 @@ NS_IMETHODIMP nsImapMoveCopyMsgTxn::OnSt
       else if (!m_dstMsgIdString.IsEmpty())
       {
         nsCOMPtr<nsIUrlListener> dstListener;
 
         dstListener = do_QueryInterface(dstFolder, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
         // ** make sure we are in the selected state; use lite select folder
         // so we won't potentially download a bunch of headers.
-        rv = imapService->LiteSelectFolder(m_eventTarget, dstFolder,
-          dstListener, nsnull, nsnull);
+        rv = imapService->LiteSelectFolder(dstFolder, dstListener, nsnull, nsnull);
         NS_ENSURE_SUCCESS(rv, rv);
-        rv = imapService->AddMessageFlags(m_eventTarget, dstFolder, dstListener,
-                                          nsnull, m_dstMsgIdString, 
+        rv = imapService->AddMessageFlags(dstFolder, dstListener,
+                                          nsnull, m_dstMsgIdString,
                                           kImapMsgDeletedFlag, m_idsAreUids);
       }
     }
     else if (imapAction == nsIImapUrl::nsImapSelectFolder)
     {
       // Now we should have the headers from the dest folder.
       // Look them up and move them back to the source folder.
       PRUint32 count = m_srcMessageIds.Length();
@@ -513,33 +506,32 @@ NS_IMETHODIMP nsImapMoveCopyMsgTxn::OnSt
           dstHdr->GetMessageKey(&dstKey);
           dstKeys.AppendElement(dstKey);
         }
       }
       if (dstKeys.Length())
       {
         nsCAutoString uids;
         nsImapMailFolder::AllocateUidStringFromKeys(dstKeys.Elements(), dstKeys.Length(), uids);
-        rv = imapService->OnlineMessageCopy(m_eventTarget, dstFolder, uids, srcFolder,
+        rv = imapService->OnlineMessageCopy(dstFolder, uids, srcFolder,
                                             true, true, nsnull,
                                             nsnull, nsnull, nsnull);
       }
     }
   }
   return NS_OK;
 }
 
 nsImapOfflineTxn::nsImapOfflineTxn(nsIMsgFolder* srcFolder, nsTArray<nsMsgKey>* srcKeyArray,
                                    const char *srcMsgIdString, nsIMsgFolder* dstFolder,
                                    bool isMove, nsOfflineImapOperationType opType,
-                                   nsIMsgDBHdr *srcHdr,
-                                   nsIEventTarget* eventTarget)
+                                   nsIMsgDBHdr *srcHdr)
 {
   Init(srcFolder, srcKeyArray, srcMsgIdString, dstFolder, true,
-       isMove, eventTarget);
+       isMove);
 
   m_opType = opType; 
   m_flags = 0;
   m_addFlags = false;
   m_header = srcHdr;
   if (opType == nsIMsgOfflineImapOperation::kDeletedMsg)
   {
     nsCOMPtr <nsIMsgDatabase> srcDB;
--- a/mailnews/imap/src/nsImapUndoTxn.h
+++ b/mailnews/imap/src/nsImapUndoTxn.h
@@ -38,33 +38,31 @@
 #ifndef nsImapUndoTxn_h__
 #define nsImapUndoTxn_h__
 
 #include "nsIMsgFolder.h"
 #include "nsImapCore.h"
 #include "nsIImapService.h"
 #include "nsIImapIncomingServer.h"
 #include "nsIUrlListener.h"
-#include "nsIEventTarget.h"
 #include "nsMsgTxn.h"
 #include "MailNewsTypes.h"
 #include "nsTArray.h"
 #include "nsIMsgOfflineImapOperation.h"
 #include "nsCOMPtr.h"
 #include "nsWeakReference.h"
 
 class nsImapMoveCopyMsgTxn : public nsMsgTxn, nsIUrlListener
 {
 public:
 
   nsImapMoveCopyMsgTxn();
   nsImapMoveCopyMsgTxn(nsIMsgFolder* srcFolder, nsTArray<nsMsgKey>* srcKeyArray,
                        const char* srcMsgIdString, nsIMsgFolder* dstFolder,
-                       bool isMove, 
-                       nsIEventTarget *eventTarget);
+                       bool isMove);
   virtual ~nsImapMoveCopyMsgTxn();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIURLLISTENER
 
   NS_IMETHOD UndoTransaction(void);
   NS_IMETHOD RedoTransaction(void);
 
@@ -72,51 +70,48 @@ public:
   nsresult SetCopyResponseUid(const char *msgIdString);
   nsresult GetSrcKeyArray(nsTArray<nsMsgKey>& srcKeyArray);
   void GetSrcMsgIds(nsCString &srcMsgIds) {srcMsgIds = m_srcMsgIdString;}
   nsresult AddDstKey(nsMsgKey aKey);
   nsresult UndoMailboxDelete();
   nsresult RedoMailboxDelete();
   nsresult Init(nsIMsgFolder* srcFolder, nsTArray<nsMsgKey>* srcKeyArray,
                 const char* srcMsgIdString, nsIMsgFolder* dstFolder,
-                bool idsAreUids, bool isMove, 
-                nsIEventTarget *eventTarget);
+                bool idsAreUids, bool isMove);
 
 protected:
 
   nsWeakPtr m_srcFolder;
   nsCOMPtr<nsISupportsArray> m_srcHdrs;
   nsTArray<nsMsgKey> m_dupKeyArray;
   nsTArray<nsMsgKey> m_srcKeyArray;
   nsTArray<nsCString> m_srcMessageIds;
   nsCString m_srcMsgIdString;
   nsWeakPtr m_dstFolder;
   nsCString m_dstMsgIdString;
-  nsCOMPtr<nsIEventTarget> m_eventTarget;
   bool m_idsAreUids;
   bool m_isMove;
   bool m_srcIsPop3;
   nsTArray<PRUint32> m_srcSizeArray;
   // this is used when we chain urls for imap undo, since "this" needs
   // to be the listener, but the folder may need to also be notified.
   nsWeakPtr m_onStopListener;
 
   nsresult GetImapDeleteModel(nsIMsgFolder* aFolder, nsMsgImapDeleteModel *aDeleteModel);
 };
 
 class nsImapOfflineTxn : public nsImapMoveCopyMsgTxn
 {
 public:
   nsImapOfflineTxn(nsIMsgFolder* srcFolder, nsTArray<nsMsgKey>* srcKeyArray,
-                   const char* srcMsgIdString, 
+                   const char* srcMsgIdString,
                    nsIMsgFolder* dstFolder,
                    bool isMove,
                    nsOfflineImapOperationType opType,
-                   nsIMsgDBHdr *srcHdr,
-                   nsIEventTarget *eventTarge);
+                   nsIMsgDBHdr *srcHdr);
   virtual ~nsImapOfflineTxn();
 
   NS_IMETHOD UndoTransaction(void);
   NS_IMETHOD RedoTransaction(void);
   void SetAddFlags(bool addFlags) {m_addFlags = addFlags;}
   void SetFlags(PRUint32 flags) {m_flags = flags;}
 protected:
   nsOfflineImapOperationType m_opType;
--- a/mailnews/imap/test/unit/test_filterCustomHeaders.js
+++ b/mailnews/imap/test/unit/test_filterCustomHeaders.js
@@ -23,17 +23,17 @@ var tests = [
   setupTest,
   checkFilterResults,
   endTest
 ]
 
 function run_test()
 {
 
-// Create a test filter.
+  // Create a test filter.
   let filterList = gIMAPIncomingServer.getFilterList(null);
   let filter = filterList.createFilter("test list-id");
   let searchTerm = filter.createTerm();
   searchTerm.attrib = Ci.nsMsgSearchAttrib.OtherHeader + 1;
   searchTerm.op = Ci.nsMsgSearchOp.Contains;
   let value = searchTerm.value;
   value.attrib = Ci.nsMsgSearchAttrib.OtherHeader;
   value.str = "gnupg-users.gnupg.org";
@@ -48,16 +48,17 @@ function run_test()
   action.type = Ci.nsMsgFilterAction.MarkRead;
   filter.appendAction(action);
   filterList.insertFilterAt(0, filter);
 
   async_run_tests(tests);
 }
 
 function setupTest() {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   let file = do_get_file("../../../data/bugmail19");
   let msgfileuri = Services.io.newFileURI(file).QueryInterface(Ci.nsIFileURL);
 
   gIMAPMailbox.addMessage(new imapMessage(msgfileuri.spec,
                                           gIMAPMailbox.uidnext++, []));
   gIMAPInbox.updateFolderWithListener(null, asyncUrlListener);
   yield false;
 }
@@ -65,16 +66,17 @@ function setupTest() {
 function checkFilterResults() {
   let msgHdr = firstMsgHdr(gIMAPInbox);
   do_check_true(msgHdr.isRead);
   yield true;
 }
 
 // Cleanup
 function endTest() {
+  gIMAPServer.performTest("UID STORE");
   teardownIMAPPump();
 }
 
 // get the first message header found in a folder
 function firstMsgHdr(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   if (enumerator.hasMoreElements())
     return enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
--- a/mailnews/imap/test/unit/test_imapCopyTimeout.js
+++ b/mailnews/imap/test/unit/test_imapCopyTimeout.js
@@ -220,16 +220,17 @@ mfnListener =
       async_driver();
     gGotMsgAdded = true;
   },
 
 };
 
 function run_test()
 {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   // Add folder listeners that will capture async events
   const nsIMFNService = Ci.nsIMsgFolderNotificationService;
   let MFNService = Cc["@mozilla.org/messenger/msgnotificationservice;1"]
                       .getService(nsIMFNService);
   let flags =
         nsIMFNService.folderAdded |
         nsIMFNService.msgAdded;
   MFNService.addListener(mfnListener, flags);
--- a/mailnews/imap/test/unit/test_imapHighWater.js
+++ b/mailnews/imap/test/unit/test_imapHighWater.js
@@ -162,16 +162,17 @@ function doMoves() {
                                  CopyListener, dummyMsgWindow, true);
   yield false;
   gFolder1.msgDatabase.DeleteHeader(msgHdr, null, true, false);
   gIMAPInbox.updateFolderWithListener(null, UrlListener);
   yield false;
   // this should clear the dummy headers.
   gFolder1.updateFolderWithListener(dummyMsgWindow, UrlListener);
   yield false;
+  let serverSink = gIMAPIncomingServer.QueryInterface(Ci.nsIImapServerSink);
   do_check_eq(gFolder1.msgDatabase.dBFolderInfo.highWater, 11);
   yield true;
 }
 
 var UrlListener =
 {
   OnStartRunningUrl: function(url) { },
   OnStopRunningUrl: function(url, rc)
@@ -203,15 +204,17 @@ var tests = [
 ]
 
 function actually_run_test() {
   async_run_tests(tests);
 }
 
 function endTest()
 {
-  gIMAPIncomingServer.closeCachedConnections();
+  Services.io.offline = true;
+  gServer.performTest("LOGOUT");
+//  gIMAPIncomingServer.closeCachedConnections();
   gServer.stop();
   let thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
   yield true;
 }
--- a/mailnews/imap/test/unit/test_imapMove.js
+++ b/mailnews/imap/test/unit/test_imapMove.js
@@ -14,17 +14,17 @@
  * The Original Code is mozilla.org code.
  *
  * The Initial Developer of the Original Code is
  * the Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
- *   David Bienvenu <bienvenu@mozillamessaging.com>
+ *   David Bienvenu <bienvenu@mozilla.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -32,22 +32,20 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // This tests that we use IMAP move if the IMAP server supports it.
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource:///modules/mailServices.js");
+
 var gMessages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-var gCopyService = Cc["@mozilla.org/messenger/messagecopyservice;1"]
-                .getService(Ci.nsIMsgCopyService);
-const ioService = Cc["@mozilla.org/network/io-service;1"]
-                     .getService(Ci.nsIIOService);
-
 
 load("../../../resources/logHelper.js");
 load("../../../resources/mailTestUtils.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/messageGenerator.js");
 
 // IMAP pump
 load("../../../resources/IMAPpump.js");
@@ -59,46 +57,44 @@ var tests = [
   startTest,
   doMove,
   testMove,
   endTest
 ];
 
 function startTest()
 {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   // Add folder listeners that will capture async events
-  const nsIMFNService = Ci.nsIMsgFolderNotificationService;
-  let MFNService = Cc["@mozilla.org/messenger/msgnotificationservice;1"]
-                     .getService(nsIMFNService);
-  MFNService.addListener(mfnListener, nsIMFNService.folderAdded);
+  MailServices.mfn.addListener(mfnListener, MailServices.mfn.folderAdded);
 
   gIMAPIncomingServer.rootFolder.createSubfolder("folder 1", null);
   yield false;
   let messages = [];
   let gMessageGenerator = new MessageGenerator();
   messages = messages.concat(gMessageGenerator.makeMessage());
   gSynthMessage = messages[0];
-  let dataUri = ioService.newURI("data:text/plain;base64," +
+  let dataUri = Services.io.newURI("data:text/plain;base64," +
                   btoa(messages[0].toMessageString()),
                   null, null);
   let imapMsg = new imapMessage(dataUri.spec, gIMAPMailbox.uidnext++, []);
   gIMAPMailbox.addMessage(imapMsg);
 
   gIMAPInbox.updateFolderWithListener(null, UrlListener);
   yield false;
 }
 
 function doMove() {
   let rootFolder = gIMAPIncomingServer.rootFolder;
   gFolder1 = rootFolder.getChildNamed("folder 1")
                .QueryInterface(Components.interfaces.nsIMsgImapMailFolder);
   let msg = gIMAPInbox.msgDatabase.GetMsgHdrForKey(gIMAPMailbox.uidnext - 1);
   gMessages.appendElement(msg, false);
   gIMAPServer._test = true;
-  gCopyService.CopyMessages(gIMAPInbox, gMessages, gFolder1, true,
+  MailServices.copy.CopyMessages(gIMAPInbox, gMessages, gFolder1, true,
                             asyncCopyListener, null, false);
   gIMAPServer.performTest("UID MOVE");
   yield false;
 }
 
 function testMove() {
   do_check_eq(gIMAPInbox.getTotalMessages(false), 0);
   gFolder1.updateFolderWithListener(null, UrlListener);
--- a/mailnews/imap/test/unit/test_mailboxes.js
+++ b/mailnews/imap/test/unit/test_mailboxes.js
@@ -43,20 +43,18 @@ const gTestArray =
     // Check that we've subscribed to the boxes returned by LSUB. We also get
     // checking of proper i18n in mailboxes for free here.
     do_check_true(rootFolder.containsChildNamed("Inbox"));
     do_check_true(rootFolder.containsChildNamed("I18N box\u00E1"));
     // This is not a subscribed box, so we shouldn't be subscribing to it.
     do_check_false(rootFolder.containsChildNamed("Unsubscribed box"));
 
     let i18nChild = rootFolder.getChildNamed("I18N box\u00E1");
-    let uiThread =   Cc["@mozilla.org/thread-manager;1"]
-                        .getService(Ci.nsIThreadManager).mainThread;
 
-    gIMAPService.renameLeaf(uiThread, i18nChild, "test \u00E4", UrlListener, null);
+    gIMAPService.renameLeaf(i18nChild, "test \u00E4", UrlListener, null);
   },
   function checkRename() {
     do_check_true(rootFolder.containsChildNamed("test \u00E4"));
     let newChild = rootFolder.getChildNamed("test \u00E4").
                    QueryInterface(Ci.nsIMsgImapMailFolder);
     newChild.updateFolderWithListener(null, UrlListener);
   },
   function checkEmptyFolder() {
--- a/mailnews/imap/test/unit/test_preserveDataOnMove.js
+++ b/mailnews/imap/test/unit/test_preserveDataOnMove.js
@@ -162,16 +162,17 @@ mfnListener =
     dl('msgAdded with subject <' + aMsg.subject + '>')
     async_driver();
   },
 
 };
 
 function run_test()
 {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   // Add folder listeners that will capture async events
   const nsIMFNService = Ci.nsIMsgFolderNotificationService;
   var MFNService = Cc["@mozilla.org/messenger/msgnotificationservice;1"]
                       .getService(nsIMFNService);
   let flags =
         nsIMFNService.folderAdded |
         nsIMFNService.msgAdded;
   MFNService.addListener(mfnListener, flags);
--- a/mailnews/imap/test/unit/test_saveImapDraft.js
+++ b/mailnews/imap/test/unit/test_saveImapDraft.js
@@ -39,16 +39,18 @@
  * marked as unread.
  */
 
 // async support
 load("../../../resources/logHelper.js");
 load("../../../resources/mailTestUtils.js");
 load("../../../resources/asyncTestUtils.js");
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 // IMAP pump
 load("../../../resources/IMAPpump.js");
 
 setupIMAPPump();
 
 // Definition of tests
 
 var tests = [
@@ -95,35 +97,38 @@ function saveDraft()
   progress.registerListener(progressListener);
   msgCompose.SendMsg(Ci.nsIMsgSend.nsMsgSaveAsDraft, identity, "", null,
                      progress);
   yield false;
 }
 
 function updateDrafts()
 {
+  dump("updating drafts\n");
   gDraftsFolder.updateFolderWithListener(null, urlListener);
   yield false;
 }
 
 function checkResult()
 {
+  dump("checking result\n");
   do_check_eq(gDraftsFolder.getTotalMessages(false), 1);
   do_check_eq(gDraftsFolder.getNumUnread(false), 1);
   yield true;
 }
 
 function endTest()
 {
   teardownIMAPPump();
   yield true;
 }
 
 function run_test()
 {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   let server = gIMAPIncomingServer;
 
   // Add folder listeners that will capture async events
   const nsIMFNService = Ci.nsIMsgFolderNotificationService;
   let MFNService = Cc["@mozilla.org/messenger/msgnotificationservice;1"]
                       .getService(nsIMFNService);
 
   let flags =
@@ -138,16 +143,17 @@ function run_test()
 
 var urlListener = {
   OnStartRunningUrl: function _OnStartRunningUrl(aUrl) {
     // funny but this never seems to get called.
     dl('OnStartRunningUrl');
   },
   OnStopRunningUrl: function _OnStopRunningUrl(aUrl, aExitCode) {
     dl('OnStopRunningUrl');
+    dump("got on stop running url\n");
     async_driver();
   }
 };
 
 var mfnListener =
 {
   msgsMoveCopyCompleted: function (aMove, aSrcMsgs, aDestFolder, aDestMsgs)
   {
--- a/mailnews/imap/test/unit/test_saveTemplate.js
+++ b/mailnews/imap/test/unit/test_saveTemplate.js
@@ -136,16 +136,17 @@ mfnListener =
     do_check_eq(aMsg.folder.prettyName, "Templates");
     async_driver();
   },
 };
 
 
 function run_test()
 {
+  Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
   async_run_tests(tests);
 }
 
 // get the first message header found in a folder
 function firstMsgHdr(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   if (enumerator.hasMoreElements())
     return enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
--- a/mailnews/local/src/nsLocalUndoTxn.cpp
+++ b/mailnews/local/src/nsLocalUndoTxn.cpp
@@ -150,40 +150,35 @@ nsLocalMoveCopyMsgTxn::UndoImapDeleteFla
     PRUint32 i, count = keyArray.Length();
     urlListener = do_QueryInterface(folder, &rv);
     for (i=0; i < count; i++)
     {
       if (!msgIds.IsEmpty())
           msgIds.Append(',');
       msgIds.AppendInt((PRInt32) keyArray[i]);
     }
-    nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
-    if (thread)
-    {
-      // This is to make sure that we are in the selected state
-      // when executing the imap url; we don't want to load the
-      // folder so use lite select to do the trick
-      rv = imapService->LiteSelectFolder(thread, folder,
-                                         urlListener, nsnull, nsnull);
-      if (!deleteFlag)
-          rv =imapService->AddMessageFlags(thread, folder,
-                                          urlListener, nsnull,
-                                          msgIds,
-                                          kImapMsgDeletedFlag,
-                                          true);
-      else
-          rv = imapService->SubtractMessageFlags(thread,
-                                                folder,
-                                           urlListener, nsnull,
-                                           msgIds,
-                                           kImapMsgDeletedFlag,
-                                           true);
-      if (NS_SUCCEEDED(rv) && m_msgWindow)
-          folder->UpdateFolder(m_msgWindow);
-    }
+    // This is to make sure that we are in the selected state
+    // when executing the imap url; we don't want to load the
+    // folder so use lite select to do the trick
+    rv = imapService->LiteSelectFolder(folder,
+                                       urlListener, nsnull, nsnull);
+    if (!deleteFlag)
+        rv =imapService->AddMessageFlags(folder,
+                                         urlListener, nsnull,
+                                         msgIds,
+                                         kImapMsgDeletedFlag,
+                                         true);
+    else
+        rv = imapService->SubtractMessageFlags(folder,
+                                               urlListener, nsnull,
+                                               msgIds,
+                                               kImapMsgDeletedFlag,
+                                               true);
+    if (NS_SUCCEEDED(rv) && m_msgWindow)
+        folder->UpdateFolder(m_msgWindow);
     rv = NS_OK; // always return NS_OK to indicate that the src is imap
   }
   else
     rv = NS_ERROR_FAILURE;
   return rv;
 }
 
 NS_IMETHODIMP
--- a/mailnews/test/resources/IMAPpump.js
+++ b/mailnews/test/resources/IMAPpump.js
@@ -150,17 +150,21 @@ function setupIMAPPump(extensions)
   gIMAPMailbox = gIMAPDaemon.getMailbox("INBOX");
   gIMAPInbox instanceof Ci.nsIMsgImapMailFolder;
 }
 
 function teardownIMAPPump()
 {
   gIMAPInbox = null;
   gIMAPServer.resetTest();
-  gIMAPIncomingServer.closeCachedConnections();
+  try {
+    gIMAPIncomingServer.closeCachedConnections();
+    let serverSink = gIMAPIncomingServer.QueryInterface(Ci.nsIImapServerSink);
+    serverSink.abortQueuedUrls();
+  } catch (ex) {dump(ex);}
   gIMAPServer.performTest();
   gIMAPServer.stop();
   let thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 }
 
 } // end run only once
--- a/mailnews/test/resources/messageInjection.js
+++ b/mailnews/test/resources/messageInjection.js
@@ -190,19 +190,16 @@ function configure_message_injection(aIn
     //  that we set the pref above?)
     if (mis.injectionConfig.offline)
       mis.inboxFolder.setFlag(Ci.nsMsgFolderFlags.Offline);
     else
       mis.inboxFolder.clearFlag(Ci.nsMsgFolderFlags.Offline);
     _messageInjectionSetup.notifyListeners("onRealFolderCreated",
                                            [mis.inboxFolder]);
 
-    mis.mainThread = Cc["@mozilla.org/thread-manager;1"]
-                       .getService()
-                       .mainThread;
     mis.imapService = Cc["@mozilla.org/messenger/imapservice;1"]
                         .getService(Ci.nsIImapService);
 
     mis.handleUriToRealFolder = {};
     mis.handleUriToFakeFolder = {};
     mis.realUriToFakeFolder = {};
     mis.realUriToFakeFolder[mis.inboxFolder.URI] =
       mis.daemon.getMailbox("INBOX");
@@ -355,17 +352,16 @@ function make_empty_folder(aFolderName, 
   else if (mis.injectionConfig.mode == "imap") {
     let promise_completed = async_create_promise();
 
     testFolder = mis.rootFolder.URI + "/" + aFolderName;
 
     // Tell the IMAP service to create the folder, adding a listener that
     //  hooks up the 'handle' URI -> actual folder mapping.
     mis.imapService.createFolder(
-      mis.mainThread,
       mis.rootFolder,
       aFolderName,
       new AsyncUrlListener(mis.rootFolder, function() {
         // get the newly created nsIMsgFolder folder
         let msgFolder = mis.rootFolder.getChildNamed(aFolderName);
 
         // XXX there is a bug that causes folders to be reported as ImapPublic
         //  when there is no namespace support by the IMAP server.  This is