connect.js
Go to the documentation of this file.
1 /* connect.js
2  * This will be loaded into all windows, that need access to the global
3  * foldersync controllers. It connects a local foldersync namespace with the
4  * global one.
5  */
6 // Make a namespace.
7 if (typeof foldersync == 'undefined') {
8  var foldersync = {};
9 };
10 
11 /* Connection controller
12  * This connects our local foldersync namespace with the global foldersync
13  * namespace in the main window.
14  */
15 foldersync.connect = {
16  // connects local and global foldersync namespaces
17  establishConnection: function(){
18  // Get the main window
19  var mainWindow = window.QueryInterface(Components.interfaces.
21  getInterface(Components.interfaces.
23  QueryInterface(Components.interfaces.
25  rootTreeItem.QueryInterface(Components.interfaces.
27  getInterface(Components.interfaces.nsIDOMWindow);
28  // We might be in a area the main window is not accessible directly
29  if (mainWindow == window){
30  var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
31  getService(Components.interfaces.nsIWindowMediator);
32  mainWindow = wm.getMostRecentWindow("Songbird:Main");
33  }
34  // Get the global namespace
35  var _foldersync = mainWindow.foldersync;
36  // Link controllers in local namespace
37  foldersync.central = _foldersync.central;
38  foldersync.sync = _foldersync.sync;
39  foldersync.preferences = _foldersync.preferences;
40  foldersync.rockbox = _foldersync.rockbox;
41 
42  foldersync.central.logEvent("connect", "Connected: " + window.location, 4);
43  },
44 };
45 
46 // Connect to global namespace
47 foldersync.connect.establishConnection();
const nsIDocShellTreeItem
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
let window
foldersync connect establishConnection()
const nsIWebNavigation
Definition: browser.js:71
const nsIInterfaceRequestor