2002-08-21 14:25:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** 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.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2003-09-29 10:04:02 +04:00
|
|
|
* Brian Ryner <bryner@brianryner.com>
|
2002-08-21 14:25:54 +04:00
|
|
|
*
|
|
|
|
* 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 _nsXREDirProvider_h__
|
|
|
|
#define _nsXREDirProvider_h__
|
|
|
|
|
|
|
|
#include "nsIDirectoryService.h"
|
2004-06-18 01:23:51 +04:00
|
|
|
#include "nsIProfileMigrator.h"
|
|
|
|
#include "nsILocalFile.h"
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-09-04 16:55:29 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
class nsXREDirProvider : public nsIDirectoryServiceProvider2,
|
|
|
|
public nsIProfileStartup
|
2002-08-21 14:25:54 +04:00
|
|
|
{
|
|
|
|
public:
|
2004-06-18 01:23:51 +04:00
|
|
|
// we use a custom isupports implementation (no refcount)
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release(void);
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2002-09-29 10:51:54 +04:00
|
|
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
2004-06-18 01:23:51 +04:00
|
|
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
|
|
|
NS_DECL_NSIPROFILESTARTUP
|
|
|
|
|
|
|
|
nsXREDirProvider();
|
2006-01-12 18:29:10 +03:00
|
|
|
|
|
|
|
// if aXULAppDir is null, use gArgv[0]
|
|
|
|
nsresult Initialize(nsIFile *aXULAppDir,
|
2006-08-17 18:22:04 +04:00
|
|
|
nsILocalFile *aGREDir,
|
2006-01-12 18:29:10 +03:00
|
|
|
nsIDirectoryServiceProvider* aAppProvider = nsnull);
|
2004-06-18 01:23:51 +04:00
|
|
|
~nsXREDirProvider();
|
|
|
|
|
|
|
|
// We only set the profile dir, we don't ensure that it exists;
|
|
|
|
// that is the responsibility of the toolkit profile service.
|
|
|
|
// We also don't fire profile-changed notifications... that is
|
|
|
|
// the responsibility of the apprunner.
|
2005-04-26 04:37:23 +04:00
|
|
|
nsresult SetProfile(nsIFile* aProfileDir, nsIFile* aProfileLocalDir);
|
2004-06-18 01:23:51 +04:00
|
|
|
|
|
|
|
void DoShutdown();
|
|
|
|
|
|
|
|
nsresult GetProfileDefaultsDir(nsIFile* *aResult);
|
2005-04-26 04:37:23 +04:00
|
|
|
|
|
|
|
static nsresult GetUserAppDataDirectory(nsILocalFile* *aFile) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetUserDataDirectory(aFile, false);
|
2005-04-26 04:37:23 +04:00
|
|
|
}
|
|
|
|
static nsresult GetUserLocalDataDirectory(nsILocalFile* *aFile) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetUserDataDirectory(aFile, true);
|
2005-04-26 04:37:23 +04:00
|
|
|
}
|
2004-06-18 01:23:51 +04:00
|
|
|
|
|
|
|
/* make sure you clone it, if you need to do stuff to it */
|
2005-12-23 17:51:39 +03:00
|
|
|
nsIFile* GetGREDir() { return mGREDir; }
|
2007-09-26 22:35:21 +04:00
|
|
|
nsIFile* GetAppDir() {
|
2005-12-23 17:51:39 +03:00
|
|
|
if (mXULAppDir)
|
|
|
|
return mXULAppDir;
|
|
|
|
return mGREDir;
|
|
|
|
}
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-04-20 19:22:17 +04:00
|
|
|
/**
|
|
|
|
* Get the directory under which update directory is created.
|
|
|
|
* This method may be called before XPCOM is started. aResult
|
|
|
|
* is a clone, it may be modified.
|
|
|
|
*/
|
|
|
|
nsresult GetUpdateRootDir(nsIFile* *aResult);
|
|
|
|
|
2006-01-12 18:29:10 +03:00
|
|
|
/**
|
|
|
|
* Get the profile startup directory as determined by this class or by
|
|
|
|
* mAppProvider. This method may be called before XPCOM is started. aResult
|
|
|
|
* is a clone, it may be modified.
|
|
|
|
*/
|
2007-04-20 19:22:17 +04:00
|
|
|
nsresult GetProfileStartupDir(nsIFile* *aResult);
|
2006-01-12 18:29:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the profile directory as determined by this class or by an
|
|
|
|
* embedder-provided XPCOM directory provider. Only call this method
|
|
|
|
* when XPCOM is initialized! aResult is a clone, it may be modified.
|
|
|
|
*/
|
|
|
|
nsresult GetProfileDir(nsIFile* *aResult);
|
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
protected:
|
2006-01-12 18:29:10 +03:00
|
|
|
nsresult GetFilesInternal(const char* aProperty, nsISimpleEnumerator** aResult);
|
2011-09-29 10:19:26 +04:00
|
|
|
static nsresult GetUserDataDirectory(nsILocalFile* *aFile, bool aLocal);
|
|
|
|
static nsresult GetUserDataDirectoryHome(nsILocalFile* *aFile, bool aLocal);
|
2008-01-15 18:13:59 +03:00
|
|
|
static nsresult GetSysUserExtensionsDirectory(nsILocalFile* *aFile);
|
2008-03-07 04:58:18 +03:00
|
|
|
#if defined(XP_UNIX) || defined(XP_MACOSX)
|
|
|
|
static nsresult GetSystemExtensionsDirectory(nsILocalFile** aFile);
|
|
|
|
#endif
|
2004-06-18 01:23:51 +04:00
|
|
|
static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
|
|
|
|
void EnsureProfileFileExists(nsIFile* aFile);
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-09-26 22:35:21 +04:00
|
|
|
// Determine the profile path within the UAppData directory. This is different
|
|
|
|
// on every major platform.
|
|
|
|
static nsresult AppendProfilePath(nsIFile* aFile);
|
|
|
|
|
2008-01-15 18:13:59 +03:00
|
|
|
static nsresult AppendSysUserExtensionPath(nsIFile* aFile);
|
|
|
|
|
2007-09-26 22:35:21 +04:00
|
|
|
// Internal helper that splits a path into components using the '/' and '\\'
|
|
|
|
// delimiters.
|
|
|
|
static inline nsresult AppendProfileString(nsIFile* aFile, const char* aPath);
|
|
|
|
|
2010-06-23 20:18:32 +04:00
|
|
|
// Calculate and register extension and theme bundle directories.
|
|
|
|
void LoadExtensionBundleDirectories();
|
|
|
|
|
|
|
|
// Calculate and register app-bundled extension directories.
|
2007-09-04 16:55:29 +04:00
|
|
|
void LoadAppBundleDirs();
|
|
|
|
|
|
|
|
void Append(nsIFile* aDirectory);
|
|
|
|
|
2006-01-12 18:29:10 +03:00
|
|
|
nsCOMPtr<nsIDirectoryServiceProvider> mAppProvider;
|
2005-12-23 17:51:39 +03:00
|
|
|
nsCOMPtr<nsILocalFile> mGREDir;
|
2004-09-07 22:59:07 +04:00
|
|
|
nsCOMPtr<nsIFile> mXULAppDir;
|
2004-06-18 01:23:51 +04:00
|
|
|
nsCOMPtr<nsIFile> mProfileDir;
|
2005-04-26 04:37:23 +04:00
|
|
|
nsCOMPtr<nsIFile> mProfileLocalDir;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mProfileNotified;
|
2007-09-04 16:55:29 +04:00
|
|
|
nsCOMArray<nsIFile> mAppBundleDirectories;
|
|
|
|
nsCOMArray<nsIFile> mExtensionDirectories;
|
|
|
|
nsCOMArray<nsIFile> mThemeDirectories;
|
2002-08-21 14:25:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|