From b08b54ba838ff8ee331389b0d9e5388620637b1c Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 7 Aug 2011 23:37:51 +0000 Subject: [PATCH] Add some documentation on the connector switching process --- chrome/content/zotero/xpcom/ipc.js | 22 ++++++++++++++++++++++ chrome/content/zotero/xpcom/zotero.js | 4 ---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js index 3c0d7d3b4b..107b3d8355 100755 --- a/chrome/content/zotero/xpcom/ipc.js +++ b/chrome/content/zotero/xpcom/ipc.js @@ -49,16 +49,38 @@ Zotero.IPC = new function() { if(!msg) continue; Zotero.debug('IPC: Received "'+msg+'"'); + /* + * The below messages coordinate switching Zotero for Firefox from extension mode to + * connector mode without restarting after Zotero Standalone has been launched. The + * dance typically proceeds as follows: + * + * 1. SA sends a releaseLock message to Z4Fx that tells it to release its lock. + * 2. Z4Fx releases its lock and sends a lockReleased message to SA. + * 3. Z4Fx restarts in connector mode. Once it's ready for an IPC command, it sends + * a checkInitComplete message to SA. + * 4. Once SA finishes initializing, or immediately after a checkInitComplete message + * has been received if it is already initialized, SA sends an initComplete message + * to Z4Fx. + */ if(msg === "releaseLock" && !Zotero.isConnector) { + // Standalone sends this to the Firefox extension to tell the Firefox extension to + // release its lock on the Zotero database switchConnectorMode(true); } else if(msg === "lockReleased") { + // The Firefox extension sends this to Standalone to let Standalone know that it has + // released its lock Zotero.onDBLockReleased(); } else if(msg === "checkInitComplete") { + // The Firefox extension sends this to Standalone to tell Standalone to send an + // initComplete message when it is fully initialized while(!Zotero.initialized) { Zotero.mainThread.processNextEvent(true) } Zotero.IPC.broadcast("initComplete"); } else if(msg === "initComplete") { + // Standalone sends this to the Firefox extension to let the Firefox extension + // know that Standalone has fully initialized and it should pull the list of + // translators Zotero.onInitComplete(); } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 00d7cc8f80..f2a1f0ca45 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -185,10 +185,6 @@ if(appInfo.platformVersion[0] >= 2) { // whether we are waiting for another Zotero process to initialize so we can use connector var _waitingForInitComplete = false; - // whether we should broadcast an initComplete message when initialization finishes (we should - // do this if we forced another Zotero process to release its lock) - var _broadcastInitComplete = false; - /** * Maintains nsITimers to be used when Zotero.wait() completes (to reduce performance penalty * of initializing new objects)