From bea3b02a660a75ea6adbe19c08dc041bc497b7eb Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Wed, 6 Dec 2006 05:22:26 +0000 Subject: [PATCH] Bug #360702 --> Look for ISP RDF files in extension directories that contain "isp" sub directories. This should make it easy for extensions to make account setup easy for ISPs. sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@216539 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mail/extensions/newsblog/Makefile.in | 9 +- mozilla/mail/installer/removed-files.in | 9 + mozilla/mailnews/base/ispdata/Makefile.in | 22 ++- mozilla/mailnews/base/ispdata/dotmac.rdf | 1 - mozilla/mailnews/base/src/Makefile.in | 6 + .../mailnews/base/src/nsMailDirProvider.cpp | 172 ++++++++++++++++++ mozilla/mailnews/base/src/nsMailDirProvider.h | 77 ++++++++ .../mailnews/base/src/nsMailDirServiceDefs.h | 57 ++++++ .../base/src/nsMsgServiceProvider.cpp | 167 +++++++++++++---- .../mailnews/base/src/nsMsgServiceProvider.h | 10 +- mozilla/mailnews/build/nsMailModule.cpp | 10 + 11 files changed, 485 insertions(+), 55 deletions(-) create mode 100755 mozilla/mailnews/base/src/nsMailDirProvider.cpp create mode 100644 mozilla/mailnews/base/src/nsMailDirProvider.h create mode 100644 mozilla/mailnews/base/src/nsMailDirServiceDefs.h diff --git a/mozilla/mail/extensions/newsblog/Makefile.in b/mozilla/mail/extensions/newsblog/Makefile.in index f844a9684cb..41831352c06 100755 --- a/mozilla/mail/extensions/newsblog/Makefile.in +++ b/mozilla/mail/extensions/newsblog/Makefile.in @@ -45,21 +45,16 @@ include $(DEPTH)/config/autoconf.mk MODULE = newsblog -EXPORT_DIR = $(DIST)/bin/defaults/isp -EXPORT_DIR_L10N = $(DIST)/bin/defaults/isp/$(AB_CD) +EXPORT_DIR = $(DIST)/bin/isp -GARBAGE += $(EXPORT_DIR)/rss.rdf \ - $(EXPORT_DIR_L10N)/rss.rdf +GARBAGE += $(EXPORT_DIR)/rss.rdf libs:: rss.rdf $(INSTALL) $^ $(EXPORT_DIR) - $(INSTALL) $^ $(EXPORT_DIR_L10N) install:: rss.rdf $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/isp - $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/isp/$(AB_CD) EXTRA_COMPONENTS = js/newsblog.js include $(topsrcdir)/config/rules.mk - diff --git a/mozilla/mail/installer/removed-files.in b/mozilla/mail/installer/removed-files.in index 3289f41a575..8fdea0e6c9a 100644 --- a/mozilla/mail/installer/removed-files.in +++ b/mozilla/mail/installer/removed-files.in @@ -180,6 +180,15 @@ defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/ defaults/profile/extensions/Extensions.rdf defaults/profile/extensions/installed-extensions.txt defaults/profile/extensions/ +defaults/isp/rss.rdf +defaults/isp/movemail.rdf +defaults/isp/dotmac.rdf +defaults/isp/en-US/rss.rdf +defaults/isp/en-US/movemail.rdf +defaults/isp/en-US/dotmac.rdf +defaults/isp/en-US/ +defaults/isp/ + @DLL_PREFIX@zlib@DLL_SUFFIX@ #Remove Talkback files from old location (in case user updates from 1.0.x) components/BrandRes.dll diff --git a/mozilla/mailnews/base/ispdata/Makefile.in b/mozilla/mailnews/base/ispdata/Makefile.in index 22349c7a6ae..416cfa95f7a 100644 --- a/mozilla/mailnews/base/ispdata/Makefile.in +++ b/mozilla/mailnews/base/ispdata/Makefile.in @@ -42,8 +42,12 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +ifdef MOZ_XUL_APP +EXPORT_DIR = $(DIST)/bin/isp +else EXPORT_DIR = $(DIST)/bin/defaults/isp EXPORT_DIR_L10N = $(DIST)/bin/defaults/isp/$(AB_CD) +endif EXPORT_RESOURCE_FILES = \ $(NULL) @@ -58,16 +62,24 @@ endif include $(topsrcdir)/config/rules.mk -GARBAGE += $(addprefix $(EXPORT_DIR)/, $(EXPORT_RESOURCE_FILES)) \ - $(addprefix $(EXPORT_DIR_L10N)/, $(EXPORT_RESOURCE_FILES)) +GARBAGE += $(addprefix $(EXPORT_DIR)/, $(EXPORT_RESOURCE_FILES)) + +ifndef MOZ_XUL_APP +GARBAGE += $(addprefix $(EXPORT_DIR_L10N)/, $(EXPORT_RESOURCE_FILES)) +endif ifneq ($(EXPORT_RESOURCE_FILES),$(NULL)) libs:: $(EXPORT_RESOURCE_FILES) $(INSTALL) $^ $(EXPORT_DIR) - $(INSTALL) $^ $(EXPORT_DIR_L10N) install:: $(EXPORT_RESOURCE_FILES) $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/isp - $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/isp/$(AB_CD) -endif +ifndef MOZ_XUL_APP +libs:: $(EXPORT_RESOURCE_FILES) + $(INSTALL) $^ $(EXPORT_DIR_L10N) + +install:: $(EXPORT_RESOURCE_FILES) + $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/isp/$(AB_CD) +endif +endif diff --git a/mozilla/mailnews/base/ispdata/dotmac.rdf b/mozilla/mailnews/base/ispdata/dotmac.rdf index 7c940862f52..e1782e6ba02 100644 --- a/mozilla/mailnews/base/ispdata/dotmac.rdf +++ b/mozilla/mailnews/base/ispdata/dotmac.rdf @@ -46,7 +46,6 @@ steve@mac.com steve .Mac username: - username true diff --git a/mozilla/mailnews/base/src/Makefile.in b/mozilla/mailnews/base/src/Makefile.in index b2105cc0333..214f64f37cf 100644 --- a/mozilla/mailnews/base/src/Makefile.in +++ b/mozilla/mailnews/base/src/Makefile.in @@ -85,6 +85,7 @@ REQUIRES = xpcom \ windowwatcher \ webbrwsr \ exthandler \ + xulapp \ $(NULL) CPPSRCS = \ @@ -156,6 +157,10 @@ ifneq (,$(filter $(MOZ_GFX_TOOLKIT),gtk gtk2)) CPPSRCS += nsMessengerUnixIntegration.cpp endif +ifdef MOZ_XUL_APP +CPPSRCS += nsMailDirProvider.cpp +endif + ifdef MOZ_LDAP_XPCOM REQUIRES += mozldap \ $(NULL) @@ -167,6 +172,7 @@ endif EXPORTS = \ nsMsgRDFDataSource.h \ nsMsgRDFUtils.h \ + nsMailDirServiceDefs.h \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/mailnews/base/src/nsMailDirProvider.cpp b/mozilla/mailnews/base/src/nsMailDirProvider.cpp new file mode 100755 index 00000000000..3f5401b30aa --- /dev/null +++ b/mozilla/mailnews/base/src/nsMailDirProvider.cpp @@ -0,0 +1,172 @@ +/* ***** 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 Mozilla Mail Directory Provider. + * + * The Initial Developer of the Original Code is + * Scott MacGregor . + * Portions created by the Initial Developer are Copyright (C) 2006 + * 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 "nsMailDirProvider.h" +#include "nsMailDirServiceDefs.h" +#include "nsXULAppAPI.h" +#include "nsString.h" +#include "nsMsgBaseCID.h" + +#include "nsICategoryManager.h" + +NS_IMPL_ISUPPORTS2(nsMailDirProvider, + nsIDirectoryServiceProvider, + nsIDirectoryServiceProvider2) + +NS_IMETHODIMP +nsMailDirProvider::GetFile(const char *aKey, PRBool *aPersist, + nsIFile* *aResult) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsMailDirProvider::GetFiles(const char *aKey, + nsISimpleEnumerator* *aResult) +{ + if (strcmp(aKey, ISP_SEARCH_DIRECTORY_LIST) != 0) { + return NS_ERROR_FAILURE; + } + + nsCOMPtr dirSvc = + do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); + if (!dirSvc) + return NS_ERROR_FAILURE; + + nsCOMPtr list; + nsresult rv = dirSvc->Get(XRE_EXTENSIONS_DIR_LIST, + NS_GET_IID(nsISimpleEnumerator), + getter_AddRefs(list)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr e = new AppendingEnumerator(list); + if (!e) + return NS_ERROR_OUT_OF_MEMORY; + + *aResult = nsnull; + e.swap(*aResult); + return NS_SUCCESS_AGGREGATE_RESULT; +} + +NS_IMPL_ISUPPORTS1(nsMailDirProvider::AppendingEnumerator, + nsISimpleEnumerator) + +NS_IMETHODIMP +nsMailDirProvider::AppendingEnumerator::HasMoreElements(PRBool *aResult) +{ + *aResult = mNext ? PR_TRUE : PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsMailDirProvider::AppendingEnumerator::GetNext(nsISupports* *aResult) +{ + if (aResult) + NS_ADDREF(*aResult = mNext); + + mNext = nsnull; + + nsresult rv; + + // Ignore all errors + + PRBool more; + while (NS_SUCCEEDED(mBase->HasMoreElements(&more)) && more) { + nsCOMPtr nextbasesupp; + mBase->GetNext(getter_AddRefs(nextbasesupp)); + + nsCOMPtr nextbase(do_QueryInterface(nextbasesupp)); + if (!nextbase) + continue; + + nextbase->Clone(getter_AddRefs(mNext)); + if (!mNext) + continue; + + mNext->AppendNative(NS_LITERAL_CSTRING("isp")); + + PRBool exists; + rv = mNext->Exists(&exists); + if (NS_SUCCEEDED(rv) && exists) + break; + + mNext = nsnull; + } + + return NS_OK; +} + +nsMailDirProvider::AppendingEnumerator::AppendingEnumerator + (nsISimpleEnumerator* aBase) : + mBase(aBase) +{ + // Initialize mNext to begin + GetNext(nsnull); +} + +NS_METHOD +nsMailDirProvider::Register(nsIComponentManager* aCompMgr, + nsIFile* aPath, const char *aLoaderStr, + const char *aType, + const nsModuleComponentInfo *aInfo) +{ + nsCOMPtr catMan = + do_GetService(NS_CATEGORYMANAGER_CONTRACTID); + if (!catMan) + return NS_ERROR_FAILURE; + + return catMan->AddCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, + "mail-directory-provider", + NS_MAILDIRPROVIDER_CONTRACTID, PR_TRUE, PR_TRUE, nsnull); +} + +NS_METHOD +nsMailDirProvider::Unregister(nsIComponentManager* aCompMgr, + nsIFile* aPath, + const char *aLoaderStr, + const nsModuleComponentInfo *aInfo) +{ + nsCOMPtr catMan = + do_GetService(NS_CATEGORYMANAGER_CONTRACTID); + if (!catMan) + return NS_ERROR_FAILURE; + + return catMan->DeleteCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, + "mail-directory-provider", + PR_TRUE); +} diff --git a/mozilla/mailnews/base/src/nsMailDirProvider.h b/mozilla/mailnews/base/src/nsMailDirProvider.h new file mode 100644 index 00000000000..d97d50440f5 --- /dev/null +++ b/mozilla/mailnews/base/src/nsMailDirProvider.h @@ -0,0 +1,77 @@ +/* ***** 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 Mozilla Mail Directory Provider. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor (Original Code) + * + * 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 ***** */ + +#ifndef nsMailDirProvider_h__ +#define nsMailDirProvider_h__ + +#include "nsIDirectoryService.h" +#include "nsIGenericFactory.h" +#include "nsISimpleEnumerator.h" + +class nsMailDirProvider : public nsIDirectoryServiceProvider2 +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIDIRECTORYSERVICEPROVIDER + NS_DECL_NSIDIRECTORYSERVICEPROVIDER2 + + static NS_METHOD Register(nsIComponentManager* aCompMgr, + nsIFile* aPath, const char *aLoaderStr, + const char *aType, + const nsModuleComponentInfo *aInfo); + + static NS_METHOD Unregister(nsIComponentManager* aCompMgr, + nsIFile* aPath, const char *aLoaderStr, + const nsModuleComponentInfo *aInfo); + +private: + class AppendingEnumerator : public nsISimpleEnumerator + { + public: + NS_DECL_ISUPPORTS + NS_DECL_NSISIMPLEENUMERATOR + + AppendingEnumerator(nsISimpleEnumerator* aBase); + + private: + nsCOMPtr mBase; + nsCOMPtr mNext; + }; +}; + +#endif // nsMailDirProvider_h__ diff --git a/mozilla/mailnews/base/src/nsMailDirServiceDefs.h b/mozilla/mailnews/base/src/nsMailDirServiceDefs.h new file mode 100644 index 00000000000..40ba53a8c9d --- /dev/null +++ b/mozilla/mailnews/base/src/nsMailDirServiceDefs.h @@ -0,0 +1,57 @@ +/* ***** 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 Mail Directory Provider. + * + * The Initial Developer of the Original Code is + * Scott MacGregor . + * Portions created by the Initial Developer are Copyright (C) 2006 + * 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 ***** */ + + +#ifndef nsMailDirectoryServiceDefs_h___ +#define nsMailDirectoryServiceDefs_h___ + +//============================================================================= +// +// Defines property names for directories available from the mail-specific +// nsMailDirProvider. +// +// System and XPCOM properties are defined in nsDirectoryServiceDefs.h. +// General application properties are defined in nsAppDirectoryServiceDefs.h. +// +//============================================================================= + +// ---------------------------------------------------------------------------- +// Files and directories that exist on a per- basis. +// ---------------------------------------------------------------------------- + +#define ISP_SEARCH_DIRECTORY_LIST "ISPDL" + +#endif diff --git a/mozilla/mailnews/base/src/nsMsgServiceProvider.cpp b/mozilla/mailnews/base/src/nsMsgServiceProvider.cpp index 995791a322f..57626e0dbb2 100644 --- a/mozilla/mailnews/base/src/nsMsgServiceProvider.cpp +++ b/mozilla/mailnews/base/src/nsMsgServiceProvider.cpp @@ -51,19 +51,24 @@ #include "nsIMsgMailSession.h" #include "nsMsgBaseCID.h" +#ifdef MOZ_XUL_APP +#include "nsIChromeRegistry.h" +#include "nsMailDirServiceDefs.h" +#include "nsDirectoryServiceUtils.h" +#include "nsDirectoryServiceDefs.h" +#include "nsISimpleEnumerator.h" +#include "nsIDirectoryEnumerator.h" +#endif + static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID); static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID); nsMsgServiceProviderService::nsMsgServiceProviderService() -{ -} +{} nsMsgServiceProviderService::~nsMsgServiceProviderService() -{ - - -} +{} NS_IMPL_ISUPPORTS1(nsMsgServiceProviderService, nsIRDFDataSource) @@ -77,6 +82,9 @@ nsMsgServiceProviderService::Init() mInnerDataSource = do_CreateInstance(kRDFCompositeDataSourceCID, &rv); NS_ENSURE_SUCCESS(rv, rv); +#ifdef MOZ_XUL_APP + LoadISPFiles(); +#else nsCOMPtr mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -110,46 +118,131 @@ nsMsgServiceProviderService::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "Failed reading in the datasource\n"); } } - +#endif return NS_OK; } +#ifdef MOZ_XUL_APP +/** + * Looks for ISP configuration files in <.exe>\isp and any sub directories called isp + * located in the user's extensions directory. + */ +void nsMsgServiceProviderService::LoadISPFiles() +{ + nsresult rv; + nsCOMPtr dirSvc = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return; + + // get the current locale, we'll need this later on...don't bail out in the case of an error + nsCOMPtr packageRegistry = do_GetService("@mozilla.org/chrome/chrome-registry;1"); + nsCAutoString localeName; + if (packageRegistry) + packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), localeName); + + // First, process any isp files shipped by default in \isp + nsCOMPtr ispDirectory; + rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR, + NS_GET_IID(nsIFile), getter_AddRefs(ispDirectory)); + if (NS_SUCCEEDED(rv)) + { + ispDirectory->AppendNative(NS_LITERAL_CSTRING("isp")); + LoadISPFilesFromDir(ispDirectory); + // also look in \isp\AB-CD + if (!localeName.IsEmpty()) + { + ispDirectory->AppendNative(localeName); + LoadISPFilesFromDir(ispDirectory); + } + } + + // Now walk through the extension directories + nsCOMPtr ispDirectories; + rv = dirSvc->Get(ISP_SEARCH_DIRECTORY_LIST, + NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(ispDirectories)); + if (NS_FAILED(rv)) + return; + + PRBool hasMore; + while (NS_SUCCEEDED(ispDirectories->HasMoreElements(&hasMore)) && hasMore) { + nsCOMPtr elem; + ispDirectories->GetNext(getter_AddRefs(elem)); + + ispDirectory = do_QueryInterface(elem); + if (ispDirectory) + { + LoadISPFilesFromDir(ispDirectory); + + // If we have a current locale, look in isp\ab-cd in case there are locale specific isp files. + nsCOMPtr localeISPDir; + ispDirectory->Clone(getter_AddRefs(localeISPDir)); + if (localeISPDir && !localeName.IsEmpty()) + { + localeISPDir->AppendNative(localeName); + LoadISPFilesFromDir(localeISPDir); + } + } + } +} + +void nsMsgServiceProviderService::LoadISPFilesFromDir(nsIFile* aDir) +{ + nsresult rv; + + PRBool check = PR_FALSE; + rv = aDir->Exists(&check); + if (NS_FAILED(rv) || !check) + return; + + rv = aDir->IsDirectory(&check); + if (NS_FAILED(rv) || !check) + return; + + nsCOMPtr e; + rv = aDir->GetDirectoryEntries(getter_AddRefs(e)); + if (NS_FAILED(rv)) + return; + + nsCOMPtr files(do_QueryInterface(e)); + if (!files) + return; + + // we only care about the .rdf files in this directory + nsCOMPtr file; + while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file) { + nsAutoString leafName; + file->GetLeafName(leafName); + if (!StringEndsWith(leafName, NS_LITERAL_STRING(".rdf"))) + continue; + + nsCAutoString urlSpec; + rv = NS_GetURLSpecFromFile(file, urlSpec); + if (NS_SUCCEEDED(rv)) + LoadDataSource(urlSpec.get()); + } +} +#endif nsresult nsMsgServiceProviderService::LoadDataSource(const char *aURI) { - nsresult rv; + nsresult rv; - nsCOMPtr ds = - do_CreateInstance(kRDFXMLDataSourceCID, &rv); - NS_ENSURE_SUCCESS(rv,rv); + nsCOMPtr ds = + do_CreateInstance(kRDFXMLDataSourceCID, &rv); + NS_ENSURE_SUCCESS(rv,rv); - nsCOMPtr remote = - do_QueryInterface(ds, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = remote->Init(aURI); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr remote = + do_QueryInterface(ds, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + rv = remote->Init(aURI); + NS_ENSURE_SUCCESS(rv, rv); + // for now load synchronously (async seems to be busted) + rv = remote->Refresh(PR_TRUE); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed refresh?\n"); -#ifdef DEBUG_alecf - PRBool loaded; - rv = remote->GetLoaded(&loaded); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed getload\n"); + rv = mInnerDataSource->AddDataSource(ds); - printf("Before refresh: datasource is %s\n", loaded ? "loaded" : "not loaded"); -#endif - - // for now load synchronously (async seems to be busted) - rv = remote->Refresh(PR_TRUE); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed refresh?\n"); - -#ifdef DEBUG_alecf - rv = remote->GetLoaded(&loaded); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed getload\n"); - printf("After refresh: datasource is %s\n", loaded ? "loaded" : "not loaded"); -#endif - - rv = mInnerDataSource->AddDataSource(ds); - - return rv; + return rv; } diff --git a/mozilla/mailnews/base/src/nsMsgServiceProvider.h b/mozilla/mailnews/base/src/nsMsgServiceProvider.h index eb2cd884be8..2ede07dce61 100644 --- a/mozilla/mailnews/base/src/nsMsgServiceProvider.h +++ b/mozilla/mailnews/base/src/nsMsgServiceProvider.h @@ -57,12 +57,12 @@ class nsMsgServiceProviderService : public nsIRDFDataSource NS_FORWARD_NSIRDFDATASOURCE(mInnerDataSource->) private: - nsCOMPtr mInnerDataSource; - nsresult LoadDataSource(const char *aURL); - -}; - +#ifdef MOZ_XUL_APP + void LoadISPFilesFromDir(nsIFile* aDir); + void LoadISPFiles(); +#endif +}; #endif diff --git a/mozilla/mailnews/build/nsMailModule.cpp b/mozilla/mailnews/build/nsMailModule.cpp index 32f8749e382..a18beb3272b 100644 --- a/mozilla/mailnews/build/nsMailModule.cpp +++ b/mozilla/mailnews/build/nsMailModule.cpp @@ -104,6 +104,7 @@ #include "nsRssIncomingServer.h" #include "nsRssService.h" #include "nsMsgTagService.h" +#include "nsMailDirProvider.h" #ifdef XP_WIN #include "nsMessengerWinIntegration.h" @@ -338,6 +339,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgProgress) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSpamSettings) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgTagService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCidProtocolHandler) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailDirProvider) #ifdef XP_WIN NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMessengerWinIntegration, Init) #endif @@ -845,6 +847,14 @@ static const nsModuleComponentInfo gComponents[] = { NS_CIDPROTOCOLHANDLER_CONTRACTID, nsCidProtocolHandlerConstructor, }, + { + "mail director provider", + MAILDIRPROVIDER_CID, + NS_MAILDIRPROVIDER_CONTRACTID, + nsMailDirProviderConstructor, + nsMailDirProvider::Register, + nsMailDirProvider::Unregister + }, #ifdef XP_WIN { "Windows OS Integration", NS_MESSENGERWININTEGRATION_CID, NS_MESSENGEROSINTEGRATION_CONTRACTID,