diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index eee7367deb3..a476e47cc46 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -131,10 +131,6 @@ sub InstallDefaultsFiles() my($default_pref_dir) = "$defaults_dir"."Pref:"; mkdir($default_pref_dir, 0); InstallResources(":mozilla:xpinstall:public:MANIFEST_PREFS", "$default_pref_dir", 0); - InstallResources(":mozilla:modules:libpref:src:MANIFEST_PREFS", "$default_pref_dir", 0); - if ($main::DEBUG) { - InstallResources(":mozilla:modules:libpref:src:MANIFEST_DEBUG_PREFS", "$default_pref_dir", 0); - } InstallResources(":mozilla:modules:libpref:src:init:MANIFEST", "$default_pref_dir", 0); InstallResources(":mozilla:modules:libpref:src:mac:MANIFEST", "$default_pref_dir", 0); InstallResources(":mozilla:netwerk:base:public:MANIFEST_PREFS", "$default_pref_dir", 0); @@ -153,6 +149,7 @@ sub InstallDefaultsFiles() my($default_autoconfig_dir) = "$defaults_dir"."autoconfig:"; mkdir($default_autoconfig_dir, 0); InstallResources(":mozilla:extensions:pref:autoconfig:src:MANIFEST", "$default_autoconfig_dir"); + InstallResources(":mozilla:extensions:pref:autoconfig:src:mac:MANIFEST", "$default_autoconfig_dir"); } print("--- Defaults copying complete ----\n"); diff --git a/mozilla/editor/ui/composer.js b/mozilla/editor/ui/composer.js index 1e7d790de89..7ec0faace56 100644 --- a/mozilla/editor/ui/composer.js +++ b/mozilla/editor/ui/composer.js @@ -44,11 +44,11 @@ pref("editor.active_link_color", "#000088"); pref("editor.followed_link_color", "#FF0000"); pref("editor.background_color", "#FFFFFF"); pref("editor.use_background_image", false); -localDefPref("editor.background_image", ""); +pref("editor.background_image", ""); pref("editor.use_custom_default_colors", 1); -localDefPref("editor.hrule.height", 2); -localDefPref("editor.hrule.width", 100); +pref("editor.hrule.height", 2); +pref("editor.hrule.width", 100); pref("editor.hrule.width_percent", true); pref("editor.hrule.shading", true); pref("editor.hrule.align", 1); // center diff --git a/mozilla/extensions/pref/autoconfig/src/Makefile.in b/mozilla/extensions/pref/autoconfig/src/Makefile.in index 91b0bb22b3b..bdffe61f0d9 100644 --- a/mozilla/extensions/pref/autoconfig/src/Makefile.in +++ b/mozilla/extensions/pref/autoconfig/src/Makefile.in @@ -19,6 +19,7 @@ # # Contributor(s): # Mitesh Shah +# Brian Nesse # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -70,7 +71,27 @@ EXTRA_DSO_LDOPTS = \ $(MOZ_COMPONENT_LIBS) \ $(NULL) -AUTOCFG_JS_EXPORTS = prefcalls.js +AUTOCFG_JS_EXPORTS = \ + $(srcdir)/prefcalls.js \ + $(NULL) + +ifneq (,filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)) +AUTOCFG_JS_EXPORTS += $(srcdir)/mac/platform.js +else +ifeq ($(MOZ_WIDGET_TOOLKIT), windows) +AUTOCFG_JS_EXPORTS += $(srcdir)/win/platform.js +else +ifeq ($(MOZ_WIDGET_TOOLKIT), os2) +AUTOCFG_JS_EXPORTS += $(srcdir)/os2/platform.js +else +ifeq ($(MOZ_WIDGET_TOOLKIT), beos) +AUTOCFG_JS_EXPORTS += $(srcdir)/beos/platform.js +else +AUTOCFG_JS_EXPORTS += $(srcdir)/unix/platform.js +endif +endif +endif +endif include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/pref/autoconfig/src/makefile.win b/mozilla/extensions/pref/autoconfig/src/makefile.win index 8827b42dbb5..7307411fdbd 100644 --- a/mozilla/extensions/pref/autoconfig/src/makefile.win +++ b/mozilla/extensions/pref/autoconfig/src/makefile.win @@ -20,6 +20,7 @@ # # Contributor(s): # Mitesh Shah +# Brian Nesse # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -106,3 +107,4 @@ OBJS = .\$(OBJDIR)\nsConfigFactory.obj \ include <$(DEPTH)\config\rules.mak> libs:: $(MAKE_INSTALL) .\prefcalls.js $(DIST)\bin\defaults\autoconfig + $(MAKE_INSTALL) .\win\platform.js $(DIST)\bin\defaults\autoconfig diff --git a/mozilla/extensions/pref/autoconfig/src/nsReadConfig.cpp b/mozilla/extensions/pref/autoconfig/src/nsReadConfig.cpp index 27046edc8f6..82d2c915cbc 100644 --- a/mozilla/extensions/pref/autoconfig/src/nsReadConfig.cpp +++ b/mozilla/extensions/pref/autoconfig/src/nsReadConfig.cpp @@ -140,11 +140,15 @@ nsresult nsReadConfig::readConfigFile() return rv; // Open and evaluate function calls to set/lock/unlock prefs - rv = openAndEvaluateJSFile("prefcalls.js", PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) return rv; + // Evaluate platform specific directives + rv = openAndEvaluateJSFile("platform.js", PR_FALSE, PR_FALSE); + if (NS_FAILED(rv)) + return rv; + mRead = PR_TRUE; } // If the lockFileName is NULL return ok, because no lockFile will be used diff --git a/mozilla/extensions/pref/autoconfig/src/prefcalls.js b/mozilla/extensions/pref/autoconfig/src/prefcalls.js index b7e52528d9b..779a3a3f55c 100644 --- a/mozilla/extensions/pref/autoconfig/src/prefcalls.js +++ b/mozilla/extensions/pref/autoconfig/src/prefcalls.js @@ -21,6 +21,7 @@ * * Contributor(s): * Mitesh Shah + * Brian Nesse * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -43,6 +44,10 @@ const LDAPSyncQueryContractID = "@mozilla.org/ldapsyncquery;1"; const nsIPrefService = Components.interfaces.nsIPrefService; const PrefServiceContractID = "@mozilla.org/preferences-service;1"; +// set on a platform specific basis in platform.js +platform = { value: "" }; + + function getPrefBranch() { var prefService = Components.classes[PrefServiceContractID] diff --git a/mozilla/mailnews/mailnews.js b/mozilla/mailnews/mailnews.js index e535bf8171c..ad840d1a15d 100644 --- a/mozilla/mailnews/mailnews.js +++ b/mozilla/mailnews/mailnews.js @@ -118,7 +118,7 @@ pref("mail.addr_book.displayName.lastnamefirst", false); // generate display nam pref("mail.attach_vcard", false); pref("mail.html_compose", true); pref("mail.compose.other.header", ""); -localDefPref("mail.fcc_folder", ""); +pref("mail.fcc_folder", ""); pref("mail.encrypt_outgoing_mail", false); pref("mail.crypto_sign_outgoing_mail", false); pref("mail.default_html_action", 0); // 0=ask, 1=plain, 2=html, 3=both diff --git a/mozilla/modules/libpref/src/Makefile.in b/mozilla/modules/libpref/src/Makefile.in index 0df8b887a65..da6d5ef2920 100644 --- a/mozilla/modules/libpref/src/Makefile.in +++ b/mozilla/modules/libpref/src/Makefile.in @@ -54,16 +54,14 @@ CPPSRCS = nsPref.cpp \ $(NULL) PREF_JS_EXPORTS = \ - $(srcdir)/initpref.js \ $(srcdir)/init/all.js \ $(srcdir)/init/mailnews.js \ $(srcdir)/init/editor.js \ - $(srcdir)/init/config.js \ $(NULL) -ifdef MOZ_DEBUG -PREF_JS_EXPORTS += $(srcdir)/debug-developer.js -endif +ifneq (,filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)) +PREF_JS_EXPORTS += $(srcdir)/mac/macpref.js +else ifeq ($(MOZ_WIDGET_TOOLKIT),windows) PREF_JS_EXPORTS += $(srcdir)/win/winpref.js else @@ -80,6 +78,7 @@ PREF_JS_EXPORTS += $(srcdir)/unix/unix.js endif endif endif +endif ifeq ($(OS_ARCH),OpenVMS) PREF_JS_EXPORTS += $(srcdir)/unix/openvms.js @@ -96,7 +95,6 @@ include $(topsrcdir)/config/rules.mk DEFINES += -DB_ONE_M GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/, \ - debug-developer.js \ - initpref.js all.js mailnews.js editor.js config.js \ + all.js mailnews.js editor.js \ beos.js unix.js winpref.js os2prefs.js openvms.js photon.js) diff --git a/mozilla/modules/libpref/src/beos/beos.js b/mozilla/modules/libpref/src/beos/beos.js index e3342af3409..54a851f1b58 100644 --- a/mozilla/modules/libpref/src/beos/beos.js +++ b/mozilla/modules/libpref/src/beos/beos.js @@ -35,8 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -platform.beos = true; - pref("intl.font_charset", ""); pref("intl.font_spec_list", ""); pref("mail.signature_date", 0); diff --git a/mozilla/modules/libpref/src/init/MANIFEST b/mozilla/modules/libpref/src/init/MANIFEST index a627309fc75..87276263e19 100644 --- a/mozilla/modules/libpref/src/init/MANIFEST +++ b/mozilla/modules/libpref/src/init/MANIFEST @@ -1,4 +1,3 @@ all.js -config.js editor.js mailnews.js diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 005e5a74491..fe77dc554ea 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -38,6 +38,9 @@ // SYNTAX HINTS: dashes are delimiters. Use underscores instead. // The first character after a period must be alphabetic. +pref("startup.homepage_override_url","chrome://navigator-region/locale/region.properties"); +pref("browser.chromeURL","chrome://navigator/content/navigator.xul"); + pref("network.search.url","http://cgi.netscape.com/cgi-bin/url_search.cgi?search="); pref("keyword.URL", "http://keyword.netscape.com/keyword/"); @@ -559,12 +562,12 @@ pref("intl.locale.matchOS", false); pref("font.language.group", "chrome://navigator/locale/navigator.properties"); // -- folders (Mac: these are binary aliases.) -localDefPref("mail.signature_file", ""); -localDefPref("mail.directory", ""); +pref("mail.signature_file", ""); +pref("mail.directory", ""); pref("images.dither", "auto"); -localDefPref("news.directory", ""); -localDefPref("security.directory", ""); +pref("news.directory", ""); +pref("security.directory", ""); pref("autoupdate.enabled", true); diff --git a/mozilla/modules/libpref/src/init/editor.js b/mozilla/modules/libpref/src/init/editor.js index 1e7d790de89..7ec0faace56 100644 --- a/mozilla/modules/libpref/src/init/editor.js +++ b/mozilla/modules/libpref/src/init/editor.js @@ -44,11 +44,11 @@ pref("editor.active_link_color", "#000088"); pref("editor.followed_link_color", "#FF0000"); pref("editor.background_color", "#FFFFFF"); pref("editor.use_background_image", false); -localDefPref("editor.background_image", ""); +pref("editor.background_image", ""); pref("editor.use_custom_default_colors", 1); -localDefPref("editor.hrule.height", 2); -localDefPref("editor.hrule.width", 100); +pref("editor.hrule.height", 2); +pref("editor.hrule.width", 100); pref("editor.hrule.width_percent", true); pref("editor.hrule.shading", true); pref("editor.hrule.align", 1); // center diff --git a/mozilla/modules/libpref/src/init/mailnews.js b/mozilla/modules/libpref/src/init/mailnews.js index e535bf8171c..ad840d1a15d 100644 --- a/mozilla/modules/libpref/src/init/mailnews.js +++ b/mozilla/modules/libpref/src/init/mailnews.js @@ -118,7 +118,7 @@ pref("mail.addr_book.displayName.lastnamefirst", false); // generate display nam pref("mail.attach_vcard", false); pref("mail.html_compose", true); pref("mail.compose.other.header", ""); -localDefPref("mail.fcc_folder", ""); +pref("mail.fcc_folder", ""); pref("mail.encrypt_outgoing_mail", false); pref("mail.crypto_sign_outgoing_mail", false); pref("mail.default_html_action", 0); // 0=ask, 1=plain, 2=html, 3=both diff --git a/mozilla/modules/libpref/src/mac/macprefs.js b/mozilla/modules/libpref/src/mac/macprefs.js index a2096c630e6..c2c6805bd95 100644 --- a/mozilla/modules/libpref/src/mac/macprefs.js +++ b/mozilla/modules/libpref/src/mac/macprefs.js @@ -36,8 +36,6 @@ * ***** END LICENSE BLOCK ***** */ // Mac specific preference defaults -platform.mac = true; - pref("browser.drag_out_of_frame_style", 1); pref("ui.key.saveLink.shift", false); // true = shift, false = meta @@ -186,52 +184,6 @@ pref("font.size.fixed.zh-TW", 16); pref("ui.key.menuAccessKey", 0); pref("ui.key.accelKey", 224); -mime_type("mime.image_gif", "image/gif", "gif", 2, "JPEGView", "JVWR", "GIFf"); -mime_type("mime.image_jpeg", "image/jpeg", "jpg,jpeg,jpe", 2, "JPEGView", "JVWR", "JPEG"); -mime_type("mime.image_pict", "image/pict", "pic,pict", 1, "SimpleText", "ttxt", "PICT"); -mime_type("mime.image_tiff", "image/tiff", "tif,tiff", 1, "JPEGView", "JVWR", "TIFF"); -mime_type("mime.image_x_xbitmap", "image/x-xbitmap", "xbm", 2, "Unknown", "ttxt", "????"); - -mime_type("mime.audio_basic", "audio/basic", "au,snd", 1, "Sound Machine", "SNDM", "ULAW"); -mime_type("mime.audio_aiff", "audio/aiff", "aiff,aif", 1, "Sound Machine", "SNDM", "AIFF"); -mime_type("mime.audio_x_wav", "audio/x-wav", "wav", 1, "Sound Machine", "SNDM", "WAVE"); - -mime_type("mime.video_quicktime", "video/quicktime", "qt,mov", 1, "Simple Player", "TVOD", "MooV"); -mime_type("mime.video_mpeg", "video/mpeg", "mpg,mpeg,mpe", 1, "Sparkle", "mMPG", "MPEG"); -mime_type("mime.video_x_msvideo", "video/x-msvideo", "avi", 1, "AVI to QT Utility", "AVIC", "????"); -mime_type("mime.video_x_qtc", "video/x-qtc", "qtc", 1, "Conferencing Helper Application", "mtwh", ".qtc"); - -mime_type("mime.application_mac_binhex40", "application/mac-binhex40", "hqx", 1, "Stuffit Expander", "SITx", "TEXT"); -mime_type("mime.application_x_stuffit", "application/x-stuffit", "sit", 1, "Stuffit Expander", "SITx", "SITD"); -mime_type("mime.application_x_macbinary", "application/x-macbinary", "bin", 1, "Stuffit Expander", "SITx", "TEXT"); -mime_type("mime.application_x_conference", "application/x-conference", "nsc", 1, "Netscape Conference", "Ncq¹", "TEXT"); - -mime_type("mime.application_zip", "application/zip", "z,zip", 1, "ZipIt", "ZIP ", "ZIP "); -mime_type("mime.application_gzip", "application/gzip", "gz", 1, "MacGzip", "Gzip", "Gzip"); -mime_type("mime.application_msword", "application/msword", "doc", 0, "MS Word", "MSWD", "W6BN"); -mime_type("mime.application_x_excel", "application/x-excel", "xls", 0, "MS Excel", "XCEL", "XLS5"); - -mime_type("mime.application_octet_stream", "application/octet-stream", "exe", 3, "", "", ""); -mime_type("mime.application_postscript", "application/postscript", "ai,eps,ps", 3, "SimpleText", "ttxt", "TEXT"); -mime_type("mime.application_rtf", "application/rtf", "rtf", 0, "MS Word", "MSWD", "TEXT"); -mime_type("mime.application_x_compressed", "application/x-compressed", ".Z", 1, "MacCompress", "LZIV", "ZIVM"); -mime_type("mime.application_x_tar", "application/x-tar", "tar", 1, "tar", "TAR ", "TARF"); - -mime_type("mime.Netscape_Source", "Netscape/Source", "", 2, "SimpleText", "ttxt", "TEXT"); -pref("mime.Netscape_Source.description", "View Source"); -mime_type("mime.Netscape_Telnet", "Netscape/Telnet", "", 1, "NCSA Telnet", "NCSA", "CONF"); -mime_type("mime.Netscape_tn3270", "Netscape/tn3270", "", 1, "tn3270", "GFTM", "GFTS"); - -mime_type("mime.image_x_cmu_raster", "image/x-cmu-raster", "ras", 3, "Unknown", "ttxt", "????"); -mime_type("mime.image_x_portable_anymap", "image/x-portable-anymap", "pnm", 3, "Unknown", "ttxt", "????"); -mime_type("mime.image_x_portable_bitmap", "image/x-portable-bitmap", "pbm", 3, "Unknown", "ttxt", "????"); -mime_type("mime.image_x_portable_graymap", "image/x-portable-graymap", "pgm", 3, "Unknown", "ttxt", "????"); -mime_type("mime.image_x_rgb", "image/x-rgb", "rgb", 3, "Unknown", "ttxt", "????"); -mime_type("mime.image_x_xpixmap", "image/x-xpixmap", "xpm", 2, "Unknown", "ttxt", "????"); - -// Add mime type for SimpleText read only files -mime_type("mime.SimpleText_ReadOnly", "text/plain", "", 2, "SimpleText", "ttxt", "ttro"); - // print_extra_margin enables platforms to specify an extra gap or margin // around the content of the page for Print Preview only pref("print.print_extra_margin", 90); // twips (90 twips is an eigth of an inch) diff --git a/mozilla/modules/libpref/src/makefile.win b/mozilla/modules/libpref/src/makefile.win index 2195c3edb43..74b8f10eb82 100644 --- a/mozilla/modules/libpref/src/makefile.win +++ b/mozilla/modules/libpref/src/makefile.win @@ -87,12 +87,7 @@ OBJS = \ include <$(DEPTH)\config\rules.mak> libs:: - $(MAKE_INSTALL) .\initpref.js $(DIST)\bin\defaults\pref $(MAKE_INSTALL) .\init\all.js $(DIST)\bin\defaults\pref $(MAKE_INSTALL) .\init\mailnews.js $(DIST)\bin\defaults\pref $(MAKE_INSTALL) .\init\editor.js $(DIST)\bin\defaults\pref - $(MAKE_INSTALL) .\init\config.js $(DIST)\bin\defaults\pref $(MAKE_INSTALL) .\win\winpref.js $(DIST)\bin\defaults\pref -!ifdef MOZ_DEBUG - $(MAKE_INSTALL) .\debug-developer.js $(DIST)\bin\defaults\pref -!endif diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp index 624c1a539d8..20e5eb9756a 100644 --- a/mozilla/modules/libpref/src/nsPrefService.cpp +++ b/mozilla/modules/libpref/src/nsPrefService.cpp @@ -41,6 +41,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsICategoryManager.h" +#include "nsIFile.h" #include "nsIFileStreams.h" #include "nsIObserverService.h" #include "nsPrefBranch.h" @@ -51,29 +52,20 @@ #include "pldhash.h" #include "prefapi.h" -class nsIFileSpec; // needed for prefapi_private_data.h inclusion #include "prefapi_private_data.h" // supporting PREF_Init() #include "nsIJSRuntimeService.h" -// lose these if possible (supporting nsIFileToFileSpec) -#include "nsIFileSpec.h" -#include "nsFileStream.h" - #include "nsITimelineService.h" // Definitions -#define PREFS_HEADER_LINE_1 "# Mozilla User Preferences" -#define PREFS_HEADER_LINE_2 "// This is a generated file!" #define INITIAL_MAX_DEFAULT_PREF_FILES 10 // Prototypes -static nsresult nsIFileToFileSpec(nsIFile* inFile, nsIFileSpec **aFileSpec); static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal, PRBool aIsGlobalContext, PRBool aSkipFirstLine); -static nsresult savePrefFile(nsIFile* aFile); // needed so we can still get the JS Runtime Service during XPCOM shutdown @@ -184,11 +176,11 @@ NS_IMETHODIMP nsPrefService::ReadUserPrefs(nsIFile *aFile) nsresult rv; if (nsnull == aFile) { - rv = useDefaultPrefFile(); // really should return a value... + rv = UseDefaultPrefFile(); // really should return a value... if (NS_SUCCEEDED(rv)) - useUserPrefFile(); + UseUserPrefFile(); - notifyObservers(NS_PREFSERVICE_READ_TOPIC_ID); + NotifyServiceObservers(NS_PREFSERVICE_READ_TOPIC_ID); JS_MaybeGC(gMochaContext); } else { @@ -208,7 +200,7 @@ NS_IMETHODIMP nsPrefService::ReadUserPrefs(nsIFile *aFile) NS_IMETHODIMP nsPrefService::ResetPrefs() { - notifyObservers(NS_PREFSERVICE_RESET_TOPIC_ID); + NotifyServiceObservers(NS_PREFSERVICE_RESET_TOPIC_ID); PREF_CleanupPrefs(); if (!PREF_Init(nsnull)) @@ -223,14 +215,13 @@ NS_IMETHODIMP nsPrefService::ResetUserPrefs() return NS_OK; } -/* void savePrefFile (in nsIFile filename); */ NS_IMETHODIMP nsPrefService::SavePrefFile(nsIFile *aFile) { if (nsnull == aFile) { // It's possible that we never got a prefs file. - return mCurrentFile ? savePrefFile(mCurrentFile) : NS_OK; + return mCurrentFile ? WritePrefFile(mCurrentFile) : NS_OK; } else { - return savePrefFile(aFile); + return WritePrefFile(aFile); } } @@ -289,7 +280,7 @@ NS_IMETHODIMP nsPrefService::RemoveObserver(const char *aDomain, nsIObserver *aO } -nsresult nsPrefService::notifyObservers(const char *aTopic) +nsresult nsPrefService::NotifyServiceObservers(const char *aTopic) { nsresult rv; nsCOMPtr observerService = @@ -304,8 +295,7 @@ nsresult nsPrefService::notifyObservers(const char *aTopic) return NS_OK; } - -nsresult nsPrefService::useDefaultPrefFile() +nsresult nsPrefService::UseDefaultPrefFile() { nsresult rv; nsCOMPtr aFile; @@ -333,7 +323,7 @@ nsresult nsPrefService::useDefaultPrefFile() return rv; } -nsresult nsPrefService::useUserPrefFile() +nsresult nsPrefService::UseUserPrefFile() { nsresult rv = NS_OK; nsCOMPtr aFile; @@ -350,6 +340,59 @@ nsresult nsPrefService::useUserPrefFile() return rv; } +nsresult nsPrefService::WritePrefFile(nsIFile* aFile) +{ + const char outHeader[] = "# Mozilla User Preferences" + NS_LINEBREAK + "// This is a generated file!" + NS_LINEBREAK + NS_LINEBREAK; + nsCOMPtr outStream; + PRUint32 writeAmount; + nsresult rv; + + if (!gHashTable.ops) + return NS_ERROR_NOT_INITIALIZED; + + /* ?! Don't save (blank) user prefs if there was an error reading them */ + if (gErrorOpeningUserPrefs) + return NS_OK; + + char** valueArray = (char**) PR_Calloc(sizeof(char*), gHashTable.entryCount); + if (!valueArray) + return NS_ERROR_OUT_OF_MEMORY; + + rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStream), aFile); + if (NS_FAILED(rv)) + return rv; + + // write out the file header + rv = outStream->Write(outHeader, sizeof(outHeader) - 1, &writeAmount); + + // get the lines that we're supposed to be writing to the file + PL_DHashTableEnumerate(&gHashTable, pref_savePref, valueArray); + + /* Sort the preferences to make a readable file on disk */ + NS_QuickSort(valueArray, gHashTable.entryCount, sizeof(char*), pref_CompareStrings, NULL); + char** walker = valueArray; + for (PRUint32 valueIdx = 0; valueIdx < gHashTable.entryCount; valueIdx++, walker++) { + if (*walker) { + // skip writing if an has error occurred + if (NS_SUCCEEDED(rv)) { + rv = outStream->Write(*walker, strlen(*walker), &writeAmount); + if (NS_SUCCEEDED(rv)) + rv = outStream->Write(NS_LINEBREAK, NS_LINEBREAK_LEN, &writeAmount); + } + // always free though... + PR_Free(*walker); + } + } + PR_Free(valueArray); + outStream->Close(); + + return rv; +} + static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal, PRBool aIsGlobalContext, PRBool aSkipFirstLine) { @@ -402,74 +445,6 @@ static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal, return rv; } -static nsresult savePrefFile(nsIFile* aFile) -{ - nsresult rv; - nsCOMPtr fileSpec; - - if (!gHashTable.ops) - return NS_ERROR_NOT_INITIALIZED; - - /* ?! Don't save (blank) user prefs if there was an error reading them */ - if (gErrorOpeningUserPrefs) - return NS_OK; - - // TODO: Convert the rest of this code to nsIFile and avoid this conversion to nsIFileSpec - rv = nsIFileToFileSpec(aFile, getter_AddRefs(fileSpec)); - if (NS_FAILED(rv)) - return rv; - - char** valueArray = (char**) PR_Calloc(sizeof(char*), gHashTable.entryCount); - if (!valueArray) - return NS_ERROR_OUT_OF_MEMORY; - - nsOutputFileStream stream(fileSpec); - if (!stream.is_open()) - return NS_BASE_STREAM_OSERROR; - - stream << PREFS_HEADER_LINE_1 << nsEndl << PREFS_HEADER_LINE_2 << nsEndl << nsEndl; - - // get the lines that we're supposed to be writing to the file - PL_DHashTableEnumerate(&gHashTable, pref_savePref, valueArray); - - /* Sort the preferences to make a readable file on disk */ - NS_QuickSort(valueArray, gHashTable.entryCount, sizeof(char*), pref_CompareStrings, NULL); - char** walker = valueArray; - for (PRUint32 valueIdx = 0; valueIdx < gHashTable.entryCount; valueIdx++, walker++) { - if (*walker) { - stream << *walker << nsEndl; - PR_Free(*walker); - } - } - PR_Free(valueArray); - fileSpec->CloseStream(); - return NS_OK; -} - - -//---------------------------------------------------------------------------------------- -// So discouraged is the use of nsIFileSpec, nobody wanted to have this routine be -// public - It might lead to continued use of nsIFileSpec. Right now, this code has -// such a need for it, here it is. Let's stop having to use it though. -static nsresult nsIFileToFileSpec(nsIFile* inFile, nsIFileSpec **aFileSpec) -//---------------------------------------------------------------------------------------- -{ - nsresult rv; - nsCOMPtr newFileSpec; - nsXPIDLCString pathBuf; - - rv = inFile->GetPath(getter_Copies(pathBuf)); - if (NS_FAILED(rv)) return rv; - rv = NS_NewFileSpec(getter_AddRefs(newFileSpec)); - if (NS_FAILED(rv)) return rv; - rv = newFileSpec->SetNativePath((const char *)pathBuf); - if (NS_FAILED(rv)) return rv; - - *aFileSpec = newFileSpec; - NS_ADDREF(*aFileSpec); - - return NS_OK; -} /* * some stuff that gets called from Pref_Init() @@ -518,19 +493,15 @@ JSBool pref_InitInitialObjects() PRBool hasMoreElements; static const char* specialFiles[] = { - "initpref.js" -#ifdef NS_DEBUG - , "debug-developer.js" -#endif #ifdef XP_MAC - , "macprefs.js" + "macprefs.js" #if defined (TARGET_CARBON) , "macxprefs.js" #endif #elif defined(XP_WIN) - , "winpref.js" + "winpref.js" #elif defined(XP_UNIX) - , "unix.js" + "unix.js" #if defined(VMS) , "openvms.js" #endif @@ -538,7 +509,9 @@ JSBool pref_InitInitialObjects() , "photon.js" #endif #elif defined(XP_OS2) - , "os2pref.js" + "os2pref.js" +#elif defined(XP_BEOS) + "beos.js" #endif }; @@ -564,21 +537,6 @@ JSBool pref_InitInitialObjects() return JS_FALSE; } - // Read in initpref.js. - // Warning: aliases get resolved, so SetLeafName will not work here. - rv = defaultPrefDir->Clone(getter_AddRefs(aFile)); - if (NS_FAILED(rv)) - return JS_FALSE; - - rv = aFile->Append((char *)specialFiles[0]); - if (NS_FAILED(rv)) - return JS_FALSE; - - rv = openPrefFile(aFile, PR_FALSE, PR_FALSE, PR_FALSE); - NS_ASSERTION(NS_SUCCEEDED(rv), "initpref.js not parsed successfully"); - - // Keep this child - while (hasMoreElements) { PRBool shouldParse = PR_TRUE; char* leafName; @@ -624,7 +582,7 @@ JSBool pref_InitInitialObjects() nsMemory::Free(defaultPrefFiles); // Finally, parse any other special files (platform-specific ones). - for (k = 1; k < (int) (sizeof(specialFiles) / sizeof(char *)); k++) { + for (k = 0; k < (int) (sizeof(specialFiles) / sizeof(char *)); k++) { // we must get the directory every time so we can append the child // because SetLeafName will not work here. rv = defaultPrefDir->Clone(getter_AddRefs(aFile)); diff --git a/mozilla/modules/libpref/src/nsPrefService.h b/mozilla/modules/libpref/src/nsPrefService.h index 6870d1e67fc..e21ba000cd3 100644 --- a/mozilla/modules/libpref/src/nsPrefService.h +++ b/mozilla/modules/libpref/src/nsPrefService.h @@ -64,9 +64,10 @@ public: nsresult Init(); protected: - nsresult notifyObservers(const char *aSubject); - nsresult useDefaultPrefFile(); - nsresult useUserPrefFile(); + nsresult NotifyServiceObservers(const char *aSubject); + nsresult UseDefaultPrefFile(); + nsresult UseUserPrefFile(); + nsresult WritePrefFile(nsIFile* aFile); private: nsCOMPtr mRootBranch; diff --git a/mozilla/modules/libpref/src/os2/os2pref.js b/mozilla/modules/libpref/src/os2/os2pref.js index 208ffc63092..e8eef49b4b4 100644 --- a/mozilla/modules/libpref/src/os2/os2pref.js +++ b/mozilla/modules/libpref/src/os2/os2pref.js @@ -35,8 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -platform.windows = true; - pref("ui.key.menuAccessKeyFocuses", true); pref("browser.display.screen_resolution", 0); // System setting diff --git a/mozilla/modules/libpref/src/prefapi.cpp b/mozilla/modules/libpref/src/prefapi.cpp index 8c77f62deaf..5d531826453 100644 --- a/mozilla/modules/libpref/src/prefapi.cpp +++ b/mozilla/modules/libpref/src/prefapi.cpp @@ -36,6 +36,8 @@ * ***** END LICENSE BLOCK ***** */ #include "prefapi.h" +#include "prefapi_private_data.h" +#include "nsReadableUtils.h" #include "jsapi.h" #if defined(XP_MAC) @@ -104,10 +106,7 @@ matchPrefEntry(PLDHashTable*, const PLDHashEntryHdr* entry, PR_STATIC_CALLBACK(JSBool) pref_NativeDefaultPref(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); PR_STATIC_CALLBACK(JSBool) pref_NativeUserPref(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); -PR_STATIC_CALLBACK(JSBool) pref_NativeSetConfig(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); -PR_STATIC_CALLBACK(JSBool) pref_NativeGetPref(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval); /*----------------------------------------------------------------------------------------*/ -#include "prefapi_private_data.h" JS_STATIC_DLL_CALLBACK(JSBool) global_enumerate(JSContext *cx, JSObject *obj) @@ -147,13 +146,7 @@ static JSPropertySpec autoconf_props[] = { }; static JSFunctionSpec autoconf_methods[] = { { "pref", pref_NativeDefaultPref, 2,0,0 }, - { "defaultPref", pref_NativeDefaultPref, 2,0,0 }, { "user_pref", pref_NativeUserPref, 2,0,0 }, - { "config", pref_NativeSetConfig, 2,0,0 }, - { "getPref", pref_NativeGetPref, 1,0,0 }, - { "localPref", pref_NativeDefaultPref, 1,0,0 }, - { "localUserPref", pref_NativeUserPref, 2,0,0 }, - { "localDefPref", pref_NativeDefaultPref, 2,0,0 }, { NULL, NULL, 0,0,0 } }; @@ -1149,43 +1142,6 @@ PR_STATIC_CALLBACK(JSBool) pref_NativeUserPref return pref_HashJSPref(argc, argv, PREF_SETUSER); } -PR_STATIC_CALLBACK(JSBool) pref_NativeSetConfig - (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) -{ - return pref_HashJSPref(argc, argv, PREF_SETCONFIG); -} - -PR_STATIC_CALLBACK(JSBool) pref_NativeGetPref - (JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) -{ - /*void* value = NULL;*/ - PrefHashEntry* pref; - /*PRBool prefExists = PR_TRUE;*/ - - if (argc >= 1 && JSVAL_IS_STRING(argv[0])) - { - const char *key = JS_GetStringBytes(JSVAL_TO_STRING(argv[0])); - pref = pref_HashTableLookup(key); - - if (pref) - { - PRBool use_default = (PREF_IS_LOCKED(pref) || !PREF_HAS_USER_VALUE(pref)); - if (pref->flags & PREF_STRING) - { - char* str = use_default ? pref->defaultPref.stringVal : pref->userPref.stringVal; - JSString* jsstr = JS_NewStringCopyZ(cx, str); - *rval = STRING_TO_JSVAL(jsstr); - } - else if (pref->flags & PREF_INT) - *rval = INT_TO_JSVAL(use_default ? - pref->defaultPref.intVal : pref->userPref.intVal); - else if (pref->flags & PREF_BOOL) - *rval = BOOLEAN_TO_JSVAL(use_default ? - pref->defaultPref.boolVal : pref->userPref.boolVal); - } - } - return JS_TRUE; -} /* -- */ PRBool @@ -1388,7 +1344,7 @@ pref_ErrorReporter(JSContext *cx, const char *message, /* StandardAlert doesn't handle linefeeds. Use spaces to avoid garbage characters. */ last = PR_sprintf_append(last, " "); #else - last = PR_sprintf_append(last, LINEBREAK LINEBREAK); + last = PR_sprintf_append(last, NS_LINEBREAK NS_LINEBREAK); #endif if (!report) last = PR_sprintf_append(last, "%s\n", message); @@ -1461,10 +1417,7 @@ void pref_Alert(char* msg) static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action) /* Native implementations of JavaScript functions pref -> pref_NativeDefaultPref - defaultPref -> " userPref -> pref_NativeUserPref - getPref -> pref_NativeGetPref - config -> pref_NativeSetConfig *--------------------------------------------------------------------------------------*/ { if (argc >= 2 && JSVAL_IS_STRING(argv[0])) diff --git a/mozilla/modules/libpref/src/prefapi_private_data.h b/mozilla/modules/libpref/src/prefapi_private_data.h index a7a13e1d53b..4889e2f7e22 100644 --- a/mozilla/modules/libpref/src/prefapi_private_data.h +++ b/mozilla/modules/libpref/src/prefapi_private_data.h @@ -44,14 +44,3 @@ PLDHashOperator PR_CALLBACK pref_savePref(PLDHashTable*, PLDHashEntryHdr *, PRUi int PR_CALLBACK pref_CompareStrings(const void *v1, const void *v2, void* unused); extern JSBool pref_InitInitialObjects(void); - -#include "nsIFileSpec.h" - -#ifdef XP_MAC -# define LINEBREAK "\012" -#elif defined(XP_WIN) || defined(XP_OS2) -# define LINEBREAK "\015\012" -#elif defined(XP_UNIX) || defined(XP_BEOS) -# define LINEBREAK "\012" -#endif /* XP_MAC */ - diff --git a/mozilla/modules/libpref/src/win/winpref.js b/mozilla/modules/libpref/src/win/winpref.js index d34547abcc3..6b7b47637fc 100644 --- a/mozilla/modules/libpref/src/win/winpref.js +++ b/mozilla/modules/libpref/src/win/winpref.js @@ -35,8 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -platform.windows = true; - pref("ui.key.menuAccessKeyFocuses", true); pref("font.name.serif.ar", "Times New Roman"); diff --git a/mozilla/xpinstall/packager/mac/browser.jst b/mozilla/xpinstall/packager/mac/browser.jst index 5ec5d6ba19c..1745d5885bf 100644 --- a/mozilla/xpinstall/packager/mac/browser.jst +++ b/mozilla/xpinstall/packager/mac/browser.jst @@ -5,6 +5,8 @@ function upgradeCleanup() deleteThisFile("Components", "DOMDataSource.shlb"); deleteThisFile("Components", "PSMGlue.shlb"); deleteThisFile("Components", "ucth.shlb"); + deleteThisFile("Program", "defaults/pref/config.js"); + deleteThisFile("Program", "defaults/pref/initpref.js"); deleteThisFile("Program", "defaults/wallet/URLFieldSchema.tbl"); deleteThisFile("Program", "Essential Files/PSM.shlb"); deleteThisFolder("Program", "psmdata"); diff --git a/mozilla/xpinstall/packager/unix/browser.jst b/mozilla/xpinstall/packager/unix/browser.jst index 214febf30ae..7f580b05b3d 100644 --- a/mozilla/xpinstall/packager/unix/browser.jst +++ b/mozilla/xpinstall/packager/unix/browser.jst @@ -6,6 +6,8 @@ function upgradeCleanup() deleteThisFile("Components", "libpsmglue.so"); deleteThisFile("Components", "libsample.so"); deleteThisFile("Components", "nsSample.js"); + deleteThisFile("Program", "defaults/pref/config.js"); + deleteThisFile("Program", "defaults/pref/initpref.js"); deleteThisFile("Program", "defaults/wallet/URLFieldSchema.tbl"); deleteThisFile("Program", "libcmt.so"); deleteThisFile("Program", "libjpeg.so"); diff --git a/mozilla/xpinstall/packager/windows/browser.jst b/mozilla/xpinstall/packager/windows/browser.jst index 72e6d0686e3..158abec407e 100644 --- a/mozilla/xpinstall/packager/windows/browser.jst +++ b/mozilla/xpinstall/packager/windows/browser.jst @@ -389,6 +389,8 @@ function upgradeCleanup() deleteThisFile("Program", "img3250.dll"); deleteThisFile("Program", "gkgfxwin.dll"); deleteThisFile("Program", "gkwidget.dll"); + deleteThisFile("Program", "defaults/pref/config.js"); + deleteThisFile("Program", "defaults/pref/initpref.js"); deleteThisFile("Program", "defaults/pref/psm-glue.js"); deleteThisFile("Program", "defaults/wallet/URLFieldSchema.tbl"); deleteThisFile("Components", "gkhtml.dll");