diff --git a/extensions/p3p/src/nsP3PDataSchema.cpp b/extensions/p3p/src/nsP3PDataSchema.cpp index 9b64a785f09..2f3cdfd625f 100644 --- a/extensions/p3p/src/nsP3PDataSchema.cpp +++ b/extensions/p3p/src/nsP3PDataSchema.cpp @@ -32,13 +32,12 @@ #include "nsIDirectoryService.h" #include "nsIProperties.h" #include "nsIFile.h" +#include "nsStdURL.h" #include "nsNetUtil.h" #include "nsXPIDLString.h" -#include "nsIFileLocator.h" -#include "nsFileLocations.h" #include "nsIFileSpec.h" #include "nsAutoLock.h" @@ -117,10 +116,6 @@ nsP3PDataSchema::PostInit( nsString& aURISpec ) { nsresult rv = NS_OK; - nsCOMPtr pFileLocator; - - nsCOMPtr pFileSpec; - nsXPIDLCString xcsPath; @@ -132,45 +127,50 @@ nsP3PDataSchema::PostInit( nsString& aURISpec ) { PR_LOG_NOTICE, ("P3PDataSchema: %s PostInit, attempting to redirect base DataSchema.\n", (const char *)mcsURISpec) ); - // Create a file locator object - pFileLocator = do_CreateInstance( NS_FILELOCATOR_CONTRACTID, - &rv ); - + // Find the components directory + nsCOMPtr compsDir; + rv = NS_GetSpecialDirectory(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(compsDir)); if (NS_SUCCEEDED( rv )) { - // Find the components directory - rv = pFileLocator->GetFileLocation( nsSpecialFileSpec::App_ComponentsDirectory, - getter_AddRefs( pFileSpec ) ); - + + // Create a URL of the components directory + nsCOMPtr compsDirURI(do_CreateInstance("@mozilla.org/network/standard-url;1", &rv)); if (NS_SUCCEEDED( rv )) { - // Extract the path to the components directory - rv = pFileSpec->GetURLString( getter_Copies( xcsPath ) ); - + rv = compsDirURI->SetFile(compsDir); if (NS_SUCCEEDED( rv )) { - // Make the local path the URI to be read - mUseDOMParser = PR_TRUE; - mReadURISpec.AssignWithConversion((const char *)xcsPath ); - mReadURISpec.AppendWithConversion( P3P_BASE_DATASCHEMA_LOCAL_NAME ); - mcsReadURISpec.AssignWithConversion( mReadURISpec ); - PR_LOG( gP3PLogModule, - PR_LOG_NOTICE, - ("P3PDataSchema: %s PostInit, redirecting base DataSchema to %s.\n", (const char *)mcsURISpec, (const char *)mcsReadURISpec) ); + rv = compsDirURI->GetSpec( getter_Copies( xcsPath ) ); + + if (NS_SUCCEEDED( rv )) { + // Make the local path the URI to be read + mUseDOMParser = PR_TRUE; + mReadURISpec.AssignWithConversion((const char *)xcsPath ); + mReadURISpec.AppendWithConversion( P3P_BASE_DATASCHEMA_LOCAL_NAME ); + mcsReadURISpec.AssignWithConversion( mReadURISpec ); + PR_LOG( gP3PLogModule, + PR_LOG_NOTICE, + ("P3PDataSchema: %s PostInit, redirecting base DataSchema to %s.\n", (const char *)mcsURISpec, (const char *)mcsReadURISpec) ); + } + else { + PR_LOG( gP3PLogModule, + PR_LOG_ERROR, + ("P3PDataSchema: %s PostInit, compsDirURI->GetSpec failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); + } } else { PR_LOG( gP3PLogModule, PR_LOG_ERROR, - ("P3PDataSchema: %s PostInit, pFileSpec->GetURLString failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); + ("P3PDataSchema: %s PostInit, compsDirURI->SetFile failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); } } else { PR_LOG( gP3PLogModule, PR_LOG_ERROR, - ("P3PDataSchema: %s PostInit, pFileLocator->GetFileLocation failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); + ("P3PDataSchema: %s PostInit, Creation of nsIFileURL failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); } } else { PR_LOG( gP3PLogModule, PR_LOG_ERROR, - ("P3PDataSchema: %s PostInit, CreateInstance of pFileLocator failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); + ("P3PDataSchema: %s PostInit, NS_GetSpecialDirectory failed - %X, using remote base DataSchema.\n", (const char *)mcsURISpec, rv) ); } // Don't fail if we can't obtain the "local" base DataSchema diff --git a/intl/strres/tests/StringBundleTest.cpp b/intl/strres/tests/StringBundleTest.cpp index 05dc4757ed0..f8147c27927 100644 --- a/intl/strres/tests/StringBundleTest.cpp +++ b/intl/strres/tests/StringBundleTest.cpp @@ -37,8 +37,6 @@ #include "nsIServiceManager.h" #include "nsIComponentManager.h" // -#include "nsFileLocations.h" -#include "nsIFileLocator.h" #include "nsIFileSpec.h" #define TEST_URL "resource:/res/strres.properties" diff --git a/mailnews/base/search/src/nsMsgFilterService.cpp b/mailnews/base/search/src/nsMsgFilterService.cpp index 371e39d670d..3a36bff116a 100644 --- a/mailnews/base/search/src/nsMsgFilterService.cpp +++ b/mailnews/base/search/src/nsMsgFilterService.cpp @@ -27,7 +27,6 @@ #include "nsMsgFilterService.h" #include "nsFileStream.h" #include "nsMsgFilterList.h" -#include "nsFileLocations.h" #include "nsSpecialSystemDirectory.h" NS_IMPL_ISUPPORTS1(nsMsgFilterService, nsIMsgFilterService) diff --git a/mailnews/base/src/nsMsgMailSession.cpp b/mailnews/base/src/nsMsgMailSession.cpp index 19b92be0b9b..8831abee5b6 100644 --- a/mailnews/base/src/nsMsgMailSession.cpp +++ b/mailnews/base/src/nsMsgMailSession.cpp @@ -24,7 +24,6 @@ #include "nsMsgBaseCID.h" #include "nsMsgMailSession.h" #include "nsCOMPtr.h" -#include "nsFileLocations.h" #include "nsIMsgStatusFeedback.h" #include "nsIMsgWindow.h" #include "nsIMsgMessageService.h" diff --git a/mailnews/local/src/nsMovemailService.cpp b/mailnews/local/src/nsMovemailService.cpp index d156af8dd41..4ac5c743b4b 100644 --- a/mailnews/local/src/nsMovemailService.cpp +++ b/mailnews/local/src/nsMovemailService.cpp @@ -42,9 +42,9 @@ #include "nsParseMailbox.h" #include "nsIFolder.h" -//#include "nsFileSpec.h" #include "nsILocalFile.h" #include "nsFileStream.h" +#include "nsAppDirectoryServiceDefs.h" #include "nsIPref.h" @@ -53,14 +53,10 @@ #include "nsXPIDLString.h" #include "nsCOMPtr.h" -#include "nsIFileLocator.h" -#include "nsFileLocations.h" - #define PREF_MAIL_ROOT_MOVEMAIL "mail.root.movemail" static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID); -static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID); nsMovemailService::nsMovemailService() { @@ -539,20 +535,50 @@ nsMovemailService::SetDefaultLocalPath(nsIFileSpec *aPath) NS_IMETHODIMP nsMovemailService::GetDefaultLocalPath(nsIFileSpec ** aResult) { + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + nsresult rv; NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); if (NS_FAILED(rv)) return rv; - - rv = prefs->GetFilePref(PREF_MAIL_ROOT_MOVEMAIL, aResult); - if (NS_SUCCEEDED(rv)) return rv; - - NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv); + + PRBool havePref = PR_FALSE; + nsCOMPtr prefLocal; + nsCOMPtr localFile; + rv = prefs->GetFileXPref(PREF_MAIL_ROOT_MOVEMAIL, getter_AddRefs(prefLocal)); + if (NS_SUCCEEDED(rv)) { + localFile = prefLocal; + havePref = PR_TRUE; + } + if (!localFile) { + rv = NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(localFile)); + if (NS_FAILED(rv)) return rv; + havePref = PR_FALSE; + } + + PRBool exists; + rv = localFile->Exists(&exists); if (NS_FAILED(rv)) return rv; - - rv = locator->GetFileLocation(nsSpecialFileSpec::App_MailDirectory50, aResult); - if (NS_FAILED(rv)) return rv; - - rv = SetDefaultLocalPath(*aResult); + if (!exists) { + rv = localFile->Create(nsIFile::DIRECTORY_TYPE, 0775); + if (NS_FAILED(rv)) return rv; + } + + // Make the resulting nsIFileSpec + // TODO: Convert arg to nsILocalFile and avoid this + nsXPIDLCString pathBuf; + rv = localFile->GetPath(getter_Copies(pathBuf)); + if (NS_FAILED(rv)) return rv; + nsCOMPtr outSpec; + rv = NS_NewFileSpec(getter_AddRefs(outSpec)); + if (NS_FAILED(rv)) return rv; + outSpec->SetNativePath(pathBuf); + + if (!havePref || !exists) + rv = SetDefaultLocalPath(outSpec); + + *aResult = outSpec; + NS_IF_ADDREF(*aResult); return rv; } diff --git a/netwerk/mime/src/nsXMLMIMEDataSource.cpp b/netwerk/mime/src/nsXMLMIMEDataSource.cpp index 6ba0974726d..c8808ab5f9b 100644 --- a/netwerk/mime/src/nsXMLMIMEDataSource.cpp +++ b/netwerk/mime/src/nsXMLMIMEDataSource.cpp @@ -32,7 +32,6 @@ #include "nsIFileTransportService.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" -#include "nsFileLocations.h" #include "nsILocalFile.h" #include "nsMimeTypes.h" diff --git a/profile/pref-migrator/src/nsPrefMigration.cpp b/profile/pref-migrator/src/nsPrefMigration.cpp index dbc0e38c53d..8ff58e0c585 100644 --- a/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/profile/pref-migrator/src/nsPrefMigration.cpp @@ -43,8 +43,6 @@ #include "plstr.h" #include "prprf.h" #include "nsXPIDLString.h" -#include "nsIFileLocator.h" -#include "nsFileLocations.h" #include "nsIStringBundle.h" #include "nsISupportsPrimitives.h" #include "nsProxiedService.h" @@ -221,7 +219,6 @@ typedef struct static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID ); -static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID); static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); static NS_DEFINE_IID(kIPrefMigrationIID, NS_IPREFMIGRATION_IID); static NS_DEFINE_IID(kPrefMigrationCID, NS_PREFMIGRATION_CID); @@ -229,7 +226,6 @@ static NS_DEFINE_IID(kPrefMigrationCID, NS_PREFMIGRATION_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); -static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID); static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); diff --git a/xpfe/appshell/public/MANIFEST b/xpfe/appshell/public/MANIFEST index 550ae68fc92..abe22e16055 100644 --- a/xpfe/appshell/public/MANIFEST +++ b/xpfe/appshell/public/MANIFEST @@ -5,7 +5,6 @@ nsAppleEvents.h nsAppShellCIDs.h nsIWebShellWindow.h -nsFileLocations.h nsIDOMXPConnectFactory.h nsINetSupportDialogService.h nsISplashScreen.h diff --git a/xpfe/appshell/public/MANIFEST_IDL b/xpfe/appshell/public/MANIFEST_IDL index 6a2ee66599a..237f42e821c 100644 --- a/xpfe/appshell/public/MANIFEST_IDL +++ b/xpfe/appshell/public/MANIFEST_IDL @@ -4,7 +4,6 @@ nsIAppShellService.idl nsICmdLineService.idl -nsIFileLocator.idl nsIWindowMediator.idl nsIXULWindow.idl nsIUserInfo.idl diff --git a/xpfe/appshell/public/Makefile.in b/xpfe/appshell/public/Makefile.in index 9c846fc396c..a3bdd9b9348 100644 --- a/xpfe/appshell/public/Makefile.in +++ b/xpfe/appshell/public/Makefile.in @@ -32,7 +32,6 @@ XPIDL_MODULE = appshell EXPORTS = \ nsIWebShellWindow.h \ nsAppShellCIDs.h \ - nsFileLocations.h \ nsIDOMXPConnectFactory.h \ nsISplashScreen.h \ nsINativeAppSupport.h \ @@ -42,7 +41,6 @@ XPIDLSRCS = \ nsIAppShellService.idl \ nsICmdLineService.idl \ nsICmdLineHandler.idl \ - nsIFileLocator.idl \ nsIWindowMediator.idl \ nsIXULWindow.idl \ nsIUserInfo.idl \ diff --git a/xpfe/appshell/public/makefile.win b/xpfe/appshell/public/makefile.win index 907bba5167f..c25d5f3fbbd 100644 --- a/xpfe/appshell/public/makefile.win +++ b/xpfe/appshell/public/makefile.win @@ -29,7 +29,6 @@ XPIDLSRCS = \ .\nsIAppShellService.idl \ .\nsICmdLineService.idl \ .\nsICmdLineHandler.idl \ - .\nsIFileLocator.idl \ .\nsIWindowMediator.idl \ .\nsIXULWindow.idl \ .\nsIUserInfo.idl \ @@ -39,7 +38,6 @@ XPIDLSRCS = \ EXPORTS = \ nsIWebShellWindow.h \ nsAppShellCIDs.h \ - nsFileLocations.h \ nsISplashScreen.h \ nsINativeAppSupport.h \ $(NULL) diff --git a/xpfe/appshell/src/Makefile.in b/xpfe/appshell/src/Makefile.in index 5822a1c0648..1dcec4bc6ae 100644 --- a/xpfe/appshell/src/Makefile.in +++ b/xpfe/appshell/src/Makefile.in @@ -40,7 +40,6 @@ CPPSRCS = \ nsAppShellService.cpp \ nsWebShellWindow.cpp \ nsCommandLineService.cpp \ - nsFileLocations.cpp \ nsWindowMediator.cpp \ nsAbout.cpp \ nsAppShellFactory.cpp \ diff --git a/xpfe/appshell/src/makefile.win b/xpfe/appshell/src/makefile.win index 0b97511e223..99faeb212d1 100644 --- a/xpfe/appshell/src/makefile.win +++ b/xpfe/appshell/src/makefile.win @@ -35,7 +35,6 @@ CPP_OBJS= \ .\$(OBJDIR)\nsWebShellWindow.obj \ .\$(OBJDIR)\nsAppShellFactory.obj \ .\$(OBJDIR)\nsCommandLineService.obj \ - .\$(OBJDIR)\nsFileLocations.obj \ .\$(OBJDIR)\nsWindowMediator.obj \ .\$(OBJDIR)\nsAbout.obj \ .\$(OBJDIR)\nsUserInfoWin.obj \ diff --git a/xpfe/appshell/src/nsAppShellFactory.cpp b/xpfe/appshell/src/nsAppShellFactory.cpp index e9528f0ae44..ede7ccab465 100644 --- a/xpfe/appshell/src/nsAppShellFactory.cpp +++ b/xpfe/appshell/src/nsAppShellFactory.cpp @@ -25,7 +25,6 @@ #include "nsIComponentManager.h" #include "nsAppShellCIDs.h" #include "nsICmdLineService.h" -#include "nsIFileLocator.h" #include "nsIWindowMediator.h" #include "rdf.h" #include "nsAbout.h" @@ -36,7 +35,6 @@ #include "nsCommandLineService.h" #include "nsAppShellService.h" #include "nsWindowMediator.h" -#include "nsFileLocations.h" #include "nsTimingService.h" #ifdef XP_MAC @@ -54,7 +52,6 @@ nsresult NS_NewAppShellServiceFactory(nsIFactory** aFactory); NS_GENERIC_FACTORY_CONSTRUCTOR(nsCmdLineService); NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShellService); NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowMediator); -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileLocator); NS_GENERIC_FACTORY_CONSTRUCTOR(nsUserInfo); NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimingService); @@ -80,11 +77,6 @@ static nsModuleComponentInfo gAppShellModuleInfo[] = NS_ABOUT_MODULE_CONTRACTID_PREFIX, nsAbout::Create, }, - { "File Locator Service", - NS_FILELOCATOR_CID, - NS_FILELOCATOR_CONTRACTID, - nsFileLocatorConstructor, - }, { "User Info Service", NS_USERINFO_CID, NS_USERINFO_CONTRACTID, diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index f493711d8be..6ef769a8fd8 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -92,7 +92,6 @@ #include "nsIDocumentLoader.h" #include "nsIObserverService.h" -#include "nsFileLocations.h" #include "nsIFileSpec.h"