summaryrefslogtreecommitdiffstats
path: root/netwerk/dns
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-22 20:10:23 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:52:18 +0200
commit92edec6f587ae6b86c9b27947113997972ce0c1a (patch)
tree246706f86a7e5e3e086cf9ac83f7bdcec0055cee /netwerk/dns
parent2dea4edfd7cf9a760149da220e60dddb2b0b0d09 (diff)
downloadUXP-92edec6f587ae6b86c9b27947113997972ce0c1a.tar
UXP-92edec6f587ae6b86c9b27947113997972ce0c1a.tar.gz
UXP-92edec6f587ae6b86c9b27947113997972ce0c1a.tar.lz
UXP-92edec6f587ae6b86c9b27947113997972ce0c1a.tar.xz
UXP-92edec6f587ae6b86c9b27947113997972ce0c1a.zip
Issue #1053 - Remove android support from netwerk
Diffstat (limited to 'netwerk/dns')
-rw-r--r--netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm244
-rw-r--r--netwerk/dns/mdns/libmdns/moz.build5
-rw-r--r--netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.js10
3 files changed, 1 insertions, 258 deletions
diff --git a/netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm b/netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm
deleted file mode 100644
index 771f9a794..000000000
--- a/netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm
+++ /dev/null
@@ -1,244 +0,0 @@
-// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
-/* 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/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["MulticastDNS"];
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Messaging.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-var log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.d.bind(null, "MulticastDNS");
-
-const FAILURE_INTERNAL_ERROR = -65537;
-
-// Helper function for sending commands to Java.
-function send(type, data, callback) {
- let msg = {
- type: type
- };
-
- for (let i in data) {
- try {
- msg[i] = data[i];
- } catch (e) {
- }
- }
-
- Messaging.sendRequestForResult(msg)
- .then(result => callback(result, null),
- err => callback(null, typeof err === "number" ? err : FAILURE_INTERNAL_ERROR));
-}
-
-// Receives service found/lost event from NsdManager
-function ServiceManager() {
-}
-
-ServiceManager.prototype = {
- listeners: {},
- numListeners: 0,
-
- registerEvent: function() {
- log("registerEvent");
- Messaging.addListener(this.onServiceFound.bind(this), "NsdManager:ServiceFound");
- Messaging.addListener(this.onServiceLost.bind(this), "NsdManager:ServiceLost");
- },
-
- unregisterEvent: function() {
- log("unregisterEvent");
- Messaging.removeListener("NsdManager:ServiceFound");
- Messaging.removeListener("NsdManager:ServiceLost");
- },
-
- addListener: function(aServiceType, aListener) {
- log("addListener: " + aServiceType + ", " + aListener);
-
- if (!this.listeners[aServiceType]) {
- this.listeners[aServiceType] = [];
- }
- if (this.listeners[aServiceType].includes(aListener)) {
- log("listener already exists");
- return;
- }
-
- this.listeners[aServiceType].push(aListener);
- ++this.numListeners;
-
- if (this.numListeners === 1) {
- this.registerEvent();
- }
-
- log("listener added: " + this);
- },
-
- removeListener: function(aServiceType, aListener) {
- log("removeListener: " + aServiceType + ", " + aListener);
-
- if (!this.listeners[aServiceType]) {
- log("listener doesn't exist");
- return;
- }
- let index = this.listeners[aServiceType].indexOf(aListener);
- if (index < 0) {
- log("listener doesn't exist");
- return;
- }
-
- this.listeners[aServiceType].splice(index, 1);
- --this.numListeners;
-
- if (this.numListeners === 0) {
- this.unregisterEvent();
- }
-
- log("listener removed" + this);
- },
-
- onServiceFound: function(aServiceInfo) {
- let listeners = this.listeners[aServiceInfo.serviceType];
- if (listeners) {
- for (let listener of listeners) {
- listener.onServiceFound(aServiceInfo);
- }
- } else {
- log("no listener");
- }
- return {};
- },
-
- onServiceLost: function(aServiceInfo) {
- let listeners = this.listeners[aServiceInfo.serviceType];
- if (listeners) {
- for (let listener of listeners) {
- listener.onServiceLost(aServiceInfo);
- }
- } else {
- log("no listener");
- }
- return {};
- }
-};
-
-// make an object from nsIPropertyBag2
-function parsePropertyBag2(bag) {
- if (!bag || !(bag instanceof Ci.nsIPropertyBag2)) {
- throw new TypeError("Not a property bag");
- }
-
- let attributes = [];
- let enumerator = bag.enumerator;
- while (enumerator.hasMoreElements()) {
- let name = enumerator.getNext().QueryInterface(Ci.nsIProperty).name;
- let value = bag.getPropertyAsACString(name);
- attributes.push({
- "name": name,
- "value": value
- });
- }
-
- return attributes;
-}
-
-function MulticastDNS() {
- this.serviceManager = new ServiceManager();
-}
-
-MulticastDNS.prototype = {
- startDiscovery: function(aServiceType, aListener) {
- this.serviceManager.addListener(aServiceType, aListener);
-
- let serviceInfo = {
- serviceType: aServiceType,
- uniqueId: aListener.uuid
- };
-
- send("NsdManager:DiscoverServices", serviceInfo, (result, err) => {
- if (err) {
- log("onStartDiscoveryFailed: " + aServiceType + " (" + err + ")");
- this.serviceManager.removeListener(aServiceType, aListener);
- aListener.onStartDiscoveryFailed(aServiceType, err);
- } else {
- aListener.onDiscoveryStarted(result);
- }
- });
- },
-
- stopDiscovery: function(aServiceType, aListener) {
- this.serviceManager.removeListener(aServiceType, aListener);
-
- let serviceInfo = {
- uniqueId: aListener.uuid
- };
-
- send("NsdManager:StopServiceDiscovery", serviceInfo, (result, err) => {
- if (err) {
- log("onStopDiscoveryFailed: " + aServiceType + " (" + err + ")");
- aListener.onStopDiscoveryFailed(aServiceType, err);
- } else {
- aListener.onDiscoveryStopped(aServiceType);
- }
- });
- },
-
- registerService: function(aServiceInfo, aListener) {
- let serviceInfo = {
- port: aServiceInfo.port,
- serviceType: aServiceInfo.serviceType,
- uniqueId: aListener.uuid
- };
-
- try {
- serviceInfo.host = aServiceInfo.host;
- } catch(e) {
- // host unspecified
- }
- try {
- serviceInfo.serviceName = aServiceInfo.serviceName;
- } catch(e) {
- // serviceName unspecified
- }
- try {
- serviceInfo.attributes = parsePropertyBag2(aServiceInfo.attributes);
- } catch(e) {
- // attributes unspecified
- }
-
- send("NsdManager:RegisterService", serviceInfo, (result, err) => {
- if (err) {
- log("onRegistrationFailed: (" + err + ")");
- aListener.onRegistrationFailed(aServiceInfo, err);
- } else {
- aListener.onServiceRegistered(result);
- }
- });
- },
-
- unregisterService: function(aServiceInfo, aListener) {
- let serviceInfo = {
- uniqueId: aListener.uuid
- };
-
- send("NsdManager:UnregisterService", serviceInfo, (result, err) => {
- if (err) {
- log("onUnregistrationFailed: (" + err + ")");
- aListener.onUnregistrationFailed(aServiceInfo, err);
- } else {
- aListener.onServiceUnregistered(aServiceInfo);
- }
- });
- },
-
- resolveService: function(aServiceInfo, aListener) {
- send("NsdManager:ResolveService", aServiceInfo, (result, err) => {
- if (err) {
- log("onResolveFailed: (" + err + ")");
- aListener.onResolveFailed(aServiceInfo, err);
- } else {
- aListener.onServiceResolved(result);
- }
- });
- }
-};
diff --git a/netwerk/dns/mdns/libmdns/moz.build b/netwerk/dns/mdns/libmdns/moz.build
index efad64d64..b7d376fc3 100644
--- a/netwerk/dns/mdns/libmdns/moz.build
+++ b/netwerk/dns/mdns/libmdns/moz.build
@@ -31,11 +31,6 @@ else:
'fallback/MulticastDNS.jsm',
]
- if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
- EXTRA_JS_MODULES += [
- 'MulticastDNSAndroid.jsm',
- ]
-
UNIFIED_SOURCES += [
'nsDNSServiceInfo.cpp',
'nsMulticastDNSModule.cpp',
diff --git a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.js b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.js
index b94f67297..af9196135 100644
--- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.js
+++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.js
@@ -5,17 +5,9 @@
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
-Cu.import("resource://gre/modules/ExtensionUtils.jsm");
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-let { PlatformInfo } = ExtensionUtils;
-
-if (PlatformInfo.os == "android" && !Services.prefs.getBoolPref("network.mdns.use_js_fallback")) {
- Cu.import("resource://gre/modules/MulticastDNSAndroid.jsm");
-} else {
- Cu.import("resource://gre/modules/MulticastDNS.jsm");
-}
+Cu.import("resource://gre/modules/MulticastDNS.jsm");
const DNSSERVICEDISCOVERY_CID = Components.ID("{f9346d98-f27a-4e89-b744-493843416480}");
const DNSSERVICEDISCOVERY_CONTRACT_ID = "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1";