This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 686320 - Allow Mozmill to probe the OS for a free port instead of…
… hardcoded value in JSBridge. r=jhammel
- Loading branch information
Showing
23 changed files
with
528 additions
and
767 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,6 @@ | ||
resource jsbridge resource/ | ||
|
||
content jsbridge chrome/content/ | ||
component {2872d428-14f6-11de-ac86-001f5bd9235c} components/jsbridge.js | ||
contract @mozilla.org/jsbridge;1 {2872d428-14f6-11de-ac86-001f5bd9235c} | ||
category profile-after-change JSBridge @mozilla.org/jsbridge;1 | ||
|
||
overlay chrome://browser/content/browser.xul chrome://jsbridge/content/overlay.xul | ||
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://jsbridge/content/overlay.xul | ||
|
||
overlay chrome://calendar/content/calendar.xul chrome://jsbridge/content/overlay.xul | ||
|
||
overlay windowtype:Songbird:Main chrome://jsbridge/content/overlay.xul | ||
|
||
component {2872d428-14f6-11de-ac86-001f5bd9235c} components/cmdarg.js | ||
contract @mozilla.org/commandlinehandler/general-startup;1?type=jsbridge {2872d428-14f6-11de-ac86-001f5bd9235c} | ||
category profile-after-change jsbridge @mozilla.org/commandlinehandler/general-startup;1?type=jsbridge | ||
category command-line-handler jsbridge @mozilla.org/commandlinehandler/general-startup;1?type=jsbridge |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const Cc = Components.classes; | ||
const Ci = Components.interfaces; | ||
const Cu = Components.utils; | ||
|
||
// Import global modules | ||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||
Cu.import("resource://gre/modules/Services.jsm"); | ||
|
||
// Include local modules | ||
Cu.import("resource://jsbridge/modules/Log.jsm"); | ||
|
||
|
||
// Constants for preferences names | ||
const PREF_JSBRIDGE_PORT = "extensions.jsbridge.port"; | ||
|
||
|
||
/** | ||
* XPCOM component to observe different application states and to | ||
* handle the JSBridge server. | ||
*/ | ||
function JSBridge() { | ||
this._server = null; | ||
} | ||
|
||
JSBridge.prototype = { | ||
classDescription: "JSBridge", | ||
classID: Components.ID("{2872d428-14f6-11de-ac86-001f5bd9235c}"), | ||
contractID: "@mozilla.org/jsbridge;1", | ||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), | ||
|
||
_xpcom_categories: [{category: "profile-after-change"}], | ||
|
||
/** | ||
* Handler for registered observer notifications. | ||
* | ||
* @param {String} aSubject | ||
* Subject of the observer message (not used) | ||
* @param {String} aTopic | ||
* Topic of the observer message | ||
* @param {Object} aData | ||
* Data of the observer message (not used) | ||
*/ | ||
observe: function JSB_observe(aSubject, aTopic, aData) { | ||
Log.dump("Observer topic", aTopic); | ||
|
||
switch (aTopic) { | ||
// The server cannot be started before the ui is shown. That means | ||
// we also have to register for the final-ui-startup notification. | ||
case "profile-after-change": | ||
Services.obs.addObserver(this, "final-ui-startup", false); | ||
Services.obs.addObserver(this, "quit-application", false); | ||
break; | ||
|
||
case "final-ui-startup": | ||
Services.obs.removeObserver(this, "final-ui-startup", false); | ||
|
||
// The port the server has to be started on is set via a preference | ||
let port = Services.prefs.getIntPref(PREF_JSBRIDGE_PORT); | ||
|
||
// Start the server | ||
Cu.import('resource://jsbridge/modules/Server.jsm'); | ||
this._server = new Server.Server(port); | ||
this._server.start(); | ||
|
||
break; | ||
|
||
case "quit-application": | ||
Services.obs.removeObserver(this, "quit-application", false); | ||
|
||
// Stop the server | ||
this._server.stop(); | ||
this._server = null; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([JSBridge]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.