Add some documentation on the connector switching process

This commit is contained in:
Simon Kornblith 2011-08-07 23:37:51 +00:00
parent 75f4360175
commit b08b54ba83
2 changed files with 22 additions and 4 deletions

View file

@ -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();
}
}

View file

@ -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)