Backed out changeset d6e5d976103e (bug 441437).
authorJoshua Cranmer <Pidgeot18@gmail.com>
Sun, 14 Sep 2008 16:21:08 -0400
changeset 332 e9e7311aaae4c79e75c38f0eaa265fea054b95ef
parent 265 d6e5d976103e615ae181ad9103f7c726fb840859
child 333 f1687a5f35947a1688bdf5bb17b5bdfd3a0296b5
push idunknown
push userunknown
push dateunknown
bugs441437
backs outd6e5d976103e615ae181ad9103f7c726fb840859
Backed out changeset d6e5d976103e (bug 441437).
mail/base/content/widgetglue.js
mail/installer/windows/packages-static
mailnews/base/public/Makefile.in
mailnews/base/public/nsIFolderLookupService.idl
mailnews/base/src/Makefile.in
mailnews/base/src/folderLookupService.js
mailnews/imap/src/nsImapService.cpp
mailnews/mailnews.pkg
suite/installer/unix/packages
suite/installer/windows/packages
--- a/mail/base/content/widgetglue.js
+++ b/mail/base/content/widgetglue.js
@@ -274,17 +274,26 @@ function MsgToggleMessagePane()
 // Given a URI we would like to return corresponding message folder here.
 // An additonal input param which specifies whether or not to check folder
 // attributes (like if there exists a parent or is it a server) is also passed
 // to this routine. Qualifying against those checks would return an existing
 // folder. Callers who don't want to check those attributes will specify the
 // same and then this routine will simply return a msgfolder. This scenario
 // applies to a new imap account creation where special folders are created
 // on demand and hence needs to prior check of existence.
-function GetMsgFolderFromUri(uri, checkAttributes)
+function GetMsgFolderFromUri(uri, checkFolderAttributes)
 {
-  var folder = Components.classes["@mozilla.org/mail/folder-lookup;1"]
-                         .getService(Components.interfaces.nsIFolderLookupService)
-                         .getFolderById(uri);
-  if (folder && (!checkAttributes || (folder.parent || folder.isServer)))
-    return folder;
-  return null;
+    var msgfolder = null;
+    try {
+        var rdfService = Components.classes['@mozilla.org/rdf/rdf-service;1']
+                                   .getService(Components.interfaces.nsIRDFService);
+        var resource = rdfService.GetResource(uri);
+        msgfolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
+        if (checkFolderAttributes) {
+            if (!(msgfolder && (msgfolder.parent || msgfolder.isServer))) {
+                msgfolder = null;
+            }
+        }
+    }
+    catch (ex) {
+    }
+    return msgfolder;
 }
--- a/mail/installer/windows/packages-static
+++ b/mail/installer/windows/packages-static
@@ -96,17 +96,16 @@ bin\extensions\{972ce4c6-7e08-4474-a285-
 ; Mail Extensions (smime, etc.)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 bin\MapiProxy.dll
 bin\mozMapi32.dll
 bin\components\mapihook.xpt
 bin\components\nsSetDefaultMail.js
 bin\components\offlineStartup.js
 bin\components\nsMailDefaultHandler.js
-bin\components\folderLookupService.js
 
 bin\components\mdn-service.js
 
 bin\components\smime-service.js
 bin\components\msgsmime.xpt
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Chrome Files
--- a/mailnews/base/public/Makefile.in
+++ b/mailnews/base/public/Makefile.in
@@ -54,17 +54,16 @@ EXPORTS		= \
 		$(NULL)
 
 XPIDLSRCS	= \
                 MailNewsTypes2.idl \
 		nsICopyMessageListener.idl \
 		nsICopyMsgStreamListener.idl \
 		nsIMessenger.idl \
 		nsIFolderListener.idl \
-		nsIFolderLookupService.idl \
 		nsIMsgAccount.idl \
 		nsIMsgAccountManager.idl \
 		nsIMsgFolder.idl \
 		nsIMsgFolderCache.idl \
 		nsIMsgFolderCacheElement.idl \
 		nsIMsgFolderCompactor.idl \
 		nsIMsgIdentity.idl \
 		nsIMsgIncomingServer.idl \
deleted file mode 100644
--- a/mailnews/base/public/nsIFolderLookupService.idl
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ***** 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
- *   Joey Minta <jminta@gmail.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 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 "nsISupports.idl"
-
-interface nsIMsgFolder;
-
-[scriptable,uuid(a1aaa404-9be7-461f-a715-e92512729923)]
-interface nsIFolderLookupService : nsISupports
-{
-  /**
-   * Returns a folder with the given id. If the folder does not exist, but an
-   * identifiable parent does, we'll create it and then return that folder. If
-   * no parent exists, this will return null.
-   *
-   * @note For the moment, the id is the URI property of the folder.  This may
-   *       change
-   */
-  nsIMsgFolder getFolderById(in ACString id);
-};
-
--- a/mailnews/base/src/Makefile.in
+++ b/mailnews/base/src/Makefile.in
@@ -86,20 +86,16 @@ REQUIRES	= xpcom \
 		  webbrwsr \
 		  exthandler \
 		  xulapp \
 		  caps \
 		  xpconnect \
 		  js \
 		  $(NULL)
 
-EXTRA_COMPONENTS = \
-		folderLookupService.js \
-		$(NULL)
-
 CPPSRCS		= \
 		nsMessenger.cpp \
 		nsMessengerBootstrap.cpp \
 		nsUrlListenerManager.cpp \
 		nsMsgMailSession.cpp \
 		nsMsgAccountManager.cpp \
 		nsMsgAccount.cpp \
 		nsCopyMessageStreamListener.cpp \
deleted file mode 100644
--- a/mailnews/base/src/folderLookupService.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * ***** 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
- *   Joey Minta <jminta@gmail.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 ***** */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-function folderLookupService() {
-}
-
-folderLookupService.prototype = {
-  // XPCOM registration stuff
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIFolderLookupService,
-                                         Ci.nsIFolderListener]),
-  classDescription: "Folder Lookup Service",
-  contractID: "@mozilla.org/mail/folder-lookup;1",
-  classID: Components.ID("{a30be08c-afc8-4fed-9af7-79778a23db23}"),
-
-  // nsIFolderLookupService impl
-  getFolderById: function fls_getFolderById(aId) {
-    if (!this._map)
-      this._buildMap();
-
-    if (aId in this._map)
-      return this._map[aId];
-
-    // This additional creation functionality is provided to replicate legacy
-    // rdf functionality.  Callers of this may expect that if the folder does
-    // not exist, that we will create it for them.  Do so here.
-    var parentString = aId.substr(0, aId.lastIndexOf('/'));
-
-    // If there isn't even a parent, just bail
-    if (!(parentString in this._map)) {
-      Components.utils.reportError("Asking for subfolder with no parent! " + aId);
-      return null;
-    }
-    var parent = this._map[parentString];
-    parent.createSubfolder(aId.substring(aId.lastIndexOf('/') + 1, aId.length));
-
-    // Now that createSubfolder is done, it should have been added into our map
-    if (!(aId in this._map)) {
-      Components.utils.reportError("Added subfolder but still not in map!");
-      return null;
-    }
-    return this._map[aId];
-  },
-
-  _map: null,
-  _sessionAdded: false,
-
-  _buildMap: function fls_buildmap() {
-    this._map = {};
-    var lookupService = this;
-    // Adds a folder and any subfolders it might have to the map
-    function addFolder(aFolder) {
-      lookupService._map[aFolder.URI] = aFolder;
-
-      var childEnum = aFolder.subFolders;
-      while (childEnum.hasMoreElements()) {
-        addFolder(childEnum.getNext().QueryInterface(Ci.nsIMsgFolder));
-      }
-    }
- 
-    var acctMgr = Cc["@mozilla.org/messenger/account-manager;1"].
-                  getService(Ci.nsIMsgAccountManager);
-    var count = acctMgr.accounts.Count();
-
-    var accounts = new Array();
-    for (var i = 0; i < count; i++) {
-      var acct = acctMgr.accounts.GetElementAt(i).QueryInterface(Ci.nsIMsgAccount);
-
-      // This is a HACK to work around bug 41133. If we have one of the
-      // dummy "news" accounts there, that account won't have an
-      // incomingServer attached to it, and everything will blow up.
-      if (acct.incomingServer)
-        addFolder(acct.incomingServer.rootMsgFolder);
-    }
-
-    if (!this._sessionAdded) {
-      var session = Cc["@mozilla.org/messenger/services/session;1"].
-                    getService(Ci.nsIMsgMailSession);
-      session.AddFolderListener(this, Ci.nsIFolderListener.added|Ci.nsIFolderListener.removed);
-      this._sessionAdded = true;
-    }
-
-    // See the notes below on the observe method
-    var ps = Cc["@mozilla.org/preferences-service;1"].
-             getService(Components.interfaces.nsIPrefService);
-    var branch = ps.getBranch("").QueryInterface(Ci.nsIPrefBranch2);
-    branch.addObserver("mail.accountmanager.", this, false);
-  },
-
-  OnItemAdded: function fls_onItemAdded(aParent, aItem) {
-    if (aItem instanceof Ci.nsIMsgFolder)
-      this._map[aItem.URI] = aItem;
-  },
-  OnItemRemoved: function fls_onItemRemoved(aParent, aItem) {
-    if (aItem instanceof Ci.nsIMsgFolder && aItem.URI in this._map)
-      delete this._map[aItem.URI];
-  },
-  OnItemPropertyChanged: function fls_onItemPropertyChanged() {},
-  OnItemIntPropertyChanged: function fls_onItemIntPropertyChanged() {},
-  OnItemBoolPropertyChanged: function fls_onItemBoolPropertyChanged() {},
-  OnItemUnicharPropertyChanged: function fls_onItemUnicharPropertyChanged() {},
-  OnItemPropertyFlagChanged: function fls_onItemPropertyFlagChanged() {},
-  OnItemEvent: function fls_onItemEvent(folder, event) {},
-
-  // Eww, we also have to watch for account creations, because they have a 
-  // "root folder" that doesn't trigger any of the above notifications on
-  // creation.
-  //
-  // XXX Believe it or not, the simplest way to watch for new accounts is to
-  // throw an observer on the pref-system. I wish STEEL existed so I could just
-  // watch that
-  observe: function act_observe(aSubject, aTopic, aPrefName) {
-    if (aPrefName != "mail.accountmanager.accounts")
-      return;
-
-    // We could do a bunch of work to figure out who was added/removed, but
-    // since account creation is a rare enough event, let's just reset.
-    this._map = null;
-  }
-};
-
-function NSGetModule(compMgr, fileSpec) {
-  return XPCOMUtils.generateModule([folderLookupService]);
-}
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -53,17 +53,19 @@
 #include "nsIMsgFolder.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsIImapIncomingServer.h"
 #include "nsIImapServerSink.h"
 #include "nsIImapMockChannel.h"
 #include "nsImapUtils.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
+#include "nsIRDFService.h"
 #include "nsReadableUtils.h"
+#include "nsRDFCID.h"
 #include "nsEscape.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsILoadGroup.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgFolderFlags.h"
@@ -95,17 +97,16 @@
 #include "nsIPrompt.h"
 #include "nsIWindowWatcher.h"
 #include "nsImapProtocol.h"
 #include "nsIMsgMailSession.h"
 #include "nsIStreamConverterService.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsInt64.h"
-#include "nsIFolderLookupService.h"
 
 #define PREF_MAIL_ROOT_IMAP "mail.root.imap"            // old - for backward compatibility only
 #define PREF_MAIL_ROOT_IMAP_REL "mail.root.imap-rel"
 
 static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
 static NS_DEFINE_CID(kCImapMockChannel, NS_IMAPMOCKCHANNEL_CID);
 static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
 
@@ -903,23 +904,27 @@ nsresult nsImapService::DecomposeImapURI
   NS_ENSURE_ARG_POINTER(aFolder);
   NS_ENSURE_ARG_POINTER(aMsgKey);
   
   nsresult rv = NS_OK;
   nsCAutoString folderURI;
   rv = nsParseImapMessageURI(nsDependentCString(aMessageURI).get(), folderURI, aMsgKey, nsnull);
   NS_ENSURE_SUCCESS(rv,rv);
   
-  nsCOMPtr <nsIFolderLookupService> lookup = do_GetService("@mozilla.org/mail/folder-lookup;1",&rv);
+  nsCOMPtr <nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
   NS_ENSURE_SUCCESS(rv,rv);
   
-  nsCOMPtr<nsIMsgFolder> msgFolder;
-  rv = lookup->GetFolderById(folderURI, getter_AddRefs(msgFolder));
+  nsCOMPtr<nsIRDFResource> res;
+  rv = rdf->GetResource(folderURI, getter_AddRefs(res));
   NS_ENSURE_SUCCESS(rv,rv);
   
+  nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(res);
+  if (!msgFolder)
+    return NS_ERROR_FAILURE;
+  
   msgFolder.swap(*aFolder);
   
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI, 
                                                nsIFile *aFile, 
                                                PRBool aAddDummyEnvelope, 
--- a/mailnews/mailnews.pkg
+++ b/mailnews/mailnews.pkg
@@ -4,17 +4,16 @@ dist/bin/chrome/messenger.jar
 !xpt dist/bin/components/msgnews.xpt
 !xpt dist/bin/components/mime.xpt
 !xpt dist/bin/components/msglocal.xpt
 !xpt dist/bin/components/msgimap.xpt
 !xpt dist/bin/components/msgdb.xpt
 !xpt dist/bin/components/msgbase.xpt
 !xpt dist/bin/components/msgsearch.xpt
 dist/bin/components/nsLDAPPrefsService.js
-dist/bin/components/folderLookupService.js
 !xpt dist/bin/components/addrbook.xpt
 #if OS_ARCH==WINNT
 !xpt dist/bin/components/msgcompo.xpt
 #else
 !xpt dist/bin/components/msgcompose.xpt
 #endif
 
 #if MOZ_STATIC_MAIL_BUILD
--- a/suite/installer/unix/packages
+++ b/suite/installer/unix/packages
@@ -496,17 +496,16 @@ bin/components/libmsgsmime.so
 bin/components/msgsmime.xpt
 bin/components/nsAbAutoCompleteMyDomain.js
 bin/components/nsAbAutoCompleteSearch.js
 bin/components/nsAbLDAPAttributeMap.js
 bin/components/nsLDAPPrefsService.js
 bin/components/smime-service.js
 bin/components/mdn-service.js
 bin/components/offlineStartup.js
-bin/components/folderLookupService.js
 
 bin/isp/movemail.rdf
 bin/isp/SpamAssassin.sfd
 bin/isp/SpamPal.sfd
 
 [chatzilla]
 bin/extensions/{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}/components/chatzilla-service.js
 bin/extensions/{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}/chrome/chatzilla.jar
--- a/suite/installer/windows/packages
+++ b/suite/installer/windows/packages
@@ -490,17 +490,16 @@ bin\components\msgsearch.xpt
 ;bin\components\signed.dll
 bin\components\import.dll
 bin\components\import.xpt
 bin\components\impComm4xMail.xpt
 bin\components\nsAbAutoCompleteMyDomain.js
 bin\components\nsAbAutoCompleteSearch.js
 bin\components\nsAbLDAPAttributeMap.js
 bin\components\nsLDAPPrefsService.js
-bin\components\folderLookupService.js
 bin\chrome\messenger.jar
 bin\chrome\messenger.manifest
 bin\chrome\icons\default\abcardWindow.ico
 bin\chrome\icons\default\ablistWindow.ico
 bin\chrome\icons\default\addressbookWindow.ico
 bin\chrome\icons\default\messengerWindow.ico
 bin\chrome\icons\default\msgcomposeWindow.ico
 bin\components\mailview.xpt