mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847741 - Part 4: Remove getSimContacts impl. r=gwagner
This commit is contained in:
parent
439b55ca53
commit
f1e0084500
@ -14,7 +14,6 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(Services, "DOMRequest", function() {
|
||||
return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService);
|
||||
@ -477,34 +476,6 @@ ContactManager.prototype = {
|
||||
this._pushArray(data.cachedContacts, result);
|
||||
}
|
||||
break;
|
||||
case "Contacts:GetSimContacts:Return:OK":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
let result = contacts.map(function(c) {
|
||||
let contact = new Contact();
|
||||
let prop = {name: [c.alphaId], tel: [ { value: c.number } ]};
|
||||
|
||||
if (c.email) {
|
||||
prop.email = [{value: c.email}];
|
||||
}
|
||||
|
||||
// ANR - Additional Number
|
||||
if (c.anr) {
|
||||
for (let i = 0; i < c.anr.length; i++) {
|
||||
prop.tel.push({value: c.anr[i]});
|
||||
}
|
||||
}
|
||||
|
||||
contact.init(prop);
|
||||
return contact;
|
||||
});
|
||||
if (DEBUG) debug("result: " + JSON.stringify(result));
|
||||
Services.DOMRequest.fireSuccess(req.request,
|
||||
ObjectWrapper.wrap(result, this._window));
|
||||
} else {
|
||||
if (DEBUG) debug("no request stored!" + msg.requestID);
|
||||
}
|
||||
break;
|
||||
case "Contact:Save:Return:OK":
|
||||
case "Contacts:Clear:Return:OK":
|
||||
case "Contact:Remove:Return:OK":
|
||||
@ -516,7 +487,6 @@ ContactManager.prototype = {
|
||||
case "Contact:Save:Return:KO":
|
||||
case "Contact:Remove:Return:KO":
|
||||
case "Contacts:Clear:Return:KO":
|
||||
case "Contacts:GetSimContacts:Return:KO":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req)
|
||||
Services.DOMRequest.fireError(req.request, msg.errorMsg);
|
||||
@ -570,7 +540,6 @@ ContactManager.prototype = {
|
||||
access = "write";
|
||||
break;
|
||||
case "find":
|
||||
case "getSimContacts":
|
||||
case "listen":
|
||||
case "revision":
|
||||
access = "read";
|
||||
@ -743,25 +712,6 @@ ContactManager.prototype = {
|
||||
return request;
|
||||
},
|
||||
|
||||
getSimContacts: function(aContactType) {
|
||||
let request;
|
||||
request = this.createRequest();
|
||||
let options = {contactType: aContactType};
|
||||
|
||||
let allowCallback = function() {
|
||||
if (DEBUG) debug("getSimContacts " + aContactType);
|
||||
cpmm.sendAsyncMessage("Contacts:GetSimContacts",
|
||||
{requestID: this.getRequestId({request: request, reason: "getSimContacts"}),
|
||||
options: options});
|
||||
}.bind(this);
|
||||
|
||||
let cancelCallback = function() {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
this.askPermission("getSimContacts", request, allowCallback, cancelCallback);
|
||||
return request;
|
||||
},
|
||||
|
||||
getRevision: function() {
|
||||
let request = this.createRequest();
|
||||
|
||||
@ -784,8 +734,6 @@ ContactManager.prototype = {
|
||||
"Contacts:Clear:Return:OK", "Contacts:Clear:Return:KO",
|
||||
"Contact:Save:Return:OK", "Contact:Save:Return:KO",
|
||||
"Contact:Remove:Return:OK", "Contact:Remove:Return:KO",
|
||||
"Contacts:GetSimContacts:Return:OK",
|
||||
"Contacts:GetSimContacts:Return:KO",
|
||||
"Contact:Changed",
|
||||
"PermissionPromptHelper:AskPermission:OK",
|
||||
"Contacts:GetAll:Next",
|
||||
|
@ -21,19 +21,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
|
||||
let telephony = Cc["@mozilla.org/ril;1"];
|
||||
if (!telephony) {
|
||||
// Return a mock RIL because B2G Desktop build does not support telephony.
|
||||
return {
|
||||
getICCContacts: function(aContactType, aCallback) {
|
||||
aCallback("!telephony", null, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
return telephony.getService(Ci.nsIRadioInterfaceLayer);
|
||||
});
|
||||
|
||||
let myGlobal = this;
|
||||
|
||||
let ContactService = {
|
||||
@ -41,9 +28,8 @@ let ContactService = {
|
||||
if (DEBUG) debug("Init");
|
||||
this._messages = ["Contacts:Find", "Contacts:GetAll", "Contacts:GetAll:SendNow",
|
||||
"Contacts:Clear", "Contact:Save",
|
||||
"Contact:Remove", "Contacts:GetSimContacts",
|
||||
"Contacts:RegisterForMessages", "child-process-shutdown",
|
||||
"Contacts:GetRevision"];
|
||||
"Contact:Remove", "Contacts:RegisterForMessages",
|
||||
"child-process-shutdown", "Contacts:GetRevision"];
|
||||
this._children = [];
|
||||
this._messages.forEach(function(msgName) {
|
||||
ppmm.addMessageListener(msgName, this);
|
||||
@ -173,24 +159,6 @@ let ContactService = {
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Clear:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:GetSimContacts":
|
||||
if (!this.assertPermission(aMessage, "contacts-read")) {
|
||||
return null;
|
||||
}
|
||||
mRIL.getICCContacts(
|
||||
msg.options.contactType,
|
||||
function (aErrorMsg, aType, aContacts) {
|
||||
if (aErrorMsg !== 'undefined') {
|
||||
mm.sendAsyncMessage("Contacts:GetSimContacts:Return:KO",
|
||||
{requestID: msg.requestID,
|
||||
errorMsg: aErrorMsg});
|
||||
} else {
|
||||
mm.sendAsyncMessage("Contacts:GetSimContacts:Return:OK",
|
||||
{requestID: msg.requestID,
|
||||
contacts: aContacts});
|
||||
}
|
||||
}.bind(this));
|
||||
break;
|
||||
case "Contacts:GetRevision":
|
||||
if (!this.assertPermission(aMessage, "contacts-read")) {
|
||||
return null;
|
||||
|
@ -1,6 +0,0 @@
|
||||
[DEFAULT]
|
||||
b2g = true
|
||||
browser = false
|
||||
qemu = true
|
||||
|
||||
[test_sim_contacts.js]
|
@ -1,68 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 30000;
|
||||
|
||||
SpecialPowers.addPermission("contacts-read", true, document);
|
||||
// TODO: see bug 804623, We are preventing "read" operations
|
||||
// even if just "write" has been set to DENY_ACTION.
|
||||
// Bug 816900: Because PermissionPromptHelper.jsm will expand the
|
||||
// contacts-read to contacts-read, contacts-write, contacts-create,
|
||||
// we add the other two permissions here.
|
||||
SpecialPowers.addPermission("contacts-write", true, document);
|
||||
SpecialPowers.addPermission("contacts-create", true, document);
|
||||
|
||||
let mozContacts = window.navigator.mozContacts;
|
||||
ok(mozContacts);
|
||||
|
||||
function testImportSimContacts() {
|
||||
let request = mozContacts.getSimContacts("ADN");
|
||||
request.onsuccess = function onsuccess() {
|
||||
let simContacts = request.result;
|
||||
|
||||
is(Array.isArray(simContacts), true);
|
||||
|
||||
// These SIM contacts are harded in external/qemu/telephony/sim_card.c
|
||||
is(simContacts[0].name, "Mozilla");
|
||||
is(simContacts[0].tel[0].value, "15555218201");
|
||||
|
||||
is(simContacts[1].name, "Saßê黃");
|
||||
is(simContacts[1].tel[0].value, "15555218202");
|
||||
|
||||
is(simContacts[2].name, "Fire 火");
|
||||
is(simContacts[2].tel[0].value, "15555218203");
|
||||
|
||||
is(simContacts[3].name, "Huang 黃");
|
||||
is(simContacts[3].tel[0].value, "15555218204");
|
||||
|
||||
runNextTest();
|
||||
};
|
||||
|
||||
request.onerror = function onerror() {
|
||||
ok(false, "Cannot get Sim Contacts");
|
||||
runNextTest();
|
||||
};
|
||||
};
|
||||
|
||||
let tests = [
|
||||
testImportSimContacts,
|
||||
];
|
||||
|
||||
function runNextTest() {
|
||||
let test = tests.pop();
|
||||
if (!test) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
test();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
SpecialPowers.removePermission("contacts-read", document);
|
||||
SpecialPowers.removePermission("contacts-write", document);
|
||||
SpecialPowers.removePermission("contacts-create", document);
|
||||
finish();
|
||||
}
|
||||
|
||||
runNextTest();
|
@ -23,4 +23,3 @@ skip = false
|
||||
[include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/icc/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/system/tests/marionette/manifest.ini]
|
||||
[include:../../../../../dom/contacts/tests/marionette/manifest.ini]
|
||||
|
Loading…
Reference in New Issue
Block a user