Fixing bugscape bug 4198. This fix allows ISPs add signature files to the user accounts. Adding changes to AppFileLocationProvider to get to messenger defaults.

This commit is contained in:
racham%netscape.com 2001-09-15 07:53:54 +00:00
Родитель 7d2ff6bfc3
Коммит 2b71c485c2
3 изменённых файлов: 56 добавлений и 0 удалений

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

@ -55,6 +55,7 @@
#define NS_APP_CHROME_DIR "AChrom"
#define NS_APP_PLUGINS_DIR "APlugns"
#define NS_APP_SEARCH_DIR "SrchPlugns"
#define NS_APP_MESSENGER_DIR "AMessenger"
// --------------------------------------------------------------------------------------
// Files and directories which exist on a per-profile basis

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

@ -29,6 +29,7 @@
#include "nsILocalFile.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIChromeRegistry.h"
#if defined(XP_MAC)
@ -94,6 +95,8 @@
#define SEARCH_DIR_NAME "searchplugins"
#endif
// default mailnews files parent folder
#define MESSENGER_DIR_NAME "messenger"
//*****************************************************************************
// nsAppFileLocationProvider::Constructor/Destructor
@ -108,6 +111,8 @@ nsAppFileLocationProvider::~nsAppFileLocationProvider()
{
}
// Chrome reg service
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
//*****************************************************************************
// nsAppFileLocationProvider::nsISupports
@ -191,6 +196,18 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_MESSENGER_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(MESSENGER_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = GetSelectedLocaleDataDir(localFile);
}
}
}
if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
@ -349,3 +366,40 @@ NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aL
return rv;
}
//----------------------------------------------------------------------------------------
// GetSelectedLocaleDataDir - If a locale is selected, appends the selected locale to the
// defaults data dir and returns that new defaults data dir
//----------------------------------------------------------------------------------------
NS_METHOD nsAppFileLocationProvider::GetSelectedLocaleDataDir(nsILocalFile *defaultsDataDir)
{
NS_ENSURE_ARG_POINTER(defaultsDataDir);
nsresult rv;
PRBool baseDirExists = PR_FALSE;
rv = defaultsDataDir->Exists(&baseDirExists);
NS_ENSURE_SUCCESS(rv,rv);
if (baseDirExists) {
nsCOMPtr<nsIChromeRegistry> chromeRegistry = do_GetService(kChromeRegistryCID, &rv);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString localeName;
nsAutoString regionKey; regionKey.AssignWithConversion("global-region");
rv = chromeRegistry->GetSelectedLocale(regionKey.get(), getter_Copies(localeName));
if (NS_SUCCEEDED(rv) && + localeName.get() && + nsCRT::strlen(localeName.get())) {
PRBool localeDirExists = PR_FALSE;
nsCOMPtr<nsIFile> localeDataDir;
rv = defaultsDataDir->Clone(getter_AddRefs(localeDataDir));
NS_ENSURE_SUCCESS(rv,rv);
rv = localeDataDir->AppendUnicode(localeName);
NS_ENSURE_SUCCESS(rv,rv);
rv = localeDataDir->Exists(&localeDirExists);
NS_ENSURE_SUCCESS(rv,rv);
if (localeDirExists) {
// use locale provider instead
rv = defaultsDataDir->AppendUnicode(localeName);
NS_ENSURE_SUCCESS(rv,rv);
}
}
}
}
return NS_OK;
}

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

@ -45,6 +45,7 @@ protected:
NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile);
NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile);
NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile);
NS_METHOD GetSelectedLocaleDataDir(nsILocalFile *aLocalFile);
nsCOMPtr<nsILocalFile> mMozBinDirectory;
};