diff --git a/.mozconfig.mk b/.mozconfig.mk index cc5b448a..7f871989 100644 --- a/.mozconfig.mk +++ b/.mozconfig.mk @@ -1,12 +1,12 @@ # gmake # This file is automatically generated for client.mk. -# Do not edit. Edit /c/projects/retrozilla/mozilla/mozconfig instead. +# Do not edit. Edit /c/projects/moz95/mozilla/mozconfig instead. # To create a new .mozconfig file, you can visit, # http://webtools.mozilla.org/build/config.cgi # PATH=/local/bin:/c/mozilla-build//wget:/c/mozilla-build//7zip:/c/mozilla-build//blat261/full:/c/mozilla-build//python25:/c/mozilla-build//svn-win32-1.4.2/bin:/c/mozilla-build//upx203w:/c/mozilla-build//xemacs/XEmacs-21.4.19/i586-pc-win32:/c/mozilla-build//info-zip:/c/mozilla-build//nsis-2.22:/c/mozilla-build//nsis-2.33u:.:/usr/local/bin:/mingw/bin:/bin:/c/PROGRA~1/MICROS~3/Common/msdev98/BIN:/c/PROGRA~1/MICROS~3/VC98/BIN:/c/PROGRA~1/MICROS~3/Common/TOOLS/WINNT:/c/PROGRA~1/MICROS~3/Common/TOOLS:/c/WINNT/System32:/c/WINNT:/c/WINNT/System32/Wbem:/c/mozilla-build/moztools-180compat/bin MOZ_MAKE_FLAGS=-j4 -MOZ_OBJDIR=/c/projects/retrozilla/obj-sm95-release +MOZ_OBJDIR=/c/projects/moz95/obj-sm95-release # --target=i586-pc-msvc is used by configure (not client.mk) # --enable-application=suite is used by configure (not client.mk) # --enable-optimize is used by configure (not client.mk) diff --git a/.mozconfig.mk-tmp2536 b/.mozconfig.mk-tmp2536 deleted file mode 100644 index d4e358bf..00000000 --- a/.mozconfig.mk-tmp2536 +++ /dev/null @@ -1,14 +0,0 @@ -# gmake -# This file is automatically generated for client.mk. -# Do not edit. Edit /c/projects/moz95/mozilla/mozconfig instead. -# To create a new .mozconfig file, you can visit, -# http://webtools.mozilla.org/build/config.cgi - -# PATH=/local/bin:/c/mozilla-build//wget:/c/mozilla-build//7zip:/c/mozilla-build//blat261/full:/c/mozilla-build//python25:/c/mozilla-build//svn-win32-1.4.2/bin:/c/mozilla-build//upx203w:/c/mozilla-build//xemacs/XEmacs-21.4.19/i586-pc-win32:/c/mozilla-build//info-zip:/c/mozilla-build//nsis-2.22:/c/mozilla-build//nsis-2.33u:.:/usr/local/bin:/mingw/bin:/bin:/c/PROGRA~1/MICROS~3/Common/msdev98/BIN:/c/PROGRA~1/MICROS~3/VC98/BIN:/c/PROGRA~1/MICROS~3/Common/TOOLS/WINNT:/c/PROGRA~1/MICROS~3/Common/TOOLS:/c/WINNT/System32:/c/WINNT:/c/WINNT/System32/Wbem:/c/mozilla-build/moztools-180compat/bin -MOZ_MAKE_FLAGS=-j4 -MOZ_OBJDIR=/c/projects/moz95/obj-sm95-release -# --target=i586-pc-msvc is used by configure (not client.mk) -# --enable-application=suite is used by configure (not client.mk) -# --enable-optimize is used by configure (not client.mk) -# --disable-debug is used by configure (not client.mk) -# --disable-tests is used by configure (not client.mk) diff --git a/xpfe/bootstrap/browser-prefs.js b/xpfe/bootstrap/browser-prefs.js index 6a1e6854..a468f919 100644 --- a/xpfe/bootstrap/browser-prefs.js +++ b/xpfe/bootstrap/browser-prefs.js @@ -41,6 +41,29 @@ #expand pref("general.useragent.extra.__MOZ_APP_NAME__", "__MOZ_APP_DISPLAYNAME__/__MOZ_APP_VERSION__ SeaMonkey/1.1.19 Firefox/2.0.20"); pref("rzHome.autofocus", true); +// RETROZILLA SESSION RESTORE PREFERENCES +pref("extensions.crashrecovery.interval", 10000); +pref("extensions.crashrecovery.postdata", -1); +pref("extensions.crashrecovery.privacy_level", 1); +pref("extensions.crashrecovery.restore_prompt", true); +pref("extensions.crashrecovery.restore_prompt_uri", "chrome://global/content/extensions/sessionmanager/restore_prompt.xul"); // change this to new URI +pref("extensions.crashrecovery.resume_session", false); +pref("extensions.crashrecovery.resume_session_once", false); + +pref("extensions.sessionmanager.backup_session", 1); +pref("extensions.sessionmanager.max_backup_keep", 1); +pref("extensions.sessionmanager.max_closed_undo", 10); +pref("extensions.sessionmanager.max_tabs_undo", 10); +pref("extensions.sessionmanager.name_format", "%40t-%d"); +pref("extensions.sessionmanager.options_selected_tab", 0); +pref("extensions.sessionmanager.overwrite", true); +pref("extensions.sessionmanager.reload", false); +pref("extensions.sessionmanager.resume_session", ""); +pref("extensions.sessionmanager.save_closed_tabs", 0); +pref("extensions.sessionmanager.save_window_list", false); +pref("extensions.sessionmanager.session_list_order", 1); +pref("extensions.sessionmanager.submenus", false); + /* The prefs in this file are specific to the seamonkey browser. * Generic default prefs that would be useful to embedders belong in * modules/libpref/src/init/all.js diff --git a/xpfe/browser/resources/content/navigator.xul b/xpfe/browser/resources/content/navigator.xul index 1c65bd01..584a0963 100644 --- a/xpfe/browser/resources/content/navigator.xul +++ b/xpfe/browser/resources/content/navigator.xul @@ -49,6 +49,8 @@ + + + + + +
  • + + + + + +
  • + + + + diff --git a/xpfe/components/sessionstore/crashrecovery.properties b/xpfe/components/sessionstore/crashrecovery.properties new file mode 100644 index 00000000..3dab2473 --- /dev/null +++ b/xpfe/components/sessionstore/crashrecovery.properties @@ -0,0 +1,4 @@ +extensions.{1280606b-2510-4fe0-97ef-9b5a22eafe6a}.description=Automagically recovers all windows (after a crash). + +restore_prompt=All windows from before the last crash will be restored. +restore_prompt_again=Don't show this dialog again diff --git a/xpfe/components/sessionstore/locale/en-US/contents.rdf b/xpfe/components/sessionstore/locale/en-US/contents.rdf new file mode 100644 index 00000000..8854db1f --- /dev/null +++ b/xpfe/components/sessionstore/locale/en-US/contents.rdf @@ -0,0 +1,19 @@ + + + + +
  • + + + + + +
  • + + + + diff --git a/xpfe/components/sessionstore/locale/en-US/crashrecovery.properties b/xpfe/components/sessionstore/locale/en-US/crashrecovery.properties new file mode 100644 index 00000000..3dab2473 --- /dev/null +++ b/xpfe/components/sessionstore/locale/en-US/crashrecovery.properties @@ -0,0 +1,4 @@ +extensions.{1280606b-2510-4fe0-97ef-9b5a22eafe6a}.description=Automagically recovers all windows (after a crash). + +restore_prompt=All windows from before the last crash will be restored. +restore_prompt_again=Don't show this dialog again diff --git a/xpfe/components/sessionstore/public/Makefile.in b/xpfe/components/sessionstore/public/Makefile.in new file mode 100644 index 00000000..407aee36 --- /dev/null +++ b/xpfe/components/sessionstore/public/Makefile.in @@ -0,0 +1,51 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = crashrecovery +XPIDL_MODULE=crashrecovery + +XPIDLSRCS = crashrecovery.idl \ + +include $(topsrcdir)/config/rules.mk + diff --git a/xpfe/components/sessionstore/public/crashrecovery.idl b/xpfe/components/sessionstore/public/crashrecovery.idl new file mode 100644 index 00000000..b7679ab0 --- /dev/null +++ b/xpfe/components/sessionstore/public/crashrecovery.idl @@ -0,0 +1,32 @@ +#include "nsISupports.idl" + +interface nsIDOMWindow; + +/** + * nsICrashRecoveryService keeps track of the current browsing state - i.e. + * tab history, cookies, scroll state, form data, POSTDATA and window features + * - and allows to restore everything into one window. + */ + +[scriptable, uuid(1280606b-2510-4fe0-97ef-9b5a22eafe33)] +interface nsICrashRecoveryService : nsISupports +{ + /** + * @return The current browsing state, serialized into a string. + */ + wstring getCurrentState(); + + /** + * @param aWindow is the window whose state is to be returned. + * + * @return The current state of one window, serialized into a string. + */ + wstring getWindowState(in nsIDOMWindow aWindow); + + /** + * @param aWindow is the window into which the browsing state will be restored. + * @param aState is a serialized browsing state as produced by getCurrentState. + * @param aOverwriteTabs indicates whether the window's tabs will be overwritten. + */ + void restoreWindow(in nsIDOMWindow aWindow, in wstring aState, in boolean aOverwriteTabs); +}; diff --git a/xpfe/components/sessionstore/src/Makefile.in b/xpfe/components/sessionstore/src/Makefile.in new file mode 100644 index 00000000..afd88972 --- /dev/null +++ b/xpfe/components/sessionstore/src/Makefile.in @@ -0,0 +1,48 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org Code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +EXTRA_COMPONENTS = crashrecovery.js + +include $(topsrcdir)/config/rules.mk + diff --git a/xpfe/components/sessionstore/src/crashrecovery.js b/xpfe/components/sessionstore/src/crashrecovery.js new file mode 100644 index 00000000..d24f87fe --- /dev/null +++ b/xpfe/components/sessionstore/src/crashrecovery.js @@ -0,0 +1,1940 @@ +/* Crash Recovery 2006-07-30 - Copyleft © 2006 Simon Bünzli */ + +/* :::::::: Basic Convenience ::::::::::::::: */ + +/*const*/ var Cc = Components.classes; +/*const*/ var Ci = Components.interfaces; +/*const*/ var Cr = Components.results; + +/*const*/ var report = Components.utils.reportError; + + +/* :::::::: Constants ::::::::::::::: */ + +/*const*/ var gIOService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); +/*const*/ var gObserverService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); +/*const*/ var gPrefRoot = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2); +/*const*/ var gWindowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); + +/*const*/ var gObserving = ["domwindowopened", "domwindowclosed", "quit-application-requested", "quit-application-granted", "quit-application", "browser:purge-session-history"]; +/*const*/ var gPrefBranch = gPrefRoot.QueryInterface(Ci.nsIPrefService).getBranch("extensions.crashrecovery.").QueryInterface(Ci.nsIPrefBranch2); + +/*const*/ var gCapabilities = ["Subframes", "Plugins", "Javascript", "MetaRedirects", "Images"]; +/*const*/ var gWinAttributes = ["width", "height", "screenX", "screenY", "sizemode"]; +/*const*/ var gWinHidable = ["menubar", "toolbar", "locationbar", "personalbar", "statusbar", "scrollbars"]; +/*const*/ var gXulAttributes = ["locked", "protected", "marked"]; + +/*const*/ var STATE_STOPPED = 0; +/*const*/ var STATE_RUNNING = 1; +/*const*/ var STATE_QUITTING = -1; + +/*const*/ var POTENTIAL_CRASH_DELAY = 8000; + + +/* :::::::: State Variables ::::::::::::::: */ + +var gInitialState, gLastSaveTime, gQuitRequest, gSaveTimer; + +var gLoadState = STATE_STOPPED; +var gLastClosedWindow = null; +var gWindows = {}; +var gDirty = {}; +var gPrefs = {}; + + +/* :::::::: Crash Recovery Service ::::::::::::::: */ + +/*const*/ var CrashRecoveryService = { + mCID: Components.ID("{1280606b-2510-4fe0-97ef-9b5a22eafe6b}"), + mContractID: "@zeniko/crashrecoveryservice;1", + mClassName: "Crash Recovery Service", + +/* ........ Global Event Handlers .............. */ + + init: function() + { + gObserving.forEach(function(aTopic) { gObserverService.addObserver(this, aTopic, false); }, this); + + gPrefs.interval = getPref("interval", 10000); + gPrefs.postdata = getPref("postdata", -1); + gPrefs.privacy_level = getPref("privacy_level", 1); + gPrefBranch.addObserver("", this, false); + + try + { + gInitialState = readFile(getSessionFile()); + } + catch (ex) { report(ex); } + if (gInitialState) + { + try + { + writeFile(getSessionFile("bak"), gInitialState); + + gInitialState = decodeINI(gInitialState); + delete gInitialState.Window[0].hidden; + gWinAttributes.forEach(function(aAttr) { delete gInitialState.Window[0][aAttr]; }); + } + catch (ex) + { + report(ex); + gInitialState = null; + } + } + if (gInitialState && gInitialState.CrashRecovery && gInitialState.CrashRecovery.state && gInitialState.CrashRecovery.state != "stopped") + { + if (gInitialState.CrashRecovery.state == "running") + { + try + { + writeFile(getSessionFile(), readFile(getSessionFile()).replace(/^state=running$/m, "state=crashed")); + } + catch (ex) { report(ex); } + } + try + { + restoreCache(); + } + catch (ex) { report(ex); } + } + }, + + uninit: function() + { + if (doResumeSession()) + { + saveState(true); + } + else + { + clearDisk(); + } + + if (gSaveTimer) + { + gSaveTimer.cancel(); + gSaveTimer = null; + } + + gObserving.forEach(function(aTopic) { gObserverService.removeObserver(this, aTopic); }, this); + gPrefBranch.removeObserver("", this); + }, + + observe: function(aSubject, aTopic, aData) + { + switch (aTopic) + { + case "app-startup": + gObserverService.addObserver(this, "profile-after-change", false); + break; + case "profile-after-change": + gObserverService.removeObserver(this, aTopic); + this.init(); + break; + case "domwindowopened": + aSubject.addEventListener("load", onWindowLoad_window, false); + break; + case "domwindowclosed": + onWindowClose(aSubject, gQuitRequest && gQuitRequest > Date.now() - 3000); + break; + case "quit-application-requested": + forEachBrowserWindow(collectWindowData); + gDirty = {}; + gQuitRequest = Date.now(); + break; + case "quit-application-granted": + gLoadState = STATE_QUITTING; + break; + case "quit-application": + if (aData == "restart") + { + gPrefBranch.setBoolPref("resume_session_once", true); + } + gLoadState = STATE_QUITTING; + this.uninit(); + break; + case "browser:purge-session-history": + onPurgeHistory(); + break; + case "nsPref:changed": + if (aData in gPrefs) + { + gPrefs[aData] = getPref(aData); + } + switch (aData) + { + case "interval": + if (gSaveTimer && gLastSaveTime - Date.now() + gPrefs.interval <= 0) + { + saveState(); + } + break; + case "privacy_level": + saveState(true); + break; + } + break; + } + }, + +/* ........ Saving Functionality .............. */ + + /*API*/ getCurrentState: function() + { + return encodeINI(getCurrentState()); + }, + + /*API*/ getWindowState: function(aWindow) + { + return encodeINI(getCurrentState(aWindow)); + }, + +/* ........ Restoring Functionality .............. */ + + /*API*/ restoreWindow: function(aWindow, aState, aOverwriteTabs) + { + try + { + var root = decodeINI(aState); + if (!root.Window[0]) + { + return; + } + } + catch (ex) + { + report(ex); + return; + } + + restoreWindow(aWindow, root, aOverwriteTabs); + }, + +/* ........ QueryInterface .............. */ + + QueryInterface: function(aIID) + { + if (!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.nsIObserver) && !aIID.equals(Ci.nsICrashRecoveryService || null)) + { + Components.returnCode = Cr.NS_ERROR_NO_INTERFACE; + return null; + } + + return this; + } +}; + + +/* :::::::: Window Event Handlers ::::::::::::::: */ + +function onWindowLoad_window() +{ + this.removeEventListener("load", onWindowLoad_window, false); + + if (this.document.documentElement.getAttribute("windowtype") != "navigator:browser" || gLoadState == STATE_QUITTING) + { + return; + } + + this.__CRi = "window" + Date.now(); + + if (gLoadState == STATE_STOPPED) + { + gWindows = {}; + } + gWindows[this.__CRi] = { Tab: [], selected: 0 }; + + if (gLoadState == STATE_STOPPED) + { + var lastSessionState = gInitialState && gInitialState.CrashRecovery && gInitialState.CrashRecovery.state && gInitialState.CrashRecovery.state || "stopped"; + + if (gInitialState && !((lastSessionState != "stopped")?doRecoverSession(lastSessionState == "crashed"):doResumeSession())) + { + gInitialState = null; + } + if (getPref("resume_session_once")) + { + gPrefBranch.setBoolPref("resume_session_once", false); + } + gLoadState = STATE_RUNNING; + gLastSaveTime = Date.now(); + + saveStateDelayed(this, 5000); + + if (gInitialState) + { + gInitialState._firstTabs = true; + gInitialState._crashed = lastSessionState != "stopped"; + restoreWindow(this, gInitialState, isCmdLineEmpty(this)); + gInitialState = null; + } + + if (lastSessionState != "stopped") + { + this.setTimeout(retryDownloads, 0, this); + } + } + + var tabpanels = this.getBrowser().mPanelContainer; + Array.forEach(tabpanels.childNodes, function(aPanel) { onTabAdd(this, aPanel, true); }, this); + tabpanels.addEventListener("DOMNodeInserted", onTabAdd_panels, false); + tabpanels.addEventListener("DOMNodeRemoved", onTabRemove_panels, false); + tabpanels.addEventListener("select", onTabSelect_panels, false); +} + +function onWindowClose(aWindow, aIgnoreClosure) +{ + if (aWindow.document.documentElement.getAttribute("windowtype") != "navigator:browser" || !aWindow.__CRi) + { + return; + } + + var tabpanels = aWindow.getBrowser().mPanelContainer; + Array.forEach(tabpanels.childNodes, function(aPanel) { onTabRemove(this, aPanel, true); }, this); + tabpanels.removeEventListener("DOMNodeInserted", onTabAdd_panels, false); + tabpanels.removeEventListener("DOMNodeRemoved", onTabRemove_panels, false); + tabpanels.removeEventListener("select", onTabSelect_panels, false); + + if (gLoadState == STATE_RUNNING && !aIgnoreClosure) + { + gLastClosedWindow = getCurrentState(aWindow); + delete gWindows[aWindow.__CRi]; + saveStateDelayed(); + + if (gQuitRequest) + { + var windows = {}; + forEachBrowserWindow(function(aWindow) { windows[aWindow.__CRi] = true; }); + for (var ix in gWindows) + { + if (!windows[ix]) + { + delete gWindows[ix]; + } + } + gQuitRequest = null; + } + + var notifyClosedWindow = gLastClosedWindow; + } + if (gLoadState == STATE_RUNNING && !getMostRecentBrowserWindow()) + { + if (!getPref("allow_empty_session")) + { + gLoadState = STATE_STOPPED; + gInitialState = getCurrentState(); + notifyClosedWindow = null; + } + else + { + gLastClosedWindow = null; + } + } + if (notifyClosedWindow) + { + gObserverService.notifyObservers(aWindow, "crashrecovery:windowclosed", encodeINI(notifyClosedWindow)); + } + + delete aWindow.__CRi; +} + +function onTabAdd_panels(aEvent) +{ + onTabAdd(this.ownerDocument.defaultView, aEvent.target); +} + +function onTabAdd(aWindow, aBrowser, aNoNotification) +{ + aBrowser.addEventListener("load", onTabLoad_browser, true); + aBrowser.addEventListener("pageshow", onTabLoad_browser, true); + aBrowser.addEventListener("input", onTabInput_browser, true); + aBrowser.addEventListener("DOMAutoComplete", onTabInput_browser, true); + + if (!aNoNotification) + { + saveStateDelayed(aWindow); + } +} + +function onTabRemove_panels(aEvent) +{ + onTabRemove(this.ownerDocument.defaultView, aEvent.target); +} + +function onTabRemove(aWindow, aBrowser, aNoNotification) +{ + aBrowser.removeEventListener("load", onTabLoad_browser, true); + aBrowser.removeEventListener("pageshow", onTabLoad_browser, true); + aBrowser.removeEventListener("input", onTabInput_browser, true); + aBrowser.removeEventListener("DOMAutoComplete", onTabInput_browser, true); + + aBrowser = ensureBrowser(aBrowser); + delete aBrowser.__CR_data; + delete aBrowser.__CR_text; + + if (!aNoNotification) + { + saveStateDelayed(aWindow); + } +} + +function onTabSelect_panels(aEvent) +{ + if (gLoadState == STATE_RUNNING) + { + var window = this.ownerDocument.defaultView; + + gWindows[window.__CRi].selected = this.selectedIndex + 1; + saveStateDelayed(window); + } +} + +function onTabLoad_browser(aEvent) +{ + if (aEvent.type != "load" && !aEvent.persisted) + { + return; + } + + var browser = ensureBrowser(this); + var window = this.ownerDocument.defaultView; + + delete browser.__CR_data; + delete browser.__CR_text; + saveStateDelayed(window); +} + +function onTabInput_browser(aEvent) +{ + if (saveTextData(ensureBrowser(this), aEvent.originalTarget)) + { + var window = this.ownerDocument.defaultView; + + saveStateDelayed(window, 3000); + } +} + +function onPurgeHistory() +{ + forEachBrowserWindow(function(aWindow) { + Array.forEach(aWindow.getBrowser().browsers, function(aBrowser) { + delete aBrowser.__CR_data; + }); + }); + clearDisk(); + + var window = getMostRecentBrowserWindow(); + if (window) + { + window.setTimeout(saveState, 0, true); + } + else + { + saveState(true); + } +} + +/* :::::::: Saving Functionality ::::::::::::::: */ + +function getCurrentState(aWindow) +{ + if (!aWindow) + { + var activeWindow = getMostRecentBrowserWindow(); + + if (gLoadState == STATE_RUNNING) + { + forEachBrowserWindow(function(aWindow) { + if (gDirty.all || gDirty[aWindow.__CRi] || aWindow == activeWindow) + { + collectWindowData(aWindow); + } + else + { + updateWindowFeatures(aWindow); + } + }); + gDirty = {}; + } + + var winDataList = [], windows = []; + for (var ix in gWindows) + { + winDataList.push(gWindows[ix]); + windows.push(ix); + } + if (windows.length == 0 && gLastClosedWindow) + { + return gLastClosedWindow; + } + ix = (activeWindow)?windows.indexOf(activeWindow.__CRi || ""):-1; + if (ix > 0) + { + winDataList.unshift(winDataList.splice(ix, 1)[0]); + } + } + else + { + if (gLoadState == STATE_RUNNING) + { + collectWindowData(aWindow); + } + + winDataList = [gWindows[aWindow.__CRi]]; + } + + updateCookies(winDataList); + + return { Window: winDataList }; +} + +function collectWindowData(aWindow) +{ + saveWindowHistory(aWindow); + updateTextAndScrollData(aWindow); + updateCookieHosts(aWindow); + updateWindowFeatures(aWindow); + + gDirty[aWindow.__CRi] = false; +} + +function saveWindowHistory(aWindow) +{ + var tabbrowser = aWindow.getBrowser(); + var browsers = tabbrowser.browsers; + if (!tabbrowser.mTabs) // MultiZilla + { + tabbrowser.mTabs = tabbrowser.mTabContainer.childNodes; + } + var tabs = gWindows[aWindow.__CRi].Tab = []; + gWindows[aWindow.__CRi].selected = 0; + + for (var i = 0; i < browsers.length; i++) + { + var tabData = { Entry: [], index: 0 }; + + var browser = browsers[i]; + if (!browser) + { + tabs.push(tabData); + continue; + } + + try + { + var history = browser.sessionHistory; + } + catch (ex) { report(ex); } + + if (history && browser.__CR_data && browser.__CR_data.Entry[history.index]) + { + tabData = browser.__CR_data; + tabData.index = history.index + 1; + if (tabData.recent && Date.now() - tabData.recent > POTENTIAL_CRASH_DELAY) + { + delete tabData.recent; + } + } + else if (history && history.count > 0) + { + for (var j = 0; j < history.count; j++) + { + tabData.Entry.push(serializeHistoryEntry(history.getEntryAtIndex(j, false))); + } + tabData.index = history.index + 1; + tabData.recent = Date.now(); + + browser.__CR_data = tabData; + } + else if (browser.currentURI) + { + tabData.Entry[0] = { uri: browser.currentURI.spec }; + tabData.index = 1; + } + tabData.zoom = (((browser.markupDocumentViewer.textZoom - 1) || -1) + 1) || ""; + + var disallow = gCapabilities.filter(function(aCapability) { + return !browser.docShell["allow" + aCapability]; + }); + tabData.disallow = disallow.join(","); + + var xulattr = Array.filter(tabbrowser.mTabs[i].attributes, function(aAttr) { + return aAttr.name.substr(0, 3).toUpperCase() == "CR_" || gXulAttributes.indexOf(aAttr.name) > -1; + }).map(function(aAttr) { + return aAttr.name + "=" + encodeURI(aAttr.value); + }); + tabData.xultab = xulattr.join(" "); + + tabs.push(tabData); + + if (browser == tabbrowser.selectedBrowser) + { + gWindows[aWindow.__CRi].selected = i + 1; + } + } +} + +function serializeHistoryEntry(aEntry) +{ + var entry = { uri: aEntry.URI.spec, Child: [] }; + + if (aEntry.title && aEntry.title != entry.uri) + { + entry.title = aEntry.title; + } + if (aEntry.isSubFrame) + { + entry.subframe = true; + } + if (!(aEntry instanceof Ci.nsISHEntry)) + { + return entry; + } + + var cacheKey = aEntry.cacheKey; + if (cacheKey && cacheKey instanceof Ci.nsISupportsPRUint32) + { + entry.cacheKey = cacheKey.data || ""; + } + entry.ID = aEntry.ID; + + var x = {}, y = {}; + aEntry.getScrollPosition(x, y); + entry.scroll = x.value + "," + y.value; + + try + { + if (gPrefs.postdata && aEntry.postData && checkPrivacyLevel(entry.uri)) + { + aEntry.postData.QueryInterface(Ci.nsISeekableStream).seek(Ci.nsISeekableStream.NS_SEEK_SET, 0); + var stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream); + stream.init(aEntry.postData); + var postdata = stream.read(stream.available()); + if (gPrefs.postdata == -1 || postdata.replace(/^(Content-.*\r\n)+(\r\n)*/, "").length <= gPrefs.postdata) + { + entry.postdata = postdata; + } + } + } + catch (ex) { report(ex); } + + if (!(aEntry instanceof Ci.nsISHContainer)) + { + return entry; + } + + for (var i = 0; i < aEntry.childCount; i++) + { + var child = aEntry.GetChildAt(i); + if (child) + { + entry.Child.push(serializeHistoryEntry(child)); + } + else + { + entry.Child.push({ uri: "about:blank" }); + } + } + + return entry; +} + +function saveTextData(aBrowser, aTextarea) +{ + var wrappedTextarea = XPCNativeWrapper(aTextarea); + var id = (wrappedTextarea.id)?"#" + wrappedTextarea.id:wrappedTextarea.name; + if (!id || !(wrappedTextarea instanceof Ci.nsIDOMHTMLTextAreaElement || wrappedTextarea instanceof Ci.nsIDOMHTMLInputElement)) + { + return false; + } + + if (!aBrowser.__CR_text) + { + aBrowser.__CR_text = {}; + } + else if (aBrowser.__CR_text[aTextarea] && !aBrowser.__CR_text[aTextarea].cache) + { + return false; + } + + var content = wrappedTextarea.ownerDocument.defaultView; + while (content != content.top) + { + var frames = content.parent.frames; + for (var i = frames.length - 1; i >= 0 && frames[i] != content; i--); + id = i + "|" + id; + content = content.parent; + } + + aBrowser.__CR_text[aTextarea] = { id: id, element: wrappedTextarea }; + + return true; +} + +function updateTextAndScrollData(aWindow) +{ + Array.forEach(aWindow.getBrowser().browsers, function(aBrowser, aIx) { + try + { + var tabData = gWindows[aWindow.__CRi].Tab[aIx]; + + var text = []; + if (aBrowser.__CR_text && checkPrivacyLevel(aBrowser.currentURI.spec)) + { + for (var key in aBrowser.__CR_text) + { + var data = aBrowser.__CR_text[key]; + if (!data.cache) + { + data.cache = encodeURI(data.element.value); + } + text.push(data.id + "=" + data.cache); + } + } + if (aBrowser.currentURI.spec == "about:config") + { + text = ["#textbox=" + encodeURI(aBrowser.contentDocument.getElementById("textbox").value)]; + } + tabData.text = text.join(" "); + + updateScrollDataRecursively(aWindow, XPCNativeWrapper(aBrowser.contentWindow), tabData.Entry[tabData.index - 1]); + } + catch (ex) { report(ex); } + }); +} + +function updateScrollDataRecursively(aWindow, aContent, aData) +{ + for (var i = aContent.frames.length - 1; i >= 0; i--) + { + if (aData.Child && aData.Child[i]) + { + updateScrollDataRecursively(aWindow, aContent.frames[i], aData.Child[i]); + } + } + if ((aContent.document.designMode || "") == "on" && checkPrivacyLevel((aContent.parent || aContent).document.location.href)) + { + if (aData.innerHTML == undefined) + { + aContent.addEventListener("keypress", function(aEvent) { saveStateDelayed(aWindow, 3000); }, true); + } + aData.innerHTML = aContent.document.body.innerHTML; + } + aData.scroll = aContent.scrollX + "," + aContent.scrollY; +} + +function updateCookieHosts(aWindow) +{ + var hosts = gWindows[aWindow.__CRi]._hosts = {}; + + function extractHosts(aEntry) + { + if (/^https?:\/\/(?:[^@\/\s]+@)?([\w.-]+)/.test(aEntry.uri) && !hosts[RegExp.$1] && checkPrivacyLevel(aEntry.uri)) + { + var host = RegExp.$1; + for (var ix = host.indexOf(".") + 1; ix; ix = host.indexOf(".", ix) + 1) + { + hosts[host.substr(ix)] = true; + } + hosts[host] = true; + } + if (aEntry.Child) + { + aEntry.Child.forEach(extractHosts); + } + } + + gWindows[aWindow.__CRi].Tab.forEach(function(aTabData) { aTabData.Entry.forEach(extractHosts); }); +} + +function updateCookies(aWindows) +{ + var cookiesEnum = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager).enumerator; + var cookieSets = aWindows.map(function() { return { count: 0 }; }); + + while (cookiesEnum.hasMoreElements()) + { + var cookie = cookiesEnum.getNext().QueryInterface(Ci.nsICookie2); + if (cookie.isSession && cookie.host) + { + var url = "", value = ""; + aWindows.forEach(function(aWindow, aIx) { + if (aWindow._hosts && aWindow._hosts[cookie.rawHost]) + { + if (!url) + { + url = "http" + ((cookie.isSecure)?"s":"") + "://" + cookie.host + (cookie.path || "").replace(/^(?!\/)/, "/"); + if (checkPrivacyLevel(url)) + { + value = (cookie.name || "name") + "=" + (cookie.value || "") + ";"; + value += (cookie.isDomain)?"domain=" + cookie.rawHost + ";":""; + value += (cookie.path)?"path=" + cookie.path + ";":""; + value += (cookie.isSecure)?"secure;":""; + } + } + if (value) + { + var set = cookieSets[aIx]; + set["domain" + ++set.count] = url; + set["value" + set.count] = value; + } + } + }); + } + } + + cookieSets.forEach(function(aSet, aIx) { aWindows[aIx].Cookies = (aSet.count > 0)?aSet:null; }); +} + +function updateWindowFeatures(aWindow) +{ + var winData = gWindows[aWindow.__CRi]; + + gWinAttributes.forEach(function(aAttr) { winData[aAttr] = getWindowDimension(aWindow, aAttr); }); + + winData.hidden = gWinHidable.filter(function(aItem) { + return aWindow[aItem] && !aWindow[aItem].visible; + }).join(","); + + if (aWindow.toggleSidebar) // Firefox + { + winData.sidebar = aWindow.document.getElementById("sidebar-box").getAttribute("sidebarcommand"); + } + else if (aWindow.sidebar_is_hidden) // SeaMonkey + { + winData.sidebar = !aWindow.sidebar_is_hidden(); + } +} + + +/* :::::::: Restoring Functionality ::::::::::::::: */ + +function restoreWindow(aWindow, aRootObj, aOverwriteTabs) +{ + for (var w = aRootObj.Window.length - 1; w >= 1; w--) + { + var winObj = aRootObj.Window[w]; + if (winObj.Tab && winObj.Tab.length > 0) + { + openWindowWithState({ Window: [winObj], opener: aWindow, _crashed: aRootObj._crashed || false }); + } + } + + var winData = aRootObj.Window[0]; + if (!winData.Tab) + { + winData.Tab = []; + } + var tabbrowser = aWindow.getBrowser(); + if (!tabbrowser.mTabs) // MultiZilla + { + tabbrowser.mTabs = tabbrowser.mTabContainer.childNodes; + tabbrowser.moveTabTo = tabbrowser.moveTabTo || tabbrowser.moveTab; + } + var openTabCount = (aOverwriteTabs)?tabbrowser.browsers.length:-1; + var newTabCount = winData.Tab.length; + + for (var t = 0; t < newTabCount; t++) + { + winData.Tab[t]._tab = (t < openTabCount)?tabbrowser.mTabs[t]:tabbrowser.addTab(); + if (!aOverwriteTabs && aRootObj._firstTabs) + { + tabbrowser.moveTabTo(winData.Tab[t]._tab, t); + } + } + for (t = openTabCount - 1; t >= newTabCount; t--) + { + tabbrowser.removeTab(tabbrowser.mTabs[t]); + } + + if (aOverwriteTabs) + { + restoreWindowFeatures(aWindow, winData, aRootObj.opener || null); + } + if (winData.Cookies) + { + restoreCookies(winData.Cookies); + } + + aWindow.setTimeout(restoreHistory_window, 0, winData.Tab, (aOverwriteTabs)?parseInt(winData.selected) || 1:0, (aRootObj._crashed)?getPref("crash_warning_uri"):null, 0, 0); +} + +function restoreHistory_window(aTabs, aSelectTab, aWarningURL, aIx, aCount) +{ + var tabbrowser = this.getBrowser(); + + for (var t = aIx; t < aTabs.length; t++) + { + try + { + if (!tabbrowser.getBrowserForTab(aTabs[t]._tab).webNavigation.sessionHistory) + { + throw new Error(); + } + } + catch (ex) + { + if (++aCount < 10) + { + this.setTimeout(restoreHistory_window, 100, aTabs, aSelectTab, aWarningURL, t, aCount); + return; + } + } + } + + try + { + var tabLoading = getStringBundle("chrome://global/locale/tabbrowser.properties").GetStringFromName("tabs.loading"); + for (t = 0; t < aTabs.length; t++) + { + var tab = aTabs[t]._tab; + tab.setAttribute("busy", "true"); + tab.removeAttribute("image"); + tab.label = tabLoading; + } + } + catch (ex) { } + + if (aSelectTab-- && aTabs[aSelectTab]) + { + aTabs.unshift(aTabs.splice(aSelectTab, 1)[0]); + tabbrowser.selectedTab = aTabs[0]._tab; + } + + this.setTimeout(restoreHistory, 0, this, aTabs, aWarningURL, null); +} + +function restoreHistory(aWindow, aTabs, aWarningURL, aIdMap) +{ + while (aTabs.length > 0 && (!aTabs[0]._tab || !aTabs[0]._tab.parentNode)) + { + aTabs.shift(); + } + if (aTabs.length == 0) + { + return; + } + + var tabData = aTabs.shift(); + var idMap = aIdMap || { used: {} }; + + var tab = tabData._tab; + var browser = aWindow.getBrowser().getBrowserForTab(tab); + var history = browser.webNavigation.sessionHistory; + + if (history.count > 0) + { + history.PurgeHistory(history.count); + } + history.QueryInterface(Ci.nsISHistoryInternal); + + if (!tabData.Entry) + { + tabData.Entry = []; + } + + browser.markupDocumentViewer.textZoom = parseFloat(tabData.zoom || 1); + + if (tabData.recent && !tabData.text && aWarningURL) + { + var warnEntry = { uri: aWarningURL }; + if (tabData.index < tabData.Entry.length) + { + warnEntry.uri += "#" + tabData.index; + } + tabData.Entry.push(warnEntry); + tabData.index = tabData.Entry.length; + } + for (var i = 0; i < tabData.Entry.length; i++) + { + history.addEntry(deserializeHistoryEntry(tabData.Entry[i], idMap), true); + } + + var disallow = (tabData.disallow)?tabData.disallow.split(","):[]; + gCapabilities.forEach(function(aCapability) { + browser.docShell["allow" + aCapability] = disallow.indexOf(aCapability) == -1; + }); + Array.filter(tab.attributes, function(aAttr) { + return aAttr.name.substr(0, 3).toUpperCase() == "CR_" || gXulAttributes.indexOf(aAttr.name) > -1; + }).forEach(tab.removeAttribute, tab); + if (tabData.xultab) + { + tabData.xultab.split(" ").forEach(function(aAttr) { + if (/^([^\s=]+)=(.*)/.test(aAttr)) + { + tab.setAttribute(RegExp.$1, decodeURI(RegExp.$2)); + } + }); + } + + var event = aWindow.document.createEvent("Events"); + event.initEvent("CRTabRestoring", true, false); + tab.dispatchEvent(event); + + var activeIndex = (tabData.index || tabData.Entry.length) - 1; + try + { + browser.webNavigation.gotoIndex(activeIndex); + } + catch (ex) { report(ex); } + + browser.__CR_restore_data = tabData.Entry[activeIndex] || {}; + browser.__CR_restore_text = tabData.text || ""; + browser.__CR_restore_tab = tab; + browser.__CR_restore = restoreDocument_browser; + browser.addEventListener("load", browser.__CR_restore, true); + + aWindow.setTimeout(restoreHistory, 0, aWindow, aTabs, aWarningURL, idMap); +} + +function deserializeHistoryEntry(aEntry, aIdMap) +{ + var shEntry = Cc["@mozilla.org/browser/session-history-entry;1"].createInstance(Ci.nsISHEntry); + + shEntry.setURI(gIOService.newURI(aEntry.uri, null, null)); + shEntry.setTitle(aEntry.title || aEntry.uri); + shEntry.setIsSubFrame(aEntry.subframe || false); + shEntry.loadType = Ci.nsIDocShellLoadInfo.loadHistory; + + if (aEntry.cacheKey) + { + var cacheKey = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32); + cacheKey.data = aEntry.cacheKey; + shEntry.cacheKey = cacheKey; + } + if (aEntry.ID) + { + var id = aIdMap[aEntry.ID] || 0; + if (!id) + { + for (id = Date.now(); aIdMap.used[id]; id++); + aIdMap[aEntry.ID] = id; + aIdMap.used[id] = true; + } + shEntry.ID = id; + } + + var scrollPos = (aEntry.scroll || "0,0").split(","); + scrollPos = [parseInt(scrollPos[0]) || 0, parseInt(scrollPos[1]) || 0]; + shEntry.setScrollPosition(scrollPos[0], scrollPos[1]); + + if (aEntry.postdata) + { + var stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); + stream.setData(aEntry.postdata, -1); + shEntry.postData = stream; + } + + if (aEntry.Child && shEntry instanceof Ci.nsISHContainer) + { + for (var i = 0; i < aEntry.Child.length; i++) + { + shEntry.AddChild(deserializeHistoryEntry(aEntry.Child[i], aIdMap), i); + } + } + + return shEntry; +} + +function restoreDocument_browser(aEvent) +{ + if (!aEvent || !aEvent.originalTarget || !aEvent.originalTarget.defaultView || aEvent.originalTarget.defaultView != aEvent.originalTarget.defaultView.top) + { + return; + } + + var content = XPCNativeWrapper(aEvent.originalTarget).defaultView; + if (this.currentURI.spec == "about:config") + { + content = aEvent.originalTarget.defaultView; + } + var textArray = (this.__CR_restore_text)?this.__CR_restore_text.split(" "):[]; + restoreTextDataAndScrolling(content, this.__CR_restore_data, "", textArray); + + var event = this.ownerDocument.createEvent("Events"); + event.initEvent("CRTabRestored", true, false); + this.__CR_restore_tab.dispatchEvent(event); + + this.removeEventListener("load", this.__CR_restore, true); + delete this.__CR_restore_data; + delete this.__CR_restore_text; + delete this.__CR_restore_tab; + delete this.__CR_restore; +} + +function restoreTextData(aContent, aPrefix, aTextArray) +{ + aTextArray.forEach(function(aEntry) { + if (/^((?:\d+\|)*)(#?)([^\s=]+)=(.*)$/.test(aEntry) && (!RegExp.$1 || RegExp.$1 == aPrefix)) + { + var document = aContent.document; + var node = (RegExp.$2)?document.getElementById(RegExp.$3):document.getElementsByName(RegExp.$3)[0] || null; + if (node && "value" in node) + { + node.value = decodeURI(RegExp.$4); + + var event = document.createEvent("UIEvents"); + event.initUIEvent("input", true, true, aContent, 0); + node.dispatchEvent(event); + } + } + }); +} + +function restoreTextDataAndScrolling(aContent, aData, aPrefix, aTextArray) +{ + restoreTextData(aContent, aPrefix, aTextArray); + if (aData.innerHTML) + { + aContent.setTimeout(function(aHTML) { if (this.document.designMode == "on") { this.document.body.innerHTML = aHTML; } }, 0, aData.innerHTML); + } + if (aData.scroll && /(\d+),(\d+)/.test(aData.scroll)) + { + aContent.scrollTo(RegExp.$1, RegExp.$2); + } + for (var i = 0; i < aContent.frames.length; i++) + { + if (aData.Child && aData.Child[i]) + { + restoreTextDataAndScrolling(aContent.frames[i], aData.Child[i], i + "|" + aPrefix, aTextArray); + } + } +} + +function restoreWindowFeatures(aWindow, aWinData, aOpener) +{ + var hidden = (aWinData.hidden)?aWinData.hidden.split(","):[]; + gWinHidable.forEach(function(aItem) { + aWindow[aItem].visible = hidden.indexOf(aItem) == -1; + }); + + aWindow.setTimeout(restoreDimensions, 0, aWindow, aOpener, aWinData.width || 0, aWinData.height || 0, ("screenX" in aWinData)?aWinData.screenX:NaN, ("screenY" in aWinData)?aWinData.screenY:NaN, aWinData.sizemode || "", aWinData.sidebar || ""); +} + +function restoreDimensions(aWindow, aOpener, aWidth, aHeight, aLeft, aTop, aSizeMode, aSidebar) +{ + function win_(aName) { return getWindowDimension(aWindow, aName); } + + if (aWidth && aHeight && (aWidth != win_("width") || aHeight != win_("height"))) + { + aWindow.resizeTo(aWidth, aHeight); + } + if (!isNaN(aLeft) && !isNaN(aTop) && (aLeft != win_("screenX") || aTop != win_("screenY"))) + { + aWindow.moveTo(aLeft, aTop); + } + if (aSizeMode == "maximized" && win_("sizemode") != "maximized") + { + aWindow.maximize(); + } + else if (aSizeMode && aSizeMode != "maximized" && win_("sizemode") != "normal") + { + aWindow.restore(); + } + var sidebar = aWindow.document.getElementById("sidebar-box"); + if (aWindow.toggleSidebar && sidebar.getAttribute("sidebarcommand") != aSidebar) + { + aWindow.toggleSidebar(aSidebar); + } + else if (aWindow.sidebar_is_hidden && aWindow.sidebar_is_hidden() != !aSidebar) + { + aWindow.SidebarShowHide(); + } + if (aOpener) + { + aOpener.focus(); + } +} + +function restoreCookies(aCookies) +{ + var cookieService = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); + + for (var i = 1; i <= aCookies.count; i++) + { + try + { + cookieService.setCookieString(gIOService.newURI(aCookies["domain" + i], null, null), null, aCookies["value" + i] + "expires=0;", null); + } + catch (ex) { report(ex); } + } +} + +// code adapted from Danil Ivanov's "Cache Fixer" extension +function restoreCache() +{ + var cache = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfLD", Ci.nsILocalFile); + cache.append("Cache"); + cache.append("_CACHE_MAP_"); + if (!cache.exists()) + { + return; + } + + var stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream); + stream.init(cache, 0x01, 0, 0); // PR_RDONLY + var input = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream); + input.setInputStream(stream); + var content = input.readByteArray(input.available()); + input.close(); + + if (content[15] != 1) + { + return; + } + content[15] = 0; + + stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); + stream.init(cache, 0x02 | 0x20, 0600, 0); // PR_WRONLY | PR_TRUNCATE + var output = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(Ci.nsIBinaryOutputStream); + output.setOutputStream(stream); + output.writeByteArray(content, content.length); + output.flush(); + output.close(); +} + +function retryDownloads(aWindow) +{ + var downloadManager = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); + var rdfService = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService); + var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + + var rdfContainer = Cc["@mozilla.org/rdf/container;1"].createInstance(Ci.nsIRDFContainer); + var datasource = downloadManager.datasource; + + try + { + rdfContainer.Init(datasource, rdfService.GetResource("NC:DownloadsRoot")); + } + catch (ex) + { + // SeaMonkey doesn't support saveURL without user interaction, so we stop here + // (it doesn't support downloadManager.datasource, either) + return; + } + + var downloads = rdfContainer.GetElements(); + + while (downloads.hasMoreElements()) + { + var download = downloads.getNext().QueryInterface(Ci.nsIRDFResource); + + var node = datasource.GetTarget(rdfService.GetResource(download.Value), rdfService.GetResource("http://home.netscape.com/NC-rdf#DownloadState"), true); + if (!node || node.QueryInterface(Ci.nsIRDFInt).Value != Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING) + { + continue; + } + + node = datasource.GetTarget(rdfService.GetResource(download.Value), rdfService.GetResource("http://home.netscape.com/NC-rdf#URL"), true).QueryInterface(Ci.nsIRDFResource); + + var url = node.Value; + + node = datasource.GetTarget(rdfService.GetResource(download.Value), rdfService.GetResource("http://home.netscape.com/NC-rdf#File"), true).QueryInterface(Ci.nsIRDFResource); + + var linkChecker = Cc["@mozilla.org/network/urichecker;1"].createInstance(Ci.nsIURIChecker); + + linkChecker.init(ioService.newURI(url, null, null)); + linkChecker.loadFlags = Ci.nsIRequest.LOAD_BACKGROUND; + linkChecker.asyncCheck(new AutoDownloader(url, node.Value, aWindow), null); + } +} + +/* ........ Asynchronous File Downloader .............. */ + +function AutoDownloader(aURL, aFilename, aWindow) +{ + this.mURL = aURL; + this.mFilename = aFilename; + this.mWindow = aWindow; +} + +AutoDownloader.prototype = { + onStartRequest: function(aRequest, aContext) { }, + + onStopRequest: function(aRequest, aContext, aStatus) + { + if (Components.isSuccessCode(aStatus)) + { + var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); + file.initWithPath(this.mFilename); + if (file.exists()) + { + file.remove(false); + } + + this.mWindow.saveURL(this.mURL, this.mFilename, null, true, true, null); + } + } +}; + + +/* :::::::: Timed Session Saving Functionality ::::::::::::::: */ + +function saveStateDelayed(aWindow, aDelay) +{ + if (aWindow) + { + gDirty[aWindow.__CRi] = true; + } + if (!gSaveTimer) + { + aDelay = Math.max(gLastSaveTime - Date.now() + gPrefs.interval, aDelay || Math.min(gPrefs.interval, 2000)); + if (aDelay > 0) + { + gSaveTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + gSaveTimer.init(gSaveStateDelayedObserver, aDelay, Ci.nsITimer.TYPE_ONE_SHOT); + } + else + { + saveState(); + } + } +} + +/*const*/ var gSaveStateDelayedObserver = { + observe: function(aSubject, aTopic, aData) + { + gSaveTimer = null; + saveState(); + } +}; + +function saveState(aUpdateAll) +{ + if (!gLastSaveTime) + { + return; + } + if (gSaveTimer) + { + gSaveTimer.cancel(); + gSaveTimer = null; + } + + gDirty.all = aUpdateAll; + gThreadedSaver.saveCurrentState(aUpdateAll); + gLastSaveTime = Date.now(); +} + +function clearDisk() +{ + delFile(getSessionFile()); + delFile(getSessionFile("bak")); + delFile(getSessionFile("dat.tmp", true)); +} + +function getSessionFile(aExt, aLocal) +{ + var dirs = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); + try + { + var file = dirs.get((!aLocal)?"ProfD":"ProfLD", Ci.nsILocalFile); + } + catch (ex) + { + file = dirs.get("ProfD", Ci.nsILocalFile); + } + file.append("crashrecovery." + (aExt || "dat")); + + return file; +} + +/* ........ Threaded State Saver .............. */ + +/*const*/ var gThreadedSaver = { + saveCurrentState: function(aMainThread) + { + if (this.mThread) + { + try + { + if (Ci.nsIThreadManager) + { + this.mThread.shutdown(); + } + else + { + this.mThread.join(); + } + } + catch (ex) { report(ex); } + this.mThread = null; + } + + this.mState = getCurrentState(); + if (aMainThread) + { + this.run(); + } + else if (Ci.nsIThreadManager) + { + this.mThread = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager).newThread(0); + this.mThread.QueryInterface(Ci.nsIEventTarget).dispatch(this, Ci.nsIEventTarget.DISPATCH_NORMAL) + } + else + { + this.mThread = Cc["@mozilla.org/thread;1"].createInstance(Ci.nsIThread); + this.mThread.init(this, 128 * 1024, Ci.nsIThread.PRIORITY_NORMAL, Ci.nsIThread.SCOPE_GLOBAL, Ci.nsIThread.STATE_JOINABLE); + } + }, + + run: function() + { + var tmpFile = getSessionFile("dat.tmp", true); + writeFile(tmpFile, [ + "; This file will be periodically overwritten by Crash Recovery", + "; Do not edit while the state indicated below is 'running'", + "; The file encoding is UTF-8", + "[CrashRecovery]", + "state=" + ((gLoadState == STATE_RUNNING)?"running":"stopped"), + "date=" + (new Date()).toString(), + encodeINI(this.mState), + "" + ].join("\n").replace(/\n\[/g, "\n$&")); + + var sessionFile = getSessionFile(); + tmpFile.moveTo(sessionFile.parent, sessionFile.leafName); + } +}; + + +/* :::::::: Auxiliary Functions ::::::::::::::: */ + +function forEachBrowserWindow(aFunc) +{ + var windowsEnum = gWindowMediator.getEnumerator("navigator:browser"); + while (windowsEnum.hasMoreElements()) + { + var window = windowsEnum.getNext(); + if (window.__CRi) + { + aFunc(window); + } + } +} + +function getMostRecentBrowserWindow() +{ + return gWindowMediator.getMostRecentWindow("navigator:browser"); +} + +function openWindowWithState(aState) +{ + var argString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString); + argString.data = ""; + + var window = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher).openWindow(null, getPref("browser.chromeURL", null, true), "_blank", "chrome,all,dialog=no", argString); + + window.__CR_state = aState; + window.addEventListener("load", openWindowWithState_onLoad_window, true); +} + +function openWindowWithState_onLoad_window() +{ + this.removeEventListener("load", openWindowWithState_onLoad_window, true); + restoreWindow(this, this.__CR_state, true); + delete this.__CR_state; +} + +function doResumeSession() +{ + return getPref("resume_session") || getPref("resume_session_once") || getPref("browser.startup.page", 1, true) == 3 || getPref("browser.startup.page", 1, true) == 2; +} + +function doRecoverSession(aRepeatedCrash) +{ + if (!getPref("restore_prompt", true)) + { + return true; + } + + var recover = true; + var dontPrompt = { value: false }; + var dialogURI = getPref("restore_prompt_uri"); + + try + { + if (dialogURI) + { + var params = Cc["@mozilla.org/embedcomp/dialogparam;1"].createInstance(Ci.nsIDialogParamBlock); + params.SetInt(0, (aRepeatedCrash)?0:1); + params.SetInt(1, 0); + Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher).openWindow(null, dialogURI, "_blank", "chrome,modal,centerscreen,titlebar,dialog=yes", params); + recover = params.GetInt(0) == 0; + dontPrompt.value = params.GetInt(1); + } + else if (aRepeatedCrash) + { + var strings = getStringBundle("chrome://crashrecovery/locale/crashrecovery.properties"); + var branding = getStringBundle("chrome://branding/locale/brand.properties"); + + recover = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService).confirmCheck(null, "Crash Recovery - " + branding.GetStringFromName("brandFullName"), strings.GetStringFromName("restore_prompt"), strings.GetStringFromName("restore_prompt_again"), dontPrompt); + } + } + catch (ex) { report(ex); } + + if (dontPrompt.value) + { + gPrefBranch.setBoolPref("restore_prompt", false); + } + + return recover; +} + +function isCmdLineEmpty(aWindow) +{ + if (!aWindow.arguments || !aWindow.arguments[0]) + { + return true; + } + + var homepage = "about:blank"; + switch (getPref("browser.startup.page", 1, true)) + { + case 1: + try + { + homepage = gPrefRoot.getComplexValue("browser.startup.homepage", Ci.nsIPrefLocalizedString).data; + } + catch (ex) + { + homepage = getPref("browser.startup.homepage", "", true); + } + homepage = homepage.split("\n")[0]; + break; + case 2: + homepage = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIBrowserHistory).lastPageVisited; + break; + } + + if (aWindow.arguments[0] == homepage) + { + aWindow.arguments[0] = null; + } + + return !aWindow.arguments[0]; +} + +function getWindowDimension(aWindow, aAttribute) +{ + if (aAttribute == "sizemode") + { + return (aWindow.windowState == aWindow.STATE_MAXIMIZED)?"maximized":"normal"; + } + + var equivalents = { width: "outerWidth", height: "outerHeight" }; + var attribute = equivalents[aAttribute] || aAttribute; + var dimension = (attribute in aWindow)?aWindow[attribute]:""; + + if (aWindow.windowState == aWindow.STATE_NORMAL) + { + return dimension; + } + return aWindow.document.documentElement.getAttribute(aAttribute) || dimension; +} + +function checkPrivacyLevel(aURL) +{ + return gPrefs.privacy_level < ((aURL.substr(0, 6) == "https:")?1:2); +} + +function ensureBrowser(aBrowser) +{ + if (aBrowser.localName == "browser") + { + return aBrowser; + } + + var children = aBrowser.childNodes; + for (var i = children.length - 1; i >= 0; i--) + { + if (children[i].localName == "browser") + { + return children[i]; + } + } + + return aBrowser.getElementsByTagName("browser")[0] || null; +} + +function getStringBundle(aURI) +{ + return Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService).createBundle(aURI, Cc["@mozilla.org/intl/nslocaleservice;1"].getService(Ci.nsILocaleService).getApplicationLocale()); +} + + +/* :::::::: Storage API ::::::::::::::: */ + +function getPref(aName, aDefault, aUseRootBranch) +{ + try + { + var pb = (aUseRootBranch)?gPrefRoot:gPrefBranch; + switch (pb.getPrefType(aName)) + { + case pb.PREF_STRING: + return pb.getCharPref(aName); + case pb.PREF_BOOL: + return pb.getBoolPref(aName); + case pb.PREF_INT: + return pb.getIntPref(aName); + } + } + catch (ex) { /* return the default value */ } + + return aDefault; +} + +function readFile(aFile) +{ + if (!aFile.exists()) + { + return null; + } + + var stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream); + stream.init(aFile, 0x01, 0, 0); + var cvstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream); + cvstream.init(stream, "UTF-8", 1024, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); + + var content = ""; + var data = {}; + while (cvstream.readString(4096, data)) + { + content += data.value; + } + cvstream.close(); + + return content.replace(/\r\n?/g, "\n"); +} + +function writeFile(aFile, aData) +{ + var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); + stream.init(aFile, 0x02 | 0x08 | 0x20, 0600, 0); + var cvstream = Cc["@mozilla.org/intl/converter-output-stream;1"].createInstance(Ci.nsIConverterOutputStream); + cvstream.init(stream, "UTF-8", 0, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); + + cvstream.writeString(aData.replace(/\n/g, getEOL())); + cvstream.flush(); + cvstream.close(); +} + +function getEOL() +{ + if (!Ci.nsIXULRuntime) // SeaMonkey + { + return "\r\n"; + } + + var OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS; + return /win|os[\/_]?2/i.test(OS)?"\r\n":/mac/i.test(OS)?"\r":"\n"; +} + +function delFile(aFile) +{ + try + { + if (aFile.exists()) + { + aFile.remove(false); + } + } + catch (ex) { report(ex); } +} + + +/* :::::::: File Format Conversion ::::::::::::::: */ + +function encodeINI(aObj, aPrefix) +{ + aPrefix = (aPrefix)?aPrefix + ".":""; + + var ini = [], iniChildren = []; + + for (var key in aObj) + { + if (!key || /[;\[\]=]/.test(key)) + { + report("Ignoring invalid key name: '" + key + "'!"); + continue; + } + else if (key.charAt(0) == "_") + { + continue; + } + + var value = aObj[key]; + if (typeof value == "boolean" || typeof value == "number") + { + ini.push(key + "=" + value); + } + else if (typeof value == "string" && value) + { + ini.push(key + "=" + ((/^\s|[%\t\r\n;]|\s$/.test(value))?encodeURI(value).replace(/;/g, "%3B"):value)); + } + else if (value instanceof Array) + { + for (var i = 0; i < value.length; i++) + { + if (value[i] instanceof Object) + { + iniChildren.push("[" + aPrefix + key + (i + 1) + "]"); + iniChildren.push(encodeINI(value[i], aPrefix + key + (i + 1))); + } + } + } + else if (typeof value == "object" && value) + { + iniChildren.push("[" + aPrefix + key + "]"); + iniChildren.push(encodeINI(value, aPrefix + key)); + } + } + + return ini.concat(iniChildren).join("\n"); +} + +function decodeINI(aIniString) +{ + if (CR_ini_isOldFormat(aIniString)) + { + return CR_ini_decodeOldFormat(aIniString); + } + + var rootObject = {}; + var obj = rootObject; + var lines = aIniString.split("\n"); + + for (var i = 0; i < lines.length; i++) + { + try + { + if (lines[i].charAt(0) == "[") + { + obj = ini_getObjForHeader(rootObject, lines[i]); + } + else if (lines[i] && lines[i].charAt(0) != ";") + { + ini_setValueForLine(obj, lines[i]); + } + } + catch (ex) + { + throw new Error("Error at line " + (i + 1) + ": " + ex.description); + } + } + + return rootObject; +} + +function ini_getObjForHeader(aObj, aLine) +{ + var names = aLine.split("]")[0].substr(1).split("."); + + for (var i = 0; i < names.length; i++) + { + var name = names[i]; + if (!names[i]) + { + throw new Error("Invalid header: [" + names.join(".") + "]!"); + } + if (/(\d+)$/.test(names[i])) + { + names[i] = names[i].slice(0, -RegExp.$1.length); + var ix = parseInt(RegExp.$1) - 1; + aObj = aObj[names[i]] = aObj[names[i]] || []; + aObj = aObj[ix] = aObj[ix] || {}; + } + else + { + aObj = aObj[names[i]] = aObj[names[i]] || {}; + } + } + + return aObj; +} + +function ini_setValueForLine(aObj, aLine) +{ + var ix = aLine.indexOf("="); + if (ix < 1) + { + throw new Error("Invalid entry: " + aLine + "!"); + } + + var value = aLine.substr(ix + 1); + if (value == "true" || value == "false") + { + value = (value == "true"); + } + else if (/^\d+$/.test(value)) + { + value = parseInt(value); + } + else if (value.indexOf("%") > -1) + { + value = decodeURI(value.replace(/%3B/gi, ";")); + } + + aObj[aLine.substr(0, ix)] = value; +} + +function CR_ini_isOldFormat(aString) +{ + return /^-?\d+.*~~~~/.test(aString); +} + +function CR_ini_decodeOldFormat(aString) +{ + aString = aString.replace(/^(.*?) ~~~~( .*)?/, "$1"); + var root = { CrashRecovery: { state: (RegExp.$2)?"running":"stopped" } }; + + root.Window = aString.split("\n- WINDOW -----\n").map(function(aWindow) { + var winData = {}; + var tabs = aWindow.split("\n-- TAB ----\n"); + var cookies = tabs.shift().split("\n"); + var features = cookies.shift(); + + winData.selected = parseInt(features) + 1; + if (/ dims:(\S+)/.test(features)) + { + RegExp.$1.split(",").forEach(function(aFeat) { + if (/^(\S+)=(.*)/.test(aFeat)) winData[RegExp.$1] = decodeURI(RegExp.$2); + }); + } + if (/ hide:(\S+)/.test(features)) winData.hidden = RegExp.$1; + winData.sidebar = (/ sidebar:(\S+)/.test(features))?RegExp.$1:""; + + cookies.forEach(function(aCookie) { + if (!window.Cookies) window.Cookies = { count: 0 }; + var cookie = aCookie.split(" "); + window.Cookies["domain" + ++window.Cookies.count] = cookie[0]; + window.Cookies["value" + window.Cookies.count] = decodeURI(cookie[1]); + }); + + winData.Tab = tabs.map(CR_ini_decodeOldFormatTab); + + return winData; + }); + + return root; +} + +function CR_ini_decodeOldFormatTab(aTab) +{ + function parseEntry(aTabs, aIx, aPrefix) + { + aPrefix = aPrefix || ""; + var entries = aTabs[aIx].split(" "); + var entry = { + uri: entries[0].substr(aPrefix.length), scroll: entries[1], + postdata: decodeURI(entries[2] || ""), title: decodeURI(entries[3] || ""), + subframe: (entries[4] || "") == "1", Child: [] + }; + + aPrefix += "+"; + while (aTabs[aIx + 1] && aTabs[aIx + 1].substr(0, aPrefix.length) == aPrefix) + { + entry.Child.push(parseEntry(aTabs, aIx + 1, aPrefix)); + aTabs.splice(aIx + 1, 1); + } + + return entry; + } + + var tabData = { Entry: [], index: 0 }; + var tabs = aTab.split("\n"); + if (/^(\d+) zoom:(\S+)/.test(tabs.shift())) + { + tabData.index = parseInt(RegExp.$1) + 1; + tabData.zoom = RegExp.$2; + } + + for (var i = 0; i < tabs.length; i++) + { + if (tabs[i].charAt(0) == "@") break; + tabData.Entry.push(parseEntry(tabs, i)); + } + for (; i < tabs.length; i++) + { + if (/^@(text|xulattr|disallow) (.*)/.test(tabs[i])) + { + tabData[RegExp.$1] = RegExp.$2; + } + } + + return tabData; +} + + +/* :::::::: Service Registration & Initialization ::::::::::::::: */ + +/*const*/ var CrashRecoveryModuleAndFactory = { + +/* ........ nsIModule .............. */ + + getClassObject: function(aCompMgr, aCID, aIID) + { + if (aCID.equals(CrashRecoveryService.mCID)) + { + return this.QueryInterface(aIID); + } + + Components.returnCode = Cr.NS_ERROR_NOT_REGISTERED; + return null; + }, + + registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) + { + aCompMgr.QueryInterface(Ci.nsIComponentRegistrar); + aCompMgr.registerFactoryLocation(CrashRecoveryService.mCID, CrashRecoveryService.mClassName, CrashRecoveryService.mContractID, aFileSpec, aLocation, aType); + + Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).addCategoryEntry("app-startup", CrashRecoveryService.mClassName, "service," + CrashRecoveryService.mContractID, true, true); + }, + + unregisterSelf: function(aCompMgr, aLocation, aType) + { + aCompMgr.QueryInterface(Ci.nsIComponentRegistrar); + aCompMgr.unregisterFactoryLocation(CrashRecoveryService.mCID, aLocation); + + Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).deleteCategoryEntry("app-startup", "service," + CrashRecoveryService.mContractID, true); + }, + + canUnload: function(aCompMgr) + { + return true; + }, + +/* ........ nsIFactory .............. */ + + createInstance: function(aOuter, aIID) + { + if (aOuter != null) + { + Components.returnCode = Cr.NS_ERROR_NO_AGGREGATION; + return null; + } + + return CrashRecoveryService.QueryInterface(aIID); + }, + + lockFactory: function(aLock) { }, + +/* ........ QueryInterface .............. */ + + QueryInterface: function(aIID) + { + if (!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.nsIModule) && !aIID.equals(Ci.nsIFactory)) + { + Components.returnCode = Cr.NS_ERROR_NO_INTERFACE; + return null; + } + + return this; + } +}; + +function NSGetModule(aComMgr, aFileSpec) +{ + return CrashRecoveryModuleAndFactory; +} diff --git a/xpfe/global/jar.mn b/xpfe/global/jar.mn index 6ba5a5f1..4c629d55 100644 --- a/xpfe/global/jar.mn +++ b/xpfe/global/jar.mn @@ -90,6 +90,20 @@ toolkit.jar: content/global/fontpackage.xul (resources/content/fontpackage.xul) content/global/fontpackage.js (resources/content/fontpackage.js) content/global/XPCNativeWrapper.js (resources/content/XPCNativeWrapper.js) + content/global/extensions/sessionmanager/sessionmanager.xul (resources/content/extensions/sessionmanager/sessionmanager.xul) + content/global/extensions/sessionmanager/zzz_closewindow_hack.xul (resources/content/extensions/sessionmanager/zzz_closewindow_hack.xul) + content/global/extensions/sessionmanager/options.xul (resources/content/extensions/sessionmanager/options.xul) + content/global/extensions/sessionmanager/restore_prompt.xul (resources/content/extensions/sessionmanager/restore_prompt.xul) + content/global/extensions/sessionmanager/session_prompt.xul (resources/content/extensions/sessionmanager/session_prompt.xul) + content/global/extensions/sessionmanager/sessionmanager.js (resources/content/extensions/sessionmanager/sessionmanager.js) + content/global/extensions/sessionmanager/options.js (resources/content/extensions/sessionmanager/options.js) + content/global/extensions/sessionmanager/session_prompt.js (resources/content/extensions/sessionmanager/session_prompt.js) + content/global/extensions/sessionmanager/contents.rdf (resources/content/extensions/sessionmanager/contents.rdf) + content/global/extensions/sessionmanager/skin/contents.rdf (resources/content/extensions/sessionmanager/skin/contents.rdf) + content/global/extensions/sessionmanager/skin/dougeeebear.png (resources/content/extensions/sessionmanager/skin/dougeeebear.png) + content/global/extensions/sessionmanager/skin/icon.png (resources/content/extensions/sessionmanager/skin/icon.png) + content/global/extensions/sessionmanager/skin/sessionmanager.css (resources/content/extensions/sessionmanager/skin/sessionmanager.css) + content/global/extensions/sessionmanager/skin/toolbar.png (resources/content/extensions/sessionmanager/skin/toolbar.png) #ifdef MOZ_SVG content/global/svg/svgBindings.xml (/layout/svg/base/src/resources/content/svgBindings.xml) #endif @@ -123,6 +137,10 @@ en-US.jar: locale/en-US/global/fontpackage.dtd (resources/locale/en-US/fontpackage.dtd) locale/en-US/global/fontpackage.properties (resources/locale/en-US/fontpackage.properties) locale/en-US/global/tree.dtd (resources/locale/en-US/tree.dtd) + locale/en-US/global/extensions/sessionmanager/contents.rdf (resources/locale/en-US/extensions/sessionmanager/contents.rdf) + locale/en-US/global/extensions/sessionmanager/options.dtd (resources/locale/en-US/extensions/sessionmanager/options.dtd) + locale/en-US/global/extensions/sessionmanager/sessionmanager.dtd (resources/locale/en-US/extensions/sessionmanager/sessionmanager.dtd) + locale/en-US/global/extensions/sessionmanager/sessionmanager.properties (resources/locale/en-US/extensions/sessionmanager/sessionmanager.properties) US.jar: * locale/US/global-region/contents.rdf (resources/locale/en-US/contents-region.rdf) diff --git a/xpfe/global/resources/content/extensions/sessionmanager/contents.rdf b/xpfe/global/resources/content/extensions/sessionmanager/contents.rdf new file mode 100644 index 00000000..976cdf3f --- /dev/null +++ b/xpfe/global/resources/content/extensions/sessionmanager/contents.rdf @@ -0,0 +1,17 @@ + + + + +
  • + + + + + +
  • + + + +
  • chrome://sessionmanager/content/sessionmanager.xul
  • +
    +
    diff --git a/xpfe/global/resources/content/extensions/sessionmanager/options.js b/xpfe/global/resources/content/extensions/sessionmanager/options.js new file mode 100644 index 00000000..9fd129ea --- /dev/null +++ b/xpfe/global/resources/content/extensions/sessionmanager/options.js @@ -0,0 +1,77 @@ +gSessionManager._onLoad = gSessionManager.onLoad; +gSessionManager.onLoad = function() { + this._onLoad(true); + + var resume_session = _("resume_session"); + var sessions = this.getSessions(); + resume_session.appendItem(this._string("startup_none"), "", ""); + resume_session.appendItem(this._string("startup_prompt"), this.mPromptSessionName, ""); + if (!sessions.some(function(aSession) { return aSession.fileName == this.mBackupSessionName; }, this)) + { + resume_session.appendItem(this._string("startup_resume"), this.mBackupSessionName, ""); + } + sessions.forEach(function(aSession) { + resume_session.appendItem(aSession.name, aSession.fileName, ""); + }); + resume_session.value = _("extensions.sessionmanager.resume_session").value; + + _("SessionManagerPrefs").selectedIndex = _("extensions.sessionmanager.options_selected_tab").value; +}; +gSessionManager.onUnload = function() { + _("extensions.sessionmanager.options_selected_tab").valueFromPreferences = _("SessionManagerPrefs").selectedIndex; +}; + +var _disable = gSessionManager.setDisabled; + +function readMaxClosedUndo() +{ + var value = _("extensions.sessionmanager.max_closed_undo").value; + + _disable(_("save_window_list"), value == 0); + + return value; +} + +function readMaxTabsUndo() +{ + var value = _("extensions.sessionmanager.max_tabs_undo").value; + + _disable(_("save_closed_tabs"), value == 0); + _disable(document.getElementsByAttribute("control", "save_closed_tabs")[0], value == 0); + + return value; +} + +function promptClearUndoList() +{ + var max_tabs_undo = _("max_tabs").value; + + gSessionManager.clearUndoListPrompt(); + + _("max_tabs").value = max_tabs_undo; +}; + +function readInterval() +{ + return _("extensions.crashrecovery.interval").value / 1000; +} + +function writeInterval() +{ + return Math.round(parseFloat(_("interval").value) * 1000 || 0); +} + +function readPrivacyLevel() +{ + var value = _("extensions.crashrecovery.privacy_level").value; + + _disable(_("postdata"), value > 1); + _disable(document.getElementsByAttribute("control", "postdata")[0], value > 1); + + return value; +} + +function _(aId) +{ + return document.getElementById(aId); +} diff --git a/xpfe/global/resources/content/extensions/sessionmanager/options.xul b/xpfe/global/resources/content/extensions/sessionmanager/options.xul new file mode 100644 index 00000000..b553852b --- /dev/null +++ b/xpfe/global/resources/content/extensions/sessionmanager/options.xul @@ -0,0 +1,170 @@ + + + + + %sessionmanagerDTD; + + %optionsDTD; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.js b/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.js new file mode 100644 index 00000000..637517db --- /dev/null +++ b/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.js @@ -0,0 +1,176 @@ +var gParams = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock); +var gSessionList = null; +var gTextBox = null; +var gAcceptButton = null; +var gSessionNames = {}; +var gExistingName = 0; +var gNeedSelection = false; + +gSessionManager._onLoad = gSessionManager.onLoad; +gSessionManager.onLoad = function() { + this._onLoad(true); + + _("mac_title").hidden = !/mac/i.test(navigator.platform); + setDescription(_("session_label"), gParams.GetString(1)); + + gAcceptButton = document.documentElement.getButton("accept"); + gAcceptButton.label = gParams.GetString(2) || gAcceptButton.label; + + var sessions = this.getSessions(); + if (gParams.GetInt(1) & 1) // add a "virtual" current session + { + sessions.unshift({ name: this._string("current_session"), fileName: "*" }); + } + + gSessionList = _("session_list"); + gSessionList.selType = (gParams.GetInt(1) & 2)?"multiple":"single"; + + if (gParams.GetString(4)) // enable text box + { + _("text_container").hidden = false; + setDescription(_("text_label"), gParams.GetString(4)); + gTextBox = _("text_box"); + + sessions.forEach(function(aSession, aIx) { + gSessionNames[aSession.name.trim().toLowerCase()] = aIx + 1; + }); + + onTextboxInput(gParams.GetString(6)); + if (gExistingName && !(gParams.GetInt(1) & 256)) + { + gParams.SetString(3, sessions[gExistingName - 1].fileName); + gTextBox.value = ""; + onTextboxInput(); + } + } + if (gParams.GetInt(1) & 4) // show the "Don't show [...] again" checkbox + { + _("checkbox_container").hidden = false; + } + + sessions.forEach(function(aSession) { + var item = gSessionList.appendItem(aSession.name, aSession.fileName); + if (aSession.fileName == gParams.GetString(3)) + { + setTimeout(function(aItem) { gSessionList.selectItem(aItem); }, 0, item); + } + }); + + if ((gNeedSelection = !gTextBox || !gParams.GetString(5)) || (gParams.GetInt(1) & 256)) // when no textbox or renaming + { + gSessionList.addEventListener("select", onListboxSelect, false); + onListboxSelect(); + } + + // add accessibility shortcuts (single-click / double-click / return) + for (var i = 0; i < gSessionList.childNodes.length; i++) + { + gSessionList.childNodes[i].setAttribute("ondblclick", "if (event.button == 0 && !event.ctrlKey && !event.shiftKey && !event.altKey) gAcceptButton.doCommand();"); + if (gTextBox && !(gParams.GetInt(1) & 256)) + { + gSessionList.childNodes[i].setAttribute("onclick", "if (event.button == 0 && !event.ctrlKey && !event.shiftKey && !event.altKey) onTextboxInput(gSessionList.childNodes[gSessionList.selectedIndex].label);"); + } + } + if (gTextBox) + { + gSessionList.setAttribute("onkeypress", "if (event.keyCode == event.DOM_VK_RETURN && this.selectedIndex > -1) { event.button = 0; eval(this.selectedItem.getAttribute('onclick')); event.preventDefault(); }"); + } + + if (gSessionList.hasAttribute("height")) + { + gSessionList.height = gSessionList.getAttribute("height"); + } + if (!window.opener) + { + document.documentElement.removeAttribute("screenX"); + document.documentElement.removeAttribute("screenY"); + } + window.sizeToContent(); + + gParams.SetInt(0, 1); +}; + +gSessionManager.onUnload = function() { + function persist(aObj, aAttr, aValue) + { + aObj.setAttribute(aAttr, aValue); + document.persist(aObj.id, aAttr); + } + + if (window.opener) + { + persist(document.documentElement, "screenX", window.screenX - window.opener.screenX); + persist(document.documentElement, "screenY", window.screenY - window.opener.screenY); + } + persist(gSessionList, "height", gSessionList.boxObject.height); + + gParams.SetInt(1, (_("checkbox").checked)?1:0); +}; + +function onListboxSelect() +{ + if (!gTextBox) + { + gAcceptButton.disabled = gSessionList.selectedCount == 0; + } + else + { + onTextboxInput(); + } +} + +function onTextboxInput(aNewValue) +{ + if (aNewValue) + { + gTextBox.value = aNewValue; + setTimeout(function() { gTextBox.select(); gTextBox.focus(); }, 0); + } + + var input = gTextBox.value.trim().toLowerCase(); + var oldWeight = !!gAcceptButton.style.fontWeight; + + gExistingName = gSessionNames[input] || 0; + var newWeight = gExistingName || ((gParams.GetInt(1) & 256) && gSessionList.selectedCount > 0); + + if (!gNeedSelection && oldWeight != newWeight) + { + gAcceptButton.label = (newWeight)?gParams.GetString(5):gParams.GetString(2); + gAcceptButton.style.fontWeight = (newWeight)?"bold":""; + } + gAcceptButton.disabled = !input || gNeedSelection && (gSessionList.selectedCount == 0 || gExistingName); +} + +function onAcceptDialog() +{ + gParams.SetInt(0, 0); + if (gNeedSelection || ((gParams.GetInt(1) & 256) && gSessionList.selectedCount > 0)) + { + gParams.SetString(3, gSessionList.selectedItems.map(function(aItem) { return aItem.value || ""; }).join("\n")); + } + else if (gExistingName) + { + gParams.SetString(3, gSessionList.childNodes[gExistingName - 1].value); + } + else + { + gParams.SetString(3, ""); + } + gParams.SetString(6, _("text_box").value.trim()); +} + +String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " "); +}; + +function setDescription(aObj, aValue) +{ + aValue.split("\n").forEach(function(aLine) { + aObj.appendChild(document.createElement("description")).setAttribute("value", aLine); + }); +} + +function _(aId) +{ + return document.getElementById(aId); +} diff --git a/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.xul b/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.xul new file mode 100644 index 00000000..9d393d3b --- /dev/null +++ b/xpfe/global/resources/content/extensions/sessionmanager/session_prompt.xul @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/xpfe/global/resources/locale/en-US/extensions/sessionmanager/contents.rdf b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/contents.rdf new file mode 100644 index 00000000..c077efe6 --- /dev/null +++ b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/contents.rdf @@ -0,0 +1,19 @@ + + + + +
  • + + + + + +
  • + + + + diff --git a/xpfe/global/resources/locale/en-US/extensions/sessionmanager/options.dtd b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/options.dtd new file mode 100644 index 00000000..30617aac --- /dev/null +++ b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/options.dtd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.dtd b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.dtd new file mode 100644 index 00000000..a9ac3b81 --- /dev/null +++ b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.dtd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.properties b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.properties new file mode 100644 index 00000000..e14cffb5 --- /dev/null +++ b/xpfe/global/resources/locale/en-US/extensions/sessionmanager/sessionmanager.properties @@ -0,0 +1,41 @@ +extensions.{1280606b-2510-4fe0-97ef-9b5a22eafe30}.description=Saves and restores the state of all windows. + +sessionManager = Session Manager + +save_session = Save the current browsing session as: +save_window = Save the current window as: +save2_session = Double-click an existing session to replace it: +save_session_ok = Save Session +save_window_ok = Save Window +save_session_ok2 = Replace Session + +rename_session = Which session do you want to rename? +rename2_session = Rename that session to: +rename_session_ok = Rename + +remove_session = Which session(s) do you want to delete? +remove_session_ok = Delete + +recover_session = Your current browsing session crashed. Which session do you want to recover? +recover_session_ok = Recover Session + +resume_session = Which session do you want to resume? +resume_session_ok = Resume Session + +preserve_session = Do you want to preserve this session for resuming? + +current_session = [ Current Browsing Session ] +backup_session = [ Previous Browsing Session ] +crashed_session = [ Crashed Session (%d %m) ] +old_backup_session = [ Older Browsing Session (%d %m) ] + +startup_none = < None (load the homepage) > +startup_prompt = < Prompt for a session > +startup_resume = < Previous Browsing Session > + +untitled_window = (Untitled) + +clear_list_prompt = Do you really want to clear the list of recently closed windows and tabs? + +io_error = This operation failed due to a file access error:\n%S +unknown_error = unknown error diff --git a/xpinstall/packager/win_gre/config.ini b/xpinstall/packager/win_gre/config.ini index 3b6fda68..125ddab6 100644 --- a/xpinstall/packager/win_gre/config.ini +++ b/xpinstall/packager/win_gre/config.ini @@ -142,7 +142,7 @@ Show Dialog=TRUE ;*** LOCALIZE ME BABY *** Title=GRE Setup - Welcome ;*** LOCALIZE ME BABY *** -Message0=Welcome to %s Setup. You are about to install %s version 1.0.0.0000000000. +Message0=Welcome to %s Setup. You are about to install %s version 1.1.0.0000000000. ;*** LOCALIZE ME BABY *** Message1=It is strongly recommended that you exit all Windows programs before running this Setup program. ;*** LOCALIZE ME BABY *** @@ -655,7 +655,7 @@ Timing=post smartupdate Root Key=HKEY_LOCAL_MACHINE Key=[REGPATH]\Uninstall Name=Description -Name Value=GRE (1.0) +Name Value=GRE (1.1) Type=REG_SZ Decrypt Key=TRUE Decrypt Name=FALSE diff --git a/xpinstall/packager/win_gre/gre.js b/xpinstall/packager/win_gre/gre.js index 5b78dfc9..db97d4e5 100644 --- a/xpinstall/packager/win_gre/gre.js +++ b/xpinstall/packager/win_gre/gre.js @@ -191,7 +191,7 @@ function registerMainKeys(winreg) subkey = regRootKey + "\\Uninstall"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Uninstall Log Folder", fProgram + "Uninstall"); - err = winreg.setValueString(subkey, "Description", "GRE (1.0)"); + err = winreg.setValueString(subkey, "Description", "GRE (1.1)"); } // main @@ -210,7 +210,7 @@ var regRootKey; regRootKey = new String(Install.arguments); srDest = 1; -err = initInstall("GRE", "GRE", "1.0.0.0000000000"); +err = initInstall("GRE", "GRE", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); diff --git a/xpinstall/packager/win_gre/xpcom.js b/xpinstall/packager/win_gre/xpcom.js index 07a2b389..99b184d9 100644 --- a/xpinstall/packager/win_gre/xpcom.js +++ b/xpinstall/packager/win_gre/xpcom.js @@ -116,7 +116,7 @@ var fileMsvcrt; var fileMsvcirt; srDest = 1; -err = initInstall("Mozilla XPCOM", "XPCOM", "1.0.0.0000000000"); +err = initInstall("Mozilla XPCOM", "XPCOM", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -137,7 +137,7 @@ if(verifyDiskSpace(fProgram, srDest)) upgradeCleanup(); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram @@ -156,7 +156,7 @@ if(verifyDiskSpace(fProgram, srDest)) { logComment("File not found: " + fileMsvcrt); addFile("/Microsoft/Shared/msvcrt.dll", - "1.0.0.0000000000", + "1.1.0.0000000000", "msvcrt.dll", // dir name in jar to extract fWindowsSystem, // Where to put this file (Returned from getFolder) "", // subdir name to create relative to fProgram @@ -178,7 +178,7 @@ if(verifyDiskSpace(fProgram, srDest)) { logComment("File not found: " + fileMsvcirt); addFile("/Microsoft/Shared/msvcirt.dll", - "1.0.0.0000000000", + "1.1.0.0000000000", "msvcirt.dll", // dir name in jar to extract fWindowsSystem, // Where to put this file (Returned from getFolder) "", // subdir name to create relative to fProgram diff --git a/xpinstall/packager/windows/browser.js b/xpinstall/packager/windows/browser.js index dbc2c917..b215c002 100644 --- a/xpinstall/packager/windows/browser.js +++ b/xpinstall/packager/windows/browser.js @@ -105,12 +105,12 @@ function registerProgramFolderKey(winreg, fFolderPath) subkey = "SOFTWARE\\RetroZilla\\RetroZilla"; winreg.createKey(subkey,""); - err = winreg.setValueString(subkey, "CurrentVersion", "1.0 (en)"); + err = winreg.setValueString(subkey, "CurrentVersion", "1.1 (en)"); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)"; winreg.createKey(subkey,""); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Program Folder Path", fFolderPath); } @@ -219,7 +219,7 @@ function createShortcuts() } logComment("folderQuickLaunchExists: " + folderQuickLaunchExists); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; fFolderPathStr = winreg.getValueString(subkey, "Program Folder Path"); if((fFolderPathStr == "") || (fFolderPathStr == null)) { @@ -293,7 +293,7 @@ function createShortcuts() fileDelete(fFolderPath); } - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Setup"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Setup"; regvalue = winreg.getValueString(subkey, "browserargs"); /* log this so if the user turns on turbo mode in the browser the uninstaller will undo it */ @@ -366,12 +366,12 @@ function registerMainKeys(winreg) subkey = "SOFTWARE\\RetroZilla\\RetroZilla"; winreg.createKey(subkey,""); - err = winreg.setValueString(subkey, "CurrentVersion", "1.0 (en)"); + err = winreg.setValueString(subkey, "CurrentVersion", "1.1 (en)"); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)"; winreg.createKey(subkey,""); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Install Directory", fProgram); @@ -379,20 +379,20 @@ function registerMainKeys(winreg) // The following keys are required to be created to supply information // about the location of the Gecko Embedded Client to 3rd party apps. // "SOFTWARE\\Mozilla" must not be localized! - subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.0"; + subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.1"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "GeckoVer", "$GreVersion$"); - subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.0\\Extensions"; + subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.1\\Extensions"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Components", fProgram + "Components"); err = winreg.setValueString(subkey, "Plugins", fProgram + "Plugins"); - subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.0\\bin"; + subkey = "SOFTWARE\\Mozilla\\RetroZilla 1.1\\bin"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "PathToExe", fProgram + "RetroZilla.exe"); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; err = winreg.setValueString(subkey, "PathToExe", fProgram + "RetroZilla.exe"); // Register as a windows XP internet browser @@ -416,7 +416,7 @@ function registerMainKeys(winreg) data = "\"" + fProgram + "RetroZilla.exe\""; winreg.setValueString(subkey + "\\shell\\open\\command", "", data); - data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.0 (en)\" /hs browser"; + data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.1 (en)\" /hs browser"; winreg.setValueString(subkey + "\\InstallInfo", "HideIconsCommand", data); winreg.setValueNumber(subkey + "\\InstallInfo", "IconsVisible", 1); @@ -424,7 +424,7 @@ function registerMainKeys(winreg) data = "\"" + fProgram + "RetroZilla.exe\" -silent -nosplash -setDefaultBrowser "; winreg.setValueString(subkey + "\\InstallInfo", "ReinstallCommand", data); - data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.0 (en)\" /ss browser"; + data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.1 (en)\" /ss browser"; winreg.setValueString(subkey + "\\InstallInfo", "ShowIconsCommand", data); } } @@ -725,7 +725,7 @@ if(args == "-greLocal") gGreLocal = true; srDest = 1; -err = initInstall("RetroZilla", "Browser", "1.0.0.0000000000"); +err = initInstall("RetroZilla", "Browser", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -738,7 +738,7 @@ if(verifyDiskSpace(fProgram, srDest)) upgradeCleanup(); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram @@ -830,7 +830,7 @@ if(verifyDiskSpace(fProgram, srDest)) if (! ('buildID' in Install)) { logComment("Running Pre-Mozilla 0.9.1"); - initInstall("Post-install Cleanup Utility", "Browser/xpicleanup", "1.0.0.0000000000"); + initInstall("Post-install Cleanup Utility", "Browser/xpicleanup", "1.1.0.0000000000"); cleanupUtility = getFolder(fProgram, "xpicleanup.exe"); err = File.execute(cleanupUtility); logComment("execute() returned: " + err); diff --git a/xpinstall/packager/windows/chatzilla.js b/xpinstall/packager/windows/chatzilla.js index 89e922ba..4db1c409 100644 --- a/xpinstall/packager/windows/chatzilla.js +++ b/xpinstall/packager/windows/chatzilla.js @@ -95,7 +95,7 @@ function getPlatform() return platformNode; } -var err = initInstall("Chatzilla v0.5", "Chatzilla", "1.0.0.0000000000"); +var err = initInstall("Chatzilla v0.5", "Chatzilla", "1.1.0.0000000000"); logComment("initInstall: " + err); addFile("Chatzilla service", diff --git a/xpinstall/packager/windows/config.ini b/xpinstall/packager/windows/config.ini index 687ea1d0..5f271d7e 100644 --- a/xpinstall/packager/windows/config.ini +++ b/xpinstall/packager/windows/config.ini @@ -10,7 +10,7 @@ Run Mode=Normal Company Name=RetroZilla Product Name=RetroZilla Product NameInternal=RetroZilla -User Agent=1.0 (en) +User Agent=1.1 (en) ; Destination Path values: ; PROGRAMFILESDIR @@ -188,7 +188,7 @@ Show Dialog=TRUE ;*** LOCALIZE ME BABY *** Title=RetroZilla Setup - Welcome ;*** LOCALIZE ME BABY *** -Message0=Welcome to %s Setup. You are about to install %s version 1.0.0.0000000000. +Message0=Welcome to %s Setup. You are about to install %s version 1.1.0.0000000000. ;*** LOCALIZE ME BABY *** Message1=It is strongly recommended that you exit all Windows programs before running this Setup program. ;*** LOCALIZE ME BABY *** @@ -618,7 +618,7 @@ Install Size System=1 Install Size Archive=1 Attributes=SELECTED|UNCOMPRESS|SUPERSEDE|LAUNCHAPP|INVISIBLE ;*** LOCALIZE ME BABY *** -Parameter=-mmi -ms -app "RetroZilla 1.0 (en)" -app_path "[SETUP PATH]\RetroZilla.exe" +Parameter=-mmi -ms -app "RetroZilla 1.1 (en)" -app_path "[SETUP PATH]\RetroZilla.exe" SupersedeType=GRE SupersedeWinReg0=HKEY_LOCAL_MACHINE\Software\mozilla.org\GRE SupersedeVersion0=0.0.0.0 @@ -1025,7 +1025,7 @@ Timing=pre smartupdate [Windows Registry2] Root Key=HKEY_LOCAL_MACHINE ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en) +Key=Software\RetroZilla\RetroZilla\1.1 (en) Name= Name Value= Type=REG_SZ @@ -1039,7 +1039,7 @@ Timing=pre smartupdate [Windows Registry3] Root Key=HKEY_LOCAL_MACHINE ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Main +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Main Name=Program Folder Path Name Value=[Default Folder] Type=REG_SZ @@ -1053,9 +1053,9 @@ Timing=pre smartupdate [Windows Registry4] Root Key=HKEY_LOCAL_MACHINE ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Uninstall +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Uninstall Name=Description -Name Value=RetroZilla (1.0) +Name Value=RetroZilla (1.1) Type=REG_SZ Decrypt Key=FALSE Decrypt Name=FALSE @@ -1067,7 +1067,7 @@ Timing=pre smartupdate [Windows Registry5] Root Key=HKEY_LOCAL_MACHINE ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Uninstall +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Uninstall Name=Uninstall Log Folder Name Value=[SETUP PATH]\uninstall Type=REG_SZ @@ -1109,7 +1109,7 @@ Timing=pre smartupdate [Windows Registry8] Root Key=HKEY_CURRENT_USER ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en) +Key=Software\RetroZilla\RetroZilla\1.1 (en) Name= Name Value= Type=REG_SZ @@ -1123,7 +1123,7 @@ Timing=pre smartupdate [Windows Registry9] Root Key=HKEY_CURRENT_USER ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Main +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Main Name=Program Folder Path Name Value=[Default Folder] Type=REG_SZ @@ -1137,9 +1137,9 @@ Timing=pre smartupdate [Windows Registry10] Root Key=HKEY_CURRENT_USER ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Uninstall +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Uninstall Name=Description -Name Value=RetroZilla (1.0) +Name Value=RetroZilla (1.1) Type=REG_SZ Decrypt Key=FALSE Decrypt Name=FALSE @@ -1151,7 +1151,7 @@ Timing=pre smartupdate [Windows Registry11] Root Key=HKEY_CURRENT_USER ;*** LOCALIZE ME BABY *** -Key=Software\RetroZilla\RetroZilla\1.0 (en)\Uninstall +Key=Software\RetroZilla\RetroZilla\1.1 (en)\Uninstall Name=Uninstall Log Folder Name Value=[SETUP PATH]\uninstall Type=REG_SZ @@ -1164,9 +1164,9 @@ Timing=pre smartupdate [Windows Registry12] Root Key=HKEY_LOCAL_MACHINE -Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\RetroZilla (1.0) +Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\RetroZilla (1.1) Name=DisplayName -Name Value=RetroZilla (1.0) +Name Value=RetroZilla (1.1) Type=REG_SZ Decrypt Key=FALSE Decrypt Name=FALSE @@ -1177,10 +1177,10 @@ Timing=post smartupdate [Windows Registry13] Root Key=HKEY_LOCAL_MACHINE -Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\RetroZilla (1.0) +Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\RetroZilla (1.1) Name=UninstallString ;*** LOCALIZE ME BABY *** -Name Value=[WINDIR]\retrozillaUninstall.exe /ua "1.0 (en)" +Name Value=[WINDIR]\retrozillaUninstall.exe /ua "1.1 (en)" Type=REG_SZ Decrypt Key=FALSE Decrypt Name=FALSE @@ -1208,12 +1208,12 @@ Timing=pre smartupdate Reg Key Root0=HKEY_LOCAL_MACHINE Product Name0=RetroZilla Product Reg Key0=Software\RetroZilla\RetroZilla -Current Version0=1.0 (en) +Current Version0=1.1 (en) Reg Key Root1=HKEY_CURRENT_USER Product Name1=RetroZilla Product Reg Key1=Software\RetroZilla\RetroZilla -Current Version1=1.0 (en) +Current Version1=1.1 (en) @@ -1249,7 +1249,7 @@ Program Folder=[Default Folder] [Program Folder0-Shortcut0] File=[SETUP PATH]\uninstall\retrozillaUninstall.exe -Arguments=/ua "1.0 (en)" +Arguments=/ua "1.1 (en)" Working Dir=[SETUP PATH] Description=Uninstall RetroZilla Icon Path=[SETUP PATH]\uninstall\retrozillaUninstall.exe diff --git a/xpinstall/packager/windows/deflenus.js b/xpinstall/packager/windows/deflenus.js index 49254bd5..b140ef97 100644 --- a/xpinstall/packager/windows/deflenus.js +++ b/xpinstall/packager/windows/deflenus.js @@ -106,7 +106,7 @@ var regName = "defaults/mozilla/en-US"; // --- END CHANGABLE STUFF --- srDest = 1; -err = initInstall(prettyName, regName, "1.0.0.0000000000"); +err = initInstall(prettyName, regName, "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -117,7 +117,7 @@ if(verifyDiskSpace(fProgram, srDest)) setPackageFolder(fProgram); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram diff --git a/xpinstall/packager/windows/inspector.js b/xpinstall/packager/windows/inspector.js index 1ddf48db..375f5af1 100644 --- a/xpinstall/packager/windows/inspector.js +++ b/xpinstall/packager/windows/inspector.js @@ -95,13 +95,13 @@ function getPlatform() return platformNode; } -var err = initInstall("DOM Inspector", "Inspector", "1.0.0.0000000000"); +var err = initInstall("DOM Inspector", "Inspector", "1.1.0.0000000000"); logComment("initInstall: " + err); var fProgram = getFolder("Program"); logComment("fProgram: " + fProgram); -err = addDirectory("", "1.0.0.0000000000", "bin", fProgram, "", true); +err = addDirectory("", "1.1.0.0000000000", "bin", fProgram, "", true); logComment("addDirectory: " + err); addFile("Inspector Command Line Handler", diff --git a/xpinstall/packager/windows/langenus.js b/xpinstall/packager/windows/langenus.js index bdc2aa14..fbe42713 100644 --- a/xpinstall/packager/windows/langenus.js +++ b/xpinstall/packager/windows/langenus.js @@ -117,7 +117,7 @@ var platformName = langcode + "-" + platformNode + ".jar"; var localeName = "locale/" + chromeNode + "/"; srDest = 1; -err = initInstall(prettyName, regName, "1.0.0.0000000000"); +err = initInstall(prettyName, regName, "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); diff --git a/xpinstall/packager/windows/mail.js b/xpinstall/packager/windows/mail.js index 744777d9..e033d6c5 100644 --- a/xpinstall/packager/windows/mail.js +++ b/xpinstall/packager/windows/mail.js @@ -128,12 +128,12 @@ function registerProgramFolderKey(winreg, fFolderPath) subkey = "SOFTWARE\\RetroZilla\\RetroZilla"; winreg.createKey(subkey,""); - err = winreg.setValueString(subkey, "CurrentVersion", "1.0 (en)"); + err = winreg.setValueString(subkey, "CurrentVersion", "1.1 (en)"); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)"; winreg.createKey(subkey,""); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Program Folder Path", fFolderPath); } @@ -256,7 +256,7 @@ function createShortcuts() } logComment("folderQuickLaunchExists: " + folderQuickLaunchExists); - subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.0 (en)\\Main"; + subkey = "SOFTWARE\\RetroZilla\\RetroZilla\\1.1 (en)\\Main"; fFolderPathStr = winreg.getValueString(subkey, "Program Folder Path"); if((fFolderPathStr == "") || (fFolderPathStr == null)) { @@ -351,7 +351,7 @@ function createShortcuts() data = "\"" + fProgram + "RetroZilla.exe\" -mail"; winreg.setValueString(subkey + "\\shell\\open\\command", "", data); - data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.0 (en)\" /hs mail"; + data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.1 (en)\" /hs mail"; winreg.setValueString(subkey + "\\InstallInfo", "HideIconsCommand", data); // set this value to 0 because we're not creating the mail shortcuts yet. @@ -360,7 +360,7 @@ function createShortcuts() data = "\"" + fProgram + "RetroZilla.exe\" -silent -nosplash -setDefaultMail"; winreg.setValueString(subkey + "\\InstallInfo", "ReinstallCommand", data); - data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.0 (en)\" /ss mail"; + data = "\"" + fProgram + "uninstall\\retrozillaUninstall.exe\" /ua \"1.1 (en)\" /ss mail"; winreg.setValueString(subkey + "\\InstallInfo", "ShowIconsCommand", data); } } @@ -407,7 +407,7 @@ function updateMapi() // uninstaller already has a special way to deal with restoring the // appropriate previous Mapi32.dll. addFile("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin/mozMapi32.dll", // file name in jar to extract getFolder("Win System"), // Where to put this file (Returned from getFolder) "Mapi32.dll", // new name when installed @@ -473,7 +473,7 @@ var err; var fProgram; srDest = 1; -err = initInstall("RetroZilla Mail", "Mail", "1.0.0.0000000000"); +err = initInstall("RetroZilla Mail", "Mail", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -485,7 +485,7 @@ if(verifyDiskSpace(fProgram, srDest)) upgradeCleanup(); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram diff --git a/xpinstall/packager/windows/regus.js b/xpinstall/packager/windows/regus.js index a66b0999..96beca27 100644 --- a/xpinstall/packager/windows/regus.js +++ b/xpinstall/packager/windows/regus.js @@ -112,7 +112,7 @@ var chromeName = chromeNode + ".jar"; var localeName = "locale/" + chromeNode + "/"; srDest = 1; -err = initInstall(prettyName, regName, "1.0.0.0000000000"); +err = initInstall(prettyName, regName, "1.1.0.0000000000"); logComment("initInstall: " + err); if (platformNode == 'mac') diff --git a/xpinstall/packager/windows/reporter.js b/xpinstall/packager/windows/reporter.js index 1cbe4c38..1297bf05 100644 --- a/xpinstall/packager/windows/reporter.js +++ b/xpinstall/packager/windows/reporter.js @@ -95,7 +95,7 @@ function getPlatform() return platformNode; } -var err = initInstall("Website Reporter", "Reporter", "1.0.0.0000000000"); +var err = initInstall("Website Reporter", "Reporter", "1.1.0.0000000000"); logComment("initInstall: " + err); var fProgram = getFolder("Program"); @@ -104,7 +104,7 @@ var srDest = 1; if (verifyDiskSpace(fProgram, srDest)) { - err = addDirectory("", "1.0.0.0000000000", "bin", fProgram, "", true); + err = addDirectory("", "1.1.0.0000000000", "bin", fProgram, "", true); logComment("addDirectory: " + err); var jarFolder = getFolder("Chrome", "reporter.jar"); diff --git a/xpinstall/packager/windows/spellcheck.js b/xpinstall/packager/windows/spellcheck.js index ecbed001..38beacf6 100644 --- a/xpinstall/packager/windows/spellcheck.js +++ b/xpinstall/packager/windows/spellcheck.js @@ -97,7 +97,7 @@ function getPlatform() var srDest = 1; -var err = initInstall("RetroZilla Myspell Spellchecker", "Spellchecker", "1.0.0.0000000000"); +var err = initInstall("RetroZilla Myspell Spellchecker", "Spellchecker", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -108,7 +108,7 @@ if (verifyDiskSpace(fProgram, srDest)) setPackageFolder(fProgram); addDirectory("Spellchecker", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", fProgram, ""); diff --git a/xpinstall/packager/windows/sroaming.js b/xpinstall/packager/windows/sroaming.js index ee5ad5cc..8354c14d 100644 --- a/xpinstall/packager/windows/sroaming.js +++ b/xpinstall/packager/windows/sroaming.js @@ -95,13 +95,13 @@ function getPlatform() return platformNode; } -var err = initInstall("SRoaming v0.1", "Roaming", "1.0.0.0000000000"); +var err = initInstall("SRoaming v0.1", "Roaming", "1.1.0.0000000000"); logComment("initInstall: " + err); var fProgram = getFolder("Program"); logComment("fProgram: " + fProgram); -err = addDirectory("", "1.0.0.0000000000", "bin", fProgram, "", true); +err = addDirectory("", "1.1.0.0000000000", "bin", fProgram, "", true); logComment("addDirectory: " + err); addFile("SRoaming Chrome", diff --git a/xpinstall/packager/windows/talkback.js b/xpinstall/packager/windows/talkback.js index 46aa5847..763d4fa6 100644 --- a/xpinstall/packager/windows/talkback.js +++ b/xpinstall/packager/windows/talkback.js @@ -108,7 +108,7 @@ var err; var communicatorFolder; srDest = 1; -err = initInstall("Quality Feedback Utility", "Quality Feedback Utility", "1.0.0.0000000000"); +err = initInstall("Quality Feedback Utility", "Quality Feedback Utility", "1.1.0.0000000000"); logComment("initInstall: " + err); communicatorFolder = getFolder("Communicator"); @@ -120,7 +120,7 @@ if(verifyDiskSpace(communicatorFolder, srDest)) upgradeCleanup(); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract communicatorFolder, // Where to put this file (Returned from getFolder) "", // subdir name to create relative to communicatorFolder diff --git a/xpinstall/packager/windows/venkman.js b/xpinstall/packager/windows/venkman.js index f50174e8..5f959661 100644 --- a/xpinstall/packager/windows/venkman.js +++ b/xpinstall/packager/windows/venkman.js @@ -95,7 +95,7 @@ function getPlatform() return platformNode; } -var err = initInstall("JavaScript Debugger", "Venkman", "1.0.0.0000000000"); +var err = initInstall("JavaScript Debugger", "Venkman", "1.1.0.0000000000"); logComment("initInstall: " + err); addFile("Venkman Service", diff --git a/xpinstall/packager/windows/xpcom.js b/xpinstall/packager/windows/xpcom.js index 07a2b389..99b184d9 100644 --- a/xpinstall/packager/windows/xpcom.js +++ b/xpinstall/packager/windows/xpcom.js @@ -116,7 +116,7 @@ var fileMsvcrt; var fileMsvcirt; srDest = 1; -err = initInstall("Mozilla XPCOM", "XPCOM", "1.0.0.0000000000"); +err = initInstall("Mozilla XPCOM", "XPCOM", "1.1.0.0000000000"); logComment("initInstall: " + err); fProgram = getFolder("Program"); @@ -137,7 +137,7 @@ if(verifyDiskSpace(fProgram, srDest)) upgradeCleanup(); err = addDirectory("", - "1.0.0.0000000000", + "1.1.0.0000000000", "bin", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram @@ -156,7 +156,7 @@ if(verifyDiskSpace(fProgram, srDest)) { logComment("File not found: " + fileMsvcrt); addFile("/Microsoft/Shared/msvcrt.dll", - "1.0.0.0000000000", + "1.1.0.0000000000", "msvcrt.dll", // dir name in jar to extract fWindowsSystem, // Where to put this file (Returned from getFolder) "", // subdir name to create relative to fProgram @@ -178,7 +178,7 @@ if(verifyDiskSpace(fProgram, srDest)) { logComment("File not found: " + fileMsvcirt); addFile("/Microsoft/Shared/msvcirt.dll", - "1.0.0.0000000000", + "1.1.0.0000000000", "msvcirt.dll", // dir name in jar to extract fWindowsSystem, // Where to put this file (Returned from getFolder) "", // subdir name to create relative to fProgram