This commit is contained in:
ccarlen%netscape.com 2000-11-04 16:27:30 +00:00
Родитель 32498b8af3
Коммит d015f6354e
10 изменённых файлов: 98 добавлений и 79 удалений

Двоичные данные
profile/macbuild/ProfileServicesIDL.mcp

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

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

@ -30,6 +30,7 @@ MODULE = profile
XPIDLSRCS = \ XPIDLSRCS = \
nsIProfile.idl \ nsIProfile.idl \
nsIProfileInternal.idl \
nsIProfileStartupListener.idl \ nsIProfileStartupListener.idl \
$(NULL) $(NULL)

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

@ -31,6 +31,7 @@ EXPORTS=nsIAccount.h \
XPIDLSRCS = \ XPIDLSRCS = \
.\nsIProfile.idl \ .\nsIProfile.idl \
.\nsIProfileInternal.idl \
.\nsIProfileStartupListener.idl \ .\nsIProfileStartupListener.idl \
$(NULL) $(NULL)

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

@ -23,10 +23,8 @@
#include "nsISupports.idl" #include "nsISupports.idl"
#include "nsIFile.idl" #include "nsIFile.idl"
interface nsICmdLineService;
%{C++ %{C++
#include "nsICmdLineService.h"
#define NS_PROFILE_CID \ #define NS_PROFILE_CID \
{ /* {02b0625b-e7f3-11d2-9f5a-006008a6efe9} */ \ { /* {02b0625b-e7f3-11d2-9f5a-006008a6efe9} */ \
@ -45,24 +43,12 @@ interface nsICmdLineService;
[scriptable, uuid(02b0625a-e7f3-11d2-9f5a-006008a6efe9)] [scriptable, uuid(02b0625a-e7f3-11d2-9f5a-006008a6efe9)]
interface nsIProfile : nsISupports { interface nsIProfile : nsISupports {
[noscript] void startupWithArgs(in nsICmdLineService cmdLine);
void startup(in wstring filename);
[noscript] void getProfileDir(in wstring profileName,
out nsIFile profileDir);
readonly attribute long profileCount; readonly attribute long profileCount;
readonly attribute wstring currentProfile; void getProfileList(out unsigned long length, [retval, array, size_is(length)] out wstring profileNames);
readonly attribute wstring firstProfile;
// eventually we need to depricate getCurrentProfileDir
[noscript] void getCurrentProfileDir(out nsIFile profileDir);
[noscript] void setProfileDir(in wstring profileName,
in nsIFile profileDir);
boolean profileExists(in wstring profileName); boolean profileExists(in wstring profileName);
void migrateProfileInfo(); readonly attribute wstring currentProfile;
void createNewProfile(in wstring profileName, void createNewProfile(in wstring profileName,
in wstring nativeProfileDir, in wstring nativeProfileDir,
@ -70,35 +56,8 @@ interface nsIProfile : nsISupports {
in boolean useExistingDir); in boolean useExistingDir);
void renameProfile(in wstring oldName, in wstring newName); void renameProfile(in wstring oldName, in wstring newName);
void deleteProfile(in wstring name, in boolean canDeleteFiles); void deleteProfile(in wstring name, in boolean canDeleteFiles);
wstring getProfileList();
void startApprunner(in wstring profileName);
void migrateProfile(in wstring profileName, in boolean showProgressAsModalWindow);
long get4xProfileCount();
void migrateAllProfiles();
void cloneProfile(in wstring profileName); void cloneProfile(in wstring profileName);
void forgetCurrentProfile();
void loadNewProfilePrefs();
boolean isCurrentProfileAvailable();
attribute boolean automigrate;
readonly attribute nsIFile defaultProfileParentDir;
[noscript] void updateRegistry(in nsIFile regName);
void setRegStrings(in wstring profileName,
in wstring regString,
in wstring regName,
in wstring regEmail,
in wstring regOption);
string isRegStringSet(in wstring profileName);
}; };
#endif /* nsIProfile_h__ */ #endif /* nsIProfile_h__ */

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

@ -316,6 +316,7 @@ NS_IMPL_THREADSAFE_RELEASE(nsProfile)
NS_INTERFACE_MAP_BEGIN(nsProfile) NS_INTERFACE_MAP_BEGIN(nsProfile)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProfile) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProfile)
NS_INTERFACE_MAP_ENTRY(nsIProfile) NS_INTERFACE_MAP_ENTRY(nsIProfile)
NS_INTERFACE_MAP_ENTRY(nsIProfileInternal)
NS_INTERFACE_MAP_ENTRY(nsIDirectoryServiceProvider) NS_INTERFACE_MAP_ENTRY(nsIDirectoryServiceProvider)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
@ -1094,7 +1095,7 @@ nsProfile::AddLevelOfIndirection(nsIFile *aDir)
*/ */
// Sets the current profile directory // Sets the current profile directory
NS_IMETHODIMP nsProfile::SetProfileDir(const PRUnichar *profileName, nsIFile *profileDir) nsresult nsProfile::SetProfileDir(const PRUnichar *profileName, nsIFile *profileDir)
{ {
NS_ENSURE_ARG(profileName); NS_ENSURE_ARG(profileName);
NS_ENSURE_ARG(profileDir); NS_ENSURE_ARG(profileDir);
@ -1476,16 +1477,26 @@ NS_IMETHODIMP nsProfile::DeleteProfile(const PRUnichar* profileName, PRBool canD
return rv; return rv;
} }
// Get the list of all profiles
// Populate the input param.
// This method is written to support the core service
// call to get the names all profiles.
NS_IMETHODIMP nsProfile::GetProfileList(PRUnichar **profileListStr)
{
NS_ENSURE_ARG_POINTER(profileListStr);
gProfileDataAccess->GetProfileList(profileListStr); NS_IMETHODIMP nsProfile::GetProfileList(PRUint32 *length, PRUnichar ***profileNames)
return NS_OK; {
NS_ENSURE_ARG_POINTER(length);
*length = 0;
NS_ENSURE_ARG_POINTER(profileNames);
*profileNames = nsnull;
return gProfileDataAccess->GetProfileList(nsIProfileInternal::LIST_ONLY_NEW, length, profileNames);
}
NS_IMETHODIMP nsProfile::GetProfileListX(PRUint32 whichKind, PRUint32 *length, PRUnichar ***profileNames)
{
NS_ENSURE_ARG_POINTER(length);
*length = 0;
NS_ENSURE_ARG_POINTER(profileNames);
*profileNames = nsnull;
return gProfileDataAccess->GetProfileList(whichKind, length, profileNames);
} }
@ -1532,7 +1543,7 @@ NS_IMETHODIMP nsProfile::StartApprunner(const PRUnichar* profileName)
return rv; return rv;
} }
NS_IMETHODIMP nsProfile::LoadNewProfilePrefs() nsresult nsProfile::LoadNewProfilePrefs()
{ {
nsresult rv; nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);

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

@ -21,6 +21,7 @@
*/ */
#include "nsIProfile.h" #include "nsIProfile.h"
#include "nsIProfileInternal.h"
#include "nsIProfileStartupListener.h" #include "nsIProfileStartupListener.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsISupports.h" #include "nsISupports.h"
@ -57,11 +58,12 @@
#define REGISTRY_VERSION_STRING "Version" #define REGISTRY_VERSION_STRING "Version"
#define REGISTRY_VERSION_1_0 "1.0" #define REGISTRY_VERSION_1_0 "1.0"
class nsProfile: public nsIProfile, class nsProfile: public nsIProfileInternal,
public nsIDirectoryServiceProvider public nsIDirectoryServiceProvider
{ {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIPROFILE NS_DECL_NSIPROFILE
NS_DECL_NSIPROFILEINTERNAL
NS_DECL_NSIDIRECTORYSERVICEPROVIDER NS_DECL_NSIDIRECTORYSERVICEPROVIDER
private: private:
@ -73,6 +75,8 @@ private:
nsIFile *newProfDir, nsIFile *newProfDir,
const char *fileName); const char *fileName);
nsresult EnsureProfileFileExists(nsIFile *aFile); nsresult EnsureProfileFileExists(nsIFile *aFile);
nsresult LoadNewProfilePrefs();
nsresult SetProfileDir(const PRUnichar *profileName, nsIFile *profileDir);
nsresult CloneProfileDirectorySpec(nsILocalFile **aLocalFile); nsresult CloneProfileDirectorySpec(nsILocalFile **aLocalFile);
nsresult AddLevelOfIndirection(nsIFile *aDir); nsresult AddLevelOfIndirection(nsIFile *aDir);

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

@ -1155,31 +1155,74 @@ nsProfileAccess::UpdateRegistry(nsIFile* regName)
return rv; return rv;
} }
// Return the list of profiles, 4x and 5x. // Return the list of profiles, 4x, 5x, or both.
// For 4x profiles text "- migrate" is appended // For 4x profiles text "- migrate" is appended
// to inform the JavaScript about the migration status. // to inform the JavaScript about the migration status.
void nsresult
nsProfileAccess::GetProfileList(PRUnichar **profileListStr) nsProfileAccess::GetProfileList(PRInt32 whichKind, PRUint32 *length, PRUnichar ***result)
{ {
NS_ASSERTION(profileListStr, "Invalid profileListStr pointer"); NS_ENSURE_ARG_POINTER(length);
*length = 0;
NS_ENSURE_ARG_POINTER(result);
*result = nsnull;
nsAutoString profileList; nsresult rv = NS_OK;
PRInt32 count, localLength = 0;
PRUnichar **outArray, **next;
for (PRInt32 index=0; index < mCount; index++) switch (whichKind)
{
case nsIProfileInternal::LIST_ONLY_NEW:
count = mNumProfiles;
break;
case nsIProfileInternal::LIST_ONLY_OLD:
GetNum4xProfiles(&count);
break;
case nsIProfileInternal::LIST_ALL:
count = mCount;
break;
default:
NS_ASSERTION(PR_FALSE, "Bad parameter");
return NS_ERROR_INVALID_ARG;
}
next = outArray = (PRUnichar **)nsMemory::Alloc(count * sizeof(PRUnichar *));
if (!outArray)
return NS_ERROR_OUT_OF_MEMORY;
for (PRInt32 index=0; index < mCount && localLength < count; index++)
{ {
ProfileStruct* profileItem = (ProfileStruct *) (mProfiles->ElementAt(index)); ProfileStruct* profileItem = (ProfileStruct *) (mProfiles->ElementAt(index));
PRBool isMigrated = profileItem->isMigrated.EqualsWithConversion(REGISTRY_YES_STRING);
if (index != 0) if (whichKind == nsIProfileInternal::LIST_ONLY_OLD && isMigrated)
continue;
else if (whichKind == nsIProfileInternal::LIST_ONLY_NEW && !isMigrated)
continue;
*next = profileItem->profileName.ToNewUnicode();
if (*next == nsnull)
{ {
profileList.AppendWithConversion(","); rv = NS_ERROR_OUT_OF_MEMORY;
break;
} }
profileList += profileItem->profileName; next++;
localLength++;
if (profileItem->isMigrated.EqualsWithConversion(REGISTRY_NO_STRING))
profileList.AppendWithConversion(" - migrate");
} }
*profileListStr = profileList.ToNewUnicode(); if (NS_SUCCEEDED(rv))
{
*result = outArray;
*length = localLength;
}
else
{
while (--next >= outArray)
nsMemory::Free(*next);
nsMemory::Free(outArray);
}
return rv;
} }
// Return a boolean based on the profile existence. // Return a boolean based on the profile existence.

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

@ -112,7 +112,7 @@ public:
PRInt32 FindProfileIndex(const PRUnichar* profileName); PRInt32 FindProfileIndex(const PRUnichar* profileName);
nsresult UpdateRegistry(nsIFile* regName); nsresult UpdateRegistry(nsIFile* regName);
void GetProfileList(PRUnichar **profileListStr); nsresult GetProfileList(PRInt32 whichKind, PRUint32 *length, PRUnichar ***result);
PRBool ProfileExists(const PRUnichar *profileName); PRBool ProfileExists(const PRUnichar *profileName);
nsresult Get4xProfileInfo(const char *registryName); nsresult Get4xProfileInfo(const char *registryName);
nsresult UpdateProfileArray(); nsresult UpdateProfileArray();

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

@ -52,7 +52,7 @@
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include "nsIProfile.h" #include "nsIProfileInternal.h"
#include "nsIPrefMigration.h" // for NEW_IMAPMAIL_DIR_NAME, etc #include "nsIPrefMigration.h" // for NEW_IMAPMAIL_DIR_NAME, etc
#include "plstr.h" #include "plstr.h"
@ -185,7 +185,7 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec)
{ {
// First time, initialize gProfileDir // First time, initialize gProfileDir
nsresult rv; nsresult rv;
NS_WITH_SERVICE(nsIProfile, profileService, kProfileCID, &rv); NS_WITH_SERVICE(nsIProfileInternal, profileService, kProfileCID, &rv);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return PR_FALSE; return PR_FALSE;

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

@ -99,7 +99,7 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
#endif #endif
// header file for profile manager // header file for profile manager
#include "nsIProfile.h" #include "nsIProfileInternal.h"
#if defined(XP_UNIX) #if defined(XP_UNIX)
extern void InstallUnixSignalHandlers(const char *ProgramName); extern void InstallUnixSignalHandlers(const char *ProgramName);
@ -802,7 +802,7 @@ static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
} }
else else
{ {
nsCOMPtr<nsIProfile> profileMgr = do_GetService(kProfileCID, &rv); nsCOMPtr<nsIProfileInternal> profileMgr = do_GetService(kProfileCID, &rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get profile manager"); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get profile manager");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;