From 3e26c36b69f7ca754223863a7f8560bb5fc4d597 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 20 Jul 2011 03:48:17 +0000 Subject: [PATCH] Use Zotero.startupError for connector-related errors and use the DB busy error if Zotero switched to connector mode and then couldn't contact the connector. --- chrome/content/zotero/overlay.js | 12 +++---- .../xpcom/connector/connector_firefox.js | 32 +++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 0f7c8312f..6018de863 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -178,7 +178,12 @@ var ZoteroOverlay = new function() * Hides/displays the Zotero interface */ this.toggleDisplay = function(makeVisible) - { + { + if(!Zotero || !Zotero.initialized) { + ZoteroPane.displayStartupError(); + return; + } + if(makeVisible || makeVisible === undefined) { if(Zotero.isConnector) { // If in connector mode, bring Zotero Standalone to foreground @@ -191,11 +196,6 @@ var ZoteroOverlay = new function() } } - if(!Zotero || !Zotero.initialized) { - ZoteroPane.displayStartupError(); - return; - } - if(makeVisible === undefined) makeVisible = zoteroPane.hidden || zoteroPane.collapsed; zoteroSplitter.setAttribute('hidden', !makeVisible); diff --git a/chrome/content/zotero/xpcom/connector/connector_firefox.js b/chrome/content/zotero/xpcom/connector/connector_firefox.js index 37f320f43..75849c3b1 100644 --- a/chrome/content/zotero/xpcom/connector/connector_firefox.js +++ b/chrome/content/zotero/xpcom/connector/connector_firefox.js @@ -24,23 +24,29 @@ */ Zotero.Connector_Browser = new function() { - var _incompatibleVersionMessageShown; - /** * Called if Zotero version is determined to be incompatible with Standalone */ this.onIncompatibleStandaloneVersion = function(zoteroVersion, standaloneVersion) { - if(_incompatibleVersionMessageShown) return; - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. - createInstance(Components.interfaces.nsIPromptService); - ps.alert(null, - Zotero.getString("connector.error.title"), - 'Zotero '+zoteroVersion+' is incompatible with the running '+ + Zotero.startupError = 'Zotero for Firefox '+Zotero.version+' is incompatible with the running '+ 'version of Zotero Standalone'+(standaloneVersion ? " ("+standaloneVersion+")" : "")+ - '. Zotero Connector will continue to operate, but functionality that relies upon '+ - 'Zotero Standalone may be unavaliable.\n\n'+ - 'Please ensure that you have installed the latest version of these components. See '+ - 'http://www.zotero.org/support/standalone for more details.'); - _incompatibleVersionMessageShown = true; + '.\n\nPlease ensure that you have installed the latest version of these components. See '+ + 'http://www.zotero.org/support/standalone for more details.'; + Zotero.initialized = false; + } + + /** + * Called if connector is offline. This should only happen if Zotero is getting a DB busy + * message and no connector is open, so use the DB busy error message here. + */ + this.onStateChange = function(isOnline) { + if(isOnline) return; + + var msg = Zotero.localeJoin([ + Zotero.getString('startupError.databaseInUse'), + Zotero.getString(Zotero.isStandalone ? 'startupError.closeFirefox' : 'startupError.closeStandalone') + ]); + Zotero.startupError = msg; + Zotero.initialized = false; } } \ No newline at end of file