This change-bundle fixes the long standing problem where you couldn't

run webclient at the same time mozilla was running.  It does this by
introducing a new startup command, which must be called before the first
call to BrowserControlFactory.setAppData(), like this:

	BrowserControlFactory.setProfile(startupProfile);
	BrowserControlFactory.setAppData(getBrowserBinDir());

This will cause the startupProfile to be created (if necessary) and used
as webclient's mozilla profile.  If not specified, a "webclient" profile
is created and used.  This profile sticks around on your system.

SECTION: CHANGES

M classes_spec/org/mozilla/webclient/BrowserControlFactory.java
M classes_spec/org/mozilla/webclient/WebclientFactory.java
M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java

- add setProfile().

M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java
M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java

- add setProfile() and getProfile().

M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java

- pass the wrapperFactory's profile property to the nativeStartup().

M src_moz/ProfileManagerImpl.cpp

- logic to implement above changes

M test/automated/src/classes/org/mozilla/webclient/ProfileManagerTest.java

- test that the startupProfile feature works.


git-svn-id: svn://10.0.0.236/trunk@164983 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2004-11-05 06:40:27 +00:00
parent 98020d2cc3
commit 9c96164a95
8 changed files with 96 additions and 25 deletions

View File

@@ -50,7 +50,7 @@ static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileManagerImpl_nativeStartup
(JNIEnv *env, jobject obj, jint nativeContext,
jstring profileDir , jstring profileName)
jstring profileDir , jstring profileNameJstr)
{
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("ProfileManagerImpl_nativeStartup: entering\n"));
@@ -71,43 +71,67 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("ProfileManagerImpl_nativeStartup: GetProfileCount rv: %d\n",
rv));
PRUnichar *webclientProfile = nsnull;
char *webclientProfileCstr = nsnull;
if (nsnull == profileNameJstr) {
NS_NAMED_LITERAL_STRING(webclientStr, "webclient");
webclientProfile = (PRUnichar *) webclientStr.get();
webclientProfileCstr = "webclient";
}
else {
webclientProfile = (PRUnichar *)
::util_GetStringChars(env, profileNameJstr);
webclientProfileCstr = (char *)
::util_GetStringUTFChars(env, profileNameJstr);
}
char *argv[3];
int i, argc = 0;
int i,j;
PRBool hasWebclientProfile = PR_FALSE;
argv[0] = PL_strdup(nsnull);
if (numProfiles > 1) {
argv[1] = PL_strdup("-p");
if (0 < numProfiles) {
PRUnichar **Names;
PRUint32 NamesLen = 0;
rv = profile->GetProfileList(&NamesLen, &Names);
argv[1] = PL_strdup("-p");
if (NS_SUCCEEDED(rv)) {
PR_ASSERT(NamesLen >= 1);
// PENDING(edburns): fix for 70656. Really we should have a way
// for the embedding app to specify which profile to use.
// For now we just get the name of the first profile.
char * temp = new char[100]; // de-allocated in following for loop
for (i = 0; Names[0][i] != '\0'; i++) {
temp[i] = (char) Names[0][i];
char * temp = new char[100]; // de-allocated following for loop
for (i = 0; i < NamesLen; i++) {
for (j = 0; Names[i][j] != '\0'; j++) {
temp[j] = (char) Names[i][j];
}
temp[j] = '\0';
if (0 == strcmp(webclientProfileCstr, temp)) {
hasWebclientProfile = PR_TRUE;
break;
}
}
nsMemory::Free(Names);
temp[i] = '\0';
argv[2] = temp;
argc = 3;
}
else {
argv[2] = PL_strdup("default");
}
argv[2] = PL_strdup(webclientProfileCstr);
}
else {
argc = 1;
if (!hasWebclientProfile) {
rv = profile->CreateNewProfile(webclientProfile, nsnull, nsnull,
PR_FALSE);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
return;
}
}
rv = cmdLine->Initialize(argc, argv);
rv = cmdLine->Initialize(3, argv);
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("ProfileManagerImpl_nativeStartup: commandLineService initialize rv: %d\n",
rv));
for (i = 0; i < argc; i++) {
for (i = 0; i < 3; i++) {
nsCRT::free(argv[i]);
}
if (NS_FAILED(rv)) {
@@ -130,7 +154,14 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");
return;
}
// only release if we allocated
if (nsnull != profileNameJstr) {
::util_ReleaseStringChars(env, profileNameJstr, webclientProfile);
::util_ReleaseStringUTFChars(env, profileNameJstr,
webclientProfileCstr);
}
wcContext->sProfile = profile.get();
NS_ADDREF(wcContext->sProfile);
wcContext->sProfileInternal = profileInt.get();