From 86bf1fae6ecfaf58b6a265ec74d1f1da2b31cd38 Mon Sep 17 00:00:00 2001 From: Massimiliano Mirra Date: Thu, 15 Dec 2011 00:29:44 +0100 Subject: [PATCH] Respect "allow outside connections" preference. --- chrome/content/overlay_impl.js | 5 ++--- chrome/content/server.js | 3 ++- chrome/content/ui.js | 10 ++++++---- components/CommandLine.js | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/chrome/content/overlay_impl.js b/chrome/content/overlay_impl.js index ed3a05f..277c2da 100644 --- a/chrome/content/overlay_impl.js +++ b/chrome/content/overlay_impl.js @@ -65,12 +65,11 @@ function togglePref(prefName) { } function toggleServer(sourceCommand) { - var port = pref.getIntPref('port'); - if(server.isActive()) server.stop(); else - server.start(port); + server.start(pref.getIntPref('port'), + pref.getBoolPref('loopbackOnly')); } function updateMenu(xulPopup) { diff --git a/chrome/content/server.js b/chrome/content/server.js index 9e3b50e..9daaf84 100644 --- a/chrome/content/server.js +++ b/chrome/content/server.js @@ -173,7 +173,8 @@ function observe(subject, topic, data) { srvObserver.addObserver(this, 'network:offline-status-changed', false); if(srvPref.getBranch('network.').getBoolPref('online') && pref.getBoolPref('autoStart')) - this.start(pref.getIntPref('port')); + this.start(pref.getIntPref('port'), + pref.getBoolPref('loopbackOnly')); break; case 'network:offline-status-changed': diff --git a/chrome/content/ui.js b/chrome/content/ui.js index 4f4b1d1..1e62038 100644 --- a/chrome/content/ui.js +++ b/chrome/content/ui.js @@ -37,18 +37,20 @@ function constructor(server) { } function toggleServer(sourceCommand) { - var port = Components + var pref = Components .classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefService) - .getBranch('extensions.mozrepl.') - .getIntPref('port'); + .getBranch('extensions.mozrepl.'); + + var port = pref.getIntPref('port'); + var loopbackOnly = pref.getBoolPref('loopbackOnly'); if(this._server.isActive()) { this._server.stop(); sourceCommand.setAttribute('label', 'Start Repl'); } else { - this._server.start(port); + this._server.start(port, loopbackOnly); sourceCommand.setAttribute('label', 'Stop Repl'); } } diff --git a/components/CommandLine.js b/components/CommandLine.js index bbd051c..1f847ce 100644 --- a/components/CommandLine.js +++ b/components/CommandLine.js @@ -63,6 +63,7 @@ MozReplCommandLineHandler.prototype = { if(start || contextWindowType) { var port = Number(cmdLine.handleFlagWithParam('repl', false)) || srvPref.getIntPref('port'); + var loopbackOnly = srvPref.getBoolPref('loopbackOnly'); var service = Cc['@hyperstruct.net/mozlab/mozrepl;1'] .getService(Ci.nsIMozRepl) @@ -71,7 +72,7 @@ MozReplCommandLineHandler.prototype = { if(contextWindowType) service.setContextWindowType(contextWindowType); - service.start(port); + service.start(port, loopbackOnly); } },