From e6405d047fb0d99cbbd9fa5229edc34b2dbc59d1 Mon Sep 17 00:00:00 2001 From: lxsang Date: Mon, 1 Oct 2018 17:13:47 +0000 Subject: [PATCH] fix stuff --- RemoteDesktop/README.md | 4 ++-- RemoteDesktop/build/debug/README.md | 4 ++-- RemoteDesktop/build/debug/main.js | 22 +++++++++++++++++++--- RemoteDesktop/coffees/main.coffee | 14 +++++++++++--- RemoteDesktop/javascripts/wvnc.js | 2 +- RemoteDesktop/project.apj | 2 +- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/RemoteDesktop/README.md b/RemoteDesktop/README.md index 159f679..4b4b6a1 100644 --- a/RemoteDesktop/README.md +++ b/RemoteDesktop/README.md @@ -4,7 +4,7 @@ This project is generated by AntOS Development Kit ## Howto 1. Open the project.apj file with AntOSDK (simply double Click on it) -2. Modify the UI in *assets/scheme.html* +2. Modify the UI in *assets/scheme.html* 3. Modify application code in *coffees/main.coffee* 4. Modify CSS style in *css/main.css* 5. Other files need to be copied: put in to assets @@ -14,7 +14,7 @@ This project is generated by AntOS Development Kit Click **Menu> Build > Build Option** or simply hit **ALT-Y** In the build options dialog, add or remove files that need to be -included into the build +included into the build Click **Save** diff --git a/RemoteDesktop/build/debug/README.md b/RemoteDesktop/build/debug/README.md index 159f679..4b4b6a1 100644 --- a/RemoteDesktop/build/debug/README.md +++ b/RemoteDesktop/build/debug/README.md @@ -4,7 +4,7 @@ This project is generated by AntOS Development Kit ## Howto 1. Open the project.apj file with AntOSDK (simply double Click on it) -2. Modify the UI in *assets/scheme.html* +2. Modify the UI in *assets/scheme.html* 3. Modify application code in *coffees/main.coffee* 4. Modify CSS style in *css/main.css* 5. Other files need to be copied: put in to assets @@ -14,7 +14,7 @@ This project is generated by AntOS Development Kit Click **Menu> Build > Build Option** or simply hit **ALT-Y** In the build options dialog, add or remove files that need to be -included into the build +included into the build Click **Save** diff --git a/RemoteDesktop/build/debug/main.js b/RemoteDesktop/build/debug/main.js index 9fd3b54..dadb093 100644 --- a/RemoteDesktop/build/debug/main.js +++ b/RemoteDesktop/build/debug/main.js @@ -71,7 +71,7 @@ } ], filldata: function(d) { - (d.find("content1")).value = "176.180.44.70:9999"; + (d.find("content1")).value = "/opt/www/vnc.conf"; (d.find("content3")).set("items", [ { text: "16 bits", @@ -123,9 +123,19 @@ ws: 'wss://localhost:9192/wvnc', worker: `${me._api.handler.get}/${(me.meta().path)}/decoder.js` }); + this.client.onerror = function(m) { + me.error(m); + return me.showConnectionDialog(); + }; this.client.onpassword = function() { return new Promise(function(r, e) { - return r("demopass"); + return me.openDialog("PromptDialog", function(d) { + return r(d); + }, __("VNC password"), { + label: __("VNC password"), + value: "demopass", + type: "password" + }); }); }; return this.client.init().then(function() { @@ -141,10 +151,16 @@ }, __("Connection")); } + cleanup() { + if (this.client) { + return this.client.disconnect(); + } + } + }; this.OS.register("RemoteDesktop", RemoteDesktop); }).call(this); -(function(){var e;e=function(){function e(e){var t,n;this.socket=void 0,this.ws=void 0,this.canvas=void 0,n="decoder.js",this.scale=1,e.ws&&(this.ws=e.ws),this.canvas=e.element,"string"==typeof this.canvas&&(this.canvas=document.getElementById(this.canvas)),e.worker&&(n=e.worker),this.decoder=new Worker(n),(t=this).mouseMask=0,this.decoder.onmessage=function(e){return t.process(e.data)}}return e.prototype.init=function(){var n;return n=this,new Promise(function(e,t){return n.canvas?(n.initInputEvent(),e()):t("Canvas is not set")})},e.prototype.initInputEvent=function(){var e,n,o,s;if((o=this).canvas&&(n=function(e){var t;return t=o.canvas.getBoundingClientRect(),{x:Math.floor((e.clientX-t.left)/o.scale),y:Math.floor((e.clientY-t.top)/o.scale)}},s=function(e){var t;return t=n(e),o.sendPointEvent(t.x,t.y,o.mouseMask)},o.canvas))return o.canvas.oncontextmenu=function(e){return e.preventDefault(),!1},o.canvas.onmousemove=function(e){return s(e)},o.canvas.onmousedown=function(e){var t;return t=1<>8,o[2]=255&t,o[3]=t>>8,o[4]=n,this.socket.send(this.buildCommand(5,o))},e.prototype.sendKeyEvent=function(e,t){var n;if(this.socket)return(n=new Uint8Array(3))[0]=255&e,n[1]=e>>8,n[2]=t,console.log(e,t),this.socket.send(this.buildCommand(6,n))},e.prototype.buildCommand=function(e,t){var n,o;switch(o=void 0,typeof t){case"string":o=(new TextEncoder).encode(t);break;case"number":o=new Uint8Array([t]);break;default:o=t}return(n=new Uint8Array(o.length+3))[0]=e,n[2]=o.length>>8,n[1]=15&o.length,n.set(o,3),n.buffer},e.prototype.oncopy=function(e){return console.log("Get clipboard text: "+e)},e.prototype.onpassword=function(){return new Promise(function(e,t){return t("onpassword is not implemented")})},e.prototype.sendTextAsClipboard=function(e){if(this.socket)return console.log("send ",e),this.socket.send(this.buildCommand(7,e))},e.prototype.oncredential=function(){return new Promise(function(e,t){return t("oncredential is not implemented")})},e.prototype.consume=function(e){var t,n,o,s,a,r,i;switch(t=(n=new Uint8Array(e.data))[0],r=this,t){case 254:return n=n.subarray(1,n.length-1),o=new TextDecoder("utf-8"),console.log("Error",o.decode(n));case 129:return console.log("Request for password"),this.onpassword().then(function(e){return r.socket.send(r.buildCommand(2,e))});case 130:return console.log("Request for login"),this.oncredential().then(function(e,t){var n;return(n=new Uint8Array(e.length+t.length+1)).set((new TextEncoder).encode(e),0),n.set(["\0"],e.length),n.set((new TextEncoder).encode(t),e.length+1),r.socket.send(r.buildCommand(3,n))});case 131:return console.log("resize"),i=n[1]|n[2]<<8,a=n[3]|n[4]<<8,s=n[5],this.initCanvas(i,a,s),this.socket.send(this.buildCommand(4,1));case 132:return this.decoder.postMessage(n.buffer,[n.buffer]);case 133:return n=n.subarray(1),o=new TextDecoder("utf-8"),this.oncopy(o.decode(n)),this.socket.send(this.buildCommand(4,1));default:return console.log(t)}},e}(),window.WVNC=e}).call(this); +(function(){var e;e=function(){function e(e){var t,n;this.socket=void 0,this.ws=void 0,this.canvas=void 0,n="decoder.js",this.scale=1,e.ws&&(this.ws=e.ws),this.canvas=e.element,"string"==typeof this.canvas&&(this.canvas=document.getElementById(this.canvas)),e.worker&&(n=e.worker),this.decoder=new Worker(n),(t=this).mouseMask=0,this.decoder.onmessage=function(e){return t.process(e.data)}}return e.prototype.init=function(){var n;return n=this,new Promise(function(e,t){return n.canvas?(n.initInputEvent(),e()):t("Canvas is not set")})},e.prototype.initInputEvent=function(){var e,n,o,s;if((o=this).canvas&&(n=function(e){var t;return t=o.canvas.getBoundingClientRect(),{x:Math.floor((e.clientX-t.left)/o.scale),y:Math.floor((e.clientY-t.top)/o.scale)}},s=function(e){var t;return t=n(e),o.sendPointEvent(t.x,t.y,o.mouseMask)},o.canvas))return o.canvas.oncontextmenu=function(e){return e.preventDefault(),!1},o.canvas.onmousemove=function(e){return s(e)},o.canvas.onmousedown=function(e){var t;return t=1<>8,o[2]=255&t,o[3]=t>>8,o[4]=n,this.socket.send(this.buildCommand(5,o))},e.prototype.sendKeyEvent=function(e,t){var n;if(this.socket)return(n=new Uint8Array(3))[0]=255&e,n[1]=e>>8,n[2]=t,console.log(e,t),this.socket.send(this.buildCommand(6,n))},e.prototype.buildCommand=function(e,t){var n,o;switch(o=void 0,typeof t){case"string":o=(new TextEncoder).encode(t);break;case"number":o=new Uint8Array([t]);break;default:o=t}return(n=new Uint8Array(o.length+3))[0]=e,n[2]=o.length>>8,n[1]=15&o.length,n.set(o,3),n.buffer},e.prototype.oncopy=function(e){return console.log("Get clipboard text: "+e)},e.prototype.onpassword=function(){return new Promise(function(e,t){return t("onpassword is not implemented")})},e.prototype.sendTextAsClipboard=function(e){if(this.socket)return console.log("send ",e),this.socket.send(this.buildCommand(7,e))},e.prototype.oncredential=function(){return new Promise(function(e,t){return t("oncredential is not implemented")})},e.prototype.onerror=function(e){return console.log("Error",e)},e.prototype.consume=function(e){var t,n,o,s,a,r,i;switch(t=(n=new Uint8Array(e.data))[0],r=this,t){case 254:return n=n.subarray(1,n.length-1),o=new TextDecoder("utf-8"),this.onerror(o.decode(n));case 129:return console.log("Request for password"),this.onpassword().then(function(e){return r.socket.send(r.buildCommand(2,e))});case 130:return console.log("Request for login"),this.oncredential().then(function(e,t){var n;return(n=new Uint8Array(e.length+t.length+1)).set((new TextEncoder).encode(e),0),n.set(["\0"],e.length),n.set((new TextEncoder).encode(t),e.length+1),r.socket.send(r.buildCommand(3,n))});case 131:return console.log("resize"),i=n[1]|n[2]<<8,a=n[3]|n[4]<<8,s=n[5],this.initCanvas(i,a,s),this.socket.send(this.buildCommand(4,1));case 132:return this.decoder.postMessage(n.buffer,[n.buffer]);case 133:return n=n.subarray(1),o=new TextDecoder("utf-8"),this.oncopy(o.decode(n)),this.socket.send(this.buildCommand(4,1));default:return console.log(t)}},e}(),window.WVNC=e}).call(this); \ No newline at end of file diff --git a/RemoteDesktop/coffees/main.coffee b/RemoteDesktop/coffees/main.coffee index 9898dd8..64bb074 100644 --- a/RemoteDesktop/coffees/main.coffee +++ b/RemoteDesktop/coffees/main.coffee @@ -31,7 +31,7 @@ class ConnectionDialog extends this.OS.GUI.BasicDialog { label: "__(Cancel)", onclick: (d) -> d.quit() } ], filldata: (d) -> - (d.find "content1").value = "176.180.44.70:9999" + (d.find "content1").value = "/opt/www/vnc.conf" (d.find "content3").set "items", [ { text: "16 bits", value: 16 }, { text: "32 bits", value: 32, selected:true}] @@ -56,10 +56,15 @@ class RemoteDesktop extends this.OS.GUI.BaseApplication ws: 'wss://localhost:9192/wvnc', worker: "#{me._api.handler.get}/#{me.meta().path}/decoder.js" } + @client.onerror = (m) -> + me.error m + me.showConnectionDialog() @client.onpassword = ()-> return new Promise (r,e)-> - r("demopass") - @client.init().then () -> + me.openDialog "PromptDialog", (d) -> + r(d) + , __("VNC password"), { label: __("VNC password"), value: "demopass", type: "password" } + @client.init().then () -> me.showConnectionDialog() showConnectionDialog: () -> @@ -67,4 +72,7 @@ class RemoteDesktop extends this.OS.GUI.BaseApplication @openDialog new ConnectionDialog, (d) -> me.client.connect d.server, d , __("Connection") + + cleanup: () -> + @client.disconnect() if @client this.OS.register "RemoteDesktop", RemoteDesktop \ No newline at end of file diff --git a/RemoteDesktop/javascripts/wvnc.js b/RemoteDesktop/javascripts/wvnc.js index d66d74f..55c225e 100644 --- a/RemoteDesktop/javascripts/wvnc.js +++ b/RemoteDesktop/javascripts/wvnc.js @@ -1 +1 @@ -(function(){var e;e=function(){function e(e){var t,n;this.socket=void 0,this.ws=void 0,this.canvas=void 0,n="decoder.js",this.scale=1,e.ws&&(this.ws=e.ws),this.canvas=e.element,"string"==typeof this.canvas&&(this.canvas=document.getElementById(this.canvas)),e.worker&&(n=e.worker),this.decoder=new Worker(n),(t=this).mouseMask=0,this.decoder.onmessage=function(e){return t.process(e.data)}}return e.prototype.init=function(){var n;return n=this,new Promise(function(e,t){return n.canvas?(n.initInputEvent(),e()):t("Canvas is not set")})},e.prototype.initInputEvent=function(){var e,n,o,s;if((o=this).canvas&&(n=function(e){var t;return t=o.canvas.getBoundingClientRect(),{x:Math.floor((e.clientX-t.left)/o.scale),y:Math.floor((e.clientY-t.top)/o.scale)}},s=function(e){var t;return t=n(e),o.sendPointEvent(t.x,t.y,o.mouseMask)},o.canvas))return o.canvas.oncontextmenu=function(e){return e.preventDefault(),!1},o.canvas.onmousemove=function(e){return s(e)},o.canvas.onmousedown=function(e){var t;return t=1<>8,o[2]=255&t,o[3]=t>>8,o[4]=n,this.socket.send(this.buildCommand(5,o))},e.prototype.sendKeyEvent=function(e,t){var n;if(this.socket)return(n=new Uint8Array(3))[0]=255&e,n[1]=e>>8,n[2]=t,console.log(e,t),this.socket.send(this.buildCommand(6,n))},e.prototype.buildCommand=function(e,t){var n,o;switch(o=void 0,typeof t){case"string":o=(new TextEncoder).encode(t);break;case"number":o=new Uint8Array([t]);break;default:o=t}return(n=new Uint8Array(o.length+3))[0]=e,n[2]=o.length>>8,n[1]=15&o.length,n.set(o,3),n.buffer},e.prototype.oncopy=function(e){return console.log("Get clipboard text: "+e)},e.prototype.onpassword=function(){return new Promise(function(e,t){return t("onpassword is not implemented")})},e.prototype.sendTextAsClipboard=function(e){if(this.socket)return console.log("send ",e),this.socket.send(this.buildCommand(7,e))},e.prototype.oncredential=function(){return new Promise(function(e,t){return t("oncredential is not implemented")})},e.prototype.consume=function(e){var t,n,o,s,a,r,i;switch(t=(n=new Uint8Array(e.data))[0],r=this,t){case 254:return n=n.subarray(1,n.length-1),o=new TextDecoder("utf-8"),console.log("Error",o.decode(n));case 129:return console.log("Request for password"),this.onpassword().then(function(e){return r.socket.send(r.buildCommand(2,e))});case 130:return console.log("Request for login"),this.oncredential().then(function(e,t){var n;return(n=new Uint8Array(e.length+t.length+1)).set((new TextEncoder).encode(e),0),n.set(["\0"],e.length),n.set((new TextEncoder).encode(t),e.length+1),r.socket.send(r.buildCommand(3,n))});case 131:return console.log("resize"),i=n[1]|n[2]<<8,a=n[3]|n[4]<<8,s=n[5],this.initCanvas(i,a,s),this.socket.send(this.buildCommand(4,1));case 132:return this.decoder.postMessage(n.buffer,[n.buffer]);case 133:return n=n.subarray(1),o=new TextDecoder("utf-8"),this.oncopy(o.decode(n)),this.socket.send(this.buildCommand(4,1));default:return console.log(t)}},e}(),window.WVNC=e}).call(this); +(function(){var e;e=function(){function e(e){var t,n;this.socket=void 0,this.ws=void 0,this.canvas=void 0,n="decoder.js",this.scale=1,e.ws&&(this.ws=e.ws),this.canvas=e.element,"string"==typeof this.canvas&&(this.canvas=document.getElementById(this.canvas)),e.worker&&(n=e.worker),this.decoder=new Worker(n),(t=this).mouseMask=0,this.decoder.onmessage=function(e){return t.process(e.data)}}return e.prototype.init=function(){var n;return n=this,new Promise(function(e,t){return n.canvas?(n.initInputEvent(),e()):t("Canvas is not set")})},e.prototype.initInputEvent=function(){var e,n,o,s;if((o=this).canvas&&(n=function(e){var t;return t=o.canvas.getBoundingClientRect(),{x:Math.floor((e.clientX-t.left)/o.scale),y:Math.floor((e.clientY-t.top)/o.scale)}},s=function(e){var t;return t=n(e),o.sendPointEvent(t.x,t.y,o.mouseMask)},o.canvas))return o.canvas.oncontextmenu=function(e){return e.preventDefault(),!1},o.canvas.onmousemove=function(e){return s(e)},o.canvas.onmousedown=function(e){var t;return t=1<>8,o[2]=255&t,o[3]=t>>8,o[4]=n,this.socket.send(this.buildCommand(5,o))},e.prototype.sendKeyEvent=function(e,t){var n;if(this.socket)return(n=new Uint8Array(3))[0]=255&e,n[1]=e>>8,n[2]=t,console.log(e,t),this.socket.send(this.buildCommand(6,n))},e.prototype.buildCommand=function(e,t){var n,o;switch(o=void 0,typeof t){case"string":o=(new TextEncoder).encode(t);break;case"number":o=new Uint8Array([t]);break;default:o=t}return(n=new Uint8Array(o.length+3))[0]=e,n[2]=o.length>>8,n[1]=15&o.length,n.set(o,3),n.buffer},e.prototype.oncopy=function(e){return console.log("Get clipboard text: "+e)},e.prototype.onpassword=function(){return new Promise(function(e,t){return t("onpassword is not implemented")})},e.prototype.sendTextAsClipboard=function(e){if(this.socket)return console.log("send ",e),this.socket.send(this.buildCommand(7,e))},e.prototype.oncredential=function(){return new Promise(function(e,t){return t("oncredential is not implemented")})},e.prototype.onerror=function(e){return console.log("Error",e)},e.prototype.consume=function(e){var t,n,o,s,a,r,i;switch(t=(n=new Uint8Array(e.data))[0],r=this,t){case 254:return n=n.subarray(1,n.length-1),o=new TextDecoder("utf-8"),this.onerror(o.decode(n));case 129:return console.log("Request for password"),this.onpassword().then(function(e){return r.socket.send(r.buildCommand(2,e))});case 130:return console.log("Request for login"),this.oncredential().then(function(e,t){var n;return(n=new Uint8Array(e.length+t.length+1)).set((new TextEncoder).encode(e),0),n.set(["\0"],e.length),n.set((new TextEncoder).encode(t),e.length+1),r.socket.send(r.buildCommand(3,n))});case 131:return console.log("resize"),i=n[1]|n[2]<<8,a=n[3]|n[4]<<8,s=n[5],this.initCanvas(i,a,s),this.socket.send(this.buildCommand(4,1));case 132:return this.decoder.postMessage(n.buffer,[n.buffer]);case 133:return n=n.subarray(1),o=new TextDecoder("utf-8"),this.oncopy(o.decode(n)),this.socket.send(this.buildCommand(4,1));default:return console.log(t)}},e}(),window.WVNC=e}).call(this); \ No newline at end of file diff --git a/RemoteDesktop/project.apj b/RemoteDesktop/project.apj index 75a80b2..f14eb18 100644 --- a/RemoteDesktop/project.apj +++ b/RemoteDesktop/project.apj @@ -1 +1 @@ -{"name":"RemoteDesktop","root":"home://workspace/RemoteDesktop","css":[],"javascripts":["javascripts/wvnc.js"],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md","javascripts/decoder.js","javascripts/wvnc_asm.js"]} \ No newline at end of file +{"name":"RemoteDesktop","root":"home://workspace/RemoteDesktop","css":[],"javascripts":["javascripts/wvnc.js"],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md","javascripts/decoder.js","javascripts/wvnc_asm.js","javascripts/wvnc_asm.wasm"]} \ No newline at end of file