Start adding some nicer error messages

This commit is contained in:
ben%bengoodger.com 2005-06-24 23:52:42 +00:00
Родитель 1249e5b34d
Коммит 6e37d41b47
9 изменённых файлов: 115 добавлений и 50 удалений

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

@ -482,12 +482,16 @@ function buildHelpMenu()
label = strings.getString("updates_resumeDownloadingFallback");
}
}
var checkForUpdates = document.getElementById("checkForUpdates");
checkForUpdates.label = label;
if (um.activeUpdate && updates.isDownloading)
checkForUpdates.setAttribute("loading", "true");
else
checkForUpdates.removeAttribute("loading");
// Disable the UI if the update enabled pref has been locked by the
// administrator.
checkForUpdates.disabled = gPrefService.prefIsLocked("app.update.enabled");
}

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

@ -93,27 +93,28 @@ var gAdvancedPane = {
updateAppUpdateUI: function ()
{
var preference = document.getElementById("app.update.autoUpdateEnabled");
var ids = ["enableAutoInstall", "autoInstallMode", "updateAnd"];
if (!preference.value)
for (var i = 0; i < ids.length; ++i)
document.getElementById(ids[i]).disabled = true;
else {
document.getElementById("enableAutoInstall").disabled = false;
this.updateAutoInstallUI();
}
var preference = document.getElementById("app.update.enabled");
document.getElementById("enableAutoInstall").disabled = !preference.value;
this.updateAutoInstallUI();
return undefined;
},
updateAutoInstallUI: function ()
{
var preference = document.getElementById("app.update.autoInstallEnabled");
var autoInstallPref = document.getElementById("app.update.autoInstallEnabled");
var updateEnabledPref = document.getElementById("app.update.enabled");
var ids = ["autoInstallMode", "updateAnd"];
var disabled = !updateEnabledPref.value || !autoInstallPref.value;
for (var i = 0; i < ids.length; ++i)
document.getElementById(ids[i]).disabled = !preference.value;
document.getElementById(ids[i]).disabled = disabled;
return undefined;
},
checkForAddonUpdates: function ()
{
goats
},
checkForUpdates: function ()
{
var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]

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

@ -81,15 +81,6 @@
<preference id="security.disable_button.openDeviceManager"
name="security.disable_button.openDeviceManager"
type="bool"/>
<preference id="pref.update.disable_button.update_app"
name="pref.update.disable_button.update_app"
type="bool"/>
<preference id="pref.update.disable_button.show_updates"
name="pref.update.disable_button.show_updates"
type="bool"/>
<preference id="pref.update.disable_button.update_addons"
name="pref.update.disable_button.update_addons"
type="bool"/>
</preferences>
<script type="application/x-javascript" src="chrome://browser/content/preferences/advanced.js"/>
@ -172,10 +163,9 @@
<hbox>
<button label="&checkNow.label;" accesskey="&appCheckNow.accesskey;"
oncommand="gAdvancedPane.checkForUpdates();"
preference="pref.update.disable_button.update_app"/>
preference="app.update.enabled"/>
<button label="&showUpdates.label;" accesskey="&showUpdates.accesskey;"
oncommand="gAdvancedPane.showUpdates();"
preference="pref.update.disable_button.show_updates"/>
oncommand="gAdvancedPane.showUpdates();"/>
</hbox>
</vbox>
</vbox>
@ -190,8 +180,8 @@
<separator class="thin"/>
<hbox class="indent">
<button label="&checkNow.label;" accesskey="&extensionsCheckNow.accesskey;"
oncommand="gAdvancedPane.checkForUpdates(Components.interfaces.nsIUpdateItem.TYPE_ADDON);"
preference="pref.update.disable_button.update_addons"/>
oncommand="gAdvancedPane.checkForAddonUpdates();"
preference="extensions.update.autoUpdateEnabled"/>
</hbox>
</vbox>
</vbox>

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

@ -48,8 +48,8 @@
<!ENTITY close.label "Close">
<!ENTITY close.accesskey "C">
<!ENTITY error.label "There were problems installing this update. &brandShortName; could
not be updated because:">
<!ENTITY error.label "There were problems checking for, downloading or installing this
update. &brandShortName; could not be updated because:">
<!ENTITY errorManual.label "You can update &brandShortName; manually by visiting this link
and downloading the latest version:">

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

@ -48,3 +48,10 @@ resumePausedAfterCloseTitle=Software Update
resumePausedAfterCloseMessage=You have paused downloading this update. Do you want %S to download the update in the background while you continue to browse?
updateReadyToInstallHeader=%S Ready to Install
checker_error-200=AUS: Update XML File Malformed (200)
checker_error-403=AUS: Access Denied (403)
checker_error-404=AUS: Update XML File Not Found (404)
checker_error-500=AUS: Internal Server Error (500)
checker_error-2152398878=AUS: Update Server Not Found (Contact your Administrator)

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

@ -132,5 +132,6 @@ wizard[currentpageid="updatesfound"] .wizard-page-box {
margin-bottom: 2px;
-moz-margin-start: 6px !important;
-moz-margin-end: 5px;
font-weight: bold;
}

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

@ -352,7 +352,7 @@ var gCheckingPage = {
updateListener: {
/**
* See nsIUpdateCheckListener.idl
* See nsIUpdateCheckListener
*/
onProgress: function(request, position, totalSize) {
var pm = document.getElementById("checkingProgress");
@ -361,9 +361,9 @@ var gCheckingPage = {
},
/**
* See nsIUpdateCheckListener.idl
* See nsIUpdateCheckListener
*/
onCheckComplete: function(updates, updateCount) {
onCheckComplete: function(request, updates, updateCount) {
var aus = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIApplicationUpdateService);
gUpdates.update = aus.selectUpdate(updates, updates.length);
@ -378,10 +378,33 @@ var gCheckingPage = {
},
/**
* See nsIUpdateCheckListener.idl
* See nsIUpdateCheckListener
*/
onError: function() {
LOG("UI:CheckingPage", "UpdateCheckListener: ERROR");
onError: function(request) {
LOG("UI:CheckingPage", "UpdateCheckListener: error");
try {
var status = request.status;
}
catch (e) {
var req = request.channel.QueryInterface(Components.interfaces.nsIRequest);
status = req.status;
}
var sbs =
Components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService);
var updateBundle = sbs.createBundle(URI_UPDATES_PROPERTIES);
var reason = updateBundle.GetStringFromName("checker_error-200");
try {
reason = updateBundle.GetStringFromName("checker_error-" + status);
}
catch (e) {
// If we can't find an error string specific to this status code,
// just use the 200 message from above, which means everything
// "looks" fine but there was probably an XML error or a bogus file.
}
gUpdates.advanceToErrorPage(reason);
},
/**

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

@ -43,6 +43,7 @@ interface nsIRequest;
interface nsIRequestObserver;
interface nsISimpleEnumerator;
interface nsITimerCallback;
interface nsIXMLHttpRequest;
[scriptable, uuid(56863a67-bd69-42de-9f40-583e625b457d)]
interface nsIUpdatePatch : nsISupports
@ -167,22 +168,38 @@ interface nsIUpdate : nsISupports
interface nsIUpdateCheckListener : nsISupports
{
/**
*
* Called every time there is a progress notification loading the Update
* Service file.
* @param request
* The nsIXMLHttpRequest handling the update check.
* @param position
* The current byte downloaded
* @param totalSize
* The total number of bytes that have to be downloaded
*/
void onProgress(in nsIRequest request,
void onProgress(in nsIXMLHttpRequest request,
in unsigned long position,
in unsigned long totalSize);
/**
*
* The update check was completed.
* @param request
* The nsIXMLHttpRequest handling the update check.
* @param updates
* An array of nsIUpdate objects listing available updates.
* @param updateCount
* The size of the |updates| array.
*/
void onCheckComplete([array, size_is(updateCount)] in nsIUpdate updates,
void onCheckComplete(in nsIXMLHttpRequest request,
[array, size_is(updateCount)] in nsIUpdate updates,
in unsigned long updateCount);
/**
*
* An error occurred while loading the remote update service file.
* @param request
* The nsIXMLHttpRequest handling the update check.
*/
void onError();
void onError(in nsIXMLHttpRequest request);
};
[scriptable, uuid(22b00276-ec23-4034-a764-395da539b4be)]

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

@ -499,11 +499,25 @@ UpdateService.prototype = {
var self = this;
var listener = {
onProgress: function() { },
onCheckComplete: function(updates, updateCount) {
/**
* See nsIUpdateService.idl
*/
onProgress: function(request, position, totalSize) {
},
/**
* See nsIUpdateService.idl
*/
onCheckComplete: function(request, updates, updateCount) {
self._selectAndInstallUpdate(updates);
},
onError: function() { },
/**
* See nsIUpdateService.idl
*/
onError: function(request) {
LOG("Checker", "Error during background update");
},
}
this.backgroundChecker.checkForUpdates(listener, false);
},
@ -1194,7 +1208,7 @@ Checker.prototype = {
if (updatesElement.nodeName != "updates") {
LOG("Checker", "get_updates: unexpected node name!");
return [];
throw "";
}
var updates = [];
@ -1222,12 +1236,20 @@ Checker.prototype = {
this.observer.onLoad(event.target);
// Analyze the resulting DOM and determine the set of updates to install
var updates = this._updates;
LOG("Checker", "Updates available: " + updates.length);
// ... and tell the Update Service about what we discovered.
this._callback.onCheckComplete(updates, updates.length);
try {
var updates = this._updates;
LOG("Checker", "Updates available: " + updates.length);
// ... and tell the Update Service about what we discovered.
this._callback.onCheckComplete(event.target, updates, updates.length);
}
catch (e) {
LOG("Checker", "There was a problem with the update service URL specified, " +
"either the XML file was malformed or it does not exist at the location " +
"specified");
this._callback.onError(event.target);
}
},
/**