commit 88ba3bf75bb205d2b3c8ad9fda237f160e2d5b10
parent 92f0cdd1af4dee3f5a22961c733e0ba02c2ba3e3
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 2 Mar 2010 21:54:53 +0000
put integration pipe in /Users/Shared on OS X for users accessing their home directory over AFP
Diffstat:
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -28,7 +28,8 @@ const RESELECT_KEY_ITEM_KEY = 2;
const RESELECT_KEY_ITEM_ID = 3;
Zotero.Integration = new function() {
- var _fifoFile, _osascriptFile;
+ var _fifoFile = null;
+ var _osascriptFile;
this.sessions = {};
@@ -37,11 +38,33 @@ Zotero.Integration = new function() {
*/
this.init = function() {
if(!Zotero.isWin) {
- // create a new file representing the pipe
- _fifoFile = Components.classes["@mozilla.org/file/directory_service;1"].
- getService(Components.interfaces.nsIProperties).
- get("Home", Components.interfaces.nsIFile);
- _fifoFile.append(".zoteroIntegrationPipe");
+ // determine directory to put the pipe in
+ if(Zotero.isMac) {
+ // on OS X, first try /Users/Shared for those who can't put pipes in their home
+ // directories
+ _fifoFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(Components.interfaces.nsILocalFile);
+ _fifoFile.initWithPath("/Users/Shared");
+
+ if(_fifoFile.isDirectory() && _fifoFile.isWritable()) {
+ var logname = Components.classes["@mozilla.org/process/environment;1"].
+ getService(Components.interfaces.nsIEnvironment).
+ get("LOGNAME");
+ _fifoFile.append(".zoteroIntegrationPipe_"+logname);
+ } else {
+ _fifoFile = null;
+ }
+ }
+
+ if(!_fifoFile) {
+ // on other platforms, or as a fallback, use home directory
+ _fifoFile = Components.classes["@mozilla.org/file/directory_service;1"].
+ getService(Components.interfaces.nsIProperties).
+ get("Home", Components.interfaces.nsIFile);
+ _fifoFile.append(".zoteroIntegrationPipe");
+ }
+
+ Zotero.debug("Initializing Zotero integration pipe at "+_fifoFile.path);
// destroy old pipe, if one exists
if(_fifoFile.exists()) _fifoFile.remove(false);