This commit is contained in:
ccarlen%netscape.com 2000-09-09 15:30:09 +00:00
Родитель 6672c6d541
Коммит a7e68bcf73
5 изменённых файлов: 416 добавлений и 399 удалений

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

@ -21,14 +21,12 @@
*/
#include "nsISupports.idl"
#include "nsIFile.idl"
interface nsICmdLineService;
interface nsIFileSpec;
%{C++
#include "nsFileSpec.h"
#include "nsICmdLineService.h"
#include "nsIFile.h"
#define NS_PROFILE_CID \
{ /* {02b0625b-e7f3-11d2-9f5a-006008a6efe9} */ \
@ -45,25 +43,22 @@ interface nsIFileSpec;
"profile-startup-category"
%}
[ptr] native nsFileSpec(nsFileSpec);
[ref] native nsFileSpecRef(nsFileSpec);
[ptr] native nsIFile(nsIFile);
[scriptable, uuid(02b0625a-e7f3-11d2-9f5a-006008a6efe9)]
interface nsIProfile : nsISupports {
[noscript] void startupWithArgs(in nsICmdLineService cmdLine);
void startup(in wstring filename);
[noscript] void getProfileDir(in wstring profileName,
in nsFileSpec profileDir);
out nsIFile profileDir);
readonly attribute long profileCount;
readonly attribute wstring currentProfile;
readonly attribute wstring firstProfile;
// eventually we need to depricate getCurrentProfileDir
[noscript] void getCurrentProfileDir(in nsFileSpec profileDir);
[noscript] void getCurrentProfileDir(out nsIFile profileDir);
[noscript] void setProfileDir(in wstring profileName,
in nsFileSpecRef profileDir);
in nsIFile profileDir);
boolean profileExists(in wstring profileName);
@ -94,7 +89,7 @@ interface nsIProfile : nsISupports {
attribute boolean automigrate;
readonly attribute nsIFileSpec defaultProfileParentDir;
readonly attribute nsIFile defaultProfileParentDir;
[noscript] void updateRegistry(in nsIFile regName);
void setRegStrings(in wstring profileName,

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -69,9 +69,10 @@ private:
PRBool *profileDirSet,
nsCString & profileURLStr);
nsresult LoadDefaultProfileDir(nsCString & profileURLStr);
nsresult CopyDefaultFile(nsIFileSpec *profDefaultsDir,
nsFileSpec& newProfDir,
nsresult CopyDefaultFile(nsIFile *profDefaultsDir,
nsIFile *newProfDir,
const char *fileName);
nsresult EnsureProfileFileExists(nsIFile *aFile);
nsresult CloneProfileDirectorySpec(nsILocalFile **aLocalFile);
@ -86,10 +87,10 @@ public:
nsresult RenameProfileDir(const PRUnichar *newProfileName);
// Creates associated user directories on the creation of a new profile
nsresult CreateUserDirectories(const nsFileSpec& profileDir);
nsresult CreateUserDirectories(nsILocalFile *profileDir);
// Deletes associated user directories
nsresult DeleteUserDirectories(const nsFileSpec& profileDir);
nsresult DeleteUserDirectories(nsILocalFile *profileDir);
// Copies all the registry keys from old profile to new profile
nsresult CopyRegKey(const PRUnichar *oldProfile, const PRUnichar *newProfile);

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

@ -490,6 +490,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName)
mCount = 0;
mNumProfiles = 0;
mNumOldProfiles = 0;
PRBool currentProfileValid = mCurrentProfile.IsEmpty();
while( (NS_OK != enumKeys->IsDone()) )
{
@ -578,6 +579,9 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName)
getter_Copies(NCHavePregInfo));
}
// Make sure that mCurrentProfile is valid
if (!mCurrentProfile.IsEmpty() && mCurrentProfile.Equals(profile))
currentProfileValid = PR_TRUE;
ProfileStruct* profileItem = new ProfileStruct();
if (!profileItem)
@ -624,6 +628,9 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName)
rv = enumKeys->Next();
}
if (!currentProfileValid)
mCurrentProfile.SetLength(0);
mFixRegEntries = PR_FALSE;
rv = CloseRegistry();
return rv;

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

@ -202,13 +202,13 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec)
return PR_FALSE;
PRUnichar* currProfileName;
nsFileSpec currProfileDirSpec;
nsCOMPtr<nsIFile> currProfileDir;
if (numProfiles == 1)
{
// one profile exists: use that profile
profileService->GetFirstProfile(&currProfileName);
if (currProfileName && (nsCRT::strlen(currProfileName) > 0)) {
profileService->GetProfileDir(currProfileName, &currProfileDirSpec);
profileService->GetProfileDir(currProfileName, getter_AddRefs(currProfileDir));
}
else {
// this should never happen
@ -224,13 +224,13 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec)
// we'll pick the first one as returned from the registry query)
profileService->GetCurrentProfile(&currProfileName);
if (currProfileName && (nsCRT::strlen(currProfileName) > 0)) {
profileService->GetProfileDir(currProfileName, &currProfileDirSpec);
profileService->GetProfileDir(currProfileName, getter_AddRefs(currProfileDir));
}
else
{
profileService->GetFirstProfile(&currProfileName);
if (!currProfileName || (nsCRT::strlen(currProfileName) == 0)) {
profileService->GetProfileDir(currProfileName, &currProfileDirSpec);
profileService->GetProfileDir(currProfileName, getter_AddRefs(currProfileDir));
}
}
}
@ -239,6 +239,13 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec)
PR_FREEIF(currProfileName);
return PR_FALSE;
}
nsFileSpec currProfileDirSpec;
nsXPIDLCString pathBuf;
rv = currProfileDir->GetPath(getter_Copies(pathBuf));
if (NS_FAILED(rv)) return PR_FALSE;
currProfileDirSpec = (const char *)pathBuf;
#if defined(NS_DEBUG)
if (currProfileName) {
nsCAutoString currProfileNameCStr; currProfileNameCStr.AssignWithConversion(currProfileName);
@ -256,12 +263,17 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec)
gProfileDir = new nsFileSpec("Default");
if (!gProfileDir)
return PR_FALSE;
if (NS_FAILED(profileService->GetCurrentProfileDir(gProfileDir)))
if (NS_FAILED(profileService->GetCurrentProfileDir(getter_AddRefs(currProfileDir))))
{
delete gProfileDir; // All that for nothing. sigh.
gProfileDir = nsnull;
return PR_FALSE;
}
nsXPIDLCString pathBuf2;
rv = currProfileDir->GetPath(getter_Copies(pathBuf2));
if (NS_FAILED(rv)) return PR_FALSE;
*gProfileDir = (const char *)pathBuf2;
NS_ASSERTION(*gProfileDir == currProfileDirSpec, "Profile spec does not match!");
if (!gProfileDir->Exists())