mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1205237 - Part 2: add PresentationNetworkHelper; r=schien
--HG-- extra : rebase_source : 7e5e6f1dd260cf530b2da33b4025ecbeda793c15
This commit is contained in:
parent
e998adb4cf
commit
2611240343
28
dom/presentation/PresentationNetworkHelper.js
Normal file
28
dom/presentation/PresentationNetworkHelper.js
Normal file
@ -0,0 +1,28 @@
|
||||
// -*- 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";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const NETWORKHELPER_CID = Components.ID("{5fb96caa-6d49-4f6b-9a4b-65dd0d51f92d}");
|
||||
|
||||
function PresentationNetworkHelper() {}
|
||||
|
||||
PresentationNetworkHelper.prototype = {
|
||||
classID: NETWORKHELPER_CID,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationNetworkHelper]),
|
||||
|
||||
getWifiIPAddress: function(aListener) {
|
||||
Messaging.sendRequestForResult({type: "Wifi:GetIPAddress"})
|
||||
.then(result => aListener.onGetWifiIPAddress(result),
|
||||
err => aListener.onError(err));
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PresentationNetworkHelper]);
|
3
dom/presentation/PresentationNetworkHelper.manifest
Normal file
3
dom/presentation/PresentationNetworkHelper.manifest
Normal file
@ -0,0 +1,3 @@
|
||||
# PresentationNetworkHelper.js
|
||||
component {5fb96caa-6d49-4f6b-9a4b-65dd0d51f92d} PresentationNetworkHelper.js
|
||||
contract @mozilla.org/presentation-device/networkHelper;1 {5fb96caa-6d49-4f6b-9a4b-65dd0d51f92d}
|
@ -18,5 +18,10 @@ XPIDL_SOURCES += [
|
||||
'nsITCPPresentationServer.idl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIPresentationNetworkHelper.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_presentation'
|
||||
|
||||
|
36
dom/presentation/interfaces/nsIPresentationNetworkHelper.idl
Normal file
36
dom/presentation/interfaces/nsIPresentationNetworkHelper.idl
Normal file
@ -0,0 +1,36 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#define PRESENTATION_NETWORK_HELPER_CONTRACTID \
|
||||
"@mozilla.org/presentation-device/networkHelper;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(0a7e134f-ff80-4e73-91e6-12b3134fe568)]
|
||||
interface nsIPresentationNetworkHelperListener : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called when error occurs.
|
||||
* @param aReason error message.
|
||||
*/
|
||||
void onError(in AUTF8String aReason);
|
||||
|
||||
/**
|
||||
* Called when get Wi-Fi IP address.
|
||||
* @param aIPAddress the IP address of Wi-Fi interface.
|
||||
*/
|
||||
void onGetWifiIPAddress(in AUTF8String aIPAddress);
|
||||
};
|
||||
|
||||
[scriptable, uuid(650dc16b-3d9c-49a6-9037-1d6f2d18c90c)]
|
||||
interface nsIPresentationNetworkHelper : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get IP address of Wi-Fi interface.
|
||||
* @param aListener the callback interface.
|
||||
*/
|
||||
void getWifiIPAddress(in nsIPresentationNetworkHelperListener aListener);
|
||||
};
|
@ -47,6 +47,12 @@ EXTRA_COMPONENTS += [
|
||||
'PresentationDeviceInfoManager.manifest',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
EXTRA_COMPONENTS += [
|
||||
'PresentationNetworkHelper.js',
|
||||
'PresentationNetworkHelper.manifest',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'PresentationDeviceInfoManager.jsm',
|
||||
]
|
||||
|
@ -464,6 +464,8 @@
|
||||
@BINPATH@/components/PresentationDeviceInfoManager.js
|
||||
@BINPATH@/components/BuiltinProviders.manifest
|
||||
@BINPATH@/components/TCPPresentationServer.js
|
||||
@BINPATH@/components/PresentationNetworkHelper.js
|
||||
@BINPATH@/components/PresentationNetworkHelper.manifest
|
||||
|
||||
@BINPATH@/components/PACGenerator.js
|
||||
@BINPATH@/components/PACGenerator.manifest
|
||||
|
Loading…
Reference in New Issue
Block a user