зеркало из https://github.com/mozilla/pluotsorbet.git
Make sending SMS messages use the mozActivity pipe
This commit is contained in:
Родитель
08c627c166
Коммит
d0bb18509f
|
@ -10,7 +10,8 @@
|
||||||
var loadingPromises = [];
|
var loadingPromises = [];
|
||||||
if (config.midletClassName == "RunTests") {
|
if (config.midletClassName == "RunTests") {
|
||||||
loadingPromises.push(loadScript("tests/contacts.js"),
|
loadingPromises.push(loadScript("tests/contacts.js"),
|
||||||
loadScript("tests/index.js"));
|
loadScript("tests/index.js"),
|
||||||
|
loadScript("tests/mozactivitymock.js"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navigator.userAgent.indexOf('Chrome') > -1) {
|
if (navigator.userAgent.indexOf('Chrome') > -1) {
|
||||||
|
@ -746,5 +747,9 @@ DumbPipe.registerOpener("backgroundCheck", function(message, sender) {
|
||||||
});
|
});
|
||||||
|
|
||||||
DumbPipe.registerOpener("mozActivity", 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" });
|
||||||
});
|
});
|
||||||
|
|
17
midp/sms.js
17
midp/sms.js
|
@ -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) {
|
function(handle, type, host, destPort, sourcePort, message) {
|
||||||
var ctx = $.ctx;
|
var ctx = $.ctx;
|
||||||
asyncImpl("I", new Promise(function(resolve, reject) {
|
asyncImpl("I", new Promise(function(resolve, reject) {
|
||||||
var activity = new MozActivity({
|
var pipe = DumbPipe.open("mozActivity", {
|
||||||
name: "new",
|
name: "new",
|
||||||
data: {
|
data: {
|
||||||
type: "websms/sms",
|
type: "websms/sms",
|
||||||
number: J2ME.fromJavaString(host),
|
number: J2ME.fromJavaString(host),
|
||||||
body: new TextDecoder('utf-16be').decode(message),
|
body: new TextDecoder('utf-16be').decode(message),
|
||||||
},
|
},
|
||||||
});
|
}, function(message) {
|
||||||
|
switch (message.type) {
|
||||||
activity.onsuccess = function() {
|
case "onsuccess":
|
||||||
|
DumbPipe.close(pipe);
|
||||||
resolve(message.byteLength);
|
resolve(message.byteLength);
|
||||||
};
|
break;
|
||||||
|
|
||||||
activity.onerror = function() {
|
case "onerror":
|
||||||
ctx.setAsCurrentContext();
|
ctx.setAsCurrentContext();
|
||||||
reject($.newIOException("Error while sending SMS message"));
|
reject($.newIOException("Error while sending SMS message"));
|
||||||
};
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче