зеркало из https://github.com/mozilla/pluotsorbet.git
Support updating MIDlets via platformRequest. Fixes #359
This commit is contained in:
Родитель
08ac88adbd
Коммит
7ed499d604
6
index.js
6
index.js
|
@ -472,8 +472,8 @@ DumbPipe.registerOpener("notification", function(message, sender) {
|
|||
}
|
||||
});
|
||||
|
||||
DumbPipe.registerOpener("JARDownloader", function(message, sender) {
|
||||
loadWithProgress(urlParams.downloadJAD, "text", function(jadData) {
|
||||
DumbPipe.registerOpener("JARDownloader", function(url, sender) {
|
||||
loadWithProgress(url, "text", function(jadData) {
|
||||
try {
|
||||
var manifest = {};
|
||||
|
||||
|
@ -494,7 +494,7 @@ DumbPipe.registerOpener("JARDownloader", function(message, sender) {
|
|||
|
||||
if (!jarURL.startsWith("http")) {
|
||||
var jarName = jarURL.substring(jarURL.lastIndexOf("/") + 1);
|
||||
jarURL = urlParams.downloadJAD.substring(0, urlParams.downloadJAD.lastIndexOf("/") + 1) + jarName;
|
||||
jarURL = url.substring(0, url.lastIndexOf("/") + 1) + jarName;
|
||||
}
|
||||
|
||||
loadWithProgress(jarURL, "arraybuffer", function(jarData) {
|
||||
|
|
8
main.js
8
main.js
|
@ -82,13 +82,13 @@ if (urlParams.jad) {
|
|||
loadingPromises.push(load(urlParams.jad, "text").then(processJAD));
|
||||
}
|
||||
|
||||
function performDownload(dialog, callback) {
|
||||
function performDownload(url, dialog, callback) {
|
||||
var dialogText = dialog.querySelector('h1.download-dialog-text');
|
||||
dialogText.textContent = "Downloading " + MIDlet.name + "…";
|
||||
|
||||
var progressBar = dialog.querySelector('progress.pack-activity');
|
||||
|
||||
var sender = DumbPipe.open("JARDownloader", {}, function(message) {
|
||||
var sender = DumbPipe.open("JARDownloader", url, function(message) {
|
||||
switch (message.type) {
|
||||
case "done":
|
||||
DumbPipe.close(sender);
|
||||
|
@ -121,7 +121,7 @@ function performDownload(dialog, callback) {
|
|||
|
||||
progressBar.style.display = '';
|
||||
|
||||
performDownload(dialog, callback);
|
||||
performDownload(url, dialog, callback);
|
||||
});
|
||||
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ if (urlParams.downloadJAD) {
|
|||
dialog.classList.add('visible');
|
||||
document.body.appendChild(dialog);
|
||||
|
||||
performDownload(dialog, function(data) {
|
||||
performDownload(urlParams.downloadJAD, dialog, function(data) {
|
||||
dialog.parentElement.removeChild(dialog);
|
||||
|
||||
jvm.addPath("midlet.jar", data.jarData);
|
||||
|
|
31
midp/midp.js
31
midp/midp.js
|
@ -227,7 +227,36 @@ Native.create("com/sun/midp/security/Permissions.loadGroupPermissions.(Ljava/lan
|
|||
Native.create("com/sun/midp/main/CldcPlatformRequest.dispatchPlatformRequest.(Ljava/lang/String;)Z", function(request) {
|
||||
request = util.fromJavaString(request);
|
||||
if (request.startsWith("http://") || request.startsWith("https://")) {
|
||||
DumbPipe.close(DumbPipe.open("windowOpen", request));
|
||||
if (request.endsWith(".jad")) {
|
||||
var dialog = document.getElementById('download-progress-dialog').cloneNode(true);
|
||||
dialog.style.display = 'block';
|
||||
dialog.classList.add('visible');
|
||||
document.body.appendChild(dialog);
|
||||
|
||||
performDownload(request, dialog, function(data) {
|
||||
dialog.parentElement.removeChild(dialog);
|
||||
|
||||
Promise.all([
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.remove("/midlet.jad", function() {
|
||||
console.log(data.jadData);
|
||||
fs.create("/midlet.jad", new Blob([ data.jadData ]), resolve);
|
||||
});
|
||||
}),
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.remove("/midlet.jar", function() {
|
||||
fs.create("/midlet.jar", new Blob([ data.jarData ]), resolve);
|
||||
});
|
||||
}),
|
||||
]).then(function() {
|
||||
DumbPipe.close(DumbPipe.open("alert", "Update completed!"));
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
DumbPipe.close(DumbPipe.open("windowOpen", request));
|
||||
}
|
||||
} else if (request.startsWith("x-contacts:add?number=")) {
|
||||
new MozActivity({
|
||||
name: "new",
|
||||
|
|
Загрузка…
Ссылка в новой задаче