Fixing bug 154203 -- implement a checkbox to use the system home page preference (Internet Config), but keep this preference separate from mozilla's home page pref.

This commit is contained in:
sfraser%netscape.com 2002-07-01 03:38:34 +00:00
Родитель a54925283f
Коммит d87d58ada0
12 изменённых файлов: 356 добавлений и 96 удалений

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

@ -91,7 +91,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
- (BOOL) initInternetConfig
{
OSStatus error;
error = ICStart (&internetConfig, '????');
error = ICStart (&internetConfig, 'CHIM');
if (error != noErr) {
// XXX throw here?
NSLog(@"Error initializing IC.\n");
@ -150,7 +150,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
rv = profileService->SetCurrentProfile(newProfileName.get());
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
//horrible, horrible, bad, fixed strings. need localization string file.
NSString *alert = NSLocalizedString(@"AlreadyRunningAlert",@"");
NSString *message = NSLocalizedString(@"AlreadyRunningMsg",@"");
NSString *quit = NSLocalizedString(@"AlreadyRunningButton",@"");
@ -172,7 +171,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
CFStringRef cfString;
char strbuf[1024];
int numbuf;
NSString *string;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (!prefs) {
@ -194,12 +192,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
prefs->SetIntPref(kCookieBehaviorPref, acceptCookies);
}
// get home page from Internet Config
string = [self getICStringPref:kICWWWHomePage];
if (string) {
prefs->SetCharPref("browser.startup.homepage", [string cString]);
}
// get proxies from SystemConfiguration
prefs->SetIntPref("network.proxy.type", 0); // 0 == no proxies
prefs->ClearUserPref("network.proxy.http");
@ -302,6 +294,25 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
}
}
// convenience routines for mozilla prefs
- (NSString*)getMozillaPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
char *buf = nsnull;
nsresult rv = prefs->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
}
return prefValue;
}
//- (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
//{
// ICAttr dummy;
@ -355,7 +366,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if (!prefs)
return @"about:blank";
NSString *url = nil;
PRInt32 mode = 1;
// In some cases, we need to check browser.startup.page to see if
@ -367,17 +377,17 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if ( checkStartupPagePref )
rv = prefs->GetIntPref("browser.startup.page", &mode);
if (NS_FAILED(rv) || mode == 1) {
char *buf = nsnull;
prefs->GetCharPref("browser.startup.homepage", &buf);
if (buf && *buf)
url = [NSString stringWithCString:buf];
else
url = @"about:blank";
free (buf);
return url;
// see which home page to use
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
return [self getICStringPref:kICWWWHomePage];
NSString* homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
if ([homepagePref length] > 0)
return homepagePref;
}
else
return @"about:blank";
return @"about:blank";
}
@end

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

@ -1676,6 +1676,7 @@
F52627DC027E9CCD01000102,
F52627DD027E9CCD01000102,
F52627DE027EA5BE01000102,
F5421B0802CFEAB4011C94A4,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
@ -2515,6 +2516,12 @@
settings = {
};
};
F5421B0802CFEAB4011C94A4 = {
fileRef = F52D5CDB027D412A01A80166;
isa = PBXBuildFile;
settings = {
};
};
F54AD84402C115D901A967F3 = {
isa = PBXFileReference;
name = liboji.a;

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

@ -47,4 +47,9 @@ class nsIPref;
- (IBAction)historyDaysModified:(id)sender;
- (IBAction)clearGlobalHistory:(id)sender;
- (NSString*)getSystemHomePage;
- (NSString*)getCurrentHomePage;
- (NSString*)getPrefString: (const char*)prefName;
- (void)setPref: (const char*)prefName toString:(NSString*)value;
@end

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

@ -21,7 +21,10 @@
* william@dell.wisner.name (William Dell Wisner)
*/
#import <Carbon/Carbon.h>
#import "Navigation.h"
#include "nsIServiceManager.h"
#include "nsIPrefBranch.h"
#include "nsIPref.h"
@ -75,13 +78,26 @@ const int kDefaultExpireDays = 9;
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
[checkboxOpenTabs setState:YES];
char *buf = nsnull;
rv = mPrefService->GetCharPref("browser.startup.homepage", &buf);
if (NS_SUCCEEDED(rv) && buf)
{
[textFieldHomePage setStringValue:[NSString stringWithCString:buf]];
free(buf);
}
BOOL useSystemHomePage = NO;
rv = mPrefService->GetBoolPref("chimera.use_system_home_page", &boolPref);
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
useSystemHomePage = YES;
if (useSystemHomePage)
[textFieldHomePage setEnabled:NO];
[checkboxUseSystemHomePage setState:useSystemHomePage];
[textFieldHomePage setStringValue: [self getCurrentHomePage]];
}
- (void) didUnselect
{
if (!mPrefService)
return;
// only save the home page pref if it's not the system one
if (![checkboxUseSystemHomePage state])
[self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]];
}
@ -103,7 +119,19 @@ const int kDefaultExpireDays = 9;
- (IBAction)checkboxUseSystemHomePageClicked:(id)sender
{
NSLog(@"Homepage clicked");
if (!mPrefService)
return;
BOOL useSystemHomePage = [sender state];
// save the mozilla pref
if (useSystemHomePage)
[self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]];
mPrefService->SetBoolPref("chimera.use_system_home_page", useSystemHomePage ? PR_TRUE : PR_FALSE);
[textFieldHomePage setStringValue: [self getCurrentHomePage]];
[textFieldHomePage setEnabled:!useSystemHomePage];
}
- (IBAction)checkboxStartPageClicked:(id)sender
@ -158,4 +186,67 @@ const int kDefaultExpireDays = 9;
hist->RemoveAllPages();
}
- (NSString*) getSystemHomePage
{
NSMutableString* homePageString = [[[NSMutableString alloc] init] autorelease];
ICInstance icInstance = NULL;
OSStatus error;
// it would be nice to use CHPreferenceManager, but I don't want to drag
// all that code into the plugin
error = ICStart(&icInstance, 'CHIM');
if (error != noErr) {
NSLog(@"Error from ICStart");
return @"";
}
ICAttr dummyAttr;
Str255 homePagePStr;
long prefSize = sizeof(homePagePStr);
error = ICGetPref(icInstance, kICWWWHomePage, &dummyAttr, homePagePStr, &prefSize);
if (error == noErr)
[homePageString setString: [NSString stringWithCString: (const char*)&homePagePStr[1] length:homePagePStr[0]]];
else
NSLog(@"Error getting home page from Internet Config");
ICStop(icInstance);
return homePageString;
}
- (NSString*) getCurrentHomePage
{
BOOL useSystemHomePage = NO;
PRBool boolPref;
nsresult rv = mPrefService->GetBoolPref("chimera.use_system_home_page", &boolPref);
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
return [self getSystemHomePage];
return [self getPrefString: "browser.startup.homepage"];
}
// convenience routines for mozilla prefs
- (NSString*)getPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
char *buf = nsnull;
nsresult rv = mPrefService->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
return prefValue;
}
- (void)setPref: (const char*)prefName toString:(NSString*)value
{
if (mPrefService) {
mPrefService->SetCharPref(prefName, [value cString]);
}
}
@end

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

@ -1676,6 +1676,7 @@
F52627DC027E9CCD01000102,
F52627DD027E9CCD01000102,
F52627DE027EA5BE01000102,
F5421B0802CFEAB4011C94A4,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
@ -2515,6 +2516,12 @@
settings = {
};
};
F5421B0802CFEAB4011C94A4 = {
fileRef = F52D5CDB027D412A01A80166;
isa = PBXBuildFile;
settings = {
};
};
F54AD84402C115D901A967F3 = {
isa = PBXFileReference;
name = liboji.a;

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

@ -91,7 +91,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
- (BOOL) initInternetConfig
{
OSStatus error;
error = ICStart (&internetConfig, '????');
error = ICStart (&internetConfig, 'CHIM');
if (error != noErr) {
// XXX throw here?
NSLog(@"Error initializing IC.\n");
@ -150,7 +150,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
rv = profileService->SetCurrentProfile(newProfileName.get());
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
//horrible, horrible, bad, fixed strings. need localization string file.
NSString *alert = NSLocalizedString(@"AlreadyRunningAlert",@"");
NSString *message = NSLocalizedString(@"AlreadyRunningMsg",@"");
NSString *quit = NSLocalizedString(@"AlreadyRunningButton",@"");
@ -172,7 +171,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
CFStringRef cfString;
char strbuf[1024];
int numbuf;
NSString *string;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (!prefs) {
@ -194,12 +192,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
prefs->SetIntPref(kCookieBehaviorPref, acceptCookies);
}
// get home page from Internet Config
string = [self getICStringPref:kICWWWHomePage];
if (string) {
prefs->SetCharPref("browser.startup.homepage", [string cString]);
}
// get proxies from SystemConfiguration
prefs->SetIntPref("network.proxy.type", 0); // 0 == no proxies
prefs->ClearUserPref("network.proxy.http");
@ -302,6 +294,25 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
}
}
// convenience routines for mozilla prefs
- (NSString*)getMozillaPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
char *buf = nsnull;
nsresult rv = prefs->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
}
return prefValue;
}
//- (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
//{
// ICAttr dummy;
@ -355,7 +366,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if (!prefs)
return @"about:blank";
NSString *url = nil;
PRInt32 mode = 1;
// In some cases, we need to check browser.startup.page to see if
@ -367,17 +377,17 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if ( checkStartupPagePref )
rv = prefs->GetIntPref("browser.startup.page", &mode);
if (NS_FAILED(rv) || mode == 1) {
char *buf = nsnull;
prefs->GetCharPref("browser.startup.homepage", &buf);
if (buf && *buf)
url = [NSString stringWithCString:buf];
else
url = @"about:blank";
free (buf);
return url;
// see which home page to use
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
return [self getICStringPref:kICWWWHomePage];
NSString* homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
if ([homepagePref length] > 0)
return homepagePref;
}
else
return @"about:blank";
return @"about:blank";
}
@end

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

@ -91,7 +91,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
- (BOOL) initInternetConfig
{
OSStatus error;
error = ICStart (&internetConfig, '????');
error = ICStart (&internetConfig, 'CHIM');
if (error != noErr) {
// XXX throw here?
NSLog(@"Error initializing IC.\n");
@ -150,7 +150,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
rv = profileService->SetCurrentProfile(newProfileName.get());
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
//horrible, horrible, bad, fixed strings. need localization string file.
NSString *alert = NSLocalizedString(@"AlreadyRunningAlert",@"");
NSString *message = NSLocalizedString(@"AlreadyRunningMsg",@"");
NSString *quit = NSLocalizedString(@"AlreadyRunningButton",@"");
@ -172,7 +171,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
CFStringRef cfString;
char strbuf[1024];
int numbuf;
NSString *string;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (!prefs) {
@ -194,12 +192,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
prefs->SetIntPref(kCookieBehaviorPref, acceptCookies);
}
// get home page from Internet Config
string = [self getICStringPref:kICWWWHomePage];
if (string) {
prefs->SetCharPref("browser.startup.homepage", [string cString]);
}
// get proxies from SystemConfiguration
prefs->SetIntPref("network.proxy.type", 0); // 0 == no proxies
prefs->ClearUserPref("network.proxy.http");
@ -302,6 +294,25 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
}
}
// convenience routines for mozilla prefs
- (NSString*)getMozillaPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
char *buf = nsnull;
nsresult rv = prefs->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
}
return prefValue;
}
//- (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
//{
// ICAttr dummy;
@ -355,7 +366,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if (!prefs)
return @"about:blank";
NSString *url = nil;
PRInt32 mode = 1;
// In some cases, we need to check browser.startup.page to see if
@ -367,17 +377,17 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if ( checkStartupPagePref )
rv = prefs->GetIntPref("browser.startup.page", &mode);
if (NS_FAILED(rv) || mode == 1) {
char *buf = nsnull;
prefs->GetCharPref("browser.startup.homepage", &buf);
if (buf && *buf)
url = [NSString stringWithCString:buf];
else
url = @"about:blank";
free (buf);
return url;
// see which home page to use
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
return [self getICStringPref:kICWWWHomePage];
NSString* homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
if ([homepagePref length] > 0)
return homepagePref;
}
else
return @"about:blank";
return @"about:blank";
}
@end

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

@ -1676,6 +1676,7 @@
F52627DC027E9CCD01000102,
F52627DD027E9CCD01000102,
F52627DE027EA5BE01000102,
F5421B0802CFEAB4011C94A4,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
@ -2515,6 +2516,12 @@
settings = {
};
};
F5421B0802CFEAB4011C94A4 = {
fileRef = F52D5CDB027D412A01A80166;
isa = PBXBuildFile;
settings = {
};
};
F54AD84402C115D901A967F3 = {
isa = PBXFileReference;
name = liboji.a;

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

@ -47,4 +47,9 @@ class nsIPref;
- (IBAction)historyDaysModified:(id)sender;
- (IBAction)clearGlobalHistory:(id)sender;
- (NSString*)getSystemHomePage;
- (NSString*)getCurrentHomePage;
- (NSString*)getPrefString: (const char*)prefName;
- (void)setPref: (const char*)prefName toString:(NSString*)value;
@end

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

@ -21,7 +21,10 @@
* william@dell.wisner.name (William Dell Wisner)
*/
#import <Carbon/Carbon.h>
#import "Navigation.h"
#include "nsIServiceManager.h"
#include "nsIPrefBranch.h"
#include "nsIPref.h"
@ -75,13 +78,26 @@ const int kDefaultExpireDays = 9;
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
[checkboxOpenTabs setState:YES];
char *buf = nsnull;
rv = mPrefService->GetCharPref("browser.startup.homepage", &buf);
if (NS_SUCCEEDED(rv) && buf)
{
[textFieldHomePage setStringValue:[NSString stringWithCString:buf]];
free(buf);
}
BOOL useSystemHomePage = NO;
rv = mPrefService->GetBoolPref("chimera.use_system_home_page", &boolPref);
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
useSystemHomePage = YES;
if (useSystemHomePage)
[textFieldHomePage setEnabled:NO];
[checkboxUseSystemHomePage setState:useSystemHomePage];
[textFieldHomePage setStringValue: [self getCurrentHomePage]];
}
- (void) didUnselect
{
if (!mPrefService)
return;
// only save the home page pref if it's not the system one
if (![checkboxUseSystemHomePage state])
[self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]];
}
@ -103,7 +119,19 @@ const int kDefaultExpireDays = 9;
- (IBAction)checkboxUseSystemHomePageClicked:(id)sender
{
NSLog(@"Homepage clicked");
if (!mPrefService)
return;
BOOL useSystemHomePage = [sender state];
// save the mozilla pref
if (useSystemHomePage)
[self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]];
mPrefService->SetBoolPref("chimera.use_system_home_page", useSystemHomePage ? PR_TRUE : PR_FALSE);
[textFieldHomePage setStringValue: [self getCurrentHomePage]];
[textFieldHomePage setEnabled:!useSystemHomePage];
}
- (IBAction)checkboxStartPageClicked:(id)sender
@ -158,4 +186,67 @@ const int kDefaultExpireDays = 9;
hist->RemoveAllPages();
}
- (NSString*) getSystemHomePage
{
NSMutableString* homePageString = [[[NSMutableString alloc] init] autorelease];
ICInstance icInstance = NULL;
OSStatus error;
// it would be nice to use CHPreferenceManager, but I don't want to drag
// all that code into the plugin
error = ICStart(&icInstance, 'CHIM');
if (error != noErr) {
NSLog(@"Error from ICStart");
return @"";
}
ICAttr dummyAttr;
Str255 homePagePStr;
long prefSize = sizeof(homePagePStr);
error = ICGetPref(icInstance, kICWWWHomePage, &dummyAttr, homePagePStr, &prefSize);
if (error == noErr)
[homePageString setString: [NSString stringWithCString: (const char*)&homePagePStr[1] length:homePagePStr[0]]];
else
NSLog(@"Error getting home page from Internet Config");
ICStop(icInstance);
return homePageString;
}
- (NSString*) getCurrentHomePage
{
BOOL useSystemHomePage = NO;
PRBool boolPref;
nsresult rv = mPrefService->GetBoolPref("chimera.use_system_home_page", &boolPref);
if (NS_SUCCEEDED(rv) && boolPref == PR_TRUE)
return [self getSystemHomePage];
return [self getPrefString: "browser.startup.homepage"];
}
// convenience routines for mozilla prefs
- (NSString*)getPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
char *buf = nsnull;
nsresult rv = mPrefService->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
return prefValue;
}
- (void)setPref: (const char*)prefName toString:(NSString*)value
{
if (mPrefService) {
mPrefService->SetCharPref(prefName, [value cString]);
}
}
@end

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

@ -1676,6 +1676,7 @@
F52627DC027E9CCD01000102,
F52627DD027E9CCD01000102,
F52627DE027EA5BE01000102,
F5421B0802CFEAB4011C94A4,
);
isa = PBXFrameworksBuildPhase;
name = "Frameworks & Libraries";
@ -2515,6 +2516,12 @@
settings = {
};
};
F5421B0802CFEAB4011C94A4 = {
fileRef = F52D5CDB027D412A01A80166;
isa = PBXBuildFile;
settings = {
};
};
F54AD84402C115D901A967F3 = {
isa = PBXFileReference;
name = liboji.a;

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

@ -91,7 +91,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
- (BOOL) initInternetConfig
{
OSStatus error;
error = ICStart (&internetConfig, '????');
error = ICStart (&internetConfig, 'CHIM');
if (error != noErr) {
// XXX throw here?
NSLog(@"Error initializing IC.\n");
@ -150,7 +150,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
rv = profileService->SetCurrentProfile(newProfileName.get());
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
//horrible, horrible, bad, fixed strings. need localization string file.
NSString *alert = NSLocalizedString(@"AlreadyRunningAlert",@"");
NSString *message = NSLocalizedString(@"AlreadyRunningMsg",@"");
NSString *quit = NSLocalizedString(@"AlreadyRunningButton",@"");
@ -172,7 +171,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
CFStringRef cfString;
char strbuf[1024];
int numbuf;
NSString *string;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (!prefs) {
@ -194,12 +192,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
prefs->SetIntPref(kCookieBehaviorPref, acceptCookies);
}
// get home page from Internet Config
string = [self getICStringPref:kICWWWHomePage];
if (string) {
prefs->SetCharPref("browser.startup.homepage", [string cString]);
}
// get proxies from SystemConfiguration
prefs->SetIntPref("network.proxy.type", 0); // 0 == no proxies
prefs->ClearUserPref("network.proxy.http");
@ -302,6 +294,25 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
}
}
// convenience routines for mozilla prefs
- (NSString*)getMozillaPrefString: (const char*)prefName
{
NSMutableString *prefValue = [[[NSMutableString alloc] init] autorelease];
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
char *buf = nsnull;
nsresult rv = prefs->GetCharPref(prefName, &buf);
if (NS_SUCCEEDED(rv) && buf) {
[prefValue setString:[NSString stringWithCString:buf]];
free(buf);
}
}
return prefValue;
}
//- (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
//{
// ICAttr dummy;
@ -355,7 +366,6 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if (!prefs)
return @"about:blank";
NSString *url = nil;
PRInt32 mode = 1;
// In some cases, we need to check browser.startup.page to see if
@ -367,17 +377,17 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
if ( checkStartupPagePref )
rv = prefs->GetIntPref("browser.startup.page", &mode);
if (NS_FAILED(rv) || mode == 1) {
char *buf = nsnull;
prefs->GetCharPref("browser.startup.homepage", &buf);
if (buf && *buf)
url = [NSString stringWithCString:buf];
else
url = @"about:blank";
free (buf);
return url;
// see which home page to use
PRBool boolPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
return [self getICStringPref:kICWWWHomePage];
NSString* homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
if ([homepagePref length] > 0)
return homepagePref;
}
else
return @"about:blank";
return @"about:blank";
}
@end