зеркало из 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 = [];
|
||||
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" });
|
||||
});
|
||||
|
|
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) {
|
||||
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),
|
||||
},
|
||||
});
|
||||
|
||||
activity.onsuccess = function() {
|
||||
}, function(message) {
|
||||
switch (message.type) {
|
||||
case "onsuccess":
|
||||
DumbPipe.close(pipe);
|
||||
resolve(message.byteLength);
|
||||
};
|
||||
break;
|
||||
|
||||
activity.onerror = function() {
|
||||
case "onerror":
|
||||
ctx.setAsCurrentContext();
|
||||
reject($.newIOException("Error while sending SMS message"));
|
||||
};
|
||||
break;
|
||||
}
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче