bug 341971 - Adds AUS update checking to Sunbird. r=ctalbert, jminta, ui-r=mvl

This commit is contained in:
mattwillis%gmail.com 2006-11-27 04:51:20 +00:00
Родитель 015f043c53
Коммит a19827ce0e
11 изменённых файлов: 341 добавлений и 18 удалений

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* Matthew Willis <lilmatt@mozilla.com>
* Jeff Walden <jwalden+code@mit.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -49,6 +50,10 @@ var gAdvancedPane = {
return;
}
advancedPrefs.selectedIndex = preference.value;
this.updateAppUpdateItems();
this.updateAutoItems();
this.updateModeItems();
},
tabSelectionChanged: function advPaneTabSelectionChanged() {
@ -60,6 +65,8 @@ var gAdvancedPane = {
preference.valueFromPreferences = advancedPrefs.selectedIndex;
},
// GENERAL TAB
showConnections: function advPaneShowConnections() {
var url = "chrome://calendar/content/preferences/connection.xul";
document.documentElement.openSubDialog(url, "", "chrome,dialog");
@ -71,6 +78,9 @@ var gAdvancedPane = {
"", null);
},
// PASSWORDS TAB
/**
* Caches the security module service for multiple use.
*/
@ -181,14 +191,162 @@ var gAdvancedPane = {
"", null);
},
// UPDATE TAB
/**
* The Extensions checkbox and button are disabled only if the enable
* Addon update preference is locked.
* Preferences:
*
* app.update.enabled
* - true if updates to the application are enabled, false otherwise
* extensions.update.enabled
* - true if updates to extensions and themes are enabled, false otherwise
* app.update.auto
* - true if updates should be automatically downloaded and installed,
* possibly with a warning if incompatible extensions are installed (see
* app.update.mode); false if the user should be asked what he wants to
* do when an update is available
* app.update.mode
* - an integer:
* 0 do not warn if an update will disable extensions or themes
* 1 warn if an update will disable extensions or themes
* 2 warn if an update will disable extensions or themes *or* if
* the update is a major update
*/
/**
* Enables and disables various UI preferences as necessary to reflect
* locked, disabled, and checked/unchecked states.
*
* UI state matrix for update preference conditions
*
* UI Elements: Preferences
* 1 = Sunbird checkbox i = app.update.enabled
* 2 = When updates for Sunbird are found label ii = app.update.auto
* 3 = Automatic Radiogroup (Ask vs. Auto) iii = app.update.mode
* 4 = Warn before disabling add-ons checkbox
*
* States:
* Element Disabled Pref Value Locked
* 1 false i t/f f
* true i t/f t
* false ii t/f t/f
* false iii 0/1/2 t/f
* 2,3 false i t t/f
* true i f t/f
* false ii t/f f
* true ii t/f t
* false iii 0/1/2 t/f
* 4 false i t t/f
* true i f t/f
* false ii t t/f
* true ii f t/f
* false iii 0/1/2 f
* true iii 0/1/2 t
*
*/
updateAppUpdateItems: function advPaneUpdateAppUpdateItems() {
var aus = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIApplicationUpdateService);
var enabledPref = document.getElementById("app.update.enabled");
var enableAppUpdate = document.getElementById("enableAppUpdate");
enableAppUpdate.disabled = !aus.canUpdate || enabledPref.locked;
},
/**
* Enables/disables UI for "when updates are found" based on the values,
* and "locked" states of associated preferences.
*/
updateAutoItems: function advPaneUpdateAutoItems() {
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var updateModeLabel = document.getElementById("updateModeLabel");
var updateMode = document.getElementById("updateMode");
var disable = enabledPref.locked || !enabledPref.value ||
autoPref.locked;
updateMode.disabled = disable;
updateModeLabel.disabled = updateMode.disabled;
},
/**
* Enables/disables the "warn if incompatible add-ons exist" UI based on
* the values and "locked" states of various preferences.
*/
updateModeItems: function advPaneUpdateModeItems() {
var enabledPref = document.getElementById("app.update.enabled");
var autoPref = document.getElementById("app.update.auto");
var modePref = document.getElementById("app.update.mode");
var warnIncompatible = document.getElementById("warnIncompatible");
var disable = enabledPref.locked || !enabledPref.value ||
autoPref.locked || !autoPref.value || modePref.locked;
warnIncompatible.disabled = disable;
},
/**
* The Add-ons checkbox and button are disabled only if the enable
* add-on update preference is locked.
*/
updateAddonUpdateUI: function advPaneUpdateAddonUpdateUI() {
var enabledPref = document.getElementById("extensions.update.enabled");
var enableAddonUpdate = document.getElementById("enableAddonUpdate");
var enabledPref = document.getElementById("extensions.update.enabled");
var enableAddonUpdate = document.getElementById("enableAddonUpdate");
enableAddonUpdate.disabled = enabledPref.locked;
enableAddonUpdate.disabled = enabledPref.locked;
},
/**
* Stores the value of the app.update.mode preference, which is a tristate
* integer preference. We store the value here so that we can properly
* restore the preference value if the UI reflecting the preference value
* is in a state which can represent either of two integer values (as
* opposed to only one possible value in the other UI state).
*/
_modePreference: -1,
/**
* Reads the app.update.mode preference and converts its value into a
* true/false value for use in determining whether the "Warn me if this
* will disable any of my add-ons" checkbox is checked. We also save the
* value of the preference so that the preference value can be properly
* restored if the user's preferences cannot adequately be expressed by a
* single checkbox.
*
* app.update.mode Checkbox State Meaning
* 0 Unchecked Do not warn
* 1 Checked Warn if there are incompatibilities
* 2 Checked Warn if there are incompatibilities,
* or the update is major.
*/
readAddonWarn: function advPaneReadAddonWarn() {
var preference = document.getElementById("app.update.mode");
var warnMe = preference.value != 0;
this._modePreference = warnMe ? preference.value : 1;
return warnMe;
},
/**
* Converts the state of the "Warn me if this will disable any of my
* add-ons" checkbox into the integer preference which represents it,
* returning that value.
*/
writeAddonWarn: function advPaneWriteAddonWarn() {
var warnIncompatible = document.getElementById("warnIncompatible");
return warnIncompatible.checked ? this._modePreference : 0;
},
/**
* Displays the history of installed updates.
*/
showUpdates: function advPaneShowUpdates() {
var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
.createInstance(Components.interfaces.nsIUpdatePrompt);
prompter.showUpdateHistory(window);
}
};

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

@ -21,6 +21,7 @@
-
- Contributor(s):
- Matthew Willis <lilmatt@mozilla.com>
- Jeff Walden <jwalden+code@mit.edu>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -60,16 +61,38 @@
<preference id="calendar.preferences.advanced.selectedTabIndex"
name="calendar.preferences.advanced.selectedTabIndex"
type="int"/>
<!-- Passwords tab -->
<preference id="signon.rememberSignons"
name="signon.rememberSignons"
type="bool"/>
<preference id="pref.privacy.disable_button.view_passwords"
name="pref.privacy.disable_button.view_passwords"
type="bool"/>
<!-- Advanced tab -->
<preference id="app.update.enabled"
name="app.update.enabled"
type="bool"
onchange="gAdvancedPane.updateAppUpdateItems();
gAdvancedPane.updateAutoItems();
gAdvancedPane.updateModeItems();"/>
<preference id="extensions.update.enabled"
name="extensions.update.enabled"
type="bool"
onchange="gAdvancedPane.updateAddonUpdateUI();"/>
<preference id="app.update.auto"
name="app.update.auto"
type="bool"
onchange="gAdvancedPane.updateAutoItems();
gAdvancedPane.updateModeItems();"/>
<preference id="app.update.mode"
name="app.update.mode"
type="int"
onchange="gAdvancedPane.updateModeItems();"/>
<preference id="app.update.disable_button.showUpdateHistory"
name="app.update.disable_button.showUpdateHistory"
type="bool"/>
</preferences>
<tabbox id="advancedPrefs"
@ -138,15 +161,53 @@
</tabpanel>
<!-- Update -->
<tabpanel orient="vertical" align="start">
<!-- This is indented like this so we don't hose cvs blame
- when we add the rest of the aus stuff. -->
<vbox class="indent">
<checkbox id="enableAddonUpdate"
label="&pref.calendar.advanced.update.enableAddonUpdate.label;"
accesskey="&pref.calendar.advanced.update.enableAddonUpdate.accesskey;"
preference="extensions.update.enabled"/>
</vbox>
<tabpanel id="updatePanel" orient="vertical" align="start">
<label control="autoUpdateGroup">&pref.calendar.advanced.update.autoCheck.label;</label>
<vbox id="autoUpdateGroup" class="indent">
<checkbox id="enableAppUpdate"
label="&brandShortName;"
accesskey="&pref.calendar.advanced.update.enableAppUpdate.accesskey;"
preference="app.update.enabled"/>
<checkbox id="enableAddonUpdate"
label="&pref.calendar.advanced.update.enableAddonsUpdate.label;"
accesskey="&pref.calendar.advanced.update.enableAddonsUpdate.accesskey;"
preference="extensions.update.enabled"/>
</vbox>
<separator id="updateSeparator1"/>
<label id="updateModeLabel"
control="updateMode">&pref.calendar.advanced.update.whenUpdatesFound.label;</label>
<radiogroup id="updateMode"
class="indent"
preference="app.update.auto">
<radio id="ask"
value="false"
label="&pref.calendar.advanced.update.modeAskMe.label;"
accesskey="&pref.calendar.advanced.update.modeAskMe.accesskey;"/>
<radio id="automatic"
value="true"
label="&pref.calendar.advanced.update.modeAuto.label;"
accesskey="&pref.calendar.advanced.update.modeAuto.accesskey;"/>
<hbox class="indent">
<checkbox id="warnIncompatible"
label="&pref.calendar.advanced.update.modeAutoWarn.label;"
accesskey="&pref.calendar.advanced.update.modeAutoWarn.accesskey;"
preference="app.update.mode"
onsyncfrompreference="return gAdvancedPane.readAddonWarn();"
onsynctopreference="return gAdvancedPane.writeAddonWarn();"/>
</hbox>
</radiogroup>
<separator id="updateSeparator2"/>
<hbox>
<button id="showUpdateHistory"
label="&pref.calendar.advanced.update.showHistory.label;"
accesskey="&pref.calendar.advanced.update.showHistory.accesskey;"
preference="app.update.disable_button.showUpdateHistory"
oncommand="gAdvancedPane.showUpdates();"/>
</hbox>
</tabpanel>
</tabpanels>
</tabbox>

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

@ -246,6 +246,7 @@ bin\chrome\toolkit.manifest
; [Default Preferences]
; All the pref files must be part of base to prevent migration bugs
bin\defaults\pref\sunbird.js
bin\defaults\pref\channel-prefs.js
bin\greprefs\all.js
bin\greprefs\security-prefs.js
bin\greprefs\xpinstall.js

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

@ -258,6 +258,8 @@
<!ENTITY releaseCmd.accesskey "R">
<!ENTITY aboutCmd.label "About &brandFullName;">
<!ENTITY aboutCmd.accesskey "A">
<!ENTITY updateCmd.label "Check for Updates…">
<!ENTITY updateCmd.accesskey "o">
<!-- Mac OS X "Window" menu items -->
<!ENTITY windowMenu.label "Window">

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

@ -60,5 +60,16 @@
<!ENTITY pref.calendar.advanced.viewPasswords.accesskey "V">
<!-- Update -->
<!ENTITY pref.calendar.advanced.update.enableAddonUpdate.label "Automatically check for updates to installed Add-ons">
<!ENTITY pref.calendar.advanced.update.enableAddonUpdate.accesskey "A">
<!ENTITY pref.calendar.advanced.update.autoCheck.label "Automatically check for updates to:">
<!ENTITY pref.calendar.advanced.update.enableAppUpdate.accesskey "r">
<!ENTITY pref.calendar.advanced.update.enableAddonsUpdate.label "Installed Add-ons">
<!ENTITY pref.calendar.advanced.update.enableAddonsUpdate.accesskey "n">
<!ENTITY pref.calendar.advanced.update.whenUpdatesFound.label "When updates to &brandShortName; are found:">
<!ENTITY pref.calendar.advanced.update.modeAskMe.label "Ask me what I want to do">
<!ENTITY pref.calendar.advanced.update.modeAskMe.accesskey "k">
<!ENTITY pref.calendar.advanced.update.modeAuto.label "Automatically download and install the update">
<!ENTITY pref.calendar.advanced.update.modeAuto.accesskey "d">
<!ENTITY pref.calendar.advanced.update.modeAutoWarn.label "Warn me if this will disable any of my add-ons">
<!ENTITY pref.calendar.advanced.update.modeAutoWarn.accesskey "W">
<!ENTITY pref.calendar.advanced.update.showHistory.label "Show Update History…">
<!ENTITY pref.calendar.advanced.update.showHistory.accesskey "U">

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

@ -0,0 +1,4 @@
; This file is in the UTF-8 encoding
[Strings]
Title=Software Update
Info=Sunbird is installing your updates and will start in a few moments...

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

@ -453,3 +453,22 @@ function sbOnViewToolbarCommand(aEvent)
document.persist(toolbar.id, "collapsed");
}
/**
* Checks for available updates using AUS
*/
function sbCheckForUpdates()
{
var um = Components.classes["@mozilla.org/updates/update-manager;1"]
.getService(Components.interfaces.nsIUpdateManager);
var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
.createInstance(Components.interfaces.nsIUpdatePrompt);
// If there's an update ready to be applied, show the "Update Downloaded"
// UI instead and let the user know they have to restart the application
// for the changes to be applied.
if (um.activeUpdate && um.activeUpdate.state == "pending") {
prompter.showUpdateDownloaded(um.activeUpdate);
} else {
prompter.checkForUpdates();
}
}

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

@ -47,7 +47,10 @@ include $(DEPTH)/config/autoconf.mk
DIRS = profile/extensions
PREF_JS_EXPORTS = $(srcdir)/profile/sunbird.js
PREF_JS_EXPORTS = \
$(srcdir)/profile/sunbird.js \
$(srcdir)/profile/channel-prefs.js \
$(NULL)
# hardcode en-US for the moment
AB_CD = en-US

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

@ -0,0 +1,2 @@
#filter substitution
pref("app.update.channel", "@MOZ_UPDATE_CHANNEL@");

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

@ -75,7 +75,63 @@ pref("xpinstall.whitelist.add.103", "addons.mozilla.org");
// App-specific update preferences
pref("app.update.enabled", false);
// Whether or not app updates are enabled
pref("app.update.enabled", true);
// This preference turns on app.update.mode and allows automatic download and
// install to take place. We use a separate boolean toggle for this to make
// the UI easier to construct.
pref("app.update.auto", true);
// Defines how the Application Update Service notifies the user about updates:
//
// AUS Set to: Minor Releases: Major Releases:
// 0 download no prompt download no prompt
// 1 download no prompt download no prompt if no incompatibilities
// 2 download no prompt prompt
//
// See chart in nsUpdateService.js.in for more details
//
pref("app.update.mode", 1);
// If set to true, the Update Service will present no UI for any event.
pref("app.update.silent", false);
// Update service URLs:
pref("app.update.url", "https://aus2.mozilla.org/update/2/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/update.xml");
// URL user can browse to manually if for some reason all update installation
// attempts fail.
pref("app.update.url.manual", "http://www.mozilla.org/projects/calendar/sunbird/");
// A default value for the "More information about this update" link
// supplied in the "An update is available" page of the update wizard.
pref("app.update.url.details", "http://www.mozilla.org/projects/calendar/sunbird/");
// User-settable override to app.update.url for testing purposes.
//pref("app.update.url.override", "");
// Interval: Time between checks for a new version (in seconds)
// default=1 day
pref("app.update.interval", 86400);
// Interval: Time before prompting the user to download a new version that
// is available (in seconds) default=1 day
pref("app.update.nagTimer.download", 86400);
// Interval: Time before prompting the user to restart to install the latest
// download (in seconds) default=30 minutes
pref("app.update.nagTimer.restart", 1800);
// Interval: When all registered timers should be checked (in milliseconds)
// default=5 minutes
pref("app.update.timer", 600000);
// Whether or not we show a dialog box informing the user that the update was
// successfully applied.
pref("app.update.showInstalledUI", true);
// 0 = suppress prompting for incompatibilities if there are updates available
// to newer versions of installed addons that resolve them.
// 1 = suppress prompting for incompatibilities only if there are VersionInfo
// updates available to installed addons that resolve them, not newer
// versions.
pref("app.update.incompatible.mode", 0);
// Symmetric (can be overridden by individual extensions) update preferences.
// e.g.

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

@ -470,6 +470,12 @@
<menuitem accesskey="&releaseCmd.accesskey;"
label="&releaseCmd.label;"
oncommand="openReleaseNotes();"/>
<menuseparator id="menu_HelpUpdatesSeparator"/>
<menuitem id="checkForUpdates"
class="menuitem-iconic"
label="&updateCmd.label;"
accesskey="&updateCmd.accesskey;"
oncommand="sbCheckForUpdates();"/>
# On Mac OS X, the "About Sunbird" menuitem belongs under the "Sunbird" menu.
# We hide it (and its separator) here, but we don't ifdef the entire menuitem