add msgWindow param to verifyLogon, and return URL that gets run, r/sr=neil, 480026
authorDavid Bienvenu <bienvenu@nventure.com>
Mon, 02 Mar 2009 13:09:13 -0800
changeset 2067 591e0c70e7e05585beec9b3b7a70c54f5213dd38
parent 2066 6cb07ef0eeac4303e3e76033e5f095587dc5de37
child 2068 07674dbbfbc4d94a29e8eb833ff8b0467801bef6
push idunknown
push userunknown
push dateunknown
bugs480026
add msgWindow param to verifyLogon, and return URL that gets run, r/sr=neil, 480026
mailnews/base/public/nsIMsgIncomingServer.idl
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/compose/public/nsISmtpServer.idl
mailnews/compose/public/nsISmtpService.idl
mailnews/compose/src/nsSmtpServer.cpp
mailnews/compose/src/nsSmtpService.cpp
mailnews/imap/public/nsIImapService.idl
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapIncomingServer.h
mailnews/imap/src/nsImapService.cpp
mailnews/local/public/nsIPop3Service.idl
mailnews/local/src/nsPop3IncomingServer.cpp
mailnews/local/src/nsPop3IncomingServer.h
mailnews/local/src/nsPop3Service.cpp
--- a/mailnews/base/public/nsIMsgIncomingServer.idl
+++ b/mailnews/base/public/nsIMsgIncomingServer.idl
@@ -46,16 +46,17 @@ interface nsIMsgWindow;
 interface nsIMsgFilterList;
 interface nsIMsgRetentionSettings;
 interface nsIMsgDownloadSettings;
 interface nsISpamSettings;
 interface nsIMsgFilterPlugin;
 interface nsIUrlListener;
 interface nsIMsgDBHdr;
 interface nsILocalFile;
+interface nsIURI;
 
 /*
  * Interface for incoming mail/news host
  * this is the base interface for all mail server types (imap, pop, nntp, etc)
  * often you will want to add extra interfaces that give you server-specific
  * attributes and methods.
  */
 [scriptable, uuid(2795ee91-7231-4c3b-a6ed-ea9a721371fa)]
@@ -198,22 +199,23 @@ interface nsIMsgIncomingServer : nsISupp
 
   /* set filter list */
   void setFilterList(in nsIMsgFilterList aFilterList);
 
   /* we use this to set the default local path.  we use this when migrating prefs */
   void setDefaultLocalPath(in nsILocalFile aDefaultLocalPath);
 
   /**
-   * Verify that we can logon 
+   * Verify that we can logon
    * 
    * @param  aUrlListener - gets called back with success or failure.
-   *
+   * @param aMsgWindow         nsIMsgWindow to use for notification callbacks.
+   * @return - the url that we run.
    */
-  void verifyLogon(in nsIUrlListener aUrlListener);
+  nsIURI verifyLogon(in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
 
   /* do a biff */
   void performBiff(in nsIMsgWindow aMsgWindow);
   
   /* get new messages */
   void getNewMessages(in nsIMsgFolder aFolder, in nsIMsgWindow aMsgWindow, 
                       in nsIUrlListener aUrlListener);
   /* this checks if a server needs a password to do biff */
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -179,19 +179,19 @@ nsMsgIncomingServer::GetRootMsgFolder(ns
 }
 
 NS_IMETHODIMP
 nsMsgIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow)
 {
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsMsgIncomingServer::VerifyLogon(nsIUrlListener *aUrlListener)
+nsMsgIncomingServer::VerifyLogon(nsIUrlListener *aUrlListener, nsIMsgWindow *aMsgWindow,
+                                 nsIURI **aURL)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsMsgIncomingServer::PerformBiff(nsIMsgWindow* aMsgWindow)
 {
   //This has to be implemented in the derived class, but in case someone doesn't implement it
--- a/mailnews/compose/public/nsISmtpServer.idl
+++ b/mailnews/compose/public/nsISmtpServer.idl
@@ -35,25 +35,27 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 interface nsIAuthPrompt;
 interface nsIUrlListener;
+interface nsIURI;
+interface nsIMsgWindow;
 
 /**
  * This interface represents a single SMTP Server. A SMTP server instance may be
  * created/obtained from nsIMsgAccountManager.
  *
  * Most of the attributes will set/get preferences from the main preferences
  * file.
  */
-[scriptable, uuid(67725a6a-ddab-4fed-97f1-e58105c23c0e)]
+[scriptable, uuid(cf300e82-9def-43b0-b663-be08437960eb)]
 interface nsISmtpServer : nsISupports {
 
   /// A unique identifier for the server.
   attribute string key;
 
   /// A user supplied description for the server.
   attribute AUTF8String description;
 
@@ -151,16 +153,16 @@ interface nsISmtpServer : nsISupports {
    */
   void forgetPassword();
 
     /**
    * Verify that we can logon 
    * 
    * @param  aPassword - password to use
    * @param  aUrlListener - gets called back with success or failure.
+   * @return - the url that we run.
    *
    */
-  void verifyLogon(in nsIUrlListener aUrlListener);
-
+  nsIURI verifyLogon(in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
 
   /// Call this to clear all preference values for this server.
   void clearAllValues();
 };
--- a/mailnews/compose/public/nsISmtpService.idl
+++ b/mailnews/compose/public/nsISmtpService.idl
@@ -42,18 +42,19 @@ interface nsISmtpServer;
 interface nsIURI;
 interface nsIUrlListener;
 interface nsIMsgIdentity;
 interface nsIInterfaceRequestor;
 interface nsIFile;
 interface nsIMsgStatusFeedback;
 interface nsIRequest;
 interface nsISimpleEnumerator;
+interface nsIMsgWindow;
 
-[scriptable, uuid(7b1c1604-7aad-451e-ae55-a7984c1fd0d9)]
+[scriptable, uuid(8c5c5d5b-3b69-4a80-bf4b-d6c22865a3c3)]
 interface nsISmtpService : nsISupports {
   /**
    * Sends a mail message via the given parameters. This function builds an
    * SMTP URL and makes an SMTP connection, and then runs the url.
    * The SMTP server defined
    * in the aSenderIdentity object (see nsIMsgIdentity) will be used to send
    * the message. If there is no SMTP server defined in aSenderIdentity, the
    * default SMTP server will be used.
@@ -95,18 +96,21 @@ interface nsISmtpService : nsISupports {
                        out nsIRequest aRequest);
 
   /**
    * Verifies that we can logon to the server with given password
    *
    * @param  aSmtpServer       Server to try to logon to.
    * @param  aUrlListener      Listener that will get notified whether logon
    *                           was successful or not.
+   * @param aMsgWindow         nsIMsgWindow to use for notification callbacks.
+   * @return - the url that we run.
    */
-  void verifyLogon(in nsISmtpServer aServer, in nsIUrlListener aListener);
+  nsIURI verifyLogon(in nsISmtpServer aServer, in nsIUrlListener aListener,
+                     in nsIMsgWindow aMsgWindow);
 
   /**
    * Return the SMTP server that is associated with an identity.
    */
   void GetSmtpServerByIdentity(in nsIMsgIdentity aSenderIdentity,
                                out nsISmtpServer aServer);
 
   /**
--- a/mailnews/compose/src/nsSmtpServer.cpp
+++ b/mailnews/compose/src/nsSmtpServer.cpp
@@ -410,22 +410,23 @@ nsSmtpServer::GetPassword(nsACString& aP
       if (incomingServerToUse)
         return incomingServerToUse->GetPassword(aPassword);
     }
     aPassword = m_password;
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::VerifyLogon(nsIUrlListener *aUrlListener)
+nsSmtpServer::VerifyLogon(nsIUrlListener *aUrlListener, nsIMsgWindow *aMsgWindow,
+                          nsIURI **aURL)
 {
   nsresult rv;
   nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
-  return smtpService->VerifyLogon(this, aUrlListener);
+  return smtpService->VerifyLogon(this, aUrlListener, aMsgWindow, aURL);
 }
 
 
 NS_IMETHODIMP
 nsSmtpServer::SetPassword(const nsACString& aPassword)
 {
   m_password = aPassword;
   return NS_OK;
--- a/mailnews/compose/src/nsSmtpService.cpp
+++ b/mailnews/compose/src/nsSmtpService.cpp
@@ -237,17 +237,17 @@ nsresult NS_MsgBuildSmtpUrl(nsIFile * aF
 
   return CallQueryInterface(smtpUrl, aUrl);
 }
 
 nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer, nsIRequest ** aRequest)
 {
     // for now, assume the url is an smtp url and load it....
     nsCOMPtr <nsISmtpUrl> smtpUrl;
-    nsSmtpProtocol	*smtpProtocol = nsnull;
+    nsSmtpProtocol *smtpProtocol = nsnull;
     nsresult rv = NS_OK;
 
     if (!aUrl)
         return rv;
 
     // turn the url into an smtp url...
     smtpUrl = do_QueryInterface(aUrl);
     if (smtpUrl)
@@ -262,28 +262,37 @@ nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl
         smtpProtocol->QueryInterface(NS_GET_IID(nsIRequest), (void **) aRequest);
         NS_RELEASE(smtpProtocol);
     }
 
     return rv;
 }
 
 NS_IMETHODIMP nsSmtpService::VerifyLogon(nsISmtpServer *aServer,
-                                         nsIUrlListener *aUrlListener)
+                                         nsIUrlListener *aUrlListener,
+                                         nsIMsgWindow *aMsgWindow,
+                                         nsIURI **aURL)
 {
   NS_ENSURE_ARG_POINTER(aServer);
   nsCString popHost;
   nsCString popUser;
   nsCOMPtr <nsIURI> urlToRun;
 
   nsresult rv = NS_MsgBuildSmtpUrl(nsnull, aServer,
-                          nsnull, nsnull, aUrlListener, nsnull, 
+                          nsnull, nsnull, aUrlListener, nsnull,
                           nsnull , getter_AddRefs(urlToRun), PR_FALSE);
-  if (NS_SUCCEEDED(rv) && urlToRun)	
+  if (NS_SUCCEEDED(rv) && urlToRun)
+  {
+    nsCOMPtr<nsIMsgMailNewsUrl> url(do_QueryInterface(urlToRun, &rv));
+    NS_ENSURE_SUCCESS(rv, rv);
+    url->SetMsgWindow(aMsgWindow);
     rv = NS_MsgLoadSmtpUrl(urlToRun, nsnull, nsnull /* aRequest */);
+    if (aURL)
+      urlToRun.forget(aURL);
+  }
   return rv;
 }
 
 NS_IMETHODIMP nsSmtpService::GetScheme(nsACString &aScheme)
 {
     aScheme = "mailto";
     return NS_OK; 
 }
--- a/mailnews/imap/public/nsIImapService.idl
+++ b/mailnews/imap/public/nsIImapService.idl
@@ -53,17 +53,17 @@ interface nsIUrlListener;
 interface nsIURI;
 interface nsIEventTarget;
 interface nsIFile;
 interface nsIMsgFolder;
 interface nsIMsgWindow;
 interface nsIImapIncomingServer;
 interface nsICacheSession;
 
-[scriptable, uuid(a12113ff-0cc4-41ba-ae98-fe31cf2411ce)]
+[scriptable, uuid(9308fe9b-bc6c-4e5a-93a8-a8f7d4d75ba1)]
 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,
                     in nsIUrlListener aUrlListener,
                     in nsIMsgWindow   aMsgWindow,
@@ -112,20 +112,29 @@ interface nsIImapService : nsISupports
                in nsIMsgFolder aImapMailFolder,
                in nsIUrlListener aUrlListener,
                out nsIURI aURL);
   
   nsIURI updateFolderStatus(in nsIEventTarget aClientEventTarget, 
                in nsIMsgFolder aImapMailFolder,
                in nsIUrlListener aUrlListener);
 
-  void verifyLogon(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, 
+  void biff(in nsIEventTarget aClientEventTarget,
             in nsIMsgFolder aImapMailFolder,
             in nsIUrlListener aUrlListener,
             out nsIURI aURL,
             in unsigned long aUidHighWater);
 
   void deleteMessages(in nsIEventTarget aClientEventTarget, 
                       in nsIMsgFolder aImapMailFolder,
                       in nsIUrlListener aUrlListener,
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -928,31 +928,31 @@ nsImapIncomingServer::PerformExpand(nsIM
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = imapService->DiscoverAllFolders(NS_GetCurrentThread(), rootMsgFolder,
                                        this, aMsgWindow, nsnull);
   return rv;
 }
 
 NS_IMETHODIMP
-nsImapIncomingServer::VerifyLogon(nsIUrlListener *aUrlListener)
+nsImapIncomingServer::VerifyLogon(nsIUrlListener *aUrlListener,
+                                  nsIMsgWindow *aMsgWindow, nsIURI **aURL)
 {
   nsresult rv;
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIMsgFolder> rootFolder;
   // this will create the resource if it doesn't exist, but it shouldn't
   // do anything on disk.
   rv = GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
-  return imapService->VerifyLogon(rootFolder, aUrlListener);
+  return imapService->VerifyLogon(rootFolder, aUrlListener, aMsgWindow, aURL);
 }
 
-
 NS_IMETHODIMP nsImapIncomingServer::PerformBiff(nsIMsgWindow* aMsgWindow)
 {
   nsCOMPtr<nsIMsgFolder> rootMsgFolder;
   nsresult rv = GetRootMsgFolder(getter_AddRefs(rootMsgFolder));
   if(NS_SUCCEEDED(rv))
   {
     SetPerformingBiff(PR_TRUE);
     rv = rootMsgFolder->GetNewMessages(aMsgWindow, nsnull);
--- a/mailnews/imap/src/nsImapIncomingServer.h
+++ b/mailnews/imap/src/nsImapIncomingServer.h
@@ -92,17 +92,18 @@ public:
   NS_IMETHOD GetFilterScope(nsMsgSearchScopeValue *filterScope);
   NS_IMETHOD GetSearchScope(nsMsgSearchScopeValue *searchScope);
   NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
   NS_IMETHOD OnUserOrHostNameChanged(const nsACString& oldName, const nsACString& newName);
   NS_IMETHOD GetNumIdleConnections(PRInt32 *aNumIdleConnections);
   NS_IMETHOD ForgetSessionPassword();
   NS_IMETHOD GetMsgFolderFromURI(nsIMsgFolder *aFolderResource, const nsACString& aURI, nsIMsgFolder **aFolder);
   NS_IMETHOD SetSocketType(PRInt32 aSocketType);
-  NS_IMETHOD VerifyLogon(nsIUrlListener *aUrlListener);
+  NS_IMETHOD VerifyLogon(nsIUrlListener *aUrlListener, nsIMsgWindow *aMsgWindow,
+                         nsIURI **aURL);
 
 protected:
   nsresult GetFolder(const nsACString& name, nsIMsgFolder** pFolder);
   virtual nsresult CreateRootFolderFromUri(const nsCString &serverUri,
                                            nsIMsgFolder **rootFolder);
   nsresult ResetFoldersToUnverified(nsIMsgFolder *parentFolder);
   void GetUnverifiedSubFolders(nsIMsgFolder *parentFolder,
                                nsCOMArray<nsIMsgImapMailFolder> &aFoldersArray);
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -1498,41 +1498,43 @@ nsresult nsImapService::FolderCommand(ns
       if (NS_SUCCEEDED(rv))
         rv = GetImapConnectionAndLoadUrl(clientEventTarget, imapUrl, nsnull, url);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsImapService::VerifyLogon(nsIMsgFolder *aFolder, nsIUrlListener *aUrlListener)
+nsImapService::VerifyLogon(nsIMsgFolder *aFolder, nsIUrlListener *aUrlListener,
+                           nsIMsgWindow *aMsgWindow, nsIURI **aURL)
 {
-  nsCOMPtr<nsIImapUrl> aImapUrl;
+  nsCOMPtr<nsIImapUrl> imapUrl;
   nsCAutoString urlSpec;
-  
+
   PRUnichar delimiter = '/'; // shouldn't matter what is is.
-  nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(aImapUrl), aFolder,
+  nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl), aFolder,
                                      aUrlListener, urlSpec, delimiter);
-  if (NS_SUCCEEDED(rv) && aImapUrl)
+  if (NS_SUCCEEDED(rv) && imapUrl)
   {
-    nsCOMPtr<nsIURI> uri = do_QueryInterface(aImapUrl);
-    
-    nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(aImapUrl);
+    nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
+
+    nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
     mailNewsUrl->SetSuppressErrorMsgs(PR_TRUE);
-    rv = SetImapUrlSink(aFolder, aImapUrl);
+    mailNewsUrl->SetMsgWindow(aMsgWindow);
+    rv = SetImapUrlSink(aFolder, imapUrl);
     urlSpec.Append("/verifyLogon");
     rv = uri->SetSpec(urlSpec);
     if (NS_SUCCEEDED(rv))
-      rv = GetImapConnectionAndLoadUrl(NS_GetCurrentThread(), aImapUrl, nsnull, nsnull);
+      rv = GetImapConnectionAndLoadUrl(NS_GetCurrentThread(), 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,
                                   nsIUrlListener *aUrlListener, 
                                   nsIURI **aURL)
 {
   return FolderCommand(aClientEventTarget, aImapMailFolder, aUrlListener,
                        "/selectnoop>", nsIImapUrl::nsImapSelectNoopFolder, nsnull, aURL);
--- a/mailnews/local/public/nsIPop3Service.idl
+++ b/mailnews/local/public/nsIPop3Service.idl
@@ -42,19 +42,19 @@
 
 interface nsIURI;
 interface nsIStreamListener;
 interface nsIMsgWindow;
 interface nsIMsgFolder;
 
 /*
  * The Pop3 Service is an interface designed to make building and running
- * pop3 urls easier. 
+ * pop3 urls easier.
  */
-[scriptable, uuid(d3b0eead-a0aa-47bd-a751-aa01e01c1ff7)]
+[scriptable, uuid(b6594f64-4f9d-4655-9e96-ed927823fb73)]
 interface nsIPop3Service : nsISupports {
   /*
    * All of these functions build pop3 urls and run them. If you want
    * a handle on the running task, pass in a valid nsIURI ptr. You can later
    * interrupt this action by asking the netlib service manager to interrupt
    * the url you are given back. Remember to release aURL when you are
    * done with it. Pass nsnull in for aURL if you
    * don't care about the returned URL.
@@ -69,19 +69,20 @@ interface nsIPop3Service : nsISupports {
 
   nsIURI GetNewMail(in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener,
                     in nsIMsgFolder aInbox, in nsIPop3IncomingServer popServer);
 
   nsIURI CheckForNewMail(in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener,
                          in nsIMsgFolder inbox, in nsIPop3IncomingServer popServer);
 
   /**
-   * Verify that we can logon 
-   * 
+   * Verify that we can logon
+   *
    * @param  aServer - pop3 server we're logging on to.
    * @param  aUrlListener - gets called back with success or failure.
+   * @param aMsgWindow    - nsIMsgWindow to use for notification callbacks.
+   * @return - the url that we run.
    *
    */
-  void verifyLogon(in nsIMsgIncomingServer aServer, 
-                   in nsIUrlListener aUrlListener);
-
-
+  nsIURI verifyLogon(in nsIMsgIncomingServer aServer,
+                     in nsIUrlListener aUrlListener,
+                     in nsIMsgWindow aMsgWindow);
 };
--- a/mailnews/local/src/nsPop3IncomingServer.cpp
+++ b/mailnews/local/src/nsPop3IncomingServer.cpp
@@ -413,22 +413,23 @@ nsPop3IncomingServer::GetCanCreateFolder
 
   nsCString deferredToAccount;
   GetDeferredToAccount(deferredToAccount);
   *aCanCreateFoldersOnServer = deferredToAccount.IsEmpty();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPop3IncomingServer::VerifyLogon(nsIUrlListener *aUrlListener)
+nsPop3IncomingServer::VerifyLogon(nsIUrlListener *aUrlListener,
+                                  nsIMsgWindow *aMsgWindow, nsIURI **aURL)
 {
   nsresult rv;
   nsCOMPtr<nsIPop3Service> pop3Service = do_GetService(kCPop3ServiceCID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  return pop3Service->VerifyLogon(this, aUrlListener);
+  return pop3Service->VerifyLogon(this, aUrlListener, aMsgWindow, aURL);
 }
 
 NS_IMETHODIMP nsPop3IncomingServer::DownloadMailFromServers(nsISupportsArray *aServers,
                               nsIMsgWindow *aMsgWindow,
                               nsIMsgFolder *aFolder,
                               nsIUrlListener *aUrlListener)
 {
   nsPop3GetMailChainer *getMailChainer = new nsPop3GetMailChainer;
--- a/mailnews/local/src/nsPop3IncomingServer.h
+++ b/mailnews/local/src/nsPop3IncomingServer.h
@@ -63,17 +63,18 @@ public:
   NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow);
   NS_IMETHOD GetDownloadMessagesAtStartup(PRBool *getMessages);
   NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer);
   NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
   NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
   NS_IMETHOD GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder);
   NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
   NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);
-  NS_IMETHOD VerifyLogon(nsIUrlListener *aUrlListener);
+  NS_IMETHOD VerifyLogon(nsIUrlListener *aUrlListener, nsIMsgWindow *aMsgWindow,
+                         nsIURI **aURL);
   NS_IMETHOD GetNewMessages(nsIMsgFolder *aFolder, nsIMsgWindow *aMsgWindow,
                             nsIUrlListener *aUrlListener);
 
 protected:
   nsresult GetInbox(nsIMsgWindow *msgWindow, nsIMsgFolder **inbox);
 
 private:
   PRUint32 m_capabilityFlags;
--- a/mailnews/local/src/nsPop3Service.cpp
+++ b/mailnews/local/src/nsPop3Service.cpp
@@ -165,17 +165,19 @@ nsresult nsPop3Service::GetMail(PRBool d
 
   if (aURL && url) // we already have a ref count on pop3url...
     NS_IF_ADDREF(*aURL = url);
 
   return rv;
 }
 
 NS_IMETHODIMP nsPop3Service::VerifyLogon(nsIMsgIncomingServer *aServer,
-                                         nsIUrlListener *aUrlListener)
+                                         nsIUrlListener *aUrlListener,
+                                         nsIMsgWindow *aMsgWindow,
+                                         nsIURI **aURL)
 {
   NS_ENSURE_ARG_POINTER(aServer);
   nsCString popHost;
   nsCString popUser;
   PRInt32 popPort = -1;
 
   nsresult rv = aServer->GetHostName(popHost);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -199,21 +201,25 @@ NS_IMETHODIMP nsPop3Service::VerifyLogon
   // we need to escape the username because it may contain
   // characters like / % or @
   char * urlSpec = PR_smprintf("pop3://%s@%s:%d/?verifyLogon", 
                               escapedUsername.get(), popHost.get(), popPort);
   if (!urlSpec)
     return NS_ERROR_OUT_OF_MEMORY;
   nsCOMPtr<nsIURI> url;
   rv = BuildPop3Url(urlSpec, nsnull, popServer, aUrlListener, 
-                    getter_AddRefs(url), nsnull);
+                    getter_AddRefs(url), aMsgWindow);
   PR_smprintf_free(urlSpec);
 
   if (NS_SUCCEEDED(rv) && url)
+  {
     rv = RunPopUrl(aServer, url);
+    if (NS_SUCCEEDED(rv) && aURL)
+      url.forget(aURL);
+  }
 
   return rv;
 }
 
 nsresult nsPop3Service::BuildPop3Url(const char * urlSpec,
                                      nsIMsgFolder *inbox,
                                      nsIPop3IncomingServer *server,
                                      nsIUrlListener * aUrlListener,