Make sending SMS messages use the mozActivity pipe

This commit is contained in:
Marco Castelluccio 2015-04-18 02:34:48 +02:00
Родитель 08c627c166
Коммит d0bb18509f
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -10,7 +10,8 @@
var loadingPromises = [];
if (config.midletClassName == "RunTests") {
loadingPromises.push(loadScript("tests/contacts.js"),
loadScript("tests/index.js"));
loadScript("tests/index.js"),
loadScript("tests/mozactivitymock.js"));
}
if (navigator.userAgent.indexOf('Chrome') > -1) {
@ -746,5 +747,9 @@ DumbPipe.registerOpener("backgroundCheck", function(message, sender) {
});
DumbPipe.registerOpener("mozActivity", function(message, sender) {
new MozActivity(message);
var activity = new MozActivity(message);
activity.onsuccess = sender.bind(null, { type: "onsuccess" });
activity.onerror = sender.bind(null, { type: "onerror" });
});

Просмотреть файл

@ -186,22 +186,25 @@ Native["com/sun/midp/io/j2me/sms/Protocol.send0.(IILjava/lang/String;II[B)I"] =
function(handle, type, host, destPort, sourcePort, message) {
var ctx = $.ctx;
asyncImpl("I", new Promise(function(resolve, reject) {
var activity = new MozActivity({
var pipe = DumbPipe.open("mozActivity", {
name: "new",
data: {
type: "websms/sms",
number: J2ME.fromJavaString(host),
body: new TextDecoder('utf-16be').decode(message),
type: "websms/sms",
number: J2ME.fromJavaString(host),
body: new TextDecoder('utf-16be').decode(message),
},
}, function(message) {
switch (message.type) {
case "onsuccess":
DumbPipe.close(pipe);
resolve(message.byteLength);
break;
case "onerror":
ctx.setAsCurrentContext();
reject($.newIOException("Error while sending SMS message"));
break;
}
});
activity.onsuccess = function() {
resolve(message.byteLength);
};
activity.onerror = function() {
ctx.setAsCurrentContext();
reject($.newIOException("Error while sending SMS message"));
};
}));
};