mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Merge m-c to inbound. a=merge
This commit is contained in:
commit
002f3495c6
@ -225,7 +225,8 @@ let AlertsHelper = {
|
||||
},
|
||||
|
||||
showNotification: function(imageURL, title, text, textClickable, cookie,
|
||||
uid, bidi, lang, dataObj, manifestURL, timestamp) {
|
||||
uid, bidi, lang, dataObj, manifestURL, timestamp,
|
||||
behavior) {
|
||||
function send(appName, appIcon) {
|
||||
SystemAppProxy._sendCustomEvent(kMozChromeNotificationEvent, {
|
||||
type: kDesktopNotification,
|
||||
@ -239,7 +240,8 @@ let AlertsHelper = {
|
||||
appIcon: appIcon,
|
||||
manifestURL: manifestURL,
|
||||
timestamp: timestamp,
|
||||
data: dataObj
|
||||
data: dataObj,
|
||||
mozbehavior: behavior
|
||||
});
|
||||
}
|
||||
|
||||
@ -292,7 +294,7 @@ let AlertsHelper = {
|
||||
this.showNotification(data.imageURL, data.title, data.text,
|
||||
details.textClickable, null, data.uid, details.dir,
|
||||
details.lang, dataObject, details.manifestURL,
|
||||
details.timestamp);
|
||||
details.timestamp, details.mozbehavior);
|
||||
},
|
||||
|
||||
closeAlert: function(name) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "9d4cf6d16100e4091fa14530e44ef2cdb5c0f832",
|
||||
"revision": "9fffcfaa0e101a04a867ee3cbab0f59805e7cb45",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="50666fa8bbbf3d346faff24f92ad8140a44a49d0"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="72262d054ffa5d0d2b5a0033f713149281511aea"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="f2f293787d4a86257c9e78a35bd3f73b31b706e2"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -438,8 +438,6 @@
|
||||
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
@BINPATH@/components/MmsService.js
|
||||
@BINPATH@/components/MmsService.manifest
|
||||
@BINPATH@/components/MobileConnectionService.js
|
||||
@BINPATH@/components/MobileConnectionService.manifest
|
||||
@BINPATH@/components/MobileMessageDatabaseService.js
|
||||
@BINPATH@/components/MobileMessageDatabaseService.manifest
|
||||
@BINPATH@/components/RadioInterfaceLayer.js
|
||||
@ -447,6 +445,8 @@
|
||||
@BINPATH@/components/RILContentHelper.js
|
||||
@BINPATH@/components/TelephonyService.js
|
||||
@BINPATH@/components/TelephonyService.manifest
|
||||
@BINPATH@/components/MobileConnectionGonkService.js
|
||||
@BINPATH@/components/MobileConnectionGonkService.manifest
|
||||
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
|
||||
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
|
@ -47,6 +47,10 @@ var tabPreviews = {
|
||||
},
|
||||
|
||||
capture: function tabPreviews_capture(aTab, aShouldCache) {
|
||||
// Bug 863512 - Make page thumbnails work in electrolysis
|
||||
if (gMultiProcessBrowser)
|
||||
return new Image();
|
||||
|
||||
let browser = aTab.linkedBrowser;
|
||||
let uri = browser.currentURI.spec;
|
||||
|
||||
|
@ -1215,3 +1215,13 @@ toolbarpaletteitem[place="palette"][hidden] {
|
||||
#context-navigation > .menuitem-iconic > .menu-accel-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Tracking protection doorhanger */
|
||||
.popup-notification-footer[popupid="bad-content"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.popup-notification-footer[popupid="bad-content"][mixedblockdisabled],
|
||||
.popup-notification-footer[popupid="bad-content"][trackingblockdisabled] {
|
||||
display: block;
|
||||
}
|
||||
|
@ -4134,7 +4134,7 @@ function nsBrowserAccess() { }
|
||||
nsBrowserAccess.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserDOMWindow, Ci.nsISupports]),
|
||||
|
||||
_openURIInNewTab: function(aURI, aOpener, aIsExternal, aEnsureNonRemote=false) {
|
||||
_openURIInNewTab: function(aURI, aOpener, aIsExternal) {
|
||||
let win, needToFocusWin;
|
||||
|
||||
// try the current window. if we're in a popup, fall back on the most recent browser window
|
||||
@ -4166,15 +4166,6 @@ nsBrowserAccess.prototype = {
|
||||
inBackground: loadInBackground});
|
||||
let browser = win.gBrowser.getBrowserForTab(tab);
|
||||
|
||||
// It's possible that we've been asked to open a new non-remote
|
||||
// browser in a window that defaults to having remote browsers -
|
||||
// this can happen if we're opening the new tab due to a window.open
|
||||
// or _blank anchor in a non-remote browser. If so, we have to force
|
||||
// the newly opened browser to also not be remote.
|
||||
if (win.gMultiProcessBrowser && aEnsureNonRemote) {
|
||||
win.gBrowser.updateBrowserRemoteness(browser, false);
|
||||
}
|
||||
|
||||
if (needToFocusWin || (!loadInBackground && aIsExternal))
|
||||
win.focus();
|
||||
|
||||
@ -4182,14 +4173,6 @@ nsBrowserAccess.prototype = {
|
||||
},
|
||||
|
||||
openURI: function (aURI, aOpener, aWhere, aContext) {
|
||||
// This function should only ever be called if we're opening a URI
|
||||
// from a non-remote browser window (via nsContentTreeOwner).
|
||||
if (aOpener && Cu.isCrossProcessWrapper(aOpener)) {
|
||||
Cu.reportError("nsBrowserAccess.openURI was passed a CPOW for aOpener. " +
|
||||
"openURI should only ever be called from non-remote browsers.");
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
var newWindow = null;
|
||||
var isExternal = (aContext == Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||
|
||||
@ -4215,7 +4198,7 @@ nsBrowserAccess.prototype = {
|
||||
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url, null, null, null);
|
||||
break;
|
||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
|
||||
let browser = this._openURIInNewTab(aURI, aOpener, isExternal, true);
|
||||
let browser = this._openURIInNewTab(aURI, aOpener, isExternal);
|
||||
if (browser)
|
||||
newWindow = browser.contentWindow;
|
||||
break;
|
||||
|
@ -25,8 +25,8 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.searchSuggestionRow.formHistory {
|
||||
color: hsl(210,100%,40%);
|
||||
.searchSuggestionRow.formHistory + .searchSuggestionRow.remote > td {
|
||||
border-top: 1px solid GrayText;
|
||||
}
|
||||
|
||||
.searchSuggestionRow.selected {
|
||||
@ -42,7 +42,3 @@
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.searchSuggestionEntry > span.typed {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -223,13 +223,6 @@ SearchSuggestionUIController.prototype = {
|
||||
this._hideSuggestions();
|
||||
},
|
||||
|
||||
_onMousemove: function (event) {
|
||||
// It's important to listen for mousemove, not mouseover or mouseenter. The
|
||||
// latter two are triggered when the user is typing and the mouse happens to
|
||||
// be over the suggestions popup.
|
||||
this.selectedIndex = this._indexOfTableRowOrDescendent(event.target);
|
||||
},
|
||||
|
||||
_onMousedown: function (event) {
|
||||
let idx = this._indexOfTableRowOrDescendent(event.target);
|
||||
let suggestion = this.suggestionAtIndex(idx);
|
||||
@ -307,7 +300,6 @@ SearchSuggestionUIController.prototype = {
|
||||
row.classList.add("searchSuggestionRow");
|
||||
row.classList.add(type);
|
||||
row.setAttribute("role", "presentation");
|
||||
row.addEventListener("mousemove", this);
|
||||
row.addEventListener("mousedown", this);
|
||||
|
||||
let entry = document.createElementNS(HTML_NS, "td");
|
||||
|
@ -483,5 +483,3 @@ skip-if = e10s
|
||||
skip-if = e10s # Bug ?????? - test directly manipulates content (content.document.getElementById)
|
||||
[browser_bug1045809.js]
|
||||
skip-if = e10s
|
||||
[browser_bug1047603.js]
|
||||
skip-if = os == "linux" # Bug 1066856 - waiting for OMTC to be enabled by default on Linux.
|
||||
|
@ -1,139 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const OPEN_LOCATION_PREF = "browser.link.open_newwindow";
|
||||
const NON_REMOTE_PAGE = "about:crashes";
|
||||
|
||||
const SIMPLE_PAGE_HTML = `
|
||||
<a href="about:home" target="_blank" id="testAnchor">Open a window</a>
|
||||
`;
|
||||
|
||||
function frame_script() {
|
||||
addMessageListener("test:click", (message) => {
|
||||
let element = content.document.getElementById("testAnchor");
|
||||
element.click();
|
||||
});
|
||||
sendAsyncMessage("test:ready");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Promise that resolves once the frame_script is loaded
|
||||
* in the browser, and has seen the DOMContentLoaded event.
|
||||
*/
|
||||
function waitForFrameScriptReady(mm) {
|
||||
return new Promise((resolve, reject) => {
|
||||
mm.addMessageListener("test:ready", function onTestReady() {
|
||||
mm.removeMessageListener("test:ready", onTestReady);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes some browser in some window, and forces that browser
|
||||
* to become non-remote, and then navigates it to a page that
|
||||
* we're not supposed to be displaying remotely. Returns a
|
||||
* Promise that resolves when the browser is no longer remote.
|
||||
*/
|
||||
function prepareNonRemoteBrowser(aWindow, browser) {
|
||||
aWindow.gBrowser.updateBrowserRemoteness(browser, false);
|
||||
browser.loadURI(NON_REMOTE_PAGE);
|
||||
return new Promise((resolve, reject) => {
|
||||
waitForCondition(() => !browser.isRemoteBrowser, () => {
|
||||
resolve();
|
||||
}, "Waiting for browser to become non-remote");
|
||||
})
|
||||
}
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref(OPEN_LOCATION_PREF);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if we open a new tab from a link in a non-remote
|
||||
* browser in an e10s window, that the new tab's browser is also
|
||||
* not remote. Also tests with a private browsing window.
|
||||
*/
|
||||
add_task(function* test_new_tab() {
|
||||
let normalWindow = yield promiseOpenAndLoadWindow({
|
||||
remote: true
|
||||
}, true);
|
||||
let privateWindow = yield promiseOpenAndLoadWindow({
|
||||
remote: true,
|
||||
private: true,
|
||||
}, true);
|
||||
|
||||
for (let testWindow of [normalWindow, privateWindow]) {
|
||||
let testBrowser = testWindow.gBrowser.selectedBrowser;
|
||||
yield prepareNonRemoteBrowser(testWindow, testBrowser);
|
||||
|
||||
// Get our framescript ready
|
||||
let mm = testBrowser.messageManager;
|
||||
mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", true);
|
||||
let readyPromise = waitForFrameScriptReady(mm);
|
||||
yield readyPromise;
|
||||
|
||||
// Inject our test HTML into our non-remote tab.
|
||||
testBrowser.contentDocument.body.innerHTML = SIMPLE_PAGE_HTML;
|
||||
|
||||
// Click on the link in the browser, and wait for the new tab.
|
||||
mm.sendAsyncMessage("test:click");
|
||||
let tabOpenEvent = yield waitForNewTab(testWindow.gBrowser);
|
||||
let newTab = tabOpenEvent.target;
|
||||
ok(!newTab.linkedBrowser.isRemoteBrowser,
|
||||
"The opened browser should not be remote.");
|
||||
|
||||
testWindow.gBrowser.removeTab(newTab);
|
||||
}
|
||||
|
||||
normalWindow.close();
|
||||
privateWindow.close();
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if we open a new window from a link in a non-remote
|
||||
* browser in an e10s window, that the new window is not an e10s
|
||||
* window. Also tests with a private browsing window.
|
||||
*/
|
||||
add_task(function* test_new_window() {
|
||||
let normalWindow = yield promiseOpenAndLoadWindow({
|
||||
remote: true
|
||||
}, true);
|
||||
let privateWindow = yield promiseOpenAndLoadWindow({
|
||||
remote: true,
|
||||
private: true,
|
||||
}, true);
|
||||
|
||||
// Fiddle with the prefs so that we open target="_blank" links
|
||||
// in new windows instead of new tabs.
|
||||
Services.prefs.setIntPref(OPEN_LOCATION_PREF,
|
||||
Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW);
|
||||
|
||||
for (let testWindow of [normalWindow, privateWindow]) {
|
||||
let testBrowser = testWindow.gBrowser.selectedBrowser;
|
||||
yield prepareNonRemoteBrowser(testWindow, testBrowser);
|
||||
|
||||
// Get our framescript ready
|
||||
let mm = testBrowser.messageManager;
|
||||
mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", true);
|
||||
let readyPromise = waitForFrameScriptReady(mm);
|
||||
yield readyPromise;
|
||||
|
||||
// Inject our test HTML into our non-remote window.
|
||||
testBrowser.contentDocument.body.innerHTML = SIMPLE_PAGE_HTML;
|
||||
|
||||
// Click on the link in the browser, and wait for the new window.
|
||||
let windowOpenPromise = promiseTopicObserved("browser-delayed-startup-finished");
|
||||
mm.sendAsyncMessage("test:click");
|
||||
let [newWindow] = yield windowOpenPromise;
|
||||
ok(!newWindow.gMultiProcessBrowser,
|
||||
"The opened window should not be an e10s window.");
|
||||
newWindow.close();
|
||||
}
|
||||
|
||||
normalWindow.close();
|
||||
privateWindow.close();
|
||||
|
||||
Services.prefs.clearUserPref(OPEN_LOCATION_PREF);
|
||||
});
|
@ -102,14 +102,6 @@ add_task(function* mouse() {
|
||||
let state = yield msg("key", { key: "x", waitForSuggestions: true });
|
||||
checkState(state, "x", ["xfoo", "xbar"], -1);
|
||||
|
||||
// Mouse over the first suggestion.
|
||||
state = yield msg("mousemove", 0);
|
||||
checkState(state, "xfoo", ["xfoo", "xbar"], 0);
|
||||
|
||||
// Mouse over the second suggestion.
|
||||
state = yield msg("mousemove", 1);
|
||||
checkState(state, "xbar", ["xfoo", "xbar"], 1);
|
||||
|
||||
// Click the second suggestion. This should make it sticky. To make sure it
|
||||
// sticks, trigger suggestions again and cycle through them by pressing Down
|
||||
// until nothing is selected again.
|
||||
|
@ -670,7 +670,3 @@ function makeActionURI(action, params) {
|
||||
let url = "moz-action:" + action + "," + JSON.stringify(params);
|
||||
return NetUtil.newURI(url);
|
||||
}
|
||||
|
||||
function waitForNewTab(aTabBrowser) {
|
||||
return promiseWaitForEvent(aTabBrowser.tabContainer, "TabOpen");
|
||||
}
|
||||
|
@ -37,33 +37,6 @@ let messageHandlers = {
|
||||
ack();
|
||||
},
|
||||
|
||||
mousemove: function (suggestionIdx) {
|
||||
// Copied from widget/tests/test_panel_mouse_coords.xul and
|
||||
// browser/base/content/test/newtab/head.js
|
||||
let row = gController._table.children[suggestionIdx];
|
||||
let rect = row.getBoundingClientRect();
|
||||
let left = content.mozInnerScreenX + rect.left;
|
||||
let x = left + rect.width / 2;
|
||||
let y = content.mozInnerScreenY + rect.top + rect.height / 2;
|
||||
|
||||
let utils = content.SpecialPowers.getDOMWindowUtils(content);
|
||||
let scale = utils.screenPixelsPerCSSPixel;
|
||||
|
||||
let widgetToolkit = content.SpecialPowers.
|
||||
Cc["@mozilla.org/xre/app-info;1"].
|
||||
getService(content.SpecialPowers.Ci.nsIXULRuntime).
|
||||
widgetToolkit;
|
||||
let nativeMsg = widgetToolkit == "cocoa" ? 5 : // NSMouseMoved
|
||||
widgetToolkit == "windows" ? 1 : // MOUSEEVENTF_MOVE
|
||||
3; // GDK_MOTION_NOTIFY
|
||||
|
||||
row.addEventListener("mousemove", function onMove() {
|
||||
row.removeEventListener("mousemove", onMove);
|
||||
ack();
|
||||
});
|
||||
utils.sendNativeMouseEvent(x * scale, y * scale, nativeMsg, 0, null);
|
||||
},
|
||||
|
||||
mousedown: function (suggestionIdx) {
|
||||
gController.onClick = () => {
|
||||
gController.onClick = null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp == "mulet" || e10s # Bug 915547 (social providers don't install)
|
||||
skip-if = buildapp == "mulet"
|
||||
support-files =
|
||||
blocklist.xml
|
||||
checked.jpg
|
||||
@ -26,21 +26,31 @@ support-files =
|
||||
unchecked.jpg
|
||||
|
||||
[browser_aboutHome_activation.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_addons.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_blocklist.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_share.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_activation.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_chatwindow.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_chatwindow_resize.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_chatwindowfocus.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_errorPage.js]
|
||||
[browser_social_flyout.js]
|
||||
[browser_social_isVisible.js]
|
||||
[browser_social_marks.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_multiprovider.js]
|
||||
[browser_social_multiworker.js]
|
||||
[browser_social_perwindowPB.js]
|
||||
[browser_social_sidebar.js]
|
||||
[browser_social_status.js]
|
||||
skip-if = e10s # Bug 915547 (social providers don't install)
|
||||
[browser_social_window.js]
|
||||
[browser_social_workercrash.js]
|
||||
|
@ -36,7 +36,10 @@ function goOnline(callback) {
|
||||
function openPanel(url, panelCallback, loadCallback) {
|
||||
// open a flyout
|
||||
SocialFlyout.open(url, 0, panelCallback);
|
||||
SocialFlyout.panel.firstChild.addEventListener("load", function panelLoad() {
|
||||
SocialFlyout.panel.firstChild.addEventListener("load", function panelLoad(evt) {
|
||||
if (evt.target != SocialFlyout.panel.firstChild.contentDocument) {
|
||||
return;
|
||||
}
|
||||
SocialFlyout.panel.firstChild.removeEventListener("load", panelLoad, true);
|
||||
loadCallback();
|
||||
}, true);
|
||||
@ -145,8 +148,10 @@ var tests = {
|
||||
todo_is(panelCallbackCount, 0, "Bug 833207 - should be no callback when error page loads.");
|
||||
ok(panel.firstChild.contentDocument.location.href.indexOf("about:socialerror?")==0, "is on social error page");
|
||||
gc();
|
||||
SocialFlyout.unload();
|
||||
next();
|
||||
executeSoon(function() {
|
||||
SocialFlyout.unload();
|
||||
next();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -73,7 +73,7 @@ var tests = {
|
||||
testButtonDisabledOnActivate: function(next) {
|
||||
// starting on about:blank page, share should be visible but disabled when
|
||||
// adding provider
|
||||
is(gBrowser.contentDocument.location.href, "about:blank");
|
||||
is(gBrowser.selectedTab.linkedBrowser.currentURI.spec, "about:blank");
|
||||
SocialService.addProvider(manifest2, function(provider) {
|
||||
is(provider.origin, manifest2.origin, "provider is installed");
|
||||
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
||||
|
@ -84,7 +84,10 @@ function checkUIStateMatchesProvider(provider) {
|
||||
|
||||
function onSidebarLoad(callback) {
|
||||
let sbrowser = document.getElementById("social-sidebar-browser");
|
||||
sbrowser.addEventListener("load", function load() {
|
||||
sbrowser.addEventListener("load", function load(evt) {
|
||||
if (evt.target != sbrowser.contentDocument) {
|
||||
return;
|
||||
}
|
||||
sbrowser.removeEventListener("load", load, true);
|
||||
// give the load a chance to finish before pulling the rug (ie. calling
|
||||
// next)
|
||||
|
@ -1650,7 +1650,7 @@
|
||||
&mixedContentBlocked2.message;
|
||||
</xul:description>
|
||||
<xul:description class="popup-notification-item-message"
|
||||
xbl:inherits="popupid">
|
||||
xbl:inherits="popupid,mixedblockdisabled">
|
||||
&mixedContentBlocked2.moreinfo;
|
||||
</xul:description>
|
||||
<xul:label anonid="mixedContent.helplink"
|
||||
@ -1672,8 +1672,7 @@
|
||||
</xul:menupopup>
|
||||
</xul:button>
|
||||
</xul:hbox>
|
||||
<xul:hbox anonid="mixedContentProtectionDisabled" hidden="true"
|
||||
class="popup-notification-footer" xbl:inherits="popupid">
|
||||
<xul:hbox class="popup-notification-footer" xbl:inherits="popupid,mixedblockdisabled">
|
||||
<xul:description class="popup-notification-item-message popup-notification-item-message-critical" xbl:inherits="popupid">
|
||||
&mixedContentBlocked2.disabled.message;
|
||||
</xul:description>
|
||||
@ -1689,7 +1688,7 @@
|
||||
&trackingContentBlocked.message;
|
||||
</xul:description>
|
||||
<xul:description class="popup-notification-item-message"
|
||||
xbl:inherits="popupid">
|
||||
xbl:inherits="popupid,trackingblockdisabled">
|
||||
&trackingContentBlocked.moreinfo;
|
||||
</xul:description>
|
||||
<xul:label anonid="trackingContent.helplink"
|
||||
@ -1711,8 +1710,7 @@
|
||||
</xul:menupopup>
|
||||
</xul:button>
|
||||
</xul:hbox>
|
||||
<xul:hbox anonid="trackingContentProtectionDisabled" hidden="true"
|
||||
class="popup-notification-footer" xbl:inherits="popupid">
|
||||
<xul:hbox class="popup-notification-footer" xbl:inherits="popupid,trackingblockdisabled">
|
||||
<xul:description class="popup-notification-item-message popup-notification-item-message-critical" xbl:inherits="popupid">
|
||||
&trackingContentBlocked.disabled.message;
|
||||
</xul:description>
|
||||
@ -1750,10 +1748,6 @@
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"mixedContentAction.block");
|
||||
</field>
|
||||
<field name="_mixedContentProtectionDisabledWarning">
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"mixedContentProtectionDisabled")
|
||||
</field>
|
||||
<field name="_mixedContentHelpLink">
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"mixedContent.helplink")
|
||||
@ -1776,10 +1770,6 @@
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"trackingContentAction.block");
|
||||
</field>
|
||||
<field name="_trackingContentProtectionDisabledWarning">
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"trackingContentProtectionDisabled")
|
||||
</field>
|
||||
<field name="_trackingContentHelpLink">
|
||||
document.getAnonymousElementByAttribute(this, "anonid",
|
||||
"trackingContent.helplink")
|
||||
@ -1809,9 +1799,9 @@
|
||||
}
|
||||
if (this.notification.options.state &
|
||||
Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT) {
|
||||
this.setAttribute("mixedblockdisabled", true);
|
||||
_mixedContent.hidden = false;
|
||||
_mixedContentBlock.hidden = false;
|
||||
_mixedContentProtectionDisabledWarning.hidden = false;
|
||||
_mixedContentHelpLink.href =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL")
|
||||
+ "mixed-content";
|
||||
@ -1821,7 +1811,7 @@
|
||||
_doorhangerTitle.value =
|
||||
gNavigatorBundle.getFormattedString(
|
||||
"badContentBlocked.blocked.message", [this._brandShortName]);
|
||||
_trackingContent.hidden = false
|
||||
_trackingContent.hidden = false;
|
||||
_trackingContentUnblock.hidden = false;
|
||||
_trackingContentHelpLink.href =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL")
|
||||
@ -1829,9 +1819,9 @@
|
||||
}
|
||||
if (this.notification.options.state &
|
||||
Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) {
|
||||
_trackingContent.hidden = false
|
||||
this.setAttribute("trackingblockdisabled", true);
|
||||
_trackingContent.hidden = false;
|
||||
_trackingContentBlock.hidden = false;
|
||||
_trackingContentProtectionDisabledWarning.hidden = false;
|
||||
_trackingContentHelpLink.href =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL")
|
||||
+ "tracking-protection";
|
||||
|
@ -108,6 +108,23 @@ function injectLoopAPI(targetWindow) {
|
||||
let contactsAPI;
|
||||
|
||||
let api = {
|
||||
/**
|
||||
* Gets an object with data that represents the currently
|
||||
* authenticated user's identity.
|
||||
*/
|
||||
userProfile: {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
if (!MozLoopService.userProfile)
|
||||
return null;
|
||||
let userProfile = Cu.cloneInto({
|
||||
email: MozLoopService.userProfile.email,
|
||||
uid: MozLoopService.userProfile.uid
|
||||
}, targetWindow);
|
||||
return userProfile;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets and gets the "do not disturb" mode activation flag.
|
||||
*/
|
||||
@ -440,10 +457,24 @@ function injectLoopAPI(targetWindow) {
|
||||
},
|
||||
};
|
||||
|
||||
function onStatusChanged(aSubject, aTopic, aData) {
|
||||
let event = new targetWindow.CustomEvent("LoopStatusChanged");
|
||||
targetWindow.dispatchEvent(event)
|
||||
};
|
||||
|
||||
function onDOMWindowDestroyed(aSubject, aTopic, aData) {
|
||||
if (targetWindow && aSubject != targetWindow)
|
||||
return;
|
||||
Services.obs.removeObserver(onDOMWindowDestroyed, "dom-window-destroyed");
|
||||
Services.obs.removeObserver(onStatusChanged, "loop-status-changed");
|
||||
};
|
||||
|
||||
let contentObj = Cu.createObjectIn(targetWindow);
|
||||
Object.defineProperties(contentObj, api);
|
||||
Object.seal(contentObj);
|
||||
Cu.makeObjectPropsNormal(contentObj);
|
||||
Services.obs.addObserver(onStatusChanged, "loop-status-changed", false);
|
||||
Services.obs.addObserver(onDOMWindowDestroyed, "dom-window-destroyed", false);
|
||||
|
||||
targetWindow.navigator.wrappedJSObject.__defineGetter__("mozLoop", function() {
|
||||
// We do this in a getter, so that we create these objects
|
||||
|
@ -46,6 +46,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "CommonUtils",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CryptoUtils",
|
||||
"resource://services-crypto/utils.js");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsProfileClient",
|
||||
"resource://gre/modules/FxAccountsProfileClient.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "HawkClient",
|
||||
"resource://services-common/hawkclient.js");
|
||||
|
||||
@ -76,6 +79,7 @@ let gInitializeTimer = null;
|
||||
let gFxAOAuthClientPromise = null;
|
||||
let gFxAOAuthClient = null;
|
||||
let gFxAOAuthTokenData = null;
|
||||
let gFxAOAuthProfile = null;
|
||||
let gErrors = new Map();
|
||||
|
||||
/**
|
||||
@ -884,6 +888,10 @@ this.MozLoopService = {
|
||||
MozLoopServiceInternal.doNotDisturb = aFlag;
|
||||
},
|
||||
|
||||
get userProfile() {
|
||||
return gFxAOAuthProfile;
|
||||
},
|
||||
|
||||
get errors() {
|
||||
return MozLoopServiceInternal.errors;
|
||||
},
|
||||
@ -1004,9 +1012,23 @@ this.MozLoopService = {
|
||||
}
|
||||
return gFxAOAuthTokenData;
|
||||
}));
|
||||
},
|
||||
error => {
|
||||
}).then(tokenData => {
|
||||
let client = new FxAccountsProfileClient({
|
||||
serverURL: gFxAOAuthClient.parameters.profile_uri,
|
||||
token: tokenData.access_token
|
||||
});
|
||||
client.fetchProfile().then(result => {
|
||||
gFxAOAuthProfile = result;
|
||||
MozLoopServiceInternal.notifyStatusChanged();
|
||||
}, error => {
|
||||
console.error("Failed to retrieve profile", error);
|
||||
gFxAOAuthProfile = null;
|
||||
MozLoopServiceInternal.notifyStatusChanged();
|
||||
});
|
||||
return tokenData;
|
||||
}).catch(error => {
|
||||
gFxAOAuthTokenData = null;
|
||||
gFxAOAuthProfile = null;
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
|
@ -229,8 +229,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
},
|
||||
|
||||
_isSignedIn: function() {
|
||||
// XXX to be implemented - bug 979845
|
||||
return !!navigator.mozLoop.loggedInToFxA;
|
||||
return !!navigator.mozLoop.userProfile;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
@ -448,6 +447,19 @@ loop.panel = (function(_, mozL10n) {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* FxA user identity (guest/authenticated) component.
|
||||
*/
|
||||
var UserIdentity = React.createClass({displayName: 'UserIdentity',
|
||||
render: function() {
|
||||
return (
|
||||
React.DOM.p({className: "user-identity"},
|
||||
this.props.displayName
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Panel view.
|
||||
*/
|
||||
@ -456,12 +468,32 @@ loop.panel = (function(_, mozL10n) {
|
||||
notifications: React.PropTypes.object.isRequired,
|
||||
client: React.PropTypes.object.isRequired,
|
||||
// Mostly used for UI components showcase and unit tests
|
||||
callUrl: React.PropTypes.string
|
||||
callUrl: React.PropTypes.string,
|
||||
userProfile: React.PropTypes.object,
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
userProfile: this.props.userProfile || navigator.mozLoop.userProfile,
|
||||
};
|
||||
},
|
||||
|
||||
_onAuthStatusChange: function() {
|
||||
this.setState({userProfile: navigator.mozLoop.userProfile});
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
window.addEventListener("LoopStatusChanged", this._onAuthStatusChange);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
window.removeEventListener("LoopStatusChanged", this._onAuthStatusChange);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var NotificationListView = sharedViews.NotificationListView;
|
||||
|
||||
var displayName = this.state.userProfile && this.state.userProfile.email ||
|
||||
__("display_name_guest");
|
||||
return (
|
||||
React.DOM.div(null,
|
||||
NotificationListView({notifications: this.props.notifications,
|
||||
@ -478,7 +510,10 @@ loop.panel = (function(_, mozL10n) {
|
||||
)
|
||||
),
|
||||
React.DOM.div({className: "footer"},
|
||||
AvailabilityDropdown(null),
|
||||
React.DOM.div({className: "user-details"},
|
||||
UserIdentity({displayName: displayName}),
|
||||
AvailabilityDropdown(null)
|
||||
),
|
||||
AuthLink(null),
|
||||
SettingsDropdown(null)
|
||||
)
|
||||
@ -543,6 +578,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
|
||||
return {
|
||||
init: init,
|
||||
UserIdentity: UserIdentity,
|
||||
AvailabilityDropdown: AvailabilityDropdown,
|
||||
CallUrlResult: CallUrlResult,
|
||||
PanelView: PanelView,
|
||||
|
@ -229,8 +229,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
},
|
||||
|
||||
_isSignedIn: function() {
|
||||
// XXX to be implemented - bug 979845
|
||||
return !!navigator.mozLoop.loggedInToFxA;
|
||||
return !!navigator.mozLoop.userProfile;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
@ -448,6 +447,19 @@ loop.panel = (function(_, mozL10n) {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* FxA user identity (guest/authenticated) component.
|
||||
*/
|
||||
var UserIdentity = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<p className="user-identity">
|
||||
{this.props.displayName}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Panel view.
|
||||
*/
|
||||
@ -456,12 +468,32 @@ loop.panel = (function(_, mozL10n) {
|
||||
notifications: React.PropTypes.object.isRequired,
|
||||
client: React.PropTypes.object.isRequired,
|
||||
// Mostly used for UI components showcase and unit tests
|
||||
callUrl: React.PropTypes.string
|
||||
callUrl: React.PropTypes.string,
|
||||
userProfile: React.PropTypes.object,
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
userProfile: this.props.userProfile || navigator.mozLoop.userProfile,
|
||||
};
|
||||
},
|
||||
|
||||
_onAuthStatusChange: function() {
|
||||
this.setState({userProfile: navigator.mozLoop.userProfile});
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
window.addEventListener("LoopStatusChanged", this._onAuthStatusChange);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
window.removeEventListener("LoopStatusChanged", this._onAuthStatusChange);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var NotificationListView = sharedViews.NotificationListView;
|
||||
|
||||
var displayName = this.state.userProfile && this.state.userProfile.email ||
|
||||
__("display_name_guest");
|
||||
return (
|
||||
<div>
|
||||
<NotificationListView notifications={this.props.notifications}
|
||||
@ -478,7 +510,10 @@ loop.panel = (function(_, mozL10n) {
|
||||
</Tab>
|
||||
</TabView>
|
||||
<div className="footer">
|
||||
<AvailabilityDropdown />
|
||||
<div className="user-details">
|
||||
<UserIdentity displayName={displayName} />
|
||||
<AvailabilityDropdown />
|
||||
</div>
|
||||
<AuthLink />
|
||||
<SettingsDropdown />
|
||||
</div>
|
||||
@ -543,6 +578,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
|
||||
return {
|
||||
init: init,
|
||||
UserIdentity: UserIdentity,
|
||||
AvailabilityDropdown: AvailabilityDropdown,
|
||||
CallUrlResult: CallUrlResult,
|
||||
PanelView: PanelView,
|
||||
|
@ -11,4 +11,4 @@ content/VERSION.txt
|
||||
# including the following three lines:
|
||||
content/legal/styles/*.css
|
||||
content/legal/terms/*.html
|
||||
content/legal/terms/!index.html
|
||||
!content/legal/terms/index.html
|
||||
|
@ -140,7 +140,7 @@ describe("loop.panel", function() {
|
||||
});
|
||||
|
||||
describe("loop.panel.PanelView", function() {
|
||||
var fakeClient, callUrlData, view;
|
||||
var fakeClient, callUrlData, view, callTab, contactsTab;
|
||||
|
||||
beforeEach(function() {
|
||||
callUrlData = {
|
||||
@ -158,6 +158,27 @@ describe("loop.panel", function() {
|
||||
notifications: notifications,
|
||||
client: fakeClient
|
||||
}));
|
||||
|
||||
[callTab, contactsTab] =
|
||||
TestUtils.scryRenderedDOMComponentsWithClass(view, "tab");
|
||||
});
|
||||
|
||||
describe('TabView', function() {
|
||||
it("should select contacts tab when clicking tab button", function() {
|
||||
TestUtils.Simulate.click(
|
||||
view.getDOMNode().querySelector('li[data-tab-name="contacts"]'));
|
||||
|
||||
expect(contactsTab.getDOMNode().classList.contains("selected"))
|
||||
.to.be.true;
|
||||
});
|
||||
|
||||
it("should select call tab when clicking tab button", function() {
|
||||
TestUtils.Simulate.click(
|
||||
view.getDOMNode().querySelector('li[data-tab-name="call"]'));
|
||||
|
||||
expect(callTab.getDOMNode().classList.contains("selected"))
|
||||
.to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe("AuthLink", function() {
|
||||
@ -194,7 +215,7 @@ describe("loop.panel", function() {
|
||||
});
|
||||
|
||||
it("should show a signout entry when user is authenticated", function() {
|
||||
navigator.mozLoop.loggedInToFxA = true;
|
||||
navigator.mozLoop.userProfile = {email: "test@example.com"};
|
||||
|
||||
var view = TestUtils.renderIntoDocument(loop.panel.SettingsDropdown());
|
||||
|
||||
@ -205,7 +226,7 @@ describe("loop.panel", function() {
|
||||
});
|
||||
|
||||
it("should show an account entry when user is authenticated", function() {
|
||||
navigator.mozLoop.loggedInToFxA = true;
|
||||
navigator.mozLoop.userProfile = {email: "test@example.com"};
|
||||
|
||||
var view = TestUtils.renderIntoDocument(loop.panel.SettingsDropdown());
|
||||
|
||||
@ -234,7 +255,7 @@ describe("loop.panel", function() {
|
||||
});
|
||||
|
||||
it("should sign out the user on click when authenticated", function() {
|
||||
navigator.mozLoop.loggedInToFxA = true;
|
||||
navigator.mozLoop.userProfile = {email: "test@example.com"};
|
||||
var view = TestUtils.renderIntoDocument(loop.panel.SettingsDropdown());
|
||||
|
||||
TestUtils.Simulate.click(
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
const {
|
||||
gFxAOAuthTokenData,
|
||||
gFxAOAuthProfile,
|
||||
} = Cu.import("resource:///modules/loop/MozLoopService.jsm", {});
|
||||
|
||||
const BASE_URL = "http://mochi.test:8888/browser/browser/components/loop/test/mochitest/loop_fxa.sjs?";
|
||||
@ -224,11 +225,22 @@ add_task(function* basicAuthorizationAndRegistration() {
|
||||
// to be able to check for success on the second registration.
|
||||
mockPushHandler.pushUrl = "https://localhost/pushUrl/fxa";
|
||||
|
||||
yield loadLoopPanel({loopURL: BASE_URL, stayOnline: true});
|
||||
let loopDoc = document.getElementById("loop").contentDocument;
|
||||
let visibleEmail = loopDoc.getElementsByClassName("user-identity")[0];
|
||||
is(visibleEmail.textContent, "Guest", "Guest should be displayed on the panel when not logged in");
|
||||
is(MozLoopService.userProfile, null, "profile should be null before log-in");
|
||||
|
||||
let tokenData = yield MozLoopService.logInToFxA();
|
||||
yield promiseObserverNotified("loop-status-changed");
|
||||
ise(tokenData.access_token, "code1_access_token", "Check access_token");
|
||||
ise(tokenData.scope, "profile", "Check scope");
|
||||
ise(tokenData.token_type, "bearer", "Check token_type");
|
||||
|
||||
is(MozLoopService.userProfile.email, "test@example.com", "email should exist in the profile data");
|
||||
is(MozLoopService.userProfile.uid, "1234abcd", "uid should exist in the profile data");
|
||||
is(visibleEmail.textContent, "test@example.com", "the email should be correct on the panel");
|
||||
|
||||
let registrationResponse = yield promiseOAuthGetRegistration(BASE_URL);
|
||||
ise(registrationResponse.response.simplePushURL, "https://localhost/pushUrl/fxa", "Check registered push URL");
|
||||
});
|
||||
|
@ -58,17 +58,19 @@ function promiseGetMozLoopAPI() {
|
||||
*
|
||||
* This assumes that the tests are running in a generatorTest.
|
||||
*/
|
||||
function loadLoopPanel() {
|
||||
function loadLoopPanel(aOverrideOptions = {}) {
|
||||
// Set prefs to ensure we don't access the network externally.
|
||||
Services.prefs.setCharPref("services.push.serverURL", "ws://localhost/");
|
||||
Services.prefs.setCharPref("loop.server", "http://localhost/");
|
||||
Services.prefs.setCharPref("services.push.serverURL", aOverrideOptions.pushURL || "ws://localhost/");
|
||||
Services.prefs.setCharPref("loop.server", aOverrideOptions.loopURL || "http://localhost/");
|
||||
|
||||
// Turn off the network for loop tests, so that we don't
|
||||
// try to access the remote servers. If we want to turn this
|
||||
// back on in future, be careful to check for intermittent
|
||||
// failures.
|
||||
let wasOffline = Services.io.offline;
|
||||
Services.io.offline = true;
|
||||
if (!aOverrideOptions.stayOnline) {
|
||||
Services.io.offline = true;
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("services.push.serverURL");
|
||||
@ -103,6 +105,7 @@ function resetFxA() {
|
||||
global.gFxAOAuthClientPromise = null;
|
||||
global.gFxAOAuthClient = null;
|
||||
global.gFxAOAuthTokenData = null;
|
||||
global.gFxAOAuthProfile = null;
|
||||
const fxASessionPref = MozLoopServiceInternal.getSessionTokenPrefName(LOOP_SESSION_TYPE.FXA);
|
||||
Services.prefs.clearUserPref(fxASessionPref);
|
||||
}
|
||||
@ -119,6 +122,15 @@ function promiseDeletedOAuthParams(baseURL) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function promiseObserverNotified(aTopic) {
|
||||
let deferred = Promise.defer();
|
||||
Services.obs.addObserver(function onNotification(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(onNotification, aTopic);
|
||||
deferred.resolve({subject: aSubject, data: aData});
|
||||
}, aTopic, false);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last registration on the test server.
|
||||
*/
|
||||
|
@ -37,6 +37,9 @@ function handleRequest(request, response) {
|
||||
case "/get_registration": // Test-only
|
||||
get_registration(request, response);
|
||||
return;
|
||||
case "/profile/profile":
|
||||
profile(request, response);
|
||||
return;
|
||||
}
|
||||
response.setStatusLine(request.httpVersion, 404, "Not Found");
|
||||
}
|
||||
@ -49,7 +52,7 @@ function handleRequest(request, response) {
|
||||
*
|
||||
* For a POST the X-Params header should contain a JSON object with keys to set for /fxa-oauth/params.
|
||||
* A DELETE request will delete the stored parameters and should be run in a cleanup function to
|
||||
* avoid interfering with subsequen tests.
|
||||
* avoid interfering with subsequent tests.
|
||||
*/
|
||||
function setup_params(request, response) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
@ -166,6 +169,19 @@ function token(request, response) {
|
||||
response.write(JSON.stringify(tokenData, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /profile
|
||||
*
|
||||
*/
|
||||
function profile(request, response) {
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8", false);
|
||||
let profile = {
|
||||
email: "test@example.com",
|
||||
uid: "1234abcd",
|
||||
};
|
||||
response.write(JSON.stringify(profile, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /registration
|
||||
*
|
||||
|
@ -126,11 +126,24 @@
|
||||
PanelView({client: mockClient, notifications: notifications,
|
||||
callUrl: "http://invalid.example.url/"})
|
||||
),
|
||||
Example({summary: "Call URL retrieved - authenticated", dashed: "true", style: {width: "332px"}},
|
||||
PanelView({client: mockClient, notifications: notifications,
|
||||
callUrl: "http://invalid.example.url/",
|
||||
userProfile: {email: "test@example.com"}})
|
||||
),
|
||||
Example({summary: "Pending call url retrieval", dashed: "true", style: {width: "332px"}},
|
||||
PanelView({client: mockClient, notifications: notifications})
|
||||
),
|
||||
Example({summary: "Pending call url retrieval - authenticated", dashed: "true", style: {width: "332px"}},
|
||||
PanelView({client: mockClient, notifications: notifications,
|
||||
userProfile: {email: "test@example.com"}})
|
||||
),
|
||||
Example({summary: "Error Notification", dashed: "true", style: {width: "332px"}},
|
||||
PanelView({client: mockClient, notifications: errNotifications})
|
||||
),
|
||||
Example({summary: "Error Notification - authenticated", dashed: "true", style: {width: "332px"}},
|
||||
PanelView({client: mockClient, notifications: errNotifications,
|
||||
userProfile: {email: "test@example.com"}})
|
||||
)
|
||||
),
|
||||
|
||||
|
@ -126,12 +126,25 @@
|
||||
<PanelView client={mockClient} notifications={notifications}
|
||||
callUrl="http://invalid.example.url/" />
|
||||
</Example>
|
||||
<Example summary="Call URL retrieved - authenticated" dashed="true" style={{width: "332px"}}>
|
||||
<PanelView client={mockClient} notifications={notifications}
|
||||
callUrl="http://invalid.example.url/"
|
||||
userProfile={{email: "test@example.com"}} />
|
||||
</Example>
|
||||
<Example summary="Pending call url retrieval" dashed="true" style={{width: "332px"}}>
|
||||
<PanelView client={mockClient} notifications={notifications} />
|
||||
</Example>
|
||||
<Example summary="Pending call url retrieval - authenticated" dashed="true" style={{width: "332px"}}>
|
||||
<PanelView client={mockClient} notifications={notifications}
|
||||
userProfile={{email: "test@example.com"}} />
|
||||
</Example>
|
||||
<Example summary="Error Notification" dashed="true" style={{width: "332px"}}>
|
||||
<PanelView client={mockClient} notifications={errNotifications}/>
|
||||
</Example>
|
||||
<Example summary="Error Notification - authenticated" dashed="true" style={{width: "332px"}}>
|
||||
<PanelView client={mockClient} notifications={errNotifications}
|
||||
userProfile={{email: "test@example.com"}} />
|
||||
</Example>
|
||||
</Section>
|
||||
|
||||
<Section name="IncomingCallView">
|
||||
|
@ -149,7 +149,9 @@
|
||||
tabscrolling="true"
|
||||
showcommentcolumn="true"
|
||||
observes="paneElementsBroadcaster"
|
||||
placeholder="&editBookmarkOverlay.tagsEmptyDesc.label;"/>
|
||||
placeholder="&editBookmarkOverlay.tagsEmptyDesc.label;"
|
||||
maxlength="1000"
|
||||
/>
|
||||
<button id="editBMPanel_tagsSelectorExpander"
|
||||
class="expander-down"
|
||||
tooltiptext="&editBookmarkOverlay.tagsExpanderDown.tooltip;"
|
||||
|
@ -51,8 +51,8 @@ var gMoveBookmarksDialog = {
|
||||
// Nothing to do if the node is already under the selected folder.
|
||||
if (node.parent.itemId == selectedFolderId)
|
||||
continue;
|
||||
yield PlacesTransactions.MoveItem({ GUID: node.bookmarkGuid
|
||||
, newParentGUID: newParentGUID });
|
||||
yield PlacesTransactions.Move({ GUID: node.bookmarkGuid
|
||||
, newParentGUID: newParentGUID });
|
||||
}
|
||||
}.bind(this)).then(null, Components.utils.reportError);
|
||||
},
|
||||
|
@ -6,6 +6,11 @@
|
||||
width: 17em;
|
||||
}
|
||||
|
||||
.popup-notification-item-message[popupid="bad-content"][mixedblockdisabled]:not(.popup-notification-item-message-critical),
|
||||
.popup-notification-item-message[popupid="bad-content"][trackingblockdisabled]:not(.popup-notification-item-message-critical) {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
.popup-notification-item-message-critical[popupid="bad-content"] {
|
||||
color: #d74345;
|
||||
font-style: italic;
|
||||
|
@ -23,6 +23,16 @@ prefpane {
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
* {
|
||||
-moz-user-select: text;
|
||||
}
|
||||
|
||||
button,
|
||||
treecol {
|
||||
/* override the * rule */
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
/* Category List */
|
||||
|
||||
.category-icon {
|
||||
|
@ -6,11 +6,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "CubebUtils.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "prdtoa.h"
|
||||
|
||||
#define PREF_VOLUME_SCALE "media.volume_scale"
|
||||
@ -18,28 +15,18 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace {
|
||||
|
||||
// Prefered samplerate, in Hz (characteristic of the
|
||||
// hardware/mixer/platform/API used).
|
||||
Atomic<uint32_t> sPreferredSampleRate;
|
||||
|
||||
// This mutex protects the variables below.
|
||||
StaticMutex sMutex;
|
||||
cubeb* sCubebContext;
|
||||
double sVolumeScale;
|
||||
uint32_t sCubebLatency;
|
||||
bool sCubebLatencyPrefSet;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
extern PRLogModuleInfo* gAudioStreamLog;
|
||||
|
||||
static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
|
||||
|
||||
namespace CubebUtils {
|
||||
StaticMutex CubebUtils::sMutex;
|
||||
cubeb* CubebUtils::sCubebContext;
|
||||
uint32_t CubebUtils::sPreferredSampleRate;
|
||||
double CubebUtils::sVolumeScale;
|
||||
uint32_t CubebUtils::sCubebLatency;
|
||||
bool CubebUtils::sCubebLatencyPrefSet;
|
||||
|
||||
void PrefChanged(const char* aPref, void* aClosure)
|
||||
/*static*/ void CubebUtils::PrefChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
|
||||
nsAdoptingString value = Preferences::GetString(aPref);
|
||||
@ -61,7 +48,7 @@ void PrefChanged(const char* aPref, void* aClosure)
|
||||
}
|
||||
}
|
||||
|
||||
bool GetFirstStream()
|
||||
/*static*/ bool CubebUtils::GetFirstStream()
|
||||
{
|
||||
static bool sFirstStream = true;
|
||||
|
||||
@ -71,36 +58,29 @@ bool GetFirstStream()
|
||||
return result;
|
||||
}
|
||||
|
||||
double GetVolumeScale()
|
||||
/*static*/ double CubebUtils::GetVolumeScale()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sVolumeScale;
|
||||
}
|
||||
|
||||
cubeb* GetCubebContext()
|
||||
/*static*/ cubeb* CubebUtils::GetCubebContext()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return GetCubebContextUnlocked();
|
||||
}
|
||||
|
||||
void InitPreferredSampleRate()
|
||||
/*static*/ void CubebUtils::InitPreferredSampleRate()
|
||||
{
|
||||
// The mutex is used here to prohibit concurrent initialization calls, but
|
||||
// sPreferredSampleRate itself is safe to access without the mutex because
|
||||
// it is using atomic storage.
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
uint32_t preferredSampleRate = 0;
|
||||
if (sPreferredSampleRate == 0 &&
|
||||
cubeb_get_preferred_sample_rate(GetCubebContextUnlocked(),
|
||||
&preferredSampleRate) == CUBEB_OK) {
|
||||
sPreferredSampleRate = preferredSampleRate;
|
||||
} else {
|
||||
// Query failed, use a sensible default.
|
||||
&sPreferredSampleRate) != CUBEB_OK) {
|
||||
sPreferredSampleRate = 44100;
|
||||
}
|
||||
}
|
||||
|
||||
cubeb* GetCubebContextUnlocked()
|
||||
/*static*/ cubeb* CubebUtils::GetCubebContextUnlocked()
|
||||
{
|
||||
sMutex.AssertCurrentThreadOwns();
|
||||
if (sCubebContext ||
|
||||
@ -111,19 +91,19 @@ cubeb* GetCubebContextUnlocked()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t GetCubebLatency()
|
||||
/*static*/ uint32_t CubebUtils::GetCubebLatency()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sCubebLatency;
|
||||
}
|
||||
|
||||
bool CubebLatencyPrefSet()
|
||||
/*static*/ bool CubebUtils::CubebLatencyPrefSet()
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return sCubebLatencyPrefSet;
|
||||
}
|
||||
|
||||
void InitLibrary()
|
||||
/*static*/ void CubebUtils::InitLibrary()
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
gAudioStreamLog = PR_NewLogModule("AudioStream");
|
||||
@ -134,7 +114,7 @@ void InitLibrary()
|
||||
Preferences::RegisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
|
||||
}
|
||||
|
||||
void ShutdownLibrary()
|
||||
/*static*/ void CubebUtils::ShutdownLibrary()
|
||||
{
|
||||
Preferences::UnregisterCallback(PrefChanged, PREF_VOLUME_SCALE);
|
||||
Preferences::UnregisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
|
||||
@ -146,20 +126,20 @@ void ShutdownLibrary()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t MaxNumberOfChannels()
|
||||
/*static*/ int CubebUtils::MaxNumberOfChannels()
|
||||
{
|
||||
cubeb* cubebContext = GetCubebContext();
|
||||
cubeb* cubebContext = CubebUtils::GetCubebContext();
|
||||
uint32_t maxNumberOfChannels;
|
||||
if (cubebContext &&
|
||||
cubeb_get_max_channel_count(cubebContext,
|
||||
&maxNumberOfChannels) == CUBEB_OK) {
|
||||
return maxNumberOfChannels;
|
||||
return static_cast<int>(maxNumberOfChannels);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t PreferredSampleRate()
|
||||
/*static*/ int CubebUtils::PreferredSampleRate()
|
||||
{
|
||||
MOZ_ASSERT(sPreferredSampleRate,
|
||||
"sPreferredSampleRate has not been initialized!");
|
||||
@ -167,7 +147,7 @@ uint32_t PreferredSampleRate()
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__) && defined(MOZ_B2G)
|
||||
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
/*static*/ cubeb_stream_type CubebUtils::ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
{
|
||||
switch(aChannel) {
|
||||
case dom::AudioChannel::Normal:
|
||||
@ -191,5 +171,4 @@ cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace CubebUtils
|
||||
} // namespace mozilla
|
||||
}
|
||||
|
@ -8,42 +8,65 @@
|
||||
#define CubebUtils_h_
|
||||
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "nsAutoRef.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
|
||||
{
|
||||
public:
|
||||
static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace CubebUtils {
|
||||
|
||||
// Initialize Audio Library. Some Audio backends require initializing the
|
||||
// library before using it.
|
||||
void InitLibrary();
|
||||
class CubebUtils {
|
||||
public:
|
||||
// Initialize Audio Library. Some Audio backends require initializing the
|
||||
// library before using it.
|
||||
static void InitLibrary();
|
||||
|
||||
// Shutdown Audio Library. Some Audio backends require shutting down the
|
||||
// library after using it.
|
||||
void ShutdownLibrary();
|
||||
// Shutdown Audio Library. Some Audio backends require shutting down the
|
||||
// library after using it.
|
||||
static void ShutdownLibrary();
|
||||
|
||||
// Returns the maximum number of channels supported by the audio hardware.
|
||||
uint32_t MaxNumberOfChannels();
|
||||
// Returns the maximum number of channels supported by the audio hardware.
|
||||
static int MaxNumberOfChannels();
|
||||
|
||||
// Queries the samplerate the hardware/mixer runs at, and stores it.
|
||||
// Can be called on any thread. When this returns, it is safe to call
|
||||
// PreferredSampleRate.
|
||||
void InitPreferredSampleRate();
|
||||
// Queries the samplerate the hardware/mixer runs at, and stores it.
|
||||
// Can be called on any thread. When this returns, it is safe to call
|
||||
// PreferredSampleRate without locking.
|
||||
static void InitPreferredSampleRate();
|
||||
// Get the aformentionned sample rate. Does not lock.
|
||||
static int PreferredSampleRate();
|
||||
|
||||
// Get the aforementioned sample rate. Thread safe.
|
||||
uint32_t PreferredSampleRate();
|
||||
|
||||
void PrefChanged(const char* aPref, void* aClosure);
|
||||
double GetVolumeScale();
|
||||
bool GetFirstStream();
|
||||
cubeb* GetCubebContext();
|
||||
cubeb* GetCubebContextUnlocked();
|
||||
uint32_t GetCubebLatency();
|
||||
bool CubebLatencyPrefSet();
|
||||
static void PrefChanged(const char* aPref, void* aClosure);
|
||||
static double GetVolumeScale();
|
||||
static bool GetFirstStream();
|
||||
static cubeb* GetCubebContext();
|
||||
static cubeb* GetCubebContextUnlocked();
|
||||
static uint32_t GetCubebLatency();
|
||||
static bool CubebLatencyPrefSet();
|
||||
#if defined(__ANDROID__) && defined(MOZ_B2G)
|
||||
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
||||
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
||||
#endif
|
||||
|
||||
} // namespace CubebUtils
|
||||
} // namespace mozilla
|
||||
private:
|
||||
// This mutex protects the static members below.
|
||||
static StaticMutex sMutex;
|
||||
static cubeb* sCubebContext;
|
||||
|
||||
// Prefered samplerate, in Hz (characteristic of the
|
||||
// hardware/mixer/platform/API used).
|
||||
static uint32_t sPreferredSampleRate;
|
||||
|
||||
static double sVolumeScale;
|
||||
static uint32_t sCubebLatency;
|
||||
static bool sCubebLatencyPrefSet;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // CubebUtils_h_
|
||||
|
@ -14,15 +14,9 @@
|
||||
|
||||
struct cubeb_stream;
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
|
||||
{
|
||||
public:
|
||||
static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
||||
/**
|
||||
* Assume we can run an iteration of the MediaStreamGraph loop in this much time
|
||||
* or less.
|
||||
|
@ -7,11 +7,9 @@
|
||||
#include "BluetoothRilListener.h"
|
||||
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIMobileConnectionInfo.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
#include "nsITelephonyService.h"
|
||||
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
|
||||
#include "nsIRadioInterfaceLayer.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -181,15 +179,11 @@ MobileConnectionListener::Listen(bool aStart)
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(service, false);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
service->GetItemByServiceId(mClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE(connection, false);
|
||||
|
||||
nsresult rv;
|
||||
if (aStart) {
|
||||
rv = connection->RegisterListener(this);
|
||||
rv = service->RegisterListener(mClientId, this);
|
||||
} else {
|
||||
rv = connection->UnregisterListener(this);
|
||||
rv = service->UnregisterListener(mClientId, this);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
@ -335,17 +329,17 @@ TelephonyListener::Listen(bool aStart)
|
||||
*/
|
||||
BluetoothRilListener::BluetoothRilListener()
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> service =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(service);
|
||||
|
||||
// Query number of total clients (sim slots)
|
||||
uint32_t numItems = 0;
|
||||
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
|
||||
// Init MobileConnectionListener array and IccInfoListener
|
||||
for (uint32_t i = 0; i < numItems; i++) {
|
||||
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
|
||||
}
|
||||
uint32_t numOfClients;
|
||||
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
|
||||
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
|
||||
|
||||
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
|
||||
|
||||
// Init MobileConnectionListener array and IccInfoListener
|
||||
for (uint32_t i = 0; i < numOfClients; i++) {
|
||||
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
|
||||
}
|
||||
|
||||
mTelephonyListener = new TelephonyListener();
|
||||
@ -381,15 +375,8 @@ BluetoothRilListener::SelectClient()
|
||||
NS_ENSURE_TRUE_VOID(service);
|
||||
|
||||
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
service->GetItemByServiceId(i, getter_AddRefs(connection));
|
||||
if (!connection) {
|
||||
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
|
||||
if (!voiceInfo) {
|
||||
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
|
||||
continue;
|
||||
|
@ -612,16 +612,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> mcService =
|
||||
nsCOMPtr<nsIMobileConnectionService> connection =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(mcService);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
nsString type;
|
||||
|
@ -606,16 +606,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> mcService =
|
||||
nsCOMPtr<nsIMobileConnectionService> connection =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(mcService);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
nsString type;
|
||||
@ -650,7 +646,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
* - manual: set mNetworkSelectionMode to 1 (manual)
|
||||
*/
|
||||
nsString mode;
|
||||
connection->GetNetworkSelectionMode(mode);
|
||||
connection->GetNetworkSelectionMode(aClientId, mode);
|
||||
if (mode.EqualsLiteral("manual")) {
|
||||
mNetworkSelectionMode = 1;
|
||||
} else {
|
||||
|
@ -7,11 +7,9 @@
|
||||
#include "BluetoothRilListener.h"
|
||||
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIMobileConnectionInfo.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
#include "nsITelephonyService.h"
|
||||
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
|
||||
#include "nsIRadioInterfaceLayer.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -181,15 +179,11 @@ MobileConnectionListener::Listen(bool aStart)
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(service, false);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
mcService->GetItemByServiceId(mClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE(connection, false);
|
||||
|
||||
nsresult rv;
|
||||
if (aStart) {
|
||||
rv = connection->RegisterListener(this);
|
||||
rv = service->RegisterListener(mClientId, this);
|
||||
} else {
|
||||
rv = connection->UnregisterListener(this);
|
||||
rv = service->UnregisterListener(mClientId, this);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
@ -335,17 +329,17 @@ TelephonyListener::Listen(bool aStart)
|
||||
*/
|
||||
BluetoothRilListener::BluetoothRilListener()
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> service =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(service);
|
||||
|
||||
// Query number of total clients (sim slots)
|
||||
uint32_t numItems = 0;
|
||||
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
|
||||
// Init MobileConnectionListener array and IccInfoListener
|
||||
for (uint32_t i = 0; i < numItems; i++) {
|
||||
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
|
||||
}
|
||||
uint32_t numOfClients;
|
||||
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
|
||||
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
|
||||
|
||||
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
|
||||
|
||||
// Init MobileConnectionListener array and IccInfoListener
|
||||
for (uint32_t i = 0; i < numOfClients; i++) {
|
||||
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
|
||||
}
|
||||
|
||||
mTelephonyListener = new TelephonyListener();
|
||||
@ -381,15 +375,8 @@ BluetoothRilListener::SelectClient()
|
||||
NS_ENSURE_TRUE_VOID(service);
|
||||
|
||||
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
service->GetItemByServiceId(i, getter_AddRefs(connection));
|
||||
if (!connection) {
|
||||
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
|
||||
if (!voiceInfo) {
|
||||
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
|
||||
continue;
|
||||
|
@ -615,16 +615,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> mcService =
|
||||
nsCOMPtr<nsIMobileConnectionService> connection =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(mcService);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
nsString type;
|
||||
|
@ -606,16 +606,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> mcService =
|
||||
nsCOMPtr<nsIMobileConnectionService> connection =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(mcService);
|
||||
|
||||
nsCOMPtr<nsIMobileConnection> connection;
|
||||
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoice(getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
nsString type;
|
||||
@ -650,7 +646,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
* - manual: set mNetworkSelectionMode to 1 (manual)
|
||||
*/
|
||||
nsString mode;
|
||||
connection->GetNetworkSelectionMode(mode);
|
||||
connection->GetNetworkSelectionMode(aClientId, mode);
|
||||
if (mode.EqualsLiteral("manual")) {
|
||||
mNetworkSelectionMode = 1;
|
||||
} else {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(9b12f566-2c7f-48ef-990d-e5092a71d11e)]
|
||||
[scriptable, uuid(9f1c43b9-f01b-4c87-ad3d-1a86520c2159)]
|
||||
interface nsINotificationStorageCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -27,7 +27,8 @@ interface nsINotificationStorageCallback : nsISupports
|
||||
in DOMString body,
|
||||
in DOMString tag,
|
||||
in DOMString icon,
|
||||
in DOMString data);
|
||||
in DOMString data,
|
||||
in DOMString behavior);
|
||||
|
||||
/**
|
||||
* Callback function used to notify C++ the we have returned
|
||||
@ -40,7 +41,7 @@ interface nsINotificationStorageCallback : nsISupports
|
||||
/**
|
||||
* Interface for notification persistence layer.
|
||||
*/
|
||||
[scriptable, uuid(1be733d9-d614-43f2-9fd4-8f573a33b215)]
|
||||
[scriptable, uuid(f5145be6-e34b-468b-84da-c8c4c1ad60fe)]
|
||||
interface nsINotificationStorage : nsISupports
|
||||
{
|
||||
|
||||
@ -70,7 +71,8 @@ interface nsINotificationStorage : nsISupports
|
||||
in DOMString tag,
|
||||
in DOMString icon,
|
||||
in DOMString alertName,
|
||||
in DOMString data);
|
||||
in DOMString data,
|
||||
in DOMString behavior);
|
||||
|
||||
/**
|
||||
* Retrieve a list of notifications.
|
||||
|
@ -126,7 +126,6 @@
|
||||
#include "ipc/Nuwa.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
||||
#include "mozilla/dom/PFileSystemRequestChild.h"
|
||||
@ -155,13 +154,17 @@
|
||||
#include "mozilla/net/NeckoMessageUtils.h"
|
||||
#include "mozilla/RemoteSpellCheckEngineChild.h"
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
#endif
|
||||
|
||||
using namespace base;
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::docshell;
|
||||
using namespace mozilla::dom::bluetooth;
|
||||
using namespace mozilla::dom::devicestorage;
|
||||
using namespace mozilla::dom::ipc;
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
using namespace mozilla::dom::telephony;
|
||||
using namespace mozilla::hal_sandbox;
|
||||
|
@ -44,11 +44,10 @@
|
||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
|
||||
#include "mozilla/dom/FileSystemRequestParent.h"
|
||||
#include "mozilla/dom/GeolocationBinding.h"
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsParent.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/telephony/TelephonyParent.h"
|
||||
#include "mozilla/dom/time/DateCacheCleaner.h"
|
||||
#include "SmsParent.h"
|
||||
#include "mozilla/hal_sandbox/PHalParent.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
@ -178,6 +177,10 @@ using namespace mozilla::system;
|
||||
#include "nsIIPCBackgroundChildCreateCallback.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
|
||||
#include "mozilla/Sandbox.h"
|
||||
@ -192,7 +195,6 @@ using namespace mozilla::dom::bluetooth;
|
||||
using namespace mozilla::dom::devicestorage;
|
||||
using namespace mozilla::dom::indexedDB;
|
||||
using namespace mozilla::dom::power;
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
using namespace mozilla::dom::telephony;
|
||||
using namespace mozilla::hal;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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 "mozilla/dom/DOMMMIError.h"
|
||||
#include "DOMMMIError.h"
|
||||
#include "mozilla/dom/DOMMMIErrorBinding.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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 "mozilla/dom/MobileCellInfo.h"
|
||||
#include "MobileCellInfo.h"
|
||||
#include "mozilla/dom/MozMobileCellInfoBinding.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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 "mozilla/dom/MobileConnection.h"
|
||||
#include "MobileConnection.h"
|
||||
|
||||
#include "MobileConnectionCallback.h"
|
||||
#include "mozilla/dom/CFStateChangeEvent.h"
|
||||
@ -42,7 +42,6 @@
|
||||
|
||||
using mozilla::ErrorResult;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
|
||||
class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener
|
||||
{
|
||||
@ -78,9 +77,8 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
|
||||
DOMEventTargetHelper)
|
||||
// Don't traverse mListener because it doesn't keep any reference to
|
||||
// MobileConnection but a raw pointer instead. Neither does mMobileConnection
|
||||
// because it's an xpcom service owned object and is only released at shutting
|
||||
// down.
|
||||
// MobileConnection but a raw pointer instead. Neither does mService because
|
||||
// it's an xpcom service and is only released at shutting down.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoice)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
@ -103,32 +101,25 @@ NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper)
|
||||
|
||||
MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mClientId(aClientId)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionService> service =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
|
||||
// Not being able to acquire the service isn't fatal since we check
|
||||
// for it explicitly below.
|
||||
if (!service) {
|
||||
if (!mService) {
|
||||
NS_WARNING("Could not acquire nsIMobileConnectionService!");
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = service->GetItemByServiceId(aClientId,
|
||||
getter_AddRefs(mMobileConnection));
|
||||
if (NS_FAILED(rv) || !mMobileConnection) {
|
||||
NS_WARNING("Could not acquire nsIMobileConnection!");
|
||||
return;
|
||||
}
|
||||
|
||||
mListener = new Listener(this);
|
||||
mVoice = new MobileConnectionInfo(GetOwner());
|
||||
mData = new MobileConnectionInfo(GetOwner());
|
||||
|
||||
if (CheckPermission("mobileconnection")) {
|
||||
DebugOnly<nsresult> rv = mMobileConnection->RegisterListener(mListener);
|
||||
DebugOnly<nsresult> rv = mService->RegisterListener(mClientId, mListener);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
||||
"Failed registering mobile connection messages with service");
|
||||
UpdateVoice();
|
||||
@ -140,8 +131,8 @@ void
|
||||
MobileConnection::Shutdown()
|
||||
{
|
||||
if (mListener) {
|
||||
if (mMobileConnection) {
|
||||
mMobileConnection->UnregisterListener(mListener);
|
||||
if (mService) {
|
||||
mService->UnregisterListener(mClientId, mListener);
|
||||
}
|
||||
|
||||
mListener->Disconnect();
|
||||
@ -184,24 +175,24 @@ MobileConnection::CheckPermission(const char* aType) const
|
||||
void
|
||||
MobileConnection::UpdateVoice()
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info;
|
||||
mMobileConnection->GetVoice(getter_AddRefs(info));
|
||||
mService->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
|
||||
mVoice->Update(info);
|
||||
}
|
||||
|
||||
void
|
||||
MobileConnection::UpdateData()
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info;
|
||||
mMobileConnection->GetData(getter_AddRefs(info));
|
||||
mService->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
|
||||
mData->Update(info);
|
||||
}
|
||||
|
||||
@ -212,11 +203,11 @@ MobileConnection::GetLastKnownNetwork(nsString& aRetVal) const
|
||||
{
|
||||
aRetVal.SetIsVoid(true);
|
||||
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMobileConnection->GetLastKnownNetwork(aRetVal);
|
||||
mService->GetLastKnownNetwork(mClientId, aRetVal);
|
||||
}
|
||||
|
||||
void
|
||||
@ -224,11 +215,11 @@ MobileConnection::GetLastKnownHomeNetwork(nsString& aRetVal) const
|
||||
{
|
||||
aRetVal.SetIsVoid(true);
|
||||
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMobileConnection->GetLastKnownHomeNetwork(aRetVal);
|
||||
mService->GetLastKnownHomeNetwork(mClientId, aRetVal);
|
||||
}
|
||||
|
||||
// All fields below require the "mobileconnection" permission.
|
||||
@ -250,11 +241,11 @@ MobileConnection::GetIccId(nsString& aRetVal) const
|
||||
{
|
||||
aRetVal.SetIsVoid(true);
|
||||
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMobileConnection->GetIccId(aRetVal);
|
||||
mService->GetIccId(mClientId, aRetVal);
|
||||
}
|
||||
|
||||
Nullable<MobileNetworkSelectionMode>
|
||||
@ -263,12 +254,12 @@ MobileConnection::GetNetworkSelectionMode() const
|
||||
Nullable<MobileNetworkSelectionMode> retVal =
|
||||
Nullable<MobileNetworkSelectionMode>();
|
||||
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
nsAutoString mode;
|
||||
mMobileConnection->GetNetworkSelectionMode(mode);
|
||||
mService->GetNetworkSelectionMode(mClientId, mode);
|
||||
CONVERT_STRING_TO_NULLABLE_ENUM(mode, MobileNetworkSelectionMode, retVal);
|
||||
|
||||
return retVal;
|
||||
@ -279,12 +270,12 @@ MobileConnection::GetRadioState() const
|
||||
{
|
||||
Nullable<MobileRadioState> retVal = Nullable<MobileRadioState>();
|
||||
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
nsAutoString state;
|
||||
mMobileConnection->GetRadioState(state);
|
||||
mService->GetRadioState(mClientId, state);
|
||||
CONVERT_STRING_TO_NULLABLE_ENUM(state, MobileRadioState, retVal);
|
||||
|
||||
return retVal;
|
||||
@ -293,33 +284,45 @@ MobileConnection::GetRadioState() const
|
||||
void
|
||||
MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
return;
|
||||
}
|
||||
|
||||
char16_t** types = nullptr;
|
||||
uint32_t length = 0;
|
||||
nsCOMPtr<nsIVariant> variant;
|
||||
mService->GetSupportedNetworkTypes(mClientId,
|
||||
getter_AddRefs(variant));
|
||||
|
||||
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
uint16_t type;
|
||||
nsIID iid;
|
||||
uint32_t count;
|
||||
void* data;
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsDependentString rawType(types[i]);
|
||||
Nullable<MobileNetworkType> type = Nullable<MobileNetworkType>();
|
||||
CONVERT_STRING_TO_NULLABLE_ENUM(rawType, MobileNetworkType, type);
|
||||
|
||||
if (!type.IsNull()) {
|
||||
aTypes.AppendElement(type.Value());
|
||||
}
|
||||
// Convert the nsIVariant to an array. We own the resulting buffer and its
|
||||
// elements.
|
||||
if (NS_FAILED(variant->GetAsArray(&type, &iid, &count, &data))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, types);
|
||||
// We expect the element type is wstring.
|
||||
if (type == nsIDataType::VTYPE_WCHAR_STR) {
|
||||
char16_t** rawArray = reinterpret_cast<char16_t**>(data);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
nsDependentString rawType(rawArray[i]);
|
||||
Nullable<MobileNetworkType> type = Nullable<MobileNetworkType>();
|
||||
CONVERT_STRING_TO_NULLABLE_ENUM(rawType, MobileNetworkType, type);
|
||||
|
||||
if (!type.IsNull()) {
|
||||
aTypes.AppendElement(type.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_Free(data);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetNetworks(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -328,7 +331,7 @@ MobileConnection::GetNetworks(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetNetworks(requestCallback);
|
||||
nsresult rv = mService->GetNetworks(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -340,7 +343,7 @@ MobileConnection::GetNetworks(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -349,7 +352,7 @@ MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SelectNetwork(&aNetwork, requestCallback);
|
||||
nsresult rv = mService->SelectNetwork(mClientId, &aNetwork, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -361,7 +364,7 @@ MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -370,8 +373,8 @@ MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->SelectNetworkAutomatically(requestCallback);
|
||||
nsresult rv = mService->SelectNetworkAutomatically(mClientId,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -384,7 +387,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -396,8 +399,8 @@ MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->SetPreferredNetworkType(type, requestCallback);
|
||||
nsresult rv = mService->SetPreferredNetworkType(mClientId, type,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -409,7 +412,7 @@ MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -418,7 +421,7 @@ MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetPreferredNetworkType(requestCallback);
|
||||
nsresult rv = mService->GetPreferredNetworkType(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -431,7 +434,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -443,7 +446,7 @@ MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SetRoamingPreference(mode, requestCallback);
|
||||
nsresult rv = mService->SetRoamingPreference(mClientId, mode, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -455,7 +458,7 @@ MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetRoamingPreference(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -464,7 +467,7 @@ MobileConnection::GetRoamingPreference(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetRoamingPreference(requestCallback);
|
||||
nsresult rv = mService->GetRoamingPreference(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -476,7 +479,7 @@ MobileConnection::GetRoamingPreference(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -485,8 +488,8 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->SetVoicePrivacyMode(aEnabled, requestCallback);
|
||||
nsresult rv = mService->SetVoicePrivacyMode(mClientId, aEnabled,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -498,7 +501,7 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -507,7 +510,7 @@ MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetVoicePrivacyMode(requestCallback);
|
||||
nsresult rv = mService->GetVoicePrivacyMode(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -519,7 +522,7 @@ MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -528,7 +531,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SendMMI(aMMIString, requestCallback);
|
||||
nsresult rv = mService->SendMMI(mClientId, aMMIString, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -540,7 +543,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::CancelMMI(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -549,7 +552,7 @@ MobileConnection::CancelMMI(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->CancelMMI(requestCallback);
|
||||
nsresult rv = mService->CancelMMI(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -561,7 +564,7 @@ MobileConnection::CancelMMI(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -570,7 +573,7 @@ MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetCallForwarding(aReason, requestCallback);
|
||||
nsresult rv = mService->GetCallForwarding(mClientId, aReason, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -583,7 +586,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -605,7 +608,7 @@ MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptio
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SetCallForwarding(options, requestCallback);
|
||||
nsresult rv = mService->SetCallForwarding(mClientId, options, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -618,7 +621,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -640,7 +643,7 @@ MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetCallBarring(options, requestCallback);
|
||||
nsresult rv = mService->GetCallBarring(mClientId, options, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -653,7 +656,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -675,7 +678,7 @@ MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SetCallBarring(options, requestCallback);
|
||||
nsresult rv = mService->SetCallBarring(mClientId, options, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -688,7 +691,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -710,8 +713,8 @@ MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOption
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->ChangeCallBarringPassword(options, requestCallback);
|
||||
nsresult rv = mService->ChangeCallBarringPassword(mClientId, options,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -723,7 +726,7 @@ MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOption
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -732,7 +735,7 @@ MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->GetCallWaiting(requestCallback);
|
||||
nsresult rv = mService->GetCallWaiting(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -744,7 +747,7 @@ MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -753,7 +756,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SetCallWaiting(aEnabled, requestCallback);
|
||||
nsresult rv = mService->SetCallWaiting(mClientId, aEnabled, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -765,7 +768,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -774,8 +777,8 @@ MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->GetCallingLineIdRestriction(requestCallback);
|
||||
nsresult rv = mService->GetCallingLineIdRestriction(mClientId,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -788,7 +791,7 @@ already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -797,8 +800,8 @@ MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv =
|
||||
mMobileConnection->SetCallingLineIdRestriction(aMode, requestCallback);
|
||||
nsresult rv = mService->SetCallingLineIdRestriction(mClientId, aMode,
|
||||
requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -810,7 +813,7 @@ MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -819,7 +822,7 @@ MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->ExitEmergencyCbMode(requestCallback);
|
||||
nsresult rv = mService->ExitEmergencyCbMode(mClientId, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
@ -831,7 +834,7 @@ MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
|
||||
{
|
||||
if (!mMobileConnection) {
|
||||
if (!mService) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
@ -840,7 +843,7 @@ MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
|
||||
nsRefPtr<MobileConnectionCallback> requestCallback =
|
||||
new MobileConnectionCallback(GetOwner(), request);
|
||||
|
||||
nsresult rv = mMobileConnection->SetRadioEnabled(aEnabled, requestCallback);
|
||||
nsresult rv = mService->SetRadioEnabled(mClientId, aEnabled, requestCallback);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
|
@ -5,10 +5,10 @@
|
||||
#ifndef mozilla_dom_MobileConnection_h
|
||||
#define mozilla_dom_MobileConnection_h
|
||||
|
||||
#include "MobileConnectionInfo.h"
|
||||
#include "MobileNetworkInfo.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/DOMRequest.h"
|
||||
#include "mozilla/dom/MobileConnectionInfo.h"
|
||||
#include "mozilla/dom/MobileNetworkInfo.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
@ -163,7 +163,8 @@ private:
|
||||
~MobileConnection();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIMobileConnection> mMobileConnection;
|
||||
uint32_t mClientId;
|
||||
nsCOMPtr<nsIMobileConnectionService> mService;
|
||||
nsRefPtr<Listener> mListener;
|
||||
nsRefPtr<MobileConnectionInfo> mVoice;
|
||||
nsRefPtr<MobileConnectionInfo> mData;
|
||||
|
@ -4,17 +4,9 @@
|
||||
* 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 "mozilla/dom/MobileConnectionArray.h"
|
||||
#include "MobileConnectionArray.h"
|
||||
#include "mozilla/dom/MozMobileConnectionArrayBinding.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
// Service instantiation
|
||||
#include "ipc/MobileConnectionIPCService.h"
|
||||
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
#include "nsIGonkMobileConnectionService.h"
|
||||
#endif
|
||||
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -31,9 +23,14 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileConnectionArray)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MobileConnectionArray::MobileConnectionArray(nsPIDOMWindow* aWindow)
|
||||
: mLengthInitialized(false)
|
||||
: mInitialized(false)
|
||||
, mWindow(aWindow)
|
||||
{
|
||||
uint32_t numRil = mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
|
||||
MOZ_ASSERT(numRil > 0);
|
||||
|
||||
mMobileConnections.SetLength(numRil);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
@ -41,6 +38,17 @@ MobileConnectionArray::~MobileConnectionArray()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MobileConnectionArray::Init()
|
||||
{
|
||||
mInitialized = true;
|
||||
|
||||
for (uint32_t id = 0; id < mMobileConnections.Length(); id++) {
|
||||
nsRefPtr<MobileConnection> mobileConnection = new MobileConnection(mWindow, id);
|
||||
mMobileConnections[id] = mobileConnection;
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindow*
|
||||
MobileConnectionArray::GetParentObject() const
|
||||
{
|
||||
@ -62,53 +70,20 @@ MobileConnectionArray::Item(uint32_t aIndex)
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MobileConnectionArray::Length()
|
||||
MobileConnectionArray::Length() const
|
||||
{
|
||||
if (!mLengthInitialized) {
|
||||
mLengthInitialized = true;
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionService> service =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(service, 0);
|
||||
|
||||
uint32_t length = 0;
|
||||
nsresult rv = service->GetNumItems(&length);
|
||||
NS_ENSURE_SUCCESS(rv, 0);
|
||||
|
||||
mMobileConnections.SetLength(length);
|
||||
}
|
||||
|
||||
return mMobileConnections.Length();
|
||||
}
|
||||
|
||||
MobileConnection*
|
||||
MobileConnectionArray::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
|
||||
aFound = aIndex < Length();
|
||||
if (!aFound) {
|
||||
return nullptr;
|
||||
if (!mInitialized) {
|
||||
Init();
|
||||
}
|
||||
|
||||
if (!mMobileConnections[aIndex]) {
|
||||
mMobileConnections[aIndex] = new MobileConnection(mWindow, aIndex);
|
||||
}
|
||||
aFound = false;
|
||||
aFound = aIndex < mMobileConnections.Length();
|
||||
|
||||
return mMobileConnections[aIndex];
|
||||
}
|
||||
|
||||
already_AddRefed<nsIMobileConnectionService>
|
||||
NS_CreateMobileConnectionService()
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionService> service;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
service = new mozilla::dom::mobileconnection::MobileConnectionIPCService();
|
||||
} else {
|
||||
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
service = do_CreateInstance(GONK_MOBILECONNECTION_SERVICE_CONTRACTID);
|
||||
#endif
|
||||
}
|
||||
|
||||
return service.forget();
|
||||
return aFound ? mMobileConnections[aIndex] : nullptr;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#ifndef mozilla_dom_network_MobileConnectionArray_h__
|
||||
#define mozilla_dom_network_MobileConnectionArray_h__
|
||||
|
||||
#include "mozilla/dom/MobileConnection.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "MobileConnection.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -34,7 +34,7 @@ public:
|
||||
Item(uint32_t aIndex);
|
||||
|
||||
uint32_t
|
||||
Length();
|
||||
Length() const;
|
||||
|
||||
MobileConnection*
|
||||
IndexedGetter(uint32_t aIndex, bool& aFound);
|
||||
@ -42,7 +42,10 @@ public:
|
||||
private:
|
||||
~MobileConnectionArray();
|
||||
|
||||
bool mLengthInitialized;
|
||||
void
|
||||
Init();
|
||||
|
||||
bool mInitialized;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
nsTArray<nsRefPtr<MobileConnection>> mMobileConnections;
|
||||
|
@ -4,16 +4,14 @@
|
||||
|
||||
#include "MobileConnectionCallback.h"
|
||||
|
||||
#include "mozilla/dom/DOMMMIError.h"
|
||||
#include "DOMMMIError.h"
|
||||
#include "mozilla/dom/MobileNetworkInfo.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_ISUPPORTS(MobileConnectionCallback, nsIMobileConnectionCallback)
|
||||
|
||||
@ -319,7 +317,3 @@ MobileConnectionCallback::NotifyError(const nsAString& aName,
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -2,17 +2,16 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_mobileconnection_MobileConnectionCallback_h
|
||||
#define mozilla_dom_mobileconnection_MobileConnectionCallback_h
|
||||
#ifndef mozilla_dom_MobileConnectionCallback_h
|
||||
#define mozilla_dom_MobileConnectionCallback_h
|
||||
|
||||
#include "mozilla/dom/DOMRequest.h"
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h"
|
||||
#include "mozilla/dom/MobileConnectionIPCSerializer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
|
||||
/**
|
||||
* A callback object for handling asynchronous request/response. This object is
|
||||
@ -21,7 +20,7 @@ namespace mobileconnection {
|
||||
* The modules hold the reference of MobileConnectionCallback in OOP mode and
|
||||
* non-OOP mode are different.
|
||||
* - OOP mode: MobileConnectionRequestChild
|
||||
* - non-OOP mode: MobileConnectionService
|
||||
* - non-OOP mode: MobileConnectionGonkService
|
||||
* The reference should be released after Notify*Success/Error is called.
|
||||
*/
|
||||
class MobileConnectionCallback MOZ_FINAL : public nsIMobileConnectionCallback
|
||||
@ -73,8 +72,7 @@ private:
|
||||
nsRefPtr<DOMRequest> mRequest;
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // name space dom
|
||||
} // name space mozilla
|
||||
|
||||
#endif // mozilla_dom_mobileconnection_MobileConnectionCallback_h
|
||||
#endif // mozilla_dom_MobileConnectionCallback_h
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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 "mozilla/dom/MobileConnectionInfo.h"
|
||||
#include "MobileConnectionInfo.h"
|
||||
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
#ifndef mozilla_dom_MobileConnectionInfo_h
|
||||
#define mozilla_dom_MobileConnectionInfo_h
|
||||
|
||||
#include "mozilla/dom/MobileCellInfo.h"
|
||||
#include "mozilla/dom/MobileNetworkInfo.h"
|
||||
#include "MobileCellInfo.h"
|
||||
#include "MobileNetworkInfo.h"
|
||||
#include "mozilla/dom/MozMobileConnectionInfoBinding.h"
|
||||
#include "nsIMobileConnectionInfo.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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 "mozilla/dom/MobileNetworkInfo.h"
|
||||
#include "MobileNetworkInfo.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
@ -14,13 +14,11 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
var RIL = {};
|
||||
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
||||
|
||||
const GONK_MOBILECONNECTIONSERVICE_CONTRACTID =
|
||||
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1";
|
||||
const MOBILECONNECTIONGONKSERVICE_CONTRACTID =
|
||||
"@mozilla.org/mobileconnection/mobileconnectiongonkservice;1";
|
||||
|
||||
const GONK_MOBILECONNECTIONSERVICE_CID =
|
||||
const MOBILECONNECTIONGONKSERVICE_CID =
|
||||
Components.ID("{05e20430-fe65-4984-8df9-a6a504b24a91}");
|
||||
const MOBILECONNECTIONINFO_CID =
|
||||
Components.ID("{8162b3c0-664b-45f6-96cd-f07b4e193b0e}");
|
||||
const MOBILENETWORKINFO_CID =
|
||||
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
|
||||
const MOBILECELLINFO_CID =
|
||||
@ -46,7 +44,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer",
|
||||
|
||||
let DEBUG = RIL.DEBUG_RIL;
|
||||
function debug(s) {
|
||||
dump("MobileConnectionService: " + s + "\n");
|
||||
dump("MobileConnectionGonkService: " + s + "\n");
|
||||
}
|
||||
|
||||
function MobileNetworkInfo() {
|
||||
@ -85,27 +83,6 @@ MobileCellInfo.prototype = {
|
||||
})
|
||||
};
|
||||
|
||||
function MobileConnectionInfo() {}
|
||||
MobileConnectionInfo.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionInfo]),
|
||||
classID: MOBILECONNECTIONINFO_CID,
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
classID: MOBILECONNECTIONINFO_CID,
|
||||
classDescription: "MobileConnectionInfo",
|
||||
interfaces: [Ci.nsIMobileConnectionInfo]
|
||||
}),
|
||||
|
||||
state: null,
|
||||
connected: false,
|
||||
emergencyCallsOnly: false,
|
||||
roaming: false,
|
||||
network: null,
|
||||
cell: null,
|
||||
type: null,
|
||||
signalStrength: null,
|
||||
relSignalStrength: null
|
||||
};
|
||||
|
||||
function CallForwardingOptions(aOptions) {
|
||||
this.active = aOptions.active;
|
||||
this.action = aOptions.action;
|
||||
@ -142,12 +119,28 @@ function MobileConnectionProvider(aClientId, aRadioInterface) {
|
||||
this._listeners = [];
|
||||
|
||||
this.supportedNetworkTypes = this._getSupportedNetworkTypes();
|
||||
this.voice = new MobileConnectionInfo();
|
||||
this.data = new MobileConnectionInfo();
|
||||
// These objects implement the nsIMobileConnectionInfo interface,
|
||||
// although the actual implementation lives in the content process. So are
|
||||
// the child attributes `network` and `cell`, which implement
|
||||
// nsIMobileNetworkInfo and nsIMobileCellInfo respectively.
|
||||
this.voiceInfo = {connected: false,
|
||||
emergencyCallsOnly: false,
|
||||
roaming: false,
|
||||
network: null,
|
||||
cell: null,
|
||||
type: null,
|
||||
signalStrength: null,
|
||||
relSignalStrength: null};
|
||||
this.dataInfo = {connected: false,
|
||||
emergencyCallsOnly: false,
|
||||
roaming: false,
|
||||
network: null,
|
||||
cell: null,
|
||||
type: null,
|
||||
signalStrength: null,
|
||||
relSignalStrength: null};
|
||||
}
|
||||
MobileConnectionProvider.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnection]),
|
||||
|
||||
_clientId: null,
|
||||
_radioInterface: null,
|
||||
_operatorInfo: null,
|
||||
@ -159,10 +152,10 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_selectingNetwork: null,
|
||||
|
||||
voice: null,
|
||||
data: null,
|
||||
voiceInfo: null,
|
||||
dataInfo: null,
|
||||
iccId: null,
|
||||
networkSelectionMode: null,
|
||||
networkSelectMode: null,
|
||||
radioState: null,
|
||||
lastKnownNetwork: null,
|
||||
lastKnownHomeNetwork: null,
|
||||
@ -219,12 +212,12 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_isValidCallForwardingReason: function(aReason) {
|
||||
switch (aReason) {
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_MOBILE_BUSY:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_NO_REPLY:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_NOT_REACHABLE:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_UNCONDITIONAL:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_MOBILE_BUSY:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NO_REPLY:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NOT_REACHABLE:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -236,10 +229,10 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_isValidCallForwardingAction: function(aAction) {
|
||||
switch (aAction) {
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ENABLE:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_REGISTRATION:
|
||||
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ERASURE:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_DISABLE:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ENABLE:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_REGISTRATION:
|
||||
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ERASURE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -251,11 +244,11 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_isValidCallBarringProgram: function(aProgram) {
|
||||
switch (aProgram) {
|
||||
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_OUTGOING:
|
||||
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
|
||||
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
|
||||
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_INCOMING:
|
||||
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
|
||||
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_OUTGOING:
|
||||
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
|
||||
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
|
||||
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_INCOMING:
|
||||
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -285,9 +278,9 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_isValidClirMode: function(aMode) {
|
||||
switch (aMode) {
|
||||
case Ci.nsIMobileConnection.CLIR_DEFAULT:
|
||||
case Ci.nsIMobileConnection.CLIR_INVOCATION:
|
||||
case Ci.nsIMobileConnection.CLIR_SUPPRESSION:
|
||||
case Ci.nsIMobileConnectionService.CLIR_DEFAULT:
|
||||
case Ci.nsIMobileConnectionService.CLIR_INVOCATION:
|
||||
case Ci.nsIMobileConnectionService.CLIR_SUPPRESSION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -300,7 +293,7 @@ MobileConnectionProvider.prototype = {
|
||||
*/
|
||||
_checkRoamingBetweenOperators: function(aNetworkInfo) {
|
||||
// TODO: Bug 864489 - B2G RIL: use ipdl as IPC in MozIccManager
|
||||
// Should get iccInfo from GonkIccProvider.
|
||||
// Should get iccInfo from IccGonkProvider.
|
||||
let iccInfo = this._radioInterface.rilContext.iccInfo;
|
||||
let operator = aNetworkInfo.network;
|
||||
let state = aNetworkInfo.state;
|
||||
@ -393,21 +386,21 @@ MobileConnectionProvider.prototype = {
|
||||
},
|
||||
|
||||
updateVoiceInfo: function(aNewInfo, aBatch = false) {
|
||||
let isUpdated = this._updateInfo(this.voice, aNewInfo);
|
||||
let isUpdated = this._updateInfo(this.voiceInfo, aNewInfo);
|
||||
|
||||
// Make sure we also reset the operator and signal strength information
|
||||
// if we drop off the network.
|
||||
if (this.voice.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
this.voice.cell = null;
|
||||
this.voice.network = null;
|
||||
this.voice.signalStrength = null;
|
||||
this.voice.relSignalStrength = null;
|
||||
if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
this.voiceInfo.cell = null;
|
||||
this.voiceInfo.network = null;
|
||||
this.voiceInfo.signalStrength = null;
|
||||
this.voiceInfo.relSignalStrength = null;
|
||||
} else {
|
||||
this.voice.network = this._operatorInfo;
|
||||
this.voiceInfo.network = this._operatorInfo;
|
||||
}
|
||||
|
||||
// Check roaming state
|
||||
isUpdated = this._checkRoamingBetweenOperators(this.voice) || isUpdated;
|
||||
isUpdated = this._checkRoamingBetweenOperators(this.voiceInfo) || isUpdated;
|
||||
|
||||
if (isUpdated && !aBatch) {
|
||||
this.deliverListenerEvent("notifyVoiceChanged");
|
||||
@ -427,21 +420,21 @@ MobileConnectionProvider.prototype = {
|
||||
aNewInfo.connected = true;
|
||||
}
|
||||
|
||||
isUpdated = this._updateInfo(this.data, aNewInfo);
|
||||
isUpdated = this._updateInfo(this.dataInfo, aNewInfo);
|
||||
|
||||
// Make sure we also reset the operator and signal strength information
|
||||
// if we drop off the network.
|
||||
if (this.data.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
this.data.cell = null;
|
||||
this.data.network = null;
|
||||
this.data.signalStrength = null;
|
||||
this.data.relSignalStrength = null;
|
||||
if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
this.dataInfo.cell = null;
|
||||
this.dataInfo.network = null;
|
||||
this.dataInfo.signalStrength = null;
|
||||
this.dataInfo.relSignalStrength = null;
|
||||
} else {
|
||||
this.data.network = this._operatorInfo;
|
||||
this.dataInfo.network = this._operatorInfo;
|
||||
}
|
||||
|
||||
// Check roaming state
|
||||
isUpdated = this._checkRoamingBetweenOperators(this.data) || isUpdated;
|
||||
isUpdated = this._checkRoamingBetweenOperators(this.dataInfo) || isUpdated;
|
||||
|
||||
if (isUpdated && !aBatch) {
|
||||
this.deliverListenerEvent("notifyDataChanged");
|
||||
@ -465,13 +458,13 @@ MobileConnectionProvider.prototype = {
|
||||
}
|
||||
|
||||
// If the voice is unregistered, no need to send notification.
|
||||
if (this.voice.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
isUpdated && !aBatch) {
|
||||
this.deliverListenerEvent("notifyVoiceChanged");
|
||||
}
|
||||
|
||||
// If the data is unregistered, no need to send notification.
|
||||
if (this.data.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
isUpdated && !aBatch) {
|
||||
this.deliverListenerEvent("notifyDataChanged");
|
||||
}
|
||||
@ -479,15 +472,15 @@ MobileConnectionProvider.prototype = {
|
||||
|
||||
updateSignalInfo: function(aNewInfo, aBatch = false) {
|
||||
// If the voice is not registered, no need to update signal information.
|
||||
if (this.voice.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
if (this._updateInfo(this.voice, aNewInfo.voice) && !aBatch) {
|
||||
if (this.voiceInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
if (this._updateInfo(this.voiceInfo, aNewInfo.voice) && !aBatch) {
|
||||
this.deliverListenerEvent("notifyVoiceChanged");
|
||||
}
|
||||
}
|
||||
|
||||
// If the data is not registered, no need to update signal information.
|
||||
if (this.data.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
if (this._updateInfo(this.data, aNewInfo.data) && !aBatch) {
|
||||
if (this.dataInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
|
||||
if (this._updateInfo(this.dataInfo, aNewInfo.data) && !aBatch) {
|
||||
this.deliverListenerEvent("notifyDataChanged");
|
||||
}
|
||||
}
|
||||
@ -511,11 +504,6 @@ MobileConnectionProvider.prototype = {
|
||||
this.deliverListenerEvent("notifyRadioStateChanged");
|
||||
},
|
||||
|
||||
getSupportedNetworkTypes: function(aTypes) {
|
||||
aTypes.value = this.supportedNetworkTypes.slice();
|
||||
return aTypes.value.length;
|
||||
},
|
||||
|
||||
getNetworks: function(aCallback) {
|
||||
this._radioInterface.sendWorkerMessage("getAvailableNetworks", null,
|
||||
(function(aResponse) {
|
||||
@ -962,7 +950,7 @@ MobileConnectionProvider.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
function MobileConnectionService() {
|
||||
function MobileConnectionGonkService() {
|
||||
this._providers = [];
|
||||
|
||||
let numClients = gRadioInterfaceLayer.numRadioInterfaces;
|
||||
@ -978,15 +966,15 @@ function MobileConnectionService() {
|
||||
|
||||
debug("init complete");
|
||||
}
|
||||
MobileConnectionService.prototype = {
|
||||
classID: GONK_MOBILECONNECTIONSERVICE_CID,
|
||||
classInfo: XPCOMUtils.generateCI({classID: GONK_MOBILECONNECTIONSERVICE_CID,
|
||||
contractID: GONK_MOBILECONNECTIONSERVICE_CONTRACTID,
|
||||
classDescription: "MobileConnectionService",
|
||||
interfaces: [Ci.nsIGonkMobileConnectionService,
|
||||
MobileConnectionGonkService.prototype = {
|
||||
classID: MOBILECONNECTIONGONKSERVICE_CID,
|
||||
classInfo: XPCOMUtils.generateCI({classID: MOBILECONNECTIONGONKSERVICE_CID,
|
||||
contractID: MOBILECONNECTIONGONKSERVICE_CONTRACTID,
|
||||
classDescription: "MobileConnectionGonkService",
|
||||
interfaces: [Ci.nsIMobileConnectionGonkService,
|
||||
Ci.nsIMobileConnectionService],
|
||||
flags: Ci.nsIClassInfo.SINGLETON}),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGonkMobileConnectionService,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionGonkService,
|
||||
Ci.nsIMobileConnectionService,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
@ -1009,21 +997,296 @@ MobileConnectionService.prototype = {
|
||||
/**
|
||||
* nsIMobileConnectionService interface.
|
||||
*/
|
||||
get numItems() {
|
||||
return this._providers.length;
|
||||
},
|
||||
|
||||
getItemByServiceId: function(aServiceId) {
|
||||
let provider = this._providers[aServiceId];
|
||||
registerListener: function(aClientId, aListener) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider;
|
||||
provider.registerListener(aListener);
|
||||
},
|
||||
|
||||
unregisterListener: function(aClientId, aListener) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.unregisterListener(aListener);
|
||||
},
|
||||
|
||||
getVoiceConnectionInfo: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.voiceInfo;
|
||||
},
|
||||
|
||||
getDataConnectionInfo: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.dataInfo;
|
||||
},
|
||||
|
||||
getIccId: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.iccId;
|
||||
},
|
||||
|
||||
getNetworkSelectionMode: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.networkSelectMode;
|
||||
},
|
||||
|
||||
getRadioState: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.radioState;
|
||||
},
|
||||
|
||||
getLastKnownNetwork: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.lastKnownNetwork;
|
||||
},
|
||||
|
||||
getLastKnownHomeNetwork: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.lastKnownHomeNetwork;
|
||||
},
|
||||
|
||||
getSupportedNetworkTypes: function(aClientId) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return provider.supportedNetworkTypes;
|
||||
},
|
||||
|
||||
getNetworks: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getNetworks(aCallback);
|
||||
},
|
||||
|
||||
selectNetwork: function(aClientId, aNetwork, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.selectNetwork(aNetwork, aCallback);
|
||||
},
|
||||
|
||||
selectNetworkAutomatically: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.selectNetworkAutomatically(aCallback);
|
||||
},
|
||||
|
||||
setPreferredNetworkType: function(aClientId, aType, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setPreferredNetworkType(aType, aCallback);
|
||||
},
|
||||
|
||||
getPreferredNetworkType: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getPreferredNetworkType(aCallback);
|
||||
},
|
||||
|
||||
setRoamingPreference: function(aClientId, aMode, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setRoamingPreference(aMode, aCallback);
|
||||
},
|
||||
|
||||
getRoamingPreference: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getRoamingPreference(aCallback);
|
||||
},
|
||||
|
||||
setVoicePrivacyMode: function(aClientId, aEnabled, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setVoicePrivacyMode(aEnabled, aCallback);
|
||||
},
|
||||
|
||||
getVoicePrivacyMode: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getVoicePrivacyMode(aCallback);
|
||||
},
|
||||
|
||||
sendMMI: function(aClientId, aMmi, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.sendMMI(aMmi, aCallback);
|
||||
},
|
||||
|
||||
cancelMMI: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.cancelMMI(aCallback);
|
||||
},
|
||||
|
||||
setCallForwarding: function(aClientId, aOptions, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setCallForwarding(aOptions, aCallback);
|
||||
},
|
||||
|
||||
getCallForwarding: function(aClientId, aReason, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getCallForwarding(aReason, aCallback);
|
||||
},
|
||||
|
||||
setCallBarring: function(aClientId, aOptions, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setCallBarring(aOptions, aCallback);
|
||||
},
|
||||
|
||||
getCallBarring: function(aClientId, aOptions, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getCallBarring(aOptions, aCallback);
|
||||
},
|
||||
|
||||
changeCallBarringPassword: function(aClientId, aOptions, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.changeCallBarringPassword(aOptions, aCallback);
|
||||
},
|
||||
|
||||
setCallWaiting: function(aClientId, aEnabled, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setCallWaiting(aEnabled, aCallback);
|
||||
},
|
||||
|
||||
getCallWaiting: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getCallWaiting(aCallback);
|
||||
},
|
||||
|
||||
setCallingLineIdRestriction: function(aClientId, aMode, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setCallingLineIdRestriction(aMode, aCallback);
|
||||
},
|
||||
|
||||
getCallingLineIdRestriction: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.getCallingLineIdRestriction(aCallback);
|
||||
},
|
||||
|
||||
exitEmergencyCbMode: function(aClientId, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.exitEmergencyCbMode(aCallback);
|
||||
},
|
||||
|
||||
setRadioEnabled: function(aClientId, aEnabled, aCallback) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.setRadioEnabled(aEnabled, aCallback);
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIGonkMobileConnectionService interface.
|
||||
* nsIMobileConnectionGonkService interface.
|
||||
*/
|
||||
notifyVoiceInfoChanged: function(aClientId, aVoiceInfo) {
|
||||
if (DEBUG) {
|
||||
@ -1031,7 +1294,12 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify(aVoiceInfo));
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateVoiceInfo(aVoiceInfo);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateVoiceInfo(aVoiceInfo);
|
||||
},
|
||||
|
||||
notifyDataInfoChanged: function(aClientId, aDataInfo) {
|
||||
@ -1040,7 +1308,12 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify(aDataInfo));
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateDataInfo(aDataInfo);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateDataInfo(aDataInfo);
|
||||
},
|
||||
|
||||
notifyUssdReceived: function(aClientId, aMessage, aSessionEnded) {
|
||||
@ -1049,8 +1322,13 @@ MobileConnectionService.prototype = {
|
||||
aMessage + " (sessionEnded : " + aSessionEnded + ")");
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId)
|
||||
.deliverListenerEvent("notifyUssdReceived", [aMessage, aSessionEnded]);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.deliverListenerEvent("notifyUssdReceived",
|
||||
[aMessage, aSessionEnded]);
|
||||
|
||||
let info = {
|
||||
message: aMessage,
|
||||
@ -1066,8 +1344,12 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyDataError for " + aClientId + ": " + aMessage);
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId)
|
||||
.deliverListenerEvent("notifyDataError", [aMessage]);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.deliverListenerEvent("notifyDataError", [aMessage]);
|
||||
},
|
||||
|
||||
notifyEmergencyCallbackModeChanged: function(aClientId, aActive, aTimeoutMs) {
|
||||
@ -1076,9 +1358,13 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify({active: aActive, timeoutMs: aTimeoutMs}));
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId)
|
||||
.deliverListenerEvent("notifyEmergencyCbModeChanged",
|
||||
[aActive, aTimeoutMs]);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.deliverListenerEvent("notifyEmergencyCbModeChanged",
|
||||
[aActive, aTimeoutMs]);
|
||||
},
|
||||
|
||||
notifyOtaStatusChanged: function(aClientId, aStatus) {
|
||||
@ -1086,8 +1372,12 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyOtaStatusChanged for " + aClientId + ": " + aStatus);
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId)
|
||||
.deliverListenerEvent("notifyOtaStatusChanged", [aStatus]);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.deliverListenerEvent("notifyOtaStatusChanged", [aStatus]);
|
||||
},
|
||||
|
||||
notifyIccChanged: function(aClientId, aIccId) {
|
||||
@ -1095,7 +1385,12 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyIccChanged for " + aClientId + ": " + aIccId);
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateIccId(aIccId);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateIccId(aIccId);
|
||||
},
|
||||
|
||||
notifyRadioStateChanged: function(aClientId, aRadioState) {
|
||||
@ -1103,7 +1398,12 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyRadioStateChanged for " + aClientId + ": " + aRadioState);
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateRadioState(aRadioState);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateRadioState(aRadioState);
|
||||
},
|
||||
|
||||
notifyNetworkInfoChanged: function(aClientId, aNetworkInfo) {
|
||||
@ -1112,7 +1412,10 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify(aNetworkInfo));
|
||||
}
|
||||
|
||||
let provider = this.getItemByServiceId(aClientId);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
let isVoiceUpdated = false;
|
||||
let isDataUpdated = false;
|
||||
@ -1158,7 +1461,12 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify(aSignal));
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateSignalInfo(aSignal);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateSignalInfo(aSignal);
|
||||
},
|
||||
|
||||
notifyOperatorChanged: function(aClientId, aOperator) {
|
||||
@ -1167,7 +1475,12 @@ MobileConnectionService.prototype = {
|
||||
JSON.stringify(aOperator));
|
||||
}
|
||||
|
||||
this.getItemByServiceId(aClientId).updateOperatorInfo(aOperator);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
provider.updateOperatorInfo(aOperator);
|
||||
},
|
||||
|
||||
notifyNetworkSelectModeChanged: function(aClientId, aMode) {
|
||||
@ -1175,12 +1488,16 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyNetworkSelectModeChanged for " + aClientId + ": " + aMode);
|
||||
}
|
||||
|
||||
let provider = this.getItemByServiceId(aClientId);
|
||||
if (provider.networkSelectionMode === aMode) {
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (provider.networkSelectMode === aMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
provider.networkSelectionMode = aMode;
|
||||
provider.networkSelectMode = aMode;
|
||||
provider.deliverListenerEvent("notifyNetworkSelectionModeChanged");
|
||||
},
|
||||
|
||||
@ -1189,7 +1506,10 @@ MobileConnectionService.prototype = {
|
||||
debug("notifySpnAvailable for " + aClientId);
|
||||
}
|
||||
|
||||
let provider = this.getItemByServiceId(aClientId);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Update voice roaming state
|
||||
provider.updateVoiceInfo({});
|
||||
@ -1203,7 +1523,11 @@ MobileConnectionService.prototype = {
|
||||
debug("notifyLastHomeNetworkChanged for " + aClientId + ": " + aNetwork);
|
||||
}
|
||||
|
||||
let provider = this.getItemByServiceId(aClientId);
|
||||
let provider = this._providers[aClientId];
|
||||
if (!provider) {
|
||||
throw Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (provider.lastKnownHomeNetwork === aNetwork) {
|
||||
return;
|
||||
}
|
||||
@ -1218,7 +1542,7 @@ MobileConnectionService.prototype = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID:
|
||||
for (let i = 0; i < this.numItems; i++) {
|
||||
for (let i = 0; i < this._providers.length; i++) {
|
||||
let provider = this._providers[i];
|
||||
// Update connected flag only.
|
||||
provider.updateDataInfo({});
|
||||
@ -1236,4 +1560,4 @@ MobileConnectionService.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileConnectionService]);
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileConnectionGonkService]);
|
@ -1,2 +1,2 @@
|
||||
component {05e20430-fe65-4984-8df9-a6a504b24a91} MobileConnectionService.js
|
||||
contract @mozilla.org/mobileconnection/gonkmobileconnectionservice;1 {05e20430-fe65-4984-8df9-a6a504b24a91}
|
||||
component {05e20430-fe65-4984-8df9-a6a504b24a91} MobileConnectionGonkService.js
|
||||
contract @mozilla.org/mobileconnection/mobileconnectiongonkservice;1 {05e20430-fe65-4984-8df9-a6a504b24a91}
|
21
dom/mobileconnection/interfaces/moz.build
Normal file
21
dom/mobileconnection/interfaces/moz.build
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsICellInfo.idl',
|
||||
'nsIMobileCellInfo.idl',
|
||||
'nsIMobileConnectionInfo.idl',
|
||||
'nsIMobileConnectionService.idl',
|
||||
'nsIMobileNetworkInfo.idl',
|
||||
'nsINeighboringCellInfo.idl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
|
||||
XPIDL_SOURCES += [
|
||||
'nsIMobileConnectionGonkService.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_mobileconnection'
|
@ -5,12 +5,12 @@
|
||||
#include "nsIMobileConnectionService.idl"
|
||||
|
||||
%{C++
|
||||
#define GONK_MOBILECONNECTION_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1"
|
||||
#define NS_MOBILECONNECTION_GONK_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/mobileconnection/mobileconnectiongonkservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(e54fa0a4-d357-48ef-9a1e-ffc9705b44b1)]
|
||||
interface nsIGonkMobileConnectionService : nsIMobileConnectionService
|
||||
[scriptable, uuid(c5baceda-247a-4018-855d-ad5b00f2e4e2)]
|
||||
interface nsIMobileConnectionGonkService : nsIMobileConnectionService
|
||||
{
|
||||
void notifyNetworkInfoChanged(in unsigned long clientId, in jsval networkInfo);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIMobileConnection;
|
||||
interface nsIMobileConnectionInfo;
|
||||
interface nsIMobileNetworkInfo;
|
||||
interface nsIVariant;
|
||||
@ -201,23 +200,12 @@ interface nsIMobileConnectionCallback : nsISupports
|
||||
"@mozilla.org/mobileconnection/mobileconnectionservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(eaba3c4a-0dd5-4919-b1a2-7812e49dbbcb)]
|
||||
/**
|
||||
* XPCOM component (in the content process) that provides the mobile
|
||||
* network information.
|
||||
*/
|
||||
[scriptable, uuid(b50ad32d-f70e-4729-a947-e8cfdb6ba81f)]
|
||||
interface nsIMobileConnectionService : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numItems;
|
||||
|
||||
nsIMobileConnection getItemByServiceId(in unsigned long serviceId);
|
||||
};
|
||||
|
||||
%{C++
|
||||
template<typename T> struct already_AddRefed;
|
||||
|
||||
already_AddRefed<nsIMobileConnectionService>
|
||||
NS_CreateMobileConnectionService();
|
||||
%}
|
||||
|
||||
[scriptable, uuid(04db7331-54fe-4cf7-9347-b9481350f4c2)]
|
||||
interface nsIMobileConnection : nsISupports
|
||||
{
|
||||
const long ICC_SERVICE_CLASS_VOICE = (1 << 0);
|
||||
const long ICC_SERVICE_CLASS_DATA = (1 << 1);
|
||||
@ -270,66 +258,95 @@ interface nsIMobileConnection : nsISupports
|
||||
const long CLIR_INVOCATION = 1;
|
||||
const long CLIR_SUPPRESSION = 2;
|
||||
|
||||
readonly attribute unsigned long serviceId;
|
||||
|
||||
/**
|
||||
* Called when any one who is interested in receiving unsolicited messages
|
||||
* from this nsIMobileConnection instance.
|
||||
* Called when a content process registers receiving unsolicited messages from
|
||||
* RadioInterfaceLayer in the chrome process. Only a content process that has
|
||||
* the 'mobileconnection' permission is allowed to register.
|
||||
*/
|
||||
void registerListener(in nsIMobileConnectionListener listener);
|
||||
void unregisterListener(in nsIMobileConnectionListener listener);
|
||||
void registerListener(in unsigned long clientId,
|
||||
in nsIMobileConnectionListener listener);
|
||||
void unregisterListener(in unsigned long clientId,
|
||||
in nsIMobileConnectionListener listener);
|
||||
|
||||
/**
|
||||
* String of format '<mcc>-<mnc>'. When changed, listener method
|
||||
* 'notifyLastKnownNetworkChanged' is called.
|
||||
* These two fields require the 'mobilenetwork' permission.
|
||||
*/
|
||||
readonly attribute DOMString lastKnownNetwork;
|
||||
DOMString getLastKnownNetwork(in unsigned long clientId);
|
||||
DOMString getLastKnownHomeNetwork(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* String of format '<mcc>-<mnc>[-<spn>]'. When changed, listener method
|
||||
* 'notifyLastKnownHomeNetworkChanged' is called.
|
||||
* All fields below require the 'mobileconnection' permission.
|
||||
*/
|
||||
readonly attribute DOMString lastKnownHomeNetwork;
|
||||
|
||||
/**
|
||||
* Connection information about the voice.
|
||||
* Get the connection information about the voice.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return a nsIMobileConnectionInfo
|
||||
*/
|
||||
readonly attribute nsIMobileConnectionInfo voice;
|
||||
nsIMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* Connection information about the data.
|
||||
* Get the connection information about the data.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return a nsIMobileConnectionInfo
|
||||
*/
|
||||
readonly attribute nsIMobileConnectionInfo data;
|
||||
nsIMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* The integrated circuit card identifier of the SIM.
|
||||
* Get the integrated circuit card identifier of the SIM.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return a DOMString indicates the iccId
|
||||
*/
|
||||
readonly attribute DOMString iccId;
|
||||
DOMString getIccId(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* The selection mode of the voice and data networks. Possible values are
|
||||
* 'automatic', 'manual', null (unknown).
|
||||
* Get the selection mode of the voice and data networks.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return a DOMString
|
||||
* Possible values: 'automatic', 'manual', null (unknown).
|
||||
*/
|
||||
readonly attribute DOMString networkSelectionMode;
|
||||
DOMString getNetworkSelectionMode(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* Current radio state. Possible values are 'enabling', 'enabled',
|
||||
* 'disabling', 'disabled', null (unknown).
|
||||
* Get the current radio state.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return a DOMString
|
||||
* Possible values: 'enabling', 'enabled', 'disabling', 'disabled',
|
||||
* null (unknown).
|
||||
*/
|
||||
readonly attribute DOMString radioState;
|
||||
DOMString getRadioState(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* The network types supported by this radio.
|
||||
* Get the network types that are supported by this radio.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
*
|
||||
* @return an array of DOMString
|
||||
* Possible values: 'gsm', 'wcdma', 'cdma', 'evdo', 'lte'.
|
||||
*/
|
||||
void getSupportedNetworkTypes([array, size_is(length)] out wstring types,
|
||||
[retval] out unsigned long length);
|
||||
nsIVariant getSupportedNetworkTypes(in unsigned long clientId);
|
||||
|
||||
/**
|
||||
* Search for available networks.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -340,12 +357,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getNetworks(in nsIMobileConnectionCallback requestCallback);
|
||||
void getNetworks(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Manually selects the passed in network, overriding the radio's current
|
||||
* selection.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param network
|
||||
* The manually selecting network.
|
||||
* @param requestCallback
|
||||
@ -357,12 +377,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void selectNetwork(in nsIMobileNetworkInfo network,
|
||||
void selectNetwork(in unsigned long clientId,
|
||||
in nsIMobileNetworkInfo network,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Tell the radio to automatically select a network.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -372,11 +395,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void selectNetworkAutomatically(in nsIMobileConnectionCallback requestCallback);
|
||||
void selectNetworkAutomatically(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Set preferred network type.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param type
|
||||
* DOMString indicates the desired preferred network type.
|
||||
* Possible values: 'wcdma/gsm', 'gsm', 'wcdma', 'wcdma/gsm-auto',
|
||||
@ -392,12 +418,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void setPreferredNetworkType(in DOMString type,
|
||||
void setPreferredNetworkType(in unsigned long clientId,
|
||||
in DOMString type,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Query current preferred network type.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -411,11 +440,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getPreferredNetworkType(in nsIMobileConnectionCallback requestCallback);
|
||||
void getPreferredNetworkType(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Set roaming preference.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param mode
|
||||
* DOMString indicates the desired roaming preference.
|
||||
* Possible values: 'home', 'affiliated', or 'any'.
|
||||
@ -428,12 +460,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void setRoamingPreference(in DOMString mode,
|
||||
void setRoamingPreference(in unsigned long clientId,
|
||||
in DOMString mode,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Query current roaming preference.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -445,11 +480,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getRoamingPreference(in nsIMobileConnectionCallback requestCallback);
|
||||
void getRoamingPreference(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Set voice privacy preference.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param enabled
|
||||
* Boolean indicates the preferred voice privacy mode used in voice
|
||||
* scrambling in CDMA networks. 'True' means the enhanced voice security
|
||||
@ -463,12 +501,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void setVoicePrivacyMode(in bool enabled,
|
||||
void setVoicePrivacyMode(in unsigned long clientId,
|
||||
in bool enabled,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Query current voice privacy mode.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -479,11 +520,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getVoicePrivacyMode(in nsIMobileConnectionCallback requestCallback);
|
||||
void getVoicePrivacyMode(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Send a MMI message.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param mmi
|
||||
* DOMString containing an MMI string that can be associated to a
|
||||
* USSD request or other RIL functionality.
|
||||
@ -495,12 +539,15 @@ interface nsIMobileConnection : nsISupports
|
||||
*
|
||||
* Otherwise, the notifyError() will be called.
|
||||
*/
|
||||
void sendMMI(in DOMString mmi,
|
||||
void sendMMI(in unsigned long clientId,
|
||||
in DOMString mmi,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Cancel the current MMI request if one exists.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -509,11 +556,14 @@ interface nsIMobileConnection : nsISupports
|
||||
*
|
||||
* Otherwise, the notifyError() will be called.
|
||||
*/
|
||||
void cancelMMI(in nsIMobileConnectionCallback requestCallback);
|
||||
void cancelMMI(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Queries current call forwarding options.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param reason
|
||||
* Indicates the reason the call is being forwarded. It shall be one of
|
||||
* the nsIMobileConnectionService.CALL_FORWARD_REASON_* values.
|
||||
@ -528,12 +578,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void getCallForwarding(in unsigned short reason,
|
||||
void getCallForwarding(in unsigned long clientId,
|
||||
in unsigned short reason,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Configures call forwarding options.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param options
|
||||
* An object containing the call forward rule to set.
|
||||
* @see MozCallForwardingOptions for the detail of options.
|
||||
@ -546,12 +599,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void setCallForwarding(in jsval options,
|
||||
void setCallForwarding(in unsigned long clientId,
|
||||
in jsval options,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Queries current call barring status.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param options
|
||||
* An object containing the call barring rule to query. No need to
|
||||
* specify 'enabled' property.
|
||||
@ -567,12 +623,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void getCallBarring(in jsval options,
|
||||
void getCallBarring(in unsigned long clientId,
|
||||
in jsval options,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Configures call barring option.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param options
|
||||
* An object containing the call barring rule to set.
|
||||
* @see MozCallBarringOptions for the detail of options.
|
||||
@ -585,12 +644,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void setCallBarring(in jsval options,
|
||||
void setCallBarring(in unsigned long clientId,
|
||||
in jsval options,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Change call barring facility password.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param options
|
||||
* An object containing information about pin and newPin, and,
|
||||
* this object must have both "pin" and "newPin" attributes
|
||||
@ -605,12 +667,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void changeCallBarringPassword(in jsval options,
|
||||
void changeCallBarringPassword(in unsigned long clientId,
|
||||
in jsval options,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Configures call waiting options.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param enabled
|
||||
* Boolean indicates the desired call waiting status.
|
||||
* @param requestCallback
|
||||
@ -622,12 +687,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void setCallWaiting(in bool enabled,
|
||||
void setCallWaiting(in unsigned long clientId,
|
||||
in bool enabled,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Queries current call waiting options.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -638,12 +706,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getCallWaiting(in nsIMobileConnectionCallback requestCallback);
|
||||
void getCallWaiting(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Enables or disables the presentation of the calling line identity (CLI) to
|
||||
* the called party when originating a call.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param clirMode
|
||||
* One of the nsIMobileConnectionService.CLIR_* values.
|
||||
* @param requestCallback
|
||||
@ -655,12 +726,15 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
|
||||
* 'IllegalSIMorME', or 'GenericFailure'.
|
||||
*/
|
||||
void setCallingLineIdRestriction(in unsigned short clirMode,
|
||||
void setCallingLineIdRestriction(in unsigned long clientId,
|
||||
in unsigned short clirMode,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Queries current CLIR status.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -672,11 +746,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void getCallingLineIdRestriction(in nsIMobileConnectionCallback requestCallback);
|
||||
void getCallingLineIdRestriction(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Exit emergency callback mode.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param requestCallback
|
||||
* Called when request is finished.
|
||||
*
|
||||
@ -686,11 +763,14 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
|
||||
* 'GenericFailure'.
|
||||
*/
|
||||
void exitEmergencyCbMode(in nsIMobileConnectionCallback requestCallback);
|
||||
void exitEmergencyCbMode(in unsigned long clientId,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
|
||||
/**
|
||||
* Set radio enabled/disabled.
|
||||
*
|
||||
* @param clientId
|
||||
* Indicate the RIL client, 0 ~ (number of client - 1).
|
||||
* @param enabled
|
||||
* Boolean indicates the desired radio power. True to enable the radio.
|
||||
* @param requestCallback
|
||||
@ -706,6 +786,7 @@ interface nsIMobileConnection : nsISupports
|
||||
* 'disabling'. Calling the function in above conditions will receive
|
||||
* 'InvalidStateError' error.
|
||||
*/
|
||||
void setRadioEnabled(in bool enabled,
|
||||
void setRadioEnabled(in unsigned long clientId,
|
||||
in bool enabled,
|
||||
in nsIMobileConnectionCallback requestCallback);
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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 "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
||||
#include "MobileConnectionChild.h"
|
||||
|
||||
#include "MobileConnectionCallback.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
@ -11,23 +11,15 @@
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
|
||||
NS_IMPL_ISUPPORTS(MobileConnectionChild, nsIMobileConnection)
|
||||
|
||||
MobileConnectionChild::MobileConnectionChild(uint32_t aServiceId)
|
||||
: mServiceId(aServiceId)
|
||||
, mLive(true)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MobileConnectionChild);
|
||||
}
|
||||
|
||||
void
|
||||
MobileConnectionChild::Init()
|
||||
{
|
||||
nsIMobileConnectionInfo* rawVoice;
|
||||
nsIMobileConnectionInfo* rawData;
|
||||
nsTArray<nsString> types;
|
||||
|
||||
SendInit(&rawVoice, &rawData, &mLastNetwork, &mLastHomeNetwork, &mIccId,
|
||||
&mNetworkSelectionMode, &mRadioState, &mSupportedNetworkTypes);
|
||||
&mNetworkSelectionMode, &mRadioState, &types);
|
||||
|
||||
// Use dont_AddRef here because this instances is already AddRef-ed in
|
||||
// MobileConnectionIPCSerializer.h
|
||||
@ -40,6 +32,35 @@ MobileConnectionChild::Init()
|
||||
nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(rawData);
|
||||
mData = new MobileConnectionInfo(nullptr);
|
||||
mData->Update(data);
|
||||
|
||||
|
||||
// Initial SupportedNetworkTypes
|
||||
nsresult rv;
|
||||
mSupportedNetworkTypes = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t arrayLen = types.Length();
|
||||
if (arrayLen == 0) {
|
||||
mSupportedNetworkTypes->SetAsEmptyArray();
|
||||
} else {
|
||||
// Note: The resulting nsIVariant dupes both the array and its elements.
|
||||
const char16_t** array = reinterpret_cast<const char16_t**>
|
||||
(NS_Alloc(arrayLen * sizeof(const char16_t***)));
|
||||
if (array) {
|
||||
for (uint32_t i = 0; i < arrayLen; ++i) {
|
||||
array[i] = types[i].get();
|
||||
}
|
||||
|
||||
mSupportedNetworkTypes->SetAsArray(nsIDataType::VTYPE_WCHAR_STR,
|
||||
nullptr,
|
||||
arrayLen,
|
||||
reinterpret_cast<void*>(array));
|
||||
NS_Free(array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -53,309 +74,79 @@ MobileConnectionChild::Shutdown()
|
||||
mListeners.Clear();
|
||||
mVoice = nullptr;
|
||||
mData = nullptr;
|
||||
mSupportedNetworkTypes = nullptr;
|
||||
}
|
||||
|
||||
// nsIMobileConnection
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetServiceId(uint32_t* aServiceId)
|
||||
{
|
||||
*aServiceId = mServiceId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MobileConnectionChild::RegisterListener(nsIMobileConnectionListener* aListener)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
|
||||
|
||||
mListeners.AppendObject(aListener);
|
||||
return NS_OK;
|
||||
if (!mListeners.Contains(aListener)) {
|
||||
mListeners.AppendObject(aListener);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MobileConnectionChild::UnregisterListener(nsIMobileConnectionListener* aListener)
|
||||
{
|
||||
NS_ENSURE_TRUE(mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
|
||||
|
||||
mListeners.RemoveObject(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetVoice(nsIMobileConnectionInfo** aVoice)
|
||||
MobileConnectionInfo*
|
||||
MobileConnectionChild::GetVoiceInfo()
|
||||
{
|
||||
nsRefPtr<nsIMobileConnectionInfo> voice(mVoice);
|
||||
voice.forget(aVoice);
|
||||
return NS_OK;
|
||||
return mVoice;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetData(nsIMobileConnectionInfo** aData)
|
||||
MobileConnectionInfo*
|
||||
MobileConnectionChild::GetDataInfo()
|
||||
{
|
||||
nsRefPtr<nsIMobileConnectionInfo> data(mData);
|
||||
data.forget(aData);
|
||||
return NS_OK;
|
||||
return mData;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MobileConnectionChild::GetIccId(nsAString& aIccId)
|
||||
{
|
||||
aIccId = mIccId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MobileConnectionChild::GetRadioState(nsAString& aRadioState)
|
||||
{
|
||||
aRadioState = mRadioState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetSupportedNetworkTypes(char16_t*** aTypes,
|
||||
uint32_t* aLength)
|
||||
nsIVariant*
|
||||
MobileConnectionChild::GetSupportedNetworkTypes()
|
||||
{
|
||||
NS_ENSURE_ARG(aTypes);
|
||||
NS_ENSURE_ARG(aLength);
|
||||
|
||||
*aLength = mSupportedNetworkTypes.Length();
|
||||
*aTypes =
|
||||
static_cast<char16_t**>(nsMemory::Alloc((*aLength) * sizeof(char16_t*)));
|
||||
NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < *aLength; i++) {
|
||||
(*aTypes)[i] = ToNewUnicode(mSupportedNetworkTypes[i]);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return mSupportedNetworkTypes;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetLastKnownNetwork(nsAString& aNetwork)
|
||||
void
|
||||
MobileConnectionChild::GetLastNetwork(nsAString& aNetwork)
|
||||
{
|
||||
aNetwork = mLastNetwork;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetLastKnownHomeNetwork(nsAString& aNetwork)
|
||||
void
|
||||
MobileConnectionChild::GetLastHomeNetwork(nsAString& aNetwork)
|
||||
{
|
||||
aNetwork = mLastHomeNetwork;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MobileConnectionChild::GetNetworkSelectionMode(nsAString& aMode)
|
||||
{
|
||||
aMode = mNetworkSelectionMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetNetworks(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetNetworksRequest(), aCallback) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SelectNetwork(nsIMobileNetworkInfo* aNetwork,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
|
||||
// We release the ref after serializing process is finished in
|
||||
// MobileConnectionIPCSerializer.
|
||||
return SendRequest(SelectNetworkRequest(network.forget().take()), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SelectNetworkAutomatically(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SelectNetworkAutoRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetPreferredNetworkType(const nsAString& aType,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetPreferredNetworkTypeRequest(nsAutoString(aType)),
|
||||
aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetPreferredNetworkType(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetPreferredNetworkTypeRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetRoamingPreference(const nsAString& aMode,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetRoamingPreferenceRequest(nsAutoString(aMode)),
|
||||
aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetRoamingPreference(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetRoamingPreferenceRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetVoicePrivacyMode(bool aEnabled,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetVoicePrivacyModeRequest(aEnabled), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetVoicePrivacyMode(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetVoicePrivacyModeRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SendMMI(const nsAString& aMmi,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SendMmiRequest(nsAutoString(aMmi)), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::CancelMMI(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(CancelMmiRequest(), aCallback) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetCallForwarding(JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallForwardingOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(SetCallForwardingRequest(options), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetCallForwarding(uint16_t aReason,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetCallForwardingRequest(aReason), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetCallBarring(JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(SetCallBarringRequest(options), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetCallBarring(JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(GetCallBarringRequest(options), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::ChangeCallBarringPassword(JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(ChangeCallBarringPasswordRequest(options), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetCallWaiting(bool aEnabled,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetCallWaitingRequest(aEnabled), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetCallWaiting(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetCallWaitingRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetCallingLineIdRestriction(uint16_t aMode,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetCallingLineIdRestrictionRequest(aMode), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetCallingLineIdRestriction(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(GetCallingLineIdRestrictionRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::ExitEmergencyCbMode(nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(ExitEmergencyCbModeRequest(), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::SetRadioEnabled(bool aEnabled,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
{
|
||||
return SendRequest(SetRadioEnabledRequest(aEnabled), aCallback)
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionChild::SendRequest(const MobileConnectionRequest& aRequest,
|
||||
nsIMobileConnectionCallback* aCallback)
|
||||
MobileConnectionChild::SendRequest(MobileConnectionRequest aRequest,
|
||||
nsIMobileConnectionCallback* aRequestCallback)
|
||||
{
|
||||
NS_ENSURE_TRUE(mLive, false);
|
||||
|
||||
// Deallocated in MobileConnectionChild::DeallocPMobileConnectionRequestChild().
|
||||
MobileConnectionRequestChild* actor =
|
||||
new MobileConnectionRequestChild(aCallback);
|
||||
MobileConnectionRequestChild* actor = new MobileConnectionRequestChild(aRequestCallback);
|
||||
SendPMobileConnectionRequestConstructor(actor, aRequest);
|
||||
|
||||
return true;
|
||||
|
@ -5,16 +5,15 @@
|
||||
#ifndef mozilla_dom_mobileconnection_MobileConnectionChild_h
|
||||
#define mozilla_dom_mobileconnection_MobileConnectionChild_h
|
||||
|
||||
#include "mozilla/dom/MobileConnectionCallback.h"
|
||||
#include "mozilla/dom/MobileConnectionInfo.h"
|
||||
#include "mozilla/dom/mobileconnection/PMobileConnectionChild.h"
|
||||
#include "mozilla/dom/mobileconnection/PMobileConnectionRequestChild.h"
|
||||
#include "mozilla/dom/PMobileConnectionChild.h"
|
||||
#include "mozilla/dom/PMobileConnectionRequestChild.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
#include "nsIVariant.h"
|
||||
|
||||
class nsIMobileConnectionCallback;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
@ -25,14 +24,16 @@ namespace mobileconnection {
|
||||
* shutdown. For multi-sim device, more than one instance will
|
||||
* be created and each instance represents a sim slot.
|
||||
*/
|
||||
class MobileConnectionChild MOZ_FINAL : public PMobileConnectionChild
|
||||
, public nsIMobileConnection
|
||||
class MobileConnectionChild : public PMobileConnectionChild
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILECONNECTION
|
||||
NS_INLINE_DECL_REFCOUNTING(MobileConnectionChild)
|
||||
|
||||
MobileConnectionChild(uint32_t aServiceId);
|
||||
public:
|
||||
MobileConnectionChild()
|
||||
: mLive(true)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MobileConnectionChild);
|
||||
}
|
||||
|
||||
void
|
||||
Init();
|
||||
@ -40,20 +41,48 @@ public:
|
||||
void
|
||||
Shutdown();
|
||||
|
||||
private:
|
||||
MobileConnectionChild() MOZ_DELETE;
|
||||
void
|
||||
RegisterListener(nsIMobileConnectionListener* aListener);
|
||||
|
||||
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||
void
|
||||
UnregisterListener(nsIMobileConnectionListener* aListener);
|
||||
|
||||
MobileConnectionInfo*
|
||||
GetVoiceInfo();
|
||||
|
||||
MobileConnectionInfo*
|
||||
GetDataInfo();
|
||||
|
||||
void
|
||||
GetIccId(nsAString& aIccId);
|
||||
|
||||
void
|
||||
GetRadioState(nsAString& aRadioState);
|
||||
|
||||
nsIVariant*
|
||||
GetSupportedNetworkTypes();
|
||||
|
||||
void
|
||||
GetLastNetwork(nsAString& aNetwork);
|
||||
|
||||
void
|
||||
GetLastHomeNetwork(nsAString& aNetwork);
|
||||
|
||||
void
|
||||
GetNetworkSelectionMode(nsAString& aMode);
|
||||
|
||||
bool
|
||||
SendRequest(MobileConnectionRequest aRequest,
|
||||
nsIMobileConnectionCallback* aRequestCallback);
|
||||
|
||||
protected:
|
||||
virtual
|
||||
~MobileConnectionChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(MobileConnectionChild);
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool
|
||||
SendRequest(const MobileConnectionRequest& aRequest,
|
||||
nsIMobileConnectionCallback* aCallback);
|
||||
|
||||
virtual void
|
||||
ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
@ -107,9 +136,9 @@ protected:
|
||||
RecvNotifyNetworkSelectionModeChanged(const nsString& aMode) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
uint32_t mServiceId;
|
||||
bool mLive;
|
||||
nsCOMArray<nsIMobileConnectionListener> mListeners;
|
||||
nsCOMPtr<nsIWritableVariant> mSupportedNetworkTypes;
|
||||
nsRefPtr<MobileConnectionInfo> mVoice;
|
||||
nsRefPtr<MobileConnectionInfo> mData;
|
||||
nsString mIccId;
|
||||
@ -117,7 +146,6 @@ private:
|
||||
nsString mLastNetwork;
|
||||
nsString mLastHomeNetwork;
|
||||
nsString mNetworkSelectionMode;
|
||||
nsTArray<nsString> mSupportedNetworkTypes;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -2,14 +2,14 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h
|
||||
#define mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h
|
||||
#ifndef dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
|
||||
#define dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/dom/MobileCellInfo.h"
|
||||
#include "mozilla/dom/MobileConnectionInfo.h"
|
||||
#include "mozilla/dom/MobileNetworkInfo.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "MozMobileConnectionBinding.h"
|
||||
|
||||
using mozilla::AutoSafeJSContext;
|
||||
using mozilla::dom::MobileNetworkInfo;
|
||||
@ -746,4 +746,4 @@ struct ParamTraits<MozCallBarringOptions>
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h
|
||||
#endif // dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
|
||||
|
@ -14,51 +14,381 @@ using namespace mozilla::dom::mobileconnection;
|
||||
|
||||
NS_IMPL_ISUPPORTS(MobileConnectionIPCService, nsIMobileConnectionService)
|
||||
|
||||
StaticRefPtr<MobileConnectionIPCService> sService;
|
||||
|
||||
/* static */MobileConnectionIPCService*
|
||||
MobileConnectionIPCService::GetSingleton()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sService) {
|
||||
return sService;
|
||||
}
|
||||
|
||||
sService = new MobileConnectionIPCService();
|
||||
return sService;
|
||||
}
|
||||
|
||||
MobileConnectionIPCService::MobileConnectionIPCService()
|
||||
{
|
||||
int32_t numRil = Preferences::GetInt("ril.numRadioInterfaces", 1);
|
||||
mItems.SetLength(numRil);
|
||||
for (int32_t i = 0; i < numRil; i++) {
|
||||
// Deallocated in ContentChild::DeallocPMobileConnectionChild().
|
||||
nsRefPtr<MobileConnectionChild> client = new MobileConnectionChild();
|
||||
NS_ASSERTION(client, "This shouldn't fail!");
|
||||
|
||||
ContentChild::GetSingleton()->SendPMobileConnectionConstructor(client, i);
|
||||
client->Init();
|
||||
|
||||
mClients.AppendElement(client);
|
||||
}
|
||||
}
|
||||
|
||||
MobileConnectionIPCService::~MobileConnectionIPCService()
|
||||
{
|
||||
uint32_t count = mItems.Length();
|
||||
uint32_t count = mClients.Length();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (mItems[i]) {
|
||||
mItems[i]->Shutdown();
|
||||
}
|
||||
mClients[i]->Shutdown();
|
||||
}
|
||||
|
||||
mClients.Clear();
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileConnectionIPCService::SendRequest(uint32_t aClientId,
|
||||
MobileConnectionRequest aRequest,
|
||||
nsIMobileConnectionCallback* aRequestCallback)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->SendRequest(aRequest, aRequestCallback);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIMobileConnectionService
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetNumItems(uint32_t* aNumItems)
|
||||
MobileConnectionIPCService::RegisterListener(uint32_t aClientId,
|
||||
nsIMobileConnectionListener* aListener)
|
||||
{
|
||||
*aNumItems = mItems.Length();
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->RegisterListener(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetItemByServiceId(uint32_t aServiceId,
|
||||
nsIMobileConnection** aItem)
|
||||
MobileConnectionIPCService::UnregisterListener(uint32_t aClientId,
|
||||
nsIMobileConnectionListener* aListener)
|
||||
{
|
||||
NS_ENSURE_TRUE(aServiceId < mItems.Length(), NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!mItems[aServiceId]) {
|
||||
nsRefPtr<MobileConnectionChild> child = new MobileConnectionChild(aServiceId);
|
||||
|
||||
// |SendPMobileConnectionConstructor| adds another reference to the child
|
||||
// actor and removes in |DeallocPMobileConnectionChild|.
|
||||
ContentChild::GetSingleton()->SendPMobileConnectionConstructor(child,
|
||||
aServiceId);
|
||||
child->Init();
|
||||
|
||||
mItems[aServiceId] = child;
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsRefPtr<nsIMobileConnection> item(mItems[aServiceId]);
|
||||
item.forget(aItem);
|
||||
mClients[aClientId]->UnregisterListener(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetLastKnownNetwork(uint32_t aClientId,
|
||||
nsAString& aLastNetwork)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->GetLastNetwork(aLastNetwork);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetLastKnownHomeNetwork(uint32_t aClientId,
|
||||
nsAString& aLastNetwork)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->GetLastHomeNetwork(aLastNetwork);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetVoiceConnectionInfo(uint32_t aClientId,
|
||||
nsIMobileConnectionInfo** aInfo)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetVoiceInfo();
|
||||
info.forget(aInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetDataConnectionInfo(uint32_t aClientId,
|
||||
nsIMobileConnectionInfo** aInfo)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetDataInfo();
|
||||
info.forget(aInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetIccId(uint32_t aClientId, nsAString& aIccId)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->GetIccId(aIccId);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetNetworkSelectionMode(uint32_t aClientId,
|
||||
nsAString& aNetworkSelectionMode)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->GetNetworkSelectionMode(aNetworkSelectionMode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetRadioState(uint32_t aClientId,
|
||||
nsAString& aRadioState)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mClients[aClientId]->GetRadioState(aRadioState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetSupportedNetworkTypes(uint32_t aClientId,
|
||||
nsIVariant** aSupportedTypes)
|
||||
{
|
||||
if (aClientId >= mClients.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIVariant> supportedTypes = mClients[aClientId]->GetSupportedNetworkTypes();
|
||||
supportedTypes.forget(aSupportedTypes);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetNetworks(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetNetworksRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SelectNetwork(uint32_t aClientId,
|
||||
nsIMobileNetworkInfo* aNetwork,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
|
||||
// We release the ref after serializing process is finished in
|
||||
// MobileConnectionIPCSerializer.
|
||||
return SendRequest(aClientId, SelectNetworkRequest(network.forget().take()), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SelectNetworkAutomatically(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SelectNetworkAutoRequest(), aRequest);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetPreferredNetworkType(uint32_t aClientId,
|
||||
const nsAString& aType,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId,
|
||||
SetPreferredNetworkTypeRequest(nsAutoString(aType)),
|
||||
aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetPreferredNetworkType(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetPreferredNetworkTypeRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetRoamingPreference(uint32_t aClientId,
|
||||
const nsAString& aMode,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId,
|
||||
SetRoamingPreferenceRequest(nsAutoString(aMode)),
|
||||
aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetRoamingPreference(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetRoamingPreferenceRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetVoicePrivacyMode(uint32_t aClientId,
|
||||
bool aEnabled,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SetVoicePrivacyModeRequest(aEnabled), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetVoicePrivacyMode(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetVoicePrivacyModeRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SendMMI(uint32_t aClientId,
|
||||
const nsAString& aMmi,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SendMmiRequest(nsAutoString(aMmi)), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::CancelMMI(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, CancelMmiRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetCallForwarding(uint32_t aClientId,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallForwardingOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(aClientId, SetCallForwardingRequest(options), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetCallForwarding(uint32_t aClientId,
|
||||
uint16_t aReason,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetCallForwardingRequest(aReason), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetCallBarring(uint32_t aClientId,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(aClientId, SetCallBarringRequest(options), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetCallBarring(uint32_t aClientId,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(aClientId, GetCallBarringRequest(options), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::ChangeCallBarringPassword(uint32_t aClientId,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
IPC::MozCallBarringOptions options;
|
||||
if(!options.Init(cx, aOptions)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return SendRequest(aClientId, ChangeCallBarringPasswordRequest(options), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetCallWaiting(uint32_t aClientId,
|
||||
bool aEnabled,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SetCallWaitingRequest(aEnabled), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetCallWaiting(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetCallWaitingRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetCallingLineIdRestriction(uint32_t aClientId,
|
||||
uint16_t aMode,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SetCallingLineIdRestrictionRequest(aMode), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::GetCallingLineIdRestriction(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, GetCallingLineIdRestrictionRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::ExitEmergencyCbMode(uint32_t aClientId,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, ExitEmergencyCbModeRequest(), aRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionIPCService::SetRadioEnabled(uint32_t aClientId,
|
||||
bool aEnabled,
|
||||
nsIMobileConnectionCallback* aRequest)
|
||||
{
|
||||
return SendRequest(aClientId, SetRadioEnabledRequest(aEnabled), aRequest);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define mozilla_dom_mobileconnection_MobileConnectionIPCService_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
||||
#include "MobileConnectionChild.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -19,17 +19,24 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILECONNECTIONSERVICE
|
||||
|
||||
MobileConnectionIPCService();
|
||||
static MobileConnectionIPCService*
|
||||
GetSingleton();
|
||||
|
||||
private:
|
||||
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||
MobileConnectionIPCService();
|
||||
|
||||
~MobileConnectionIPCService();
|
||||
|
||||
nsTArray<nsRefPtr<MobileConnectionChild>> mItems;
|
||||
/** Send request */
|
||||
nsresult
|
||||
SendRequest(uint32_t aClientId, MobileConnectionRequest aRequest,
|
||||
nsIMobileConnectionCallback* aRequestCallback);
|
||||
|
||||
nsTArray<nsRefPtr<MobileConnectionChild>> mClients;
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // name space mobileconnection
|
||||
} // name space dom
|
||||
} // name space mozilla
|
||||
|
||||
#endif // mozilla_dom_mobileconnection_MobileConnectionIPCService_h
|
||||
|
@ -2,11 +2,11 @@
|
||||
* 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 "mozilla/dom/mobileconnection/MobileConnectionParent.h"
|
||||
#include "MobileConnectionParent.h"
|
||||
|
||||
#include "mozilla/AppProcessChecker.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h"
|
||||
#include "mozilla/dom/MobileConnectionIPCSerializer.h"
|
||||
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsIVariant.h"
|
||||
@ -17,18 +17,16 @@ using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::mobileconnection;
|
||||
|
||||
MobileConnectionParent::MobileConnectionParent(uint32_t aClientId)
|
||||
: mLive(true)
|
||||
: mClientId(aClientId)
|
||||
, mLive(true)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MobileConnectionParent);
|
||||
|
||||
nsCOMPtr<nsIMobileConnectionService> service =
|
||||
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(service, "This shouldn't fail!");
|
||||
mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(mService, "This shouldn't fail!");
|
||||
|
||||
nsresult rv = service->GetItemByServiceId(aClientId,
|
||||
getter_AddRefs(mMobileConnection));
|
||||
if (NS_SUCCEEDED(rv) && mMobileConnection) {
|
||||
mMobileConnection->RegisterListener(this);
|
||||
if (mService) {
|
||||
mService->RegisterListener(mClientId, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,9 +34,9 @@ void
|
||||
MobileConnectionParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
mLive = false;
|
||||
if (mMobileConnection) {
|
||||
mMobileConnection->UnregisterListener(this);
|
||||
mMobileConnection = nullptr;
|
||||
if (mService) {
|
||||
mService->UnregisterListener(mClientId, this);
|
||||
mService = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,8 +105,7 @@ MobileConnectionParent::AllocPMobileConnectionRequestParent(const MobileConnecti
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MobileConnectionRequestParent* actor =
|
||||
new MobileConnectionRequestParent(mMobileConnection);
|
||||
MobileConnectionRequestParent* actor = new MobileConnectionRequestParent(mClientId);
|
||||
// Add an extra ref for IPDL. Will be released in
|
||||
// MobileConnectionParent::DeallocPMobileConnectionRequestParent().
|
||||
actor->AddRef();
|
||||
@ -133,28 +130,36 @@ MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
|
||||
nsString* aRadioState,
|
||||
nsTArray<nsString>* aSupportedNetworkTypes)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetVoice(aVoice), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetData(aData), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetLastKnownNetwork(*aLastKnownNetwork), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetLastKnownHomeNetwork(*aLastKnownHomeNetwork), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetIccId(*aIccId), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetNetworkSelectionMode(*aNetworkSelectionMode), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetRadioState(*aRadioState), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetVoiceConnectionInfo(mClientId, aVoice), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetDataConnectionInfo(mClientId, aData), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetLastKnownNetwork(mClientId, *aLastKnownNetwork), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetLastKnownHomeNetwork(mClientId, *aLastKnownHomeNetwork), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetIccId(mClientId, *aIccId), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetNetworkSelectionMode(mClientId, *aNetworkSelectionMode), false);
|
||||
NS_ENSURE_SUCCESS(mService->GetRadioState(mClientId, *aRadioState), false);
|
||||
|
||||
char16_t** types = nullptr;
|
||||
uint32_t length = 0;
|
||||
nsCOMPtr<nsIVariant> variant;
|
||||
mService->GetSupportedNetworkTypes(mClientId, getter_AddRefs(variant));
|
||||
|
||||
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsDependentString type(types[i]);
|
||||
aSupportedNetworkTypes->AppendElement(type);
|
||||
uint16_t type;
|
||||
nsIID iid;
|
||||
uint32_t count;
|
||||
void* data;
|
||||
if (NS_FAILED(variant->GetAsArray(&type, &iid, &count, &data))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, types);
|
||||
// We expect the element type is wstring.
|
||||
if (type == nsIDataType::VTYPE_WCHAR_STR) {
|
||||
char16_t** rawArray = reinterpret_cast<char16_t**>(data);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
nsDependentString networkType(rawArray[i]);
|
||||
aSupportedNetworkTypes->AppendElement(networkType);
|
||||
}
|
||||
}
|
||||
NS_Free(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -170,7 +175,7 @@ MobileConnectionParent::NotifyVoiceChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info;
|
||||
rv = mMobileConnection->GetVoice(getter_AddRefs(info));
|
||||
rv = mService->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We release the ref after serializing process is finished in
|
||||
@ -185,7 +190,7 @@ MobileConnectionParent::NotifyDataChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMobileConnectionInfo> info;
|
||||
rv = mMobileConnection->GetData(getter_AddRefs(info));
|
||||
rv = mService->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We release the ref after serializing process is finished in
|
||||
@ -251,7 +256,7 @@ MobileConnectionParent::NotifyIccChanged()
|
||||
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString iccId;
|
||||
mMobileConnection->GetIccId(iccId);
|
||||
mService->GetIccId(mClientId, iccId);
|
||||
|
||||
return SendNotifyIccChanged(iccId) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -263,7 +268,7 @@ MobileConnectionParent::NotifyRadioStateChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString radioState;
|
||||
rv = mMobileConnection->GetRadioState(radioState);
|
||||
rv = mService->GetRadioState(mClientId, radioState);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SendNotifyRadioStateChanged(radioState) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@ -284,7 +289,7 @@ MobileConnectionParent::NotifyLastKnownNetworkChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString network;
|
||||
rv = mMobileConnection->GetLastKnownNetwork(network);
|
||||
rv = mService->GetLastKnownNetwork(mClientId, network);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SendNotifyLastNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@ -297,7 +302,7 @@ MobileConnectionParent::NotifyLastKnownHomeNetworkChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString network;
|
||||
rv = mMobileConnection->GetLastKnownHomeNetwork(network);
|
||||
rv = mService->GetLastKnownHomeNetwork(mClientId, network);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SendNotifyLastHomeNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@ -310,7 +315,7 @@ MobileConnectionParent::NotifyNetworkSelectionModeChanged()
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString mode;
|
||||
rv = mMobileConnection->GetNetworkSelectionMode(mode);
|
||||
rv = mService->GetNetworkSelectionMode(mClientId, mode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@ -324,104 +329,104 @@ void
|
||||
MobileConnectionRequestParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
mLive = false;
|
||||
mMobileConnection = nullptr;
|
||||
mService = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetNetworksRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetNetworks(this));
|
||||
return NS_SUCCEEDED(mService->GetNetworks(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SelectNetworkRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
// Use dont_AddRef here because this instances is already AddRef-ed in
|
||||
// MobileConnectionIPCSerializer.h
|
||||
nsCOMPtr<nsIMobileNetworkInfo> network = dont_AddRef(aRequest.network());
|
||||
return NS_SUCCEEDED(mMobileConnection->SelectNetwork(network, this));
|
||||
return NS_SUCCEEDED(mService->SelectNetwork(mClientId, network, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SelectNetworkAutoRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SelectNetworkAutomatically(this));
|
||||
return NS_SUCCEEDED(mService->SelectNetworkAutomatically(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetPreferredNetworkTypeRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetPreferredNetworkType(aRequest.type(), this));
|
||||
return NS_SUCCEEDED(mService->SetPreferredNetworkType(mClientId, aRequest.type(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetPreferredNetworkTypeRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetPreferredNetworkType(this));
|
||||
return NS_SUCCEEDED(mService->GetPreferredNetworkType(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetRoamingPreferenceRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetRoamingPreference(aRequest.mode(), this));
|
||||
return NS_SUCCEEDED(mService->SetRoamingPreference(mClientId, aRequest.mode(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetRoamingPreferenceRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetRoamingPreference(this));
|
||||
return NS_SUCCEEDED(mService->GetRoamingPreference(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetVoicePrivacyModeRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetVoicePrivacyMode(aRequest.enabled(), this));
|
||||
return NS_SUCCEEDED(mService->SetVoicePrivacyMode(mClientId, aRequest.enabled(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetVoicePrivacyModeRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetVoicePrivacyMode(this));
|
||||
return NS_SUCCEEDED(mService->GetVoicePrivacyMode(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SendMmiRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SendMMI(aRequest.mmi(), this));
|
||||
return NS_SUCCEEDED(mService->SendMMI(mClientId, aRequest.mmi(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const CancelMmiRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->CancelMMI(this));
|
||||
return NS_SUCCEEDED(mService->CancelMMI(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetCallForwardingRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> options(cx);
|
||||
@ -430,21 +435,21 @@ MobileConnectionRequestParent::DoRequest(const SetCallForwardingRequest& aReques
|
||||
return false;
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetCallForwarding(options, this));
|
||||
return NS_SUCCEEDED(mService->SetCallForwarding(mClientId, options, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetCallForwardingRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetCallForwarding(aRequest.reason(), this));
|
||||
return NS_SUCCEEDED(mService->GetCallForwarding(mClientId, aRequest.reason(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetCallBarringRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> options(cx);
|
||||
@ -453,13 +458,13 @@ MobileConnectionRequestParent::DoRequest(const SetCallBarringRequest& aRequest)
|
||||
return false;
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetCallBarring(options, this));
|
||||
return NS_SUCCEEDED(mService->SetCallBarring(mClientId, options, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetCallBarringRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> options(cx);
|
||||
@ -468,13 +473,13 @@ MobileConnectionRequestParent::DoRequest(const GetCallBarringRequest& aRequest)
|
||||
return false;
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetCallBarring(options, this));
|
||||
return NS_SUCCEEDED(mService->GetCallBarring(mClientId, options, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const ChangeCallBarringPasswordRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> options(cx);
|
||||
@ -483,55 +488,55 @@ MobileConnectionRequestParent::DoRequest(const ChangeCallBarringPasswordRequest&
|
||||
return false;
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->ChangeCallBarringPassword(options, this));
|
||||
return NS_SUCCEEDED(mService->ChangeCallBarringPassword(mClientId, options, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetCallWaitingRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetCallWaiting(aRequest.enabled(), this));
|
||||
return NS_SUCCEEDED(mService->SetCallWaiting(mClientId, aRequest.enabled(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetCallWaitingRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetCallWaiting(this));
|
||||
return NS_SUCCEEDED(mService->GetCallWaiting(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetCallingLineIdRestrictionRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetCallingLineIdRestriction(aRequest.mode(), this));
|
||||
return NS_SUCCEEDED(mService->SetCallingLineIdRestriction(mClientId, aRequest.mode(), this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const GetCallingLineIdRestrictionRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->GetCallingLineIdRestriction(this));
|
||||
return NS_SUCCEEDED(mService->GetCallingLineIdRestriction(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const ExitEmergencyCbModeRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->ExitEmergencyCbMode(this));
|
||||
return NS_SUCCEEDED(mService->ExitEmergencyCbMode(mClientId, this));
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionRequestParent::DoRequest(const SetRadioEnabledRequest& aRequest)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
NS_ENSURE_TRUE(mService, false);
|
||||
|
||||
return NS_SUCCEEDED(mMobileConnection->SetRadioEnabled(aRequest.enabled(), this));
|
||||
return NS_SUCCEEDED(mService->SetRadioEnabled(mClientId, aRequest.enabled(), this));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -5,8 +5,8 @@
|
||||
#ifndef mozilla_dom_mobileconnection_MobileConnectionParent_h
|
||||
#define mozilla_dom_mobileconnection_MobileConnectionParent_h
|
||||
|
||||
#include "mozilla/dom/mobileconnection/PMobileConnectionParent.h"
|
||||
#include "mozilla/dom/mobileconnection/PMobileConnectionRequestParent.h"
|
||||
#include "mozilla/dom/PMobileConnectionParent.h"
|
||||
#include "mozilla/dom/PMobileConnectionRequestParent.h"
|
||||
#include "nsIMobileConnectionInfo.h"
|
||||
#include "nsIMobileConnectionService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
@ -55,8 +55,9 @@ protected:
|
||||
nsString* aRadioState, nsTArray<nsString>* aSupportedNetworkTypes) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIMobileConnection> mMobileConnection;
|
||||
uint32_t mClientId;
|
||||
bool mLive;
|
||||
nsCOMPtr<nsIMobileConnectionService> mService;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
@ -77,11 +78,14 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILECONNECTIONCALLBACK
|
||||
|
||||
explicit MobileConnectionRequestParent(nsIMobileConnection* aMobileConnection)
|
||||
: mMobileConnection(aMobileConnection)
|
||||
explicit MobileConnectionRequestParent(uint32_t aClientId)
|
||||
: mClientId(aClientId)
|
||||
, mLive(true)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MobileConnectionRequestParent);
|
||||
|
||||
mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(mService, "This shouldn't fail!");
|
||||
}
|
||||
|
||||
bool
|
||||
@ -164,8 +168,9 @@ protected:
|
||||
SendReply(const MobileConnectionReply& aReply);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIMobileConnection> mMobileConnection;
|
||||
uint32_t mClientId;
|
||||
bool mLive;
|
||||
nsCOMPtr<nsIMobileConnectionService> mService;
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
|
@ -10,7 +10,6 @@ include PMobileConnectionTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
|
||||
sync protocol PMobileConnection
|
||||
{
|
||||
@ -185,6 +184,5 @@ union MobileConnectionRequest
|
||||
SetRadioEnabledRequest;
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace dom
|
||||
|
@ -9,7 +9,6 @@ include PMobileConnectionTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
|
||||
protocol PMobileConnectionRequest
|
||||
{
|
||||
@ -100,6 +99,5 @@ union MobileConnectionReply
|
||||
MobileConnectionReplyErrorMmi;
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -4,15 +4,14 @@
|
||||
* 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/. */
|
||||
|
||||
using nsMobileConnectionInfo from "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h";
|
||||
using nsMobileNetworkInfo from "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h";
|
||||
using nsMobileConnectionInfo from "mozilla/dom/MobileConnectionIPCSerializer.h";
|
||||
using nsMobileNetworkInfo from "mozilla/dom/MobileConnectionIPCSerializer.h";
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
using struct IPC::MozCallForwardingOptions from "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h";
|
||||
using struct IPC::MozCallBarringOptions from "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h";
|
||||
using struct IPC::MozCallForwardingOptions from "mozilla/dom/MobileConnectionIPCSerializer.h";
|
||||
using struct IPC::MozCallBarringOptions from "mozilla/dom/MobileConnectionIPCSerializer.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobileconnection {
|
||||
|
||||
union AdditionalInformation {
|
||||
void_t;
|
||||
@ -21,6 +20,5 @@ union AdditionalInformation {
|
||||
MozCallForwardingOptions[];
|
||||
};
|
||||
|
||||
} // namespace mobileconnection
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -4,32 +4,27 @@
|
||||
# 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/.
|
||||
|
||||
DIRS += ['interfaces']
|
||||
|
||||
MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'DOMMMIError.h',
|
||||
'ipc/MobileConnectionIPCSerializer.h',
|
||||
'MobileCellInfo.h',
|
||||
'MobileConnection.h',
|
||||
'MobileConnectionArray.h',
|
||||
'MobileConnectionCallback.h',
|
||||
'MobileConnectionInfo.h',
|
||||
'MobileNetworkInfo.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom.mobileconnection += [
|
||||
'ipc/MobileConnectionChild.h',
|
||||
'ipc/MobileConnectionIPCSerializer.h',
|
||||
'ipc/MobileConnectionIPCService.h',
|
||||
'ipc/MobileConnectionParent.h',
|
||||
]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'interfaces/nsICellInfo.idl',
|
||||
'interfaces/nsIMobileCellInfo.idl',
|
||||
'interfaces/nsIMobileConnectionInfo.idl',
|
||||
'interfaces/nsIMobileConnectionService.idl',
|
||||
'interfaces/nsIMobileNetworkInfo.idl',
|
||||
'interfaces/nsINeighboringCellInfo.idl',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'DOMMMIError.cpp',
|
||||
'ipc/MobileConnectionChild.cpp',
|
||||
@ -50,12 +45,9 @@ IPDL_SOURCES += [
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
|
||||
XPIDL_SOURCES += [
|
||||
'gonk/nsIGonkMobileConnectionService.idl',
|
||||
]
|
||||
EXTRA_COMPONENTS += [
|
||||
'gonk/MobileConnectionService.js',
|
||||
'gonk/MobileConnectionService.manifest',
|
||||
'gonk/MobileConnectionGonkService.js',
|
||||
'gonk/MobileConnectionGonkService.manifest',
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
@ -63,5 +55,3 @@ FAIL_ON_WARNINGS = True
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
XPIDL_MODULE = 'dom_mobileconnection'
|
||||
|
@ -23,23 +23,10 @@
|
||||
#include "nsIMmsService.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "nsIMobileMessageService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISmsService.h"
|
||||
#include "nsServiceManagerUtils.h" // For do_GetService()
|
||||
|
||||
// Service instantiation
|
||||
#include "ipc/SmsIPCService.h"
|
||||
#include "MobileMessageService.h"
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "android/MobileMessageDatabaseService.h"
|
||||
#include "android/SmsService.h"
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
#include "nsIRilMobileMessageDatabaseService.h"
|
||||
#include "gonk/SmsService.h"
|
||||
#endif
|
||||
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
|
||||
|
||||
#define RECEIVED_EVENT_NAME NS_LITERAL_STRING("received")
|
||||
#define RETRIEVING_EVENT_NAME NS_LITERAL_STRING("retrieving")
|
||||
#define SENDING_EVENT_NAME NS_LITERAL_STRING("sending")
|
||||
@ -699,62 +686,3 @@ MobileMessageManager::GetSmscAddress(const Optional<uint32_t>& aServiceId,
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
already_AddRefed<nsISmsService>
|
||||
NS_CreateSmsService()
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
smsService = SmsIPCService::GetSingleton();
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
smsService = new SmsService();
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
smsService = new SmsService();
|
||||
#endif
|
||||
}
|
||||
|
||||
return smsService.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIMobileMessageDatabaseService>
|
||||
NS_CreateMobileMessageDatabaseService()
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mobileMessageDBService = SmsIPCService::GetSingleton();
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mobileMessageDBService = new MobileMessageDatabaseService();
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
mobileMessageDBService =
|
||||
do_CreateInstance(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
#endif
|
||||
}
|
||||
|
||||
return mobileMessageDBService.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIMmsService>
|
||||
NS_CreateMmsService()
|
||||
{
|
||||
nsCOMPtr<nsIMmsService> mmsService;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mmsService = SmsIPCService::GetSingleton();
|
||||
} else {
|
||||
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
mmsService = do_CreateInstance("@mozilla.org/mms/rilmmsservice;1");
|
||||
#endif
|
||||
}
|
||||
|
||||
return mmsService.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIMobileMessageService>
|
||||
NS_CreateMobileMessageService()
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageService> service = new MobileMessageService();
|
||||
return service.forget();
|
||||
}
|
||||
|
@ -14,6 +14,20 @@ namespace mobilemessage {
|
||||
|
||||
NS_IMPL_ISUPPORTS(MobileMessageService, nsIMobileMessageService)
|
||||
|
||||
/* static */ StaticRefPtr<MobileMessageService> MobileMessageService::sSingleton;
|
||||
|
||||
/* static */ already_AddRefed<MobileMessageService>
|
||||
MobileMessageService::GetInstance()
|
||||
{
|
||||
if (!sSingleton) {
|
||||
sSingleton = new MobileMessageService();
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
|
||||
nsRefPtr<MobileMessageService> service = sSingleton.get();
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
|
@ -5,8 +5,9 @@
|
||||
#ifndef mozilla_dom_mobilemessage_MobileMessageService_h
|
||||
#define mozilla_dom_mobilemessage_MobileMessageService_h
|
||||
|
||||
#include "mozilla/Attributes.h" // For MOZ_FINAL
|
||||
#include "nsIMobileMessageService.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -18,11 +19,13 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILEMESSAGESERVICE
|
||||
|
||||
MobileMessageService() { MOZ_COUNT_CTOR(MobileMessageService); }
|
||||
static already_AddRefed<MobileMessageService> GetInstance();
|
||||
|
||||
private:
|
||||
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||
~MobileMessageService() { MOZ_COUNT_DTOR(MobileMessageService); }
|
||||
~MobileMessageService() {}
|
||||
|
||||
static StaticRefPtr<MobileMessageService> sSingleton;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
|
77
dom/mobilemessage/SmsServicesFactory.cpp
Normal file
77
dom/mobilemessage/SmsServicesFactory.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "SmsServicesFactory.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "ipc/SmsIPCService.h"
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "android/MobileMessageDatabaseService.h"
|
||||
#include "android/SmsService.h"
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
#include "gonk/SmsService.h"
|
||||
#endif
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#define RIL_MMSSERVICE_CONTRACTID "@mozilla.org/mms/rilmmsservice;1"
|
||||
#define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
/* static */ already_AddRefed<nsISmsService>
|
||||
SmsServicesFactory::CreateSmsService()
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
smsService = new SmsIPCService();
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
smsService = new SmsService();
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
smsService = new SmsService();
|
||||
#endif
|
||||
}
|
||||
|
||||
return smsService.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsIMobileMessageDatabaseService>
|
||||
SmsServicesFactory::CreateMobileMessageDatabaseService()
|
||||
{
|
||||
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mobileMessageDBService = new SmsIPCService();
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mobileMessageDBService = new MobileMessageDatabaseService();
|
||||
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
mobileMessageDBService = do_GetService(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
|
||||
#endif
|
||||
}
|
||||
|
||||
return mobileMessageDBService.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsIMmsService>
|
||||
SmsServicesFactory::CreateMmsService()
|
||||
{
|
||||
nsCOMPtr<nsIMmsService> mmsService;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mmsService = new SmsIPCService();
|
||||
} else {
|
||||
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
||||
mmsService = do_CreateInstance(RIL_MMSSERVICE_CONTRACTID);
|
||||
#endif
|
||||
}
|
||||
|
||||
return mmsService.forget();
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
31
dom/mobilemessage/SmsServicesFactory.h
Normal file
31
dom/mobilemessage/SmsServicesFactory.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_mobilemessage_SmsServicesFactory_h
|
||||
#define mozilla_dom_mobilemessage_SmsServicesFactory_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsISmsService;
|
||||
class nsIMmsService;
|
||||
class nsIMobileMessageDatabaseService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
class SmsServicesFactory
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<nsISmsService> CreateSmsService();
|
||||
static already_AddRefed<nsIMobileMessageDatabaseService> CreateMobileMessageDatabaseService();
|
||||
static already_AddRefed<nsIMmsService> CreateMmsService();
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_SmsServicesFactory_h
|
@ -328,9 +328,8 @@ MmsConnection.prototype = {
|
||||
* @return true if voice call is roaming.
|
||||
*/
|
||||
isVoiceRoaming: function() {
|
||||
let connection =
|
||||
gMobileConnectionService.getItemByServiceId(this.serviceId);
|
||||
let isRoaming = connection && connection.voice && connection.voice.roaming;
|
||||
let voice = gMobileConnectionService.getVoiceConnectionInfo(this.serviceId);
|
||||
let isRoaming = voice.roaming;
|
||||
if (DEBUG) debug("isVoiceRoaming = " + isRoaming);
|
||||
return isRoaming;
|
||||
},
|
||||
|
@ -3,7 +3,6 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIMobileMessageCallback;
|
||||
interface nsIDOMBlob;
|
||||
|
||||
@ -29,10 +28,3 @@ interface nsIMmsService : nsISupports
|
||||
in DOMString toAddress,
|
||||
in DOMString iccId);
|
||||
};
|
||||
|
||||
%{C++
|
||||
template<typename T> struct already_AddRefed;
|
||||
|
||||
already_AddRefed<nsIMmsService>
|
||||
NS_CreateMmsService();
|
||||
%}
|
||||
|
@ -46,10 +46,3 @@ interface nsIMobileMessageDatabaseService : nsISupports
|
||||
|
||||
nsICursorContinueCallback createThreadCursor(in nsIMobileMessageCursorCallback callback);
|
||||
};
|
||||
|
||||
%{C++
|
||||
template<typename T> struct already_AddRefed;
|
||||
|
||||
already_AddRefed<nsIMobileMessageDatabaseService>
|
||||
NS_CreateMobileMessageDatabaseService();
|
||||
%}
|
||||
|
@ -64,10 +64,3 @@ interface nsIMobileMessageService : nsISupports
|
||||
[array, size_is(threadCount)] in unsigned long long threadIds,
|
||||
in uint32_t threadCount);
|
||||
};
|
||||
|
||||
%{C++
|
||||
template<typename T> struct already_AddRefed;
|
||||
|
||||
already_AddRefed<nsIMobileMessageService>
|
||||
NS_CreateMobileMessageService();
|
||||
%}
|
||||
|
@ -34,13 +34,6 @@ interface nsIRilMobileMessageDatabaseConcatenationCallback : nsISupports
|
||||
void notify(in nsresult aRv, in jsval aCompleteMessage);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CID \
|
||||
{ 0x29785f90, 0x6b5b, 0x11e2, { 0x92, 0x01, 0x3b, 0x28, 0x01, 0x70, 0xb2, 0xec } }
|
||||
#define RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(0b437a5c-a2bc-11e3-bd1b-dbb173eb35f8)]
|
||||
interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
|
||||
{
|
||||
|
@ -33,10 +33,3 @@ interface nsISmsService : nsISupports
|
||||
void getSmscAddress(in unsigned long serviceId,
|
||||
in nsIMobileMessageCallback request);
|
||||
};
|
||||
|
||||
%{C++
|
||||
template<typename T> struct already_AddRefed;
|
||||
|
||||
already_AddRefed<nsISmsService>
|
||||
NS_CreateSmsService();
|
||||
%}
|
||||
|
@ -32,9 +32,6 @@ const char* kObservedPrefs[] = {
|
||||
// TODO: Bug 767082 - WebSMS: sSmsChild leaks at shutdown
|
||||
PSmsChild* gSmsChild;
|
||||
|
||||
// SmsIPCService is owned by nsLayoutModule.
|
||||
SmsIPCService* sSingleton = nullptr;
|
||||
|
||||
PSmsChild*
|
||||
GetSmsChild()
|
||||
{
|
||||
@ -105,19 +102,6 @@ NS_IMPL_ISUPPORTS(SmsIPCService,
|
||||
nsIMobileMessageDatabaseService,
|
||||
nsIObserver)
|
||||
|
||||
/* static */ already_AddRefed<SmsIPCService>
|
||||
SmsIPCService::GetSingleton()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!sSingleton) {
|
||||
sSingleton = new SmsIPCService();
|
||||
}
|
||||
|
||||
nsRefPtr<SmsIPCService> service = sSingleton;
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
SmsIPCService::SmsIPCService()
|
||||
{
|
||||
Preferences::AddStrongObservers(this, kObservedPrefs);
|
||||
@ -125,11 +109,6 @@ SmsIPCService::SmsIPCService()
|
||||
mSmsDefaultServiceId = getDefaultServiceId(kPrefSmsDefaultServiceId);
|
||||
}
|
||||
|
||||
SmsIPCService::~SmsIPCService()
|
||||
{
|
||||
sSingleton = nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of nsIObserver.
|
||||
*/
|
||||
|
@ -30,14 +30,10 @@ public:
|
||||
NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static already_AddRefed<SmsIPCService>
|
||||
GetSingleton();
|
||||
|
||||
private:
|
||||
SmsIPCService();
|
||||
|
||||
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
|
||||
~SmsIPCService();
|
||||
private:
|
||||
~SmsIPCService() {}
|
||||
|
||||
uint32_t mMmsDefaultServiceId;
|
||||
uint32_t mSmsDefaultServiceId;
|
||||
|
@ -13,6 +13,8 @@ EXPORTS.mozilla.dom.mobilemessage += [
|
||||
'Constants.h', # Required by almost all cpp files
|
||||
'ipc/SmsChild.h',
|
||||
'ipc/SmsParent.h',
|
||||
'MobileMessageService.h', # Required by nsLayoutModule.cpp
|
||||
'SmsServicesFactory.h', # Required by nsLayoutModule.cpp
|
||||
'Types.h', # Required by IPDL SmsTypes.h
|
||||
]
|
||||
|
||||
@ -60,6 +62,7 @@ UNIFIED_SOURCES += [
|
||||
'MobileMessageService.cpp',
|
||||
'MobileMessageThread.cpp',
|
||||
'SmsMessage.cpp',
|
||||
'SmsServicesFactory.cpp',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
|
@ -48,6 +48,12 @@ ChromeNotifications.prototype = {
|
||||
let resentNotifications = 0;
|
||||
|
||||
notifications.forEach(function(notification) {
|
||||
let behavior;
|
||||
try {
|
||||
behavior = JSON.parse(notification.mozbehavior);
|
||||
} catch(e) {
|
||||
behavior = undefined;
|
||||
}
|
||||
appNotifier.showAppNotification(
|
||||
notification.icon,
|
||||
notification.title,
|
||||
@ -61,7 +67,8 @@ ChromeNotifications.prototype = {
|
||||
tag: notification.tag,
|
||||
dbId: notification.id,
|
||||
timestamp: notification.timestamp,
|
||||
data: notification.data
|
||||
data: notification.data,
|
||||
mozbehavior: behavior
|
||||
}
|
||||
);
|
||||
resentNotifications++;
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
const nsAString& aTag,
|
||||
const nsAString& aIcon,
|
||||
const nsAString& aData,
|
||||
const nsAString& aBehavior,
|
||||
JSContext* aCx)
|
||||
{
|
||||
MOZ_ASSERT(!aID.IsEmpty());
|
||||
@ -71,10 +72,12 @@ public:
|
||||
options.mBody = aBody;
|
||||
options.mTag = aTag;
|
||||
options.mIcon = aIcon;
|
||||
nsRefPtr<Notification> notification = Notification::CreateInternal(mWindow,
|
||||
aID,
|
||||
aTitle,
|
||||
options);
|
||||
options.mMozbehavior.Init(aBehavior);
|
||||
nsRefPtr<Notification> notification;
|
||||
notification = Notification::CreateInternal(mWindow,
|
||||
aID,
|
||||
aTitle,
|
||||
options);
|
||||
ErrorResult rv;
|
||||
notification->InitFromBase64(aCx, aData, rv);
|
||||
if (rv.Failed()) {
|
||||
@ -395,10 +398,10 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
Notification::Notification(const nsAString& aID, const nsAString& aTitle, const nsAString& aBody,
|
||||
NotificationDirection aDir, const nsAString& aLang,
|
||||
const nsAString& aTag, const nsAString& aIconUrl,
|
||||
nsPIDOMWindow* aWindow)
|
||||
const NotificationBehavior& aBehavior, nsPIDOMWindow* aWindow)
|
||||
: DOMEventTargetHelper(aWindow),
|
||||
mID(aID), mTitle(aTitle), mBody(aBody), mDir(aDir), mLang(aLang),
|
||||
mTag(aTag), mIconUrl(aIconUrl), mIsClosed(false), mIsStored(false)
|
||||
mTag(aTag), mIconUrl(aIconUrl), mBehavior(aBehavior), mIsClosed(false), mIsStored(false)
|
||||
{
|
||||
nsAutoString alertName;
|
||||
DebugOnly<nsresult> rv = GetOrigin(GetOwner(), alertName);
|
||||
@ -474,6 +477,12 @@ Notification::Constructor(const GlobalObject& aGlobal,
|
||||
scContainer->GetDataAsBase64(dataString);
|
||||
}
|
||||
|
||||
nsAutoString behavior;
|
||||
if (!aOptions.mMozbehavior.ToJSON(behavior)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aRv = notificationStorage->Put(origin,
|
||||
id,
|
||||
aTitle,
|
||||
@ -483,7 +492,8 @@ Notification::Constructor(const GlobalObject& aGlobal,
|
||||
aOptions.mTag,
|
||||
aOptions.mIcon,
|
||||
alertName,
|
||||
dataString);
|
||||
dataString,
|
||||
behavior);
|
||||
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
@ -524,6 +534,7 @@ Notification::CreateInternal(nsPIDOMWindow* aWindow,
|
||||
aOptions.mLang,
|
||||
aOptions.mTag,
|
||||
aOptions.mIcon,
|
||||
aOptions.mMozbehavior,
|
||||
aWindow);
|
||||
return notification.forget();
|
||||
}
|
||||
@ -572,12 +583,13 @@ Notification::ShowInternal()
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString absoluteUrl;
|
||||
if (mIconUrl.Length() > 0) {
|
||||
// Resolve image URL against document base URI.
|
||||
nsIDocument* doc = GetOwner()->GetExtantDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIURI> baseUri = doc->GetBaseURI();
|
||||
if (baseUri) {
|
||||
nsAutoString soundUrl;
|
||||
// Resolve image URL against document base URI.
|
||||
nsIDocument* doc = GetOwner()->GetExtantDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIURI> baseUri = doc->GetBaseURI();
|
||||
if (baseUri) {
|
||||
if (mIconUrl.Length() > 0) {
|
||||
nsCOMPtr<nsIURI> srcUri;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(srcUri),
|
||||
mIconUrl, doc, baseUri);
|
||||
@ -587,7 +599,16 @@ Notification::ShowInternal()
|
||||
absoluteUrl = NS_ConvertUTF8toUTF16(src);
|
||||
}
|
||||
}
|
||||
|
||||
if (mBehavior.mSoundFile.Length() > 0) {
|
||||
nsCOMPtr<nsIURI> srcUri;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(srcUri),
|
||||
mBehavior.mSoundFile, doc, baseUri);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString src;
|
||||
srcUri->GetSpec(src);
|
||||
soundUrl = NS_ConvertUTF8toUTF16(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,6 +644,8 @@ Notification::ShowInternal()
|
||||
ops.mLang = mLang;
|
||||
ops.mTag = mTag;
|
||||
ops.mData = dataStr;
|
||||
ops.mMozbehavior = mBehavior;
|
||||
ops.mMozbehavior.mSoundFile = soundUrl;
|
||||
|
||||
if (!ToJSValue(cx, ops, &val)) {
|
||||
NS_WARNING("Converting dict to object failed!");
|
||||
|
@ -114,11 +114,12 @@ public:
|
||||
void InitFromJSVal(JSContext* aCx, JS::Handle<JS::Value> aData, ErrorResult& aRv);
|
||||
|
||||
void InitFromBase64(JSContext* aCx, const nsAString& aData, ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
Notification(const nsAString& aID, const nsAString& aTitle, const nsAString& aBody,
|
||||
NotificationDirection aDir, const nsAString& aLang,
|
||||
const nsAString& aTag, const nsAString& aIconUrl,
|
||||
nsPIDOMWindow* aWindow);
|
||||
const NotificationBehavior& aBehavior, nsPIDOMWindow* aWindow);
|
||||
|
||||
static already_AddRefed<Notification> CreateInternal(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aID,
|
||||
@ -169,6 +170,7 @@ protected:
|
||||
nsString mTag;
|
||||
nsString mIconUrl;
|
||||
nsCOMPtr<nsIStructuredCloneContainer> mDataObjectContainer;
|
||||
NotificationBehavior mBehavior;
|
||||
|
||||
// It's null until GetData is first called
|
||||
nsCOMPtr<nsIVariant> mData;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user