2nd part of bug 64501 - obsoleting this because moved into xpcom r=dougt@netscape.com sr=brendan@mozilla.org

This commit is contained in:
ccarlen%netscape.com 2001-01-18 22:59:28 +00:00
Родитель 4a6f9e79ad
Коммит c1a1849c09
18 изменённых файлов: 0 добавлений и 884 удалений

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,32 +0,0 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Defining the following causes NS_APPSHELL to be defined as NS_EXPORT. */
#define _IMPL_NS_APPSHELL
#include "MacSharedPrefix.h"

Просмотреть файл

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* Defining the following causes NS_APPSHELL to be defined as NS_EXPORT. */
#define _IMPL_NS_APPSHELL
#include "MacSharedPrefix_debug.h"

Двоичный файл не отображается.

Просмотреть файл

@ -1,26 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,7 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#
nsAppDirectoryServiceDefs.h
nsAppFileLocationProvider.h

Просмотреть файл

@ -1,43 +0,0 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH =../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXPORTS = \
nsAppDirectoryServiceDefs.h \
nsAppFileLocationProvider.h \
nsAppFileLocProviderCID.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,30 +0,0 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
EXPORTS = \
nsAppFileLocProviderCID.h \
nsAppFileLocationProvider.h \
nsAppDirectoryServiceDefs.h \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -1,83 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen conrad@ingress.com
*/
#ifndef nsAppDirectoryServiceDefs_h___
#define nsAppDirectoryServiceDefs_h___
//========================================================================================
//
// Defines property names for directories available from standard nsIDirectoryServiceProviders.
// These keys are not guaranteed to exist because the nsIDirectoryServiceProviders which
// provide them are optional.
// System and XPCOM level properties are defined in mozilla\xpcom\io\nsDirectoryServiceDefs.h.
//
//========================================================================================
// --------------------------------------------------------------------------------------
// Files and directories which exist on a per-product basis
// These locations are typically provided by mozilla\xpfe\appfilelocprovider
// --------------------------------------------------------------------------------------
#define NS_APP_DEFAULTS_50_DIR "DefRt" // The root dir of all defaults dirs
#define NS_APP_PREF_DEFAULTS_50_DIR "PrfDef"
#define NS_APP_PROFILE_DEFAULTS_50_DIR "profDef" // The profile defaults of the "current"
// locale. Should be first choice.
#define NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR "ProfDefNoLoc" // The profile defaults of the "default"
// installed locale. Second choice
// when above is not available.
#define NS_APP_USER_PROFILES_ROOT_DIR "DefProfRt" // The dir where user profile dirs get created.
#define NS_APP_RES_DIR "ARes"
#define NS_APP_CHROME_DIR "AChrom"
#define NS_APP_PLUGINS_DIR "APlugns"
#define NS_APP_SEARCH_DIR "SrchPlugns"
// --------------------------------------------------------------------------------------
// Files and directories which exist on a per-profile basis
// These locations are typically provided by the profile mgr
// --------------------------------------------------------------------------------------
#define NS_APP_PREFS_50_DIR "PrefD" // Directory which contains user prefs
#define NS_APP_PREFS_50_FILE "PrefF"
#define NS_APP_USER_PROFILE_50_DIR "ProfD"
#define NS_APP_USER_CHROME_DIR "UChrm"
#define NS_APP_LOCALSTORE_50_FILE "LclSt"
#define NS_APP_HISTORY_50_FILE "UHist"
#define NS_APP_USER_PANELS_50_FILE "UPnls"
#define NS_APP_USER_MIMETYPES_50_FILE "UMimTyp"
#define NS_APP_BOOKMARKS_50_FILE "BMarks"
#define NS_APP_SEARCH_50_FILE "SrchF"
#define NS_APP_MAIL_50_DIR "MailD"
#define NS_APP_IMAP_MAIL_50_DIR "IMapMD"
#define NS_APP_NEWS_50_DIR "NewsD"
#define NS_APP_MESSENGER_FOLDER_CACHE_50_DIR "MFCaD"
#endif

Просмотреть файл

@ -1,26 +0,0 @@
#ifndef __nsAppFileLocProviderCID_h__
#define __nsAppFileLocProviderCID_h__
#include "nsIDirectoryService.h"
// {2f977d40-5485-11d4-87e2-0010a4e75ef2} -
#define NS_APPFILELOCATIONPROVIDER_CID \
{ 0x2f977d40, 0x5485, 0x11d4, { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
#define NS_APPFILELOCATIONPROVIDER_CONTRACTID \
"@mozilla.org/nsAppFileLocationProvider;1"
#endif /* __nsAppFileLocProviderCID_h__ */

Просмотреть файл

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <conrad@ingress.com>
*/
#include "nsIDirectoryService.h"
#include "nsILocalFile.h"
class nsIAtom;
class nsIFile;
//*****************************************************************************
// class nsAppFileLocationProvider
//*****************************************************************************
class nsAppFileLocationProvider : public nsIDirectoryServiceProvider
{
public:
nsAppFileLocationProvider();
NS_DECL_ISUPPORTS
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
protected:
virtual ~nsAppFileLocationProvider();
NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile);
static PRInt32 sInstanceCount;
static nsIAtom* sApp_PrefDefaultsFolder50;
static nsIAtom* sApp_ProfileDefaultsFolder50;
static nsIAtom* sApp_ProfileDefaultsNoLocFolder50;
static nsIAtom* sApp_DefaultUserProfileRoot50;
static nsIAtom* sApp_ResDirectory;
static nsIAtom* sApp_DefaultsFolder50;
static nsIAtom* sApp_ChromeDirectory;
static nsIAtom* sApp_PluginsDirectory;
static nsIAtom* sApp_SearchDirectory50;
nsCOMPtr<nsILocalFile> mMozBinDirectory;
};

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,40 +0,0 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xpfelocations
LIBRARY_NAME = xpfelocation_s
REQUIRES = xpcom chrome necko
CPPSRCS = nsAppFileLocationProvider.cpp
# we don't want the shared lib
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,37 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
LIBRARY_NAME=appfilelocprovider_s
CPP_OBJS= \
.\$(OBJDIR)\nsAppFileLocationProvider.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib

Просмотреть файл

@ -1,47 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <conrad@ingress.com>
*/
#include "nsIModule.h"
#include "nsIGenericFactory.h"
#include "nsAppFileLocProviderCID.h"
#include "nsAppFileLocationProvider.h"
// Factory Constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppFileLocationProvider)
// Component Table
static nsModuleComponentInfo components[] =
{
{ "AppFileLocationProvider Component", NS_APPFILELOCATIONPROVIDER_CID,
NS_APPFILELOCATIONPROVIDER_CONTRACTID, nsAppFileLocationProviderConstructor }
};
// NSGetModule implementation.
NS_IMPL_NSGETMODULE("AppFileLocationProvider Module", components)

Просмотреть файл

@ -1,394 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <conrad@ingress.com>
*/
#include "nsAppFileLocationProvider.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIAtom.h"
#include "nsILocalFile.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIChromeRegistry.h"
static nsresult GetDefaultUserProfileRoot(nsILocalFile **aLocalFile);
#if defined(XP_MAC)
#include <Folders.h>
#include <Script.h>
#include <Processes.h>
#include "nsILocalFileMac.h"
#endif
#if defined(XP_OS2)
#define INCL_DOSPROCESS
#define INCL_DOSMODULEMGR
#include <os2.h>
#elif defined(XP_PC)
#include <windows.h>
#include <shlobj.h>
#elif defined(XP_UNIX)
#include <unistd.h>
#include <stdlib.h>
#include <sys/param.h>
#include <prenv.h>
#elif defined(XP_BEOS)
#include <sys/param.h>
#include <kernel/image.h>
#include <storage/FindDirectory.h>
#endif
static nsresult GetChromeLocale(PRUnichar** localeName);
// IDs
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
// WARNING: These hard coded names need to go away. They need to
// come from localizable resources
#if XP_MAC
#define DEFAULTS_DIR_NAME "Defaults"
#define DEFAULTS_PREF_DIR_NAME "Pref"
#define DEFAULTS_PROFILE_DIR_NAME "Profile"
#define RES_DIR_NAME "Res"
#define CHROME_DIR_NAME "Chrome"
#define PLUGINS_DIR_NAME "Plug-ins"
#define SEARCH_DIR_NAME "Search Plugins"
#else
#define DEFAULTS_DIR_NAME "defaults"
#define DEFAULTS_PREF_DIR_NAME "pref"
#define DEFAULTS_PROFILE_DIR_NAME "profile"
#define RES_DIR_NAME "res"
#define CHROME_DIR_NAME "chrome"
#define PLUGINS_DIR_NAME "plugins"
#define SEARCH_DIR_NAME "searchplugins"
#endif
//*****************************************************************************
// nsAppFileLocationProvider::Static Variables
//*****************************************************************************
PRInt32 nsAppFileLocationProvider::sInstanceCount = 0;
nsIAtom* nsAppFileLocationProvider::sApp_DefaultsFolder50 = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_PrefDefaultsFolder50 = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsFolder50 = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_ProfileDefaultsNoLocFolder50 = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_DefaultUserProfileRoot50 = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_ResDirectory = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_ChromeDirectory = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_PluginsDirectory = nsnull;
nsIAtom* nsAppFileLocationProvider::sApp_SearchDirectory50 = nsnull;
//*****************************************************************************
// nsAppFileLocationProvider::Constructor/Destructor
//*****************************************************************************
nsAppFileLocationProvider::nsAppFileLocationProvider()
{
NS_INIT_ISUPPORTS();
if (sInstanceCount++ == 0) {
// Defaults
sApp_DefaultsFolder50 = NS_NewAtom(NS_APP_DEFAULTS_50_DIR);
sApp_PrefDefaultsFolder50 = NS_NewAtom(NS_APP_PREF_DEFAULTS_50_DIR);
sApp_ProfileDefaultsFolder50 = NS_NewAtom(NS_APP_PROFILE_DEFAULTS_50_DIR);
sApp_ProfileDefaultsNoLocFolder50 = NS_NewAtom(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR);
// Profile Root
sApp_DefaultUserProfileRoot50 = NS_NewAtom(NS_APP_USER_PROFILES_ROOT_DIR);
// Application Directories
sApp_ResDirectory = NS_NewAtom(NS_APP_RES_DIR);
sApp_ChromeDirectory = NS_NewAtom(NS_APP_CHROME_DIR);
sApp_PluginsDirectory = NS_NewAtom(NS_APP_PLUGINS_DIR);
// Search
sApp_SearchDirectory50 = NS_NewAtom(NS_APP_SEARCH_DIR);
}
nsresult rv;
// Get the mozilla bin directory
// 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
// This will be set if a directory was passed to NS_InitXPCOM
// 2. If that doesn't work, set it to be the current process directory
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
if (NS_FAILED(rv)) {
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
}
}
nsAppFileLocationProvider::~nsAppFileLocationProvider()
{
if (--sInstanceCount == 0) {
NS_IF_RELEASE(sApp_DefaultsFolder50);
NS_IF_RELEASE(sApp_PrefDefaultsFolder50);
NS_IF_RELEASE(sApp_ProfileDefaultsFolder50);
NS_IF_RELEASE(sApp_ProfileDefaultsNoLocFolder50);
NS_IF_RELEASE(sApp_DefaultUserProfileRoot50);
NS_IF_RELEASE(sApp_ResDirectory);
NS_IF_RELEASE(sApp_ChromeDirectory);
NS_IF_RELEASE(sApp_PluginsDirectory);
NS_IF_RELEASE(sApp_SearchDirectory50);
}
}
//*****************************************************************************
// nsAppFileLocationProvider::nsISupports
//*****************************************************************************
NS_IMPL_ISUPPORTS1(nsAppFileLocationProvider, nsIDirectoryServiceProvider)
//*****************************************************************************
// nsAppFileLocationProvider::nsIDirectoryServiceProvider
//*****************************************************************************
NS_IMETHODIMP
nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
nsCOMPtr<nsILocalFile> localFile;
nsresult rv = NS_ERROR_FAILURE;
*_retval = nsnull;
*persistant = PR_TRUE;
nsIAtom* inAtom = NS_NewAtom(prop);
NS_ENSURE_TRUE(inAtom, NS_ERROR_OUT_OF_MEMORY);
if (inAtom == sApp_DefaultsFolder50)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
}
else if (inAtom == sApp_PrefDefaultsFolder50)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PREF_DIR_NAME);
}
}
else if (inAtom == sApp_ProfileDefaultsFolder50)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString localeName;
rv = GetChromeLocale(getter_Copies(localeName));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativeUnicodePath(localeName);
}
}
}
}
else if (inAtom == sApp_ProfileDefaultsNoLocFolder50)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);
}
}
else if (inAtom == sApp_DefaultUserProfileRoot50)
{
rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
}
else if (inAtom == sApp_ResDirectory)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(RES_DIR_NAME);
}
else if (inAtom == sApp_ChromeDirectory)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(CHROME_DIR_NAME);
}
else if (inAtom == sApp_PluginsDirectory)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);
}
else if (inAtom == sApp_SearchDirectory50)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
}
NS_RELEASE(inAtom);
if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
return rv;
}
NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsILocalFile **aLocalFile)
{
NS_ENSURE_TRUE(mMozBinDirectory, NS_ERROR_FAILURE);
NS_ENSURE_ARG_POINTER(aLocalFile);
nsCOMPtr<nsIFile> aFile;
nsresult rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface (aFile);
if (!lfile)
return NS_ERROR_FAILURE;
NS_IF_ADDREF(*aLocalFile = lfile);
return NS_OK;
}
//****************************************************************************************
// Static Routines
//****************************************************************************************
static nsresult GetChromeLocale(PRUnichar** localeName)
{
NS_ENSURE_ARG_POINTER(localeName);
nsresult rv;
*localeName = nsnull;
nsCOMPtr<nsIChromeRegistry> chromeRegistry = do_GetService(kChromeRegistryCID, &rv);
if (NS_SUCCEEDED(rv)) {
nsString tmpstr; tmpstr.AssignWithConversion("navigator");
rv = chromeRegistry->GetSelectedLocale(tmpstr.GetUnicode(), localeName);
}
return rv;
}
//----------------------------------------------------------------------------------------
// GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
//
// UNIX : ~/.mozilla/
// WIN : <Application Data folder on user's machine>\Mozilla\Users50
// Mac : :Documents:Mozilla:Users50:
//----------------------------------------------------------------------------------------
static nsresult GetDefaultUserProfileRoot(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
PRBool exists;
nsCOMPtr<nsILocalFile> localDir;
#if defined(XP_MAC)
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = directoryService->Get(NS_MAC_DOCUMENTS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
#elif defined(XP_OS2)
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = directoryService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
#elif defined(XP_PC)
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_SUCCEEDED(rv))
rv = localDir->Exists(&exists);
if (NS_FAILED(rv) || !exists)
{
// On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
localDir = nsnull;
rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
}
if (NS_FAILED(rv)) return rv;
#elif defined(XP_UNIX)
rv = NS_NewLocalFile(PR_GetEnv("HOME"), PR_TRUE, getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath(".mozilla");
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
if (NS_FAILED(rv)) return rv;
#elif defined(XP_BEOS)
char path[MAXPATHLEN];
find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
// Need enough space to add the trailing backslash
int len = strlen(path);
if (len > MAXPATHLEN-2)
return NS_ERROR_FAILURE;
path[len] = '/';
path[len+1] = '\0';
rv = NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath("mozilla");
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0);
if (NS_FAILED(rv)) return rv;
#else
#error dont_know_how_to_do_profiles_on_your_platform
#endif
#if defined(XP_MAC) || defined(XP_OS2) || defined(XP_PC)
// These 3 platforms share this part of the path - do them as one
rv = localDir->AppendRelativePath("Mozilla");
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath("Users50");
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
if (NS_FAILED(rv)) return rv;
#endif
*aLocalFile = localDir;
NS_ADDREF(*aLocalFile);
return rv;
}