infrastructure work in preparation for a non-rdf folder pane, r=standard8, sr=neil 414038
authorDavid Bienvenu <bienvenu@nventure.com>
Sun, 26 Oct 2008 14:27:14 -0700
changeset 725 7d07094f79404ebf8a2eabb5cf1b0cd632146c26
parent 724 dbe13b6b38e51bc8c4f308e07c66dbd1234146cc
child 726 e6eac490c2ddf0611d6c572ec67d407a93703cfc
push idunknown
push userunknown
push dateunknown
reviewersstandard8, neil
bugs414038
infrastructure work in preparation for a non-rdf folder pane, r=standard8, sr=neil 414038
mailnews/base/src/nsMsgAccountManagerDS.cpp
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapIncomingServer.h
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapMailFolder.h
mailnews/local/src/Makefile.in
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsLocalMailFolder.h
mailnews/local/src/nsMailboxServer.cpp
mailnews/local/src/nsMailboxServer.h
mailnews/local/src/nsMovemailIncomingServer.cpp
mailnews/local/src/nsMovemailIncomingServer.h
mailnews/local/src/nsMovemailService.cpp
mailnews/local/src/nsNoIncomingServer.h
mailnews/local/src/nsNoneService.cpp
mailnews/local/src/nsPop3IncomingServer.cpp
mailnews/local/src/nsPop3IncomingServer.h
mailnews/local/src/nsRssIncomingServer.cpp
mailnews/local/src/nsRssIncomingServer.h
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNewsFolder.h
mailnews/news/src/nsNntpIncomingServer.cpp
mailnews/news/src/nsNntpIncomingServer.h
--- a/mailnews/base/src/nsMsgAccountManagerDS.cpp
+++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp
@@ -769,21 +769,20 @@ nsresult
 nsMsgAccountManagerDataSource::createSettingsResources(nsIRDFResource *aSource,
                                                        nsISupportsArray *aNodeArray)
 {
   // If this isn't a server, just return.
   if (aSource == kNC_PageTitleSMTP)
     return NS_OK;
 
   nsCOMPtr<nsIMsgIncomingServer> server;
-  nsresult rv = getServerForFolderNode(aSource, getter_AddRefs(server));
-  NS_ENSURE_SUCCESS(rv, rv);
+  getServerForFolderNode(aSource, getter_AddRefs(server));
   if (server) {
     PRBool hasIdentities;
-    rv = serverHasIdentities(server, &hasIdentities);
+    nsresult rv = serverHasIdentities(server, &hasIdentities);
 
     if (hasIdentities) {
       aNodeArray->AppendElement(kNC_PageTitleServer);
       aNodeArray->AppendElement(kNC_PageTitleCopies);
       aNodeArray->AppendElement(kNC_PageTitleAddressing);
     }
 
     // Junk settings apply for all server types except for news and rss.
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -58,17 +58,17 @@
 #include "nsImapStringBundle.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsMsgFolderFlags.h"
 #include "prmem.h"
 #include "plstr.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgWindow.h"
-#include "nsIMsgImapMailFolder.h"
+#include "nsImapMailFolder.h"
 #include "nsImapUtils.h"
 #include "nsIRDFService.h"
 #include "nsRDFCID.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIImapService.h"
 #include "nsMsgI18N.h"
 #include "nsAutoLock.h"
 #include "nsIImapMockChannel.h"
@@ -1068,16 +1068,28 @@ NS_IMETHODIMP nsImapIncomingServer::GetR
 }
 
 NS_IMETHODIMP nsImapIncomingServer::GetSentMailPFC(PRBool createIfMissing, nsIMsgFolder **aFolder)
 {
   NS_ENSURE_ARG_POINTER(aFolder);
   return GetPFCForStringId(createIfMissing, IMAP_PFC_SENT_MAIL, aFolder);
 }
 
+nsresult
+nsImapIncomingServer::CreateRootFolderFromUri(const nsCString &serverUri,
+                                              nsIMsgFolder **rootFolder)
+{
+  nsImapMailFolder *newRootFolder = new nsImapMailFolder;
+  if (!newRootFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  newRootFolder->Init(serverUri.get());
+  NS_ADDREF(*rootFolder = newRootFolder);
+  return NS_OK;
+}
+
 // nsIImapServerSink impl
 // aNewFolder will not be set if we're listing for the subscribe UI, since that's the way 4.x worked.
 NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folderPath, PRUnichar hierarchyDelimiter,
                                                         PRInt32 boxFlags, PRBool *aNewFolder)
 {
   NS_ENSURE_ARG_POINTER(aNewFolder);
   NS_ENSURE_TRUE(!folderPath.IsEmpty(), NS_ERROR_FAILURE);
   // folderPath is in canonical format, i.e., hierarchy separator has been replaced with '/'
--- a/mailnews/imap/src/nsImapIncomingServer.h
+++ b/mailnews/imap/src/nsImapIncomingServer.h
@@ -96,16 +96,18 @@ public:
   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);
 
 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);
   void GetUnverifiedFolders(nsCOMArray<nsIMsgImapMailFolder> &aFolderArray);
   nsresult DeleteNonVerifiedFolders(nsIMsgFolder *parentFolder);
   PRBool NoDescendentsAreVerified(nsIMsgFolder *parentFolder);
   PRBool AllDescendentsAreNoSelect(nsIMsgFolder *parentFolder);
 
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -297,16 +297,26 @@ nsShouldIgnoreFile(nsString& name)
   if (len > 4 && name.RFind(SUMMARY_SUFFIX, PR_TRUE) == len - 4)
   {
     name.SetLength(len-4); // truncate the string
     return PR_FALSE;
   }
   return PR_TRUE;
 }
 
+nsresult nsImapMailFolder::CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder)
+{
+  nsImapMailFolder *newFolder = new nsImapMailFolder;
+  if (!newFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  newFolder->Init(uri.get());
+  NS_ADDREF(*folder = newFolder);
+  return NS_OK;
+}
+
 // this is only called for virtual folders, currently.
 NS_IMETHODIMP nsImapMailFolder::AddSubfolder(const nsAString& aName, nsIMsgFolder** aChild)
 {
   NS_ENSURE_ARG_POINTER(aChild);
 
   PRInt32 flags = 0;
   nsresult rv;
   nsCOMPtr<nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);
--- a/mailnews/imap/src/nsImapMailFolder.h
+++ b/mailnews/imap/src/nsImapMailFolder.h
@@ -345,16 +345,17 @@ public:
   static nsresult  BuildIdsAndKeyArray(nsIArray* messages, nsCString& msgIds, nsTArray<nsMsgKey>& keyArray);
 
   // these might end up as an nsIImapMailFolder attribute.
   nsresult SetSupportedUserFlags(PRUint32 userFlags);
   nsresult GetSupportedUserFlags(PRUint32 *userFlags);
 protected:
   // Helper methods
 
+  virtual nsresult CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder);
   void FindKeysToAdd(const nsTArray<nsMsgKey> &existingKeys, nsTArray<nsMsgKey>
     &keysToFetch, PRUint32 &numNewUnread, nsIImapFlagAndUidState *flagState);
   void FindKeysToDelete(const nsTArray<nsMsgKey> &existingKeys, nsTArray<nsMsgKey>
     &keysToFetch, nsIImapFlagAndUidState *flagState);
   void PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, const
     nsTArray<nsMsgKey> &keysToFetch,
     nsIMailboxSpec *boxSpec);
   void TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr *tweakMe);
--- a/mailnews/local/src/Makefile.in
+++ b/mailnews/local/src/Makefile.in
@@ -75,16 +75,17 @@ CPPSRCS		= \
 		nsPop3URL.cpp \
 		nsPop3Sink.cpp \
 		nsParseMailbox.cpp \
 		nsMailboxProtocol.cpp \
 		nsMailboxUrl.cpp \
 		nsLocalMailFolder.cpp \
 		nsMailboxService.cpp \
 		nsPop3Service.cpp \
+		nsMailboxServer.cpp \
 		nsPop3IncomingServer.cpp \
 		nsLocalUtils.cpp \
 		nsLocalUndoTxn.cpp \
 		nsNoIncomingServer.cpp \
 		nsNoneService.cpp       \
 		nsRssIncomingServer.cpp \
 		nsRssService.cpp       \
 		$(NULL)
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -270,16 +270,26 @@ nsMsgLocalMailFolder::CreateSubFolders(n
       if (folderName.IsEmpty())
         child->SetPrettyName(leafName);
     }
   }
 
   return rv;
 }
 
+nsresult nsMsgLocalMailFolder::CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder)
+{
+  nsMsgLocalMailFolder *newFolder = new nsMsgLocalMailFolder;
+  if (!newFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(*folder = newFolder);
+  newFolder->Init(uri.get());
+  return NS_OK;
+}
+
 NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder(const nsAString &name,
                                                  nsIMsgFolder **child)
 {
   nsresult rv = nsMsgDBFolder::AddSubfolder(name, child);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr <nsILocalFile> path;
   // need to make sure folder exists...
   (*child)->GetFilePath(getter_AddRefs(path));
--- a/mailnews/local/src/nsLocalMailFolder.h
+++ b/mailnews/local/src/nsLocalMailFolder.h
@@ -193,16 +193,17 @@ public:
   NS_IMETHOD DownloadMessagesForOffline(nsIArray *aMessages, nsIMsgWindow *aWindow);
   NS_IMETHOD FetchMsgPreviewText(nsMsgKey *aKeysToFetch, PRUint32 aNumKeys,
                                                  PRBool aLocalOnly, nsIUrlListener *aUrlListener, 
                                                  PRBool *aAsyncResults);
   NS_IMETHOD AddKeywordsToMessages(nsIArray *aMessages, const nsACString& aKeywords);
   NS_IMETHOD RemoveKeywordsFromMessages(nsIArray *aMessages, const nsACString& aKeywords);
 
 protected:
+  nsresult CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder);
   nsresult CopyFolderAcrossServer(nsIMsgFolder *srcFolder, nsIMsgWindow *msgWindow,nsIMsgCopyServiceListener* listener);
 
   nsresult CreateSubFolders(nsIFile *path);
   nsresult GetTrashFolder(nsIMsgFolder** trashFolder);
   nsresult WriteStartOfNewMessage();
   nsresult IsChildOfTrash(PRBool *result);
   nsresult RecursiveSetDeleteIsMoveTrash(PRBool bVal);
   nsresult ConfirmFolderDeletion(nsIMsgWindow *aMsgWindow, nsIMsgFolder *aFolder, PRBool *aResult);
new file mode 100644
--- /dev/null
+++ b/mailnews/local/src/nsMailboxServer.cpp
@@ -0,0 +1,58 @@
+/**
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mailnews code.
+ *
+ * The Initial Developer of the Original Code is
+ *   David Bienvenu <bienvenu@nventure.com>
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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
+ * decision by deleting the provisions above and replace them with the notice
+ * 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 ***** */
+
+#include "nsMailboxServer.h"
+#include "nsLocalMailFolder.h"
+
+NS_IMETHODIMP
+nsMailboxServer::GetLocalStoreType(nsACString& type)
+{
+  type.AssignLiteral("mailbox");
+  return NS_OK;
+}
+
+nsresult
+nsMailboxServer::CreateRootFolderFromUri(const nsCString &serverUri,
+                                         nsIMsgFolder **rootFolder)
+{
+  nsMsgLocalMailFolder *newRootFolder = new nsMsgLocalMailFolder;
+  if (!newRootFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(*rootFolder = newRootFolder);
+  newRootFolder->Init(serverUri.get());
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/mailnews/local/src/nsMailboxServer.h
@@ -0,0 +1,52 @@
+/**
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mailnews code.
+ *
+ * The Initial Developer of the Original Code is
+ *   David Bienvenu <bienvenu@nventure.com>
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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
+ * decision by deleting the provisions above and replace them with the notice
+ * 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 ***** */
+
+#ifndef nsMailboxServer_h__
+#define nsMailboxServer_h__
+
+#include "nsMsgIncomingServer.h"
+
+class nsMailboxServer : public nsMsgIncomingServer
+{
+public:
+  NS_IMETHOD GetLocalStoreType(nsACString& type);
+protected:
+  virtual nsresult CreateRootFolderFromUri(const nsCString &serverUri,
+                                           nsIMsgFolder **rootFolder);
+};
+
+#endif
--- a/mailnews/local/src/nsMovemailIncomingServer.cpp
+++ b/mailnews/local/src/nsMovemailIncomingServer.cpp
@@ -67,23 +67,16 @@ nsMovemailIncomingServer::~nsMovemailInc
 NS_IMETHODIMP
 nsMovemailIncomingServer::GetIsSecureServer(PRBool *aIsSecureServer)
 {
     NS_ENSURE_ARG_POINTER(aIsSecureServer);
     *aIsSecureServer = PR_FALSE;
     return NS_OK;
 }
 
-nsresult
-nsMovemailIncomingServer::GetLocalStoreType(nsACString &type)
-{
-    type.AssignLiteral("mailbox");
-    return NS_OK;
-}
-
 NS_IMETHODIMP 
 nsMovemailIncomingServer::PerformBiff(nsIMsgWindow *aMsgWindow)
 {
     nsresult rv;
     nsCOMPtr<nsIMovemailService> movemailService(do_GetService(
                                                  kCMovemailServiceCID, &rv));
     if (NS_FAILED(rv)) return rv;
     nsCOMPtr<nsIMsgFolder> inbox;
--- a/mailnews/local/src/nsMovemailIncomingServer.h
+++ b/mailnews/local/src/nsMovemailIncomingServer.h
@@ -37,34 +37,33 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __nsMovemailIncomingServer_h
 #define __nsMovemailIncomingServer_h
 
 #include "msgCore.h"
 #include "nsIMovemailIncomingServer.h"
 #include "nsILocalMailIncomingServer.h"
-#include "nsMsgIncomingServer.h"
+#include "nsMailboxServer.h"
 
 /* get some implementation from nsMsgIncomingServer */
-class nsMovemailIncomingServer : public nsMsgIncomingServer,
+class nsMovemailIncomingServer : public nsMailboxServer,
                                  public nsIMovemailIncomingServer,
                                  public nsILocalMailIncomingServer
 
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIMOVEMAILINCOMINGSERVER
     NS_DECL_NSILOCALMAILINCOMINGSERVER
 
     nsMovemailIncomingServer();
     virtual ~nsMovemailIncomingServer();
     
     NS_IMETHOD GetIsSecureServer(PRBool *aIsSecureServer);
-    NS_IMETHOD GetLocalStoreType(nsACString &type);
     NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow);
     NS_IMETHOD GetDownloadMessagesAtStartup(PRBool *getMessages);
     NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
     NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
     NS_IMETHOD GetPasswordPromptRequired(PRBool *aPasswordIsRequired);
     NS_IMETHOD GetAccountManagerChrome(nsAString& aResult);
 };
 
--- a/mailnews/local/src/nsMovemailService.cpp
+++ b/mailnews/local/src/nsMovemailService.cpp
@@ -569,17 +569,16 @@ nsMovemailService::GetDefaultDoBiff(PRBo
   // by default, do biff for movemail
   *aDoBiff = PR_TRUE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMovemailService::GetDefaultServerPort(PRBool isSecure, PRInt32 *aDefaultPort)
 {
-  NS_ASSERTION(0, "This should probably never be called!");
   NS_ENSURE_ARG_POINTER(aDefaultPort);
   *aDefaultPort = -1;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMovemailService::GetShowComposeMsgLink(PRBool *showComposeMsgLink)
 {
--- a/mailnews/local/src/nsNoIncomingServer.h
+++ b/mailnews/local/src/nsNoIncomingServer.h
@@ -37,21 +37,22 @@
 
 #ifndef __nsNoIncomingServer_h
 #define __nsNoIncomingServer_h
 
 #include "msgCore.h"
 #include "nsINoIncomingServer.h"
 #include "nsILocalMailIncomingServer.h"
 #include "nsMsgIncomingServer.h"
+#include "nsMailboxServer.h"
 
 /* get some implementation from nsMsgIncomingServer */
-class nsNoIncomingServer : public nsMsgIncomingServer,
-                             public nsINoIncomingServer,
-                             public nsILocalMailIncomingServer
+class nsNoIncomingServer : public nsMailboxServer,
+                           public nsINoIncomingServer,
+                           public nsILocalMailIncomingServer
 
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSINOINCOMINGSERVER
   NS_DECL_NSILOCALMAILINCOMINGSERVER
 
   nsNoIncomingServer();
--- a/mailnews/local/src/nsNoneService.cpp
+++ b/mailnews/local/src/nsNoneService.cpp
@@ -176,17 +176,16 @@ nsNoneService::GetDefaultDoBiff(PRBool *
     // by default, don't do biff for "none" servers
     *aDoBiff = PR_FALSE;    
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNoneService::GetDefaultServerPort(PRBool isSecure, PRInt32 *aDefaultPort)
 {
-    NS_ASSERTION(0, "This should probably never be called!");
     NS_ENSURE_ARG_POINTER(aDefaultPort);
     *aDefaultPort = -1;
     return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsNoneService::GetShowComposeMsgLink(PRBool *showComposeMsgLink)
 {
--- a/mailnews/local/src/nsPop3IncomingServer.cpp
+++ b/mailnews/local/src/nsPop3IncomingServer.cpp
@@ -229,23 +229,16 @@ nsPop3IncomingServer::GetPop3CapabilityF
 
 nsresult
 nsPop3IncomingServer::SetPop3CapabilityFlags(PRUint32 flags)
 {
   m_capabilityFlags = flags;
   return NS_OK;
 }
 
-nsresult
-nsPop3IncomingServer::GetLocalStoreType(nsACString& type)
-{
-  type.AssignLiteral("mailbox");
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsPop3IncomingServer::GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder)
 {
   NS_ENSURE_ARG_POINTER(aRootMsgFolder);
   nsresult rv = NS_OK;
   if (!m_rootMsgFolder)
   {
     nsCString deferredToAccount;
--- a/mailnews/local/src/nsPop3IncomingServer.h
+++ b/mailnews/local/src/nsPop3IncomingServer.h
@@ -39,32 +39,32 @@
 #define __nsPop3IncomingServer_h
 
 #include "msgCore.h"
 #include "nsIPop3IncomingServer.h"
 #include "nsILocalMailIncomingServer.h"
 #include "nsMsgIncomingServer.h"
 #include "nsIPop3Protocol.h"
 #include "nsIMsgWindow.h"
+#include "nsMailboxServer.h"
 
 /* get some implementation from nsMsgIncomingServer */
-class nsPop3IncomingServer : public nsMsgIncomingServer,
+class nsPop3IncomingServer : public nsMailboxServer,
                              public nsIPop3IncomingServer,
                              public nsILocalMailIncomingServer
 
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIPOP3INCOMINGSERVER
   NS_DECL_NSILOCALMAILINCOMINGSERVER
 
   nsPop3IncomingServer();
   virtual ~nsPop3IncomingServer();
 
-  NS_IMETHOD GetLocalStoreType(nsACString& type);
   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);
--- a/mailnews/local/src/nsRssIncomingServer.cpp
+++ b/mailnews/local/src/nsRssIncomingServer.cpp
@@ -209,22 +209,16 @@ NS_IMETHODIMP nsRssIncomingServer::GetNe
         rv = rssDownloader->DownloadFeed(url.get(),
                                          aFolder, PR_FALSE, folderName.get(), aUrlListener, aMsgWindow);
       }
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsRssIncomingServer::GetLocalStoreType(nsACString& type)
-{
-  type.AssignLiteral("mailbox");
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsRssIncomingServer::GetAccountManagerChrome(nsAString& aResult)
 {
   aResult.AssignLiteral("am-newsblog.xul");
   return NS_OK;
 }
 
 NS_IMETHODIMP nsRssIncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
 {
--- a/mailnews/local/src/nsRssIncomingServer.h
+++ b/mailnews/local/src/nsRssIncomingServer.h
@@ -36,30 +36,30 @@
 
 #ifndef __nsRssIncomingServer_h
 #define __nsRssIncomingServer_h
 
 #include "nsIRssIncomingServer.h"
 #include "nsILocalMailIncomingServer.h"
 #include "nsMsgIncomingServer.h"
 #include "nsIFolderListener.h"
+#include "nsMailboxServer.h"
 
-class nsRssIncomingServer : public nsMsgIncomingServer,
-                                 public nsIRssIncomingServer,
-                                 public nsILocalMailIncomingServer,
-                                 public nsIFolderListener
+class nsRssIncomingServer : public nsMailboxServer,
+                            public nsIRssIncomingServer,
+                            public nsILocalMailIncomingServer,
+                            public nsIFolderListener
 
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIRSSINCOMINGSERVER
     NS_DECL_NSILOCALMAILINCOMINGSERVER
     NS_DECL_NSIFOLDERLISTENER
 
-    NS_IMETHOD GetLocalStoreType(nsACString& type);
     NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
     NS_IMETHOD GetSupportsDiskSpace(PRBool *aSupportsDiskSpace);
     NS_IMETHOD GetAccountManagerChrome(nsAString& aResult);
     NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow);
     NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
     NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
 
     nsRssIncomingServer();
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -462,16 +462,26 @@ NS_IMETHODIMP nsMsgNewsFolder::SetNewsrc
   nsresult rv;
 
   nsCOMPtr<nsINntpIncomingServer> nntpServer;
   rv = GetNntpServer(getter_AddRefs(nntpServer));
   if (NS_FAILED(rv)) return rv;
   return nntpServer->SetNewsrcHasChanged(newsrcHasChanged);
 }
 
+nsresult nsMsgNewsFolder::CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder)
+{
+  nsMsgNewsFolder *newFolder = new nsMsgNewsFolder;
+  if (!newFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(*folder = newFolder);
+  newFolder->Init(uri.get());
+  return NS_OK;
+}
+
 NS_IMETHODIMP nsMsgNewsFolder::CreateSubfolder(const nsAString& newsgroupName,
                                                nsIMsgWindow *msgWindow)
 {
   nsresult rv = NS_OK;
   if (newsgroupName.IsEmpty())
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIMsgFolder> child;
--- a/mailnews/news/src/nsNewsFolder.h
+++ b/mailnews/news/src/nsNewsFolder.h
@@ -114,16 +114,17 @@ public:
 
 protected:
   // helper routine to parse the URI and update member variables
   nsresult AbbreviatePrettyName(nsAString& prettyName, PRInt32 fullwords);
   nsresult ParseFolder(nsILocalFile *path);
   nsresult CreateSubFolders(nsILocalFile *path);
   nsresult AddDirectorySeparator(nsILocalFile *path);
   nsresult GetDatabase(nsIMsgWindow *aMsgWindow);
+  virtual nsresult CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder);
 
   nsresult LoadNewsrcFileAndCreateNewsgroups();
   PRInt32 RememberLine(const nsACString& line);
   nsresult RememberUnsubscribedGroup(const nsACString& newsgroup, const nsACString& setStr);
   nsresult ForgetLine(void);
   nsresult GetNewsMessages(nsIMsgWindow *aMsgWindow, PRBool getOld, nsIUrlListener *aListener);
 
   PRInt32 HandleNewsrcLine(const char * line, PRUint32 line_size);
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -36,17 +36,17 @@
  * 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 ***** */
 
 #include "nsNntpIncomingServer.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
-#include "nsIMsgNewsFolder.h"
+#include "nsNewsFolder.h"
 #include "nsIMsgFolder.h"
 #include "nsILocalFile.h"
 #include "nsCOMPtr.h"
 #include "nsINntpService.h"
 #include "nsINNTPProtocol.h"
 #include "nsMsgNewsCID.h"
 #include "nsNNTPProtocol.h"
 #include "nsIDirectoryService.h"
@@ -148,16 +148,28 @@ nsNntpIncomingServer::~nsNntpIncomingSer
 
 NS_IMPL_SERVERPREF_BOOL(nsNntpIncomingServer, NotifyOn, "notify.on")
 NS_IMPL_SERVERPREF_BOOL(nsNntpIncomingServer, MarkOldRead, "mark_old_read")
 NS_IMPL_SERVERPREF_BOOL(nsNntpIncomingServer, Abbreviate, "abbreviate")
 NS_IMPL_SERVERPREF_BOOL(nsNntpIncomingServer, PushAuth, "always_authenticate")
 NS_IMPL_SERVERPREF_BOOL(nsNntpIncomingServer, SingleSignon, "singleSignon")
 NS_IMPL_SERVERPREF_INT(nsNntpIncomingServer, MaxArticles, "max_articles")
 
+nsresult
+nsNntpIncomingServer::CreateRootFolderFromUri(const nsCString &serverUri,
+                                              nsIMsgFolder **rootFolder)
+{
+  nsMsgNewsFolder *newRootFolder = new nsMsgNewsFolder;
+  if (!newRootFolder)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(*rootFolder = newRootFolder);
+  newRootFolder->Init(serverUri.get());
+  return NS_OK;
+}
+
 NS_IMETHODIMP
 nsNntpIncomingServer::GetNewsrcFilePath(nsILocalFile **aNewsrcFilePath)
 {
   nsresult rv;
   if (mNewsrcFilePath)
   {
     *aNewsrcFilePath = mNewsrcFilePath;
     NS_IF_ADDREF(*aNewsrcFilePath);
--- a/mailnews/news/src/nsNntpIncomingServer.h
+++ b/mailnews/news/src/nsNntpIncomingServer.h
@@ -95,16 +95,18 @@ public:
     NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);
     NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
     NS_IMETHOD GetFilterScope(nsMsgSearchScopeValue *filterScope);
     NS_IMETHOD GetSearchScope(nsMsgSearchScopeValue *searchScope);
 
     nsresult AppendIfSearchMatch(nsCString& newsgroupName);
 
 protected:
+   virtual nsresult CreateRootFolderFromUri(const nsCString &serverUri,
+                                            nsIMsgFolder **rootFolder);
     nsresult CreateProtocolInstance(nsINNTPProtocol ** aNntpConnection, nsIURI *url,
                                              nsIMsgWindow *window);
     PRBool ConnectionTimeOut(nsINNTPProtocol* aNntpConnection);
     nsCOMArray<nsINNTPProtocol> mConnectionCache;
     NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
     nsresult SetupNewsrcSaveTimer();
     static void OnNewsrcSaveTimer(nsITimer *timer, void *voidIncomingServer);
     void WriteLine(nsIOutputStream *stream, nsCString &str);