From 8994961c859601bd9893c99a88037df0c30c24db Mon Sep 17 00:00:00 2001 From: aurimasv Date: Thu, 7 Nov 2013 05:33:39 -0600 Subject: [PATCH 1/3] Add "Check for Update" button to error alert when DB version is newer --- chrome/content/zotero/xpcom/zotero.js | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 217993525..589b439e4 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -639,6 +639,56 @@ Components.utils.import("resource://gre/modules/Services.jsm"); + Zotero.getString('startupError.zoteroVersionIsOlder.current', Zotero.version) + "\n\n" + Zotero.getString('general.seeForMoreInformation', kbURL); Zotero.startupError = msg; + _startupErrorHandler = function() { + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_OK) + + ps.BUTTON_POS_0_DEFAULT; + + var index = ps.confirmEx(null, "", Zotero.startupError, buttonFlags, + Zotero.getString('general.checkForUpdate'), null, null, + null, {}); + + // "Check for updates" button + if(index === 0) { + if(Zotero.isStandalone) { + ZoteroStandalone.checkForUpdates(); + } else { + // In Firefox, show the add-on manager + Components.utils.import("resource://gre/modules/AddonManager.jsm"); + AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'], + function (addon) { + // Disable auto-update so that the user is presented with the option + var initUpdateState = addon.applyBackgroundUpdates; + addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; + addon.findUpdates({ + onNoUpdateAvailable: function() { + ps.alert(null, '', Zotero.getString('zotero.preferences.update.upToDate')); + }, + onUpdateAvailable: function() { + // Show available update + Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow('navigator:browser') + .BrowserOpenAddonsMgr('addons://updates/available'); + }, + onUpdateFinished: function() { + // Restore add-on auto-update state, but don't fire + // too quickly or the update will not show in the + // add-on manager + setTimeout(function() { + addon.applyBackgroundUpdates = initUpdateState; + }, 1000); + } + }, + AddonManager.UPDATE_WHEN_USER_REQUESTED + ); + } + ); + } + } + }; } else { Zotero.startupError = Zotero.getString('startupError.databaseUpgradeError') + "\n\n" + e; From 8c3cf11df1bfee0c6b8c9a5347888a7296e3fbc1 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Thu, 7 Nov 2013 20:55:07 -0600 Subject: [PATCH 2/3] Open update wizard in Standalone --- chrome/content/zotero/xpcom/zotero.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 589b439e4..1060f605d 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -653,7 +653,10 @@ Components.utils.import("resource://gre/modules/Services.jsm"); // "Check for updates" button if(index === 0) { if(Zotero.isStandalone) { - ZoteroStandalone.checkForUpdates(); + Components.classes["@mozilla.org/embedcomp/window-watcher;1"] + .getService(Components.interfaces.nsIWindowWatcher) + .openWindow(null, 'chrome://mozapps/content/update/updates.xul', + 'updateChecker', 'chrome,centerscreen', null); } else { // In Firefox, show the add-on manager Components.utils.import("resource://gre/modules/AddonManager.jsm"); From 8e52dcca42c656bb252c792f08a2452d69053a49 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 13 Nov 2013 00:31:45 -0500 Subject: [PATCH 3/3] Tweak the text a bit in #410 --- chrome/content/zotero/xpcom/zotero.js | 19 ++++++++++++++----- chrome/locale/en-US/zotero/zotero.properties | 4 +++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 1060f605d..4e677a021 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -643,12 +643,17 @@ Components.utils.import("resource://gre/modules/Services.jsm"); var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_OK) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL) + ps.BUTTON_POS_0_DEFAULT; - var index = ps.confirmEx(null, "", Zotero.startupError, buttonFlags, - Zotero.getString('general.checkForUpdate'), null, null, - null, {}); + var index = ps.confirmEx( + null, + Zotero.getString('general.error'), + Zotero.startupError, + buttonFlags, + Zotero.getString('general.checkForUpdate'), + null, null, null, {} + ); // "Check for updates" button if(index === 0) { @@ -667,7 +672,11 @@ Components.utils.import("resource://gre/modules/Services.jsm"); addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; addon.findUpdates({ onNoUpdateAvailable: function() { - ps.alert(null, '', Zotero.getString('zotero.preferences.update.upToDate')); + ps.alert( + null, + Zotero.getString('general.noUpdatesFound'), + Zotero.getString('general.isUpToDate', 'Zotero') + ); }, onUpdateAvailable: function() { // Show available update diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 9f999aff1..5d62311b0 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -20,10 +20,12 @@ general.tryAgainLater = Please try again in a few minutes. general.serverError = The server returned an error. Please try again. general.restartFirefox = Please restart %S. general.restartFirefoxAndTryAgain = Please restart %S and try again. -general.checkForUpdate = Check for update +general.checkForUpdate = Check for Update general.actionCannotBeUndone = This action cannot be undone. general.install = Install general.updateAvailable = Update Available +general.noUpdatesFound = No Updates Found +general.isUpToDate = %S is up to date. general.upgrade = Upgrade general.yes = Yes general.no = No