diff --git a/RemoteDesktop/README.md b/RemoteDesktop/README.md index 053d7c2..4ef2bf5 100644 --- a/RemoteDesktop/README.md +++ b/RemoteDesktop/README.md @@ -7,4 +7,9 @@ Further information on **wvnc**: [https://blog.lxsang.me/post/id/23](https://blo **Credit** * antd-wvnc-plugin: [https://github.com/lxsang/antd-wvnc-plugin](https://github.com/lxsang/antd-wvnc-plugin) -* wvnc.js: [https://github.com/lxsang/wvnc.js](https://github.com/lxsang/wvnc.js) \ No newline at end of file +* wvnc.js: [https://github.com/lxsang/wvnc.js](https://github.com/lxsang/wvnc.js) +* + +## Change logs + +* v0.1.0 - adapt to the new AntOS API \ No newline at end of file diff --git a/RemoteDesktop/assets/main.css b/RemoteDesktop/assets/main.css index 36064e6..f784c19 100644 --- a/RemoteDesktop/assets/main.css +++ b/RemoteDesktop/assets/main.css @@ -5,5 +5,6 @@ afx-app-window[data-id="RemoteDesktop"] div[data-id="container"] afx-app-window[data-id="RemoteDesktop"] canvas[data-id="screen"] { border:0; - margin:0 auto; + margin: auto; + display: block; } \ No newline at end of file diff --git a/RemoteDesktop/build/debug/README.md b/RemoteDesktop/build/debug/README.md index 053d7c2..4ef2bf5 100644 --- a/RemoteDesktop/build/debug/README.md +++ b/RemoteDesktop/build/debug/README.md @@ -7,4 +7,9 @@ Further information on **wvnc**: [https://blog.lxsang.me/post/id/23](https://blo **Credit** * antd-wvnc-plugin: [https://github.com/lxsang/antd-wvnc-plugin](https://github.com/lxsang/antd-wvnc-plugin) -* wvnc.js: [https://github.com/lxsang/wvnc.js](https://github.com/lxsang/wvnc.js) \ No newline at end of file +* wvnc.js: [https://github.com/lxsang/wvnc.js](https://github.com/lxsang/wvnc.js) +* + +## Change logs + +* v0.1.0 - adapt to the new AntOS API \ No newline at end of file diff --git a/RemoteDesktop/build/debug/main.css b/RemoteDesktop/build/debug/main.css index b3d0d16..06c8fe0 100644 --- a/RemoteDesktop/build/debug/main.css +++ b/RemoteDesktop/build/debug/main.css @@ -6,5 +6,6 @@ afx-app-window[data-id="RemoteDesktop"] div[data-id="container"] afx-app-window[data-id="RemoteDesktop"] canvas[data-id="screen"] { border:0; - margin:0 auto; + margin: auto; + display: block; } \ No newline at end of file diff --git a/RemoteDesktop/build/debug/main.js b/RemoteDesktop/build/debug/main.js index 41ce987..8263c4a 100644 --- a/RemoteDesktop/build/debug/main.js +++ b/RemoteDesktop/build/debug/main.js @@ -1,289 +1 @@ -(function() { - var ConnectionDialog, CredentialDialog, RemoteDesktop; - - ConnectionDialog = class ConnectionDialog extends this.OS.GUI.BasicDialog { - constructor() { - super("ConnectionDialog", { - tags: [ - { - tag: "afx-label", - att: 'text="__(VNC server)" data-height="23" class="header"' - }, - { - tag: "input", - att: 'data-height="30"' - }, - { - tag: "afx-label", - att: 'text="__(Bits per pixel)" data-height="23" class="header"' - }, - { - tag: "afx-list-view", - att: 'dropdown="true" data-height="30"' - }, - { - tag: "afx-label", - att: 'text="__(Compression)" data-height="23" class="header"' - }, - { - tag: "afx-list-view", - att: 'dropdown="true" data-height="30"' - }, - { - tag: "afx-label", - att: 'text="__(JPEG quality)" data-height="23" class="header"' - }, - { - tag: "afx-slider", - att: 'max="100" data-height="30"' - }, - { - tag: "div", - att: ' data-height="5"' - } - ], - width: 350, - height: 280, - resizable: false, - buttons: [ - { - label: "__(Connect)", - onclick: function(d) { - var data; - if (!d.handler) { - return; - } - data = { - server: (d.find("content1")).value, - bbp: ((d.find("content3")).get("selected")).value, - flag: ((d.find("content5")).get("selected")).value, - quality: (d.find("content7")).get("value") - }; - d.handler(data); - return d.quit(); - } - }, - { - label: "__(Cancel)", - onclick: function(d) { - return d.quit(); - } - } - ], - filldata: function(d) { - (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 - } - ]); - (d.find("content5")).set("items", [ - { - text: "No compression", - value: 0 - }, - { - text: "JPEG", - value: 1 - }, - { - text: "zLib", - value: 2 - }, - { - text: "JPEG & zLib", - value: 3, - selected: true - } - ]); - return (d.find("content7")).set("value", 40); - } - }); - } - - }; - - CredentialDialog = class CredentialDialog extends this.OS.GUI.BasicDialog { - constructor() { - super("ConnectionDialog", { - tags: [ - { - tag: "afx-label", - att: 'text="__(User name)" data-height="23" class="header"' - }, - { - tag: "input", - att: 'data-height="30"' - }, - { - tag: "afx-label", - att: 'text="__(Password)" data-height="23" class="header"' - }, - { - tag: "input", - att: 'data-height="30" type="password"' - }, - { - tag: "div", - att: ' data-height="5"' - } - ], - width: 350, - height: 150, - resizable: false, - buttons: [ - { - label: "__(Ok)", - onclick: function(d) { - var data; - if (!d.handler) { - return d.quit(); - } - data = { - username: (d.find("content1")).value, - password: (d.find("content3")).value - }; - d.handler(data); - return d.quit(); - } - }, - { - label: "__(Cancel)", - onclick: function(d) { - return d.quit(); - } - } - ], - filldata: function(d) { - (d.find("content1")).value = "demo"; - return (d.find("content3")).value = "demo"; - } - }); - } - - }; - - RemoteDesktop = class RemoteDesktop extends this.OS.GUI.BaseApplication { - constructor(args) { - super("RemoteDesktop", args); - } - - main() { - var me; - me = this; - this.canvas = this.find("screen"); - this.container = this.find("container"); - this.client = new WVNC({ - element: me.canvas, - 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.onresize = function() { - return me.setScale(); - }; - this.client.onpassword = function() { - return new Promise(function(r, e) { - return me.openDialog("PromptDialog", function(d) { - return r(d); - }, __("VNC password"), { - label: __("VNC password"), - value: "demopass", - type: "password" - }); - }); - }; - this.client.oncredential = function() { - return new Promise(function(r, e) { - return me.openDialog(new CredentialDialog, function(d) { - return r(d.username, d.password); - }, __("User credential")); - }); - }; - this.on("resize", function(e) { - return me.setScale(); - }); - this.on("focus", function(e) { - return $(me.canvas).focus(); - }); - return this.client.init().then(function() { - return me.showConnectionDialog(); - }); - } - - setScale() { - var h, sx, sy, w; - if (!(this.client && this.client.resolution)) { - return; - } - w = $(this.container).width(); - h = $(this.container).height(); - sx = w / this.client.resolution.w; - sy = h / this.client.resolution.h; - if (sx > sy) { - return this.client.setScale(sy); - } else { - return this.client.setScale(sx); - } - } - - menu() { - var me; - me = this; - return [ - { - text: "__(Connection)", - child: [ - { - text: "__(New Connection)", - dataid: `${this.name}-new` - }, - { - text: "__(Disconnect)", - dataid: `${this.name}-close` - } - ], - onmenuselect: function(e) { - return me.actionConnection(); - } - } - ]; - } - - actionConnection(e) { - if (this.client) { - this.client.disconnect(); - } - return this.showConnectionDialog(); - } - - showConnectionDialog() { - var me; - me = this; - return this.openDialog(new ConnectionDialog, function(d) { - return me.client.connect(d.server, d); - }, __("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),this.enableEvent=!0,(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.canvas).attr("tabindex","1"),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;if(o.enableEvent)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&&this.enableEvent)return(n=new Uint8Array(3))[0]=255&e,n[1]=e>>8,n[2]=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.onresize=function(){return console.log("resize")},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.enableEvent=!1,this.onpassword().then(function(e){return r.socket.send(r.buildCommand(2,e)),r.enableEvent=!0});case 130:return console.log("Request for login"),this.enableEvent=!1,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)),r.enableEvent=!0});case 131:return 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)),this.onresize();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 +(function(){var t,e,n;(t=class t extends this.OS.GUI.BasicDialog{constructor(){super("ConnectionDialog",t.scheme)}main(){return super.main(),this.find("bbp").data=[{text:"16 bits",value:16,selected:!0},{text:"32 bits",value:32}],this.find("compression").data=[{text:"No compression",value:0},{text:"JPEG",value:1},{text:"zLib",value:2},{text:"JPEG & zLib",value:3,selected:!0}],this.find("jq").value=40,this.find("bt-ok").onbtclick=t=>{var e;if(this.handle)return e={wvnc:this.find("txtWVNC").value,server:this.find("txtServer").value,bbp:this.find("bbp").selectedItem.data.value,flag:this.find("compression").selectedItem.data.value,quality:this.find("jq").value},this.handle(e),this.quit()},this.find("bt-cancel").onbtclick=t=>this.quit()}}).scheme='\n \n
\n \n \n \n \n \n
\n \n \n
\n \n \n
\n \n \n \n
\n \n \n
\n
\n
\n
\n
\n
\n
\n',(e=class t extends this.OS.GUI.BasicDialog{constructor(){super("CredentialDialog",t.scheme)}main(){return this.find("bt-ok").onbtclick=()=>{var t;return this.handle?(t={username:this.find("txtUser").value,password:this.find("txtPass").value},this.handle(t),this.quit()):this.quit()},this.find("bt-cancel").onbtclick=()=>this.quit()}}).scheme='\n \n \n \n \n \n \n
\n \n \n
\n
\n
\n
\n
\n',n=class extends this.OS.application.BaseApplication{constructor(t){super("RemoteDesktop",t)}main(){return this.canvas=this.find("screen"),this.container=this.find("container"),this.client=new WVNC({element:this.canvas,worker:`${this._api.handle.get}/${this.meta().path}/decoder.js`}),this.client.onerror=t=>(this.error(t),this.showConnectionDialog()),this.client.onresize=()=>this.setScale(),this.client.onpassword=()=>new Promise((t,e)=>this.openDialog("PromptDialog",{title:__("VNC password"),label:__("VNC password"),value:"!x$@n9ph",type:"password"}).then((function(e){return t(e)}))),this.client.oncredential=()=>new Promise((t,n)=>this.openDialog(new e,{title:__("User credential")}).then((function(e){return t(e.username,e.password)}))),this.on("resize",t=>this.setScale()),this.on("focus",t=>$(this.canvas).focus()),this.client.init().then(()=>this.showConnectionDialog())}setScale(){var t,e,n,a;if(this.client&&this.client.resolution)return a=$(this.container).width(),t=$(this.container).height(),(e=a/this.client.resolution.w)>(n=t/this.client.resolution.h)?this.client.setScale(n):this.client.setScale(e)}menu(){return[{text:"__(Connection)",nodes:[{text:"__(New Connection)",dataid:this.name+"-new"},{text:"__(Disconnect)",dataid:this.name+"-close"}],onchildselect:t=>this.actionConnection()}]}actionConnection(t){return this.client&&this.client.disconnect(),this.showConnectionDialog()}showConnectionDialog(){return this.openDialog(new t,{title:__("Connection")}).then(t=>(this.client.ws=t.wvnc,console.log(t),this.client.connect(t.server,t)))}cleanup(){if(this.client)return this.client.disconnect()}},this.OS.register("RemoteDesktop",n)}).call(this),function(){var t;t=function(){function t(t){var e,n;this.socket=void 0,this.ws=void 0,this.canvas=void 0,n="decoder.js",this.scale=1,t.ws&&(this.ws=t.ws),this.canvas=t.element,"string"==typeof this.canvas&&(this.canvas=document.getElementById(this.canvas)),t.worker&&(n=t.worker),this.decoder=new Worker(n),this.enableEvent=!0,(e=this).mouseMask=0,this.decoder.onmessage=function(t){return e.process(t.data)}}return t.prototype.init=function(){var t;return t=this,new Promise((function(e,n){return t.canvas?($(t.canvas).attr("tabindex","1"),t.initInputEvent(),e()):n("Canvas is not set")}))},t.prototype.initInputEvent=function(){var t,e,n,a;if((n=this).canvas&&(e=function(t){var e;return e=n.canvas.getBoundingClientRect(),{x:Math.floor((t.clientX-e.left)/n.scale),y:Math.floor((t.clientY-e.top)/n.scale)}},a=function(t){var a;if(n.enableEvent)return a=e(t),n.sendPointEvent(a.x,a.y,n.mouseMask)},n.canvas))return n.canvas.oncontextmenu=function(t){return t.preventDefault(),!1},n.canvas.onmousemove=function(t){return a(t)},n.canvas.onmousedown=function(t){var e;return e=1<>8,a[2]=255&e,a[3]=e>>8,a[4]=n,this.socket.send(this.buildCommand(5,a))},t.prototype.sendKeyEvent=function(t,e){var n;if(this.socket&&this.enableEvent)return(n=new Uint8Array(3))[0]=255&t,n[1]=t>>8,n[2]=e,this.socket.send(this.buildCommand(6,n))},t.prototype.buildCommand=function(t,e){var n,a;switch(a=void 0,typeof e){case"string":a=(new TextEncoder).encode(e);break;case"number":a=new Uint8Array([e]);break;default:a=e}return(n=new Uint8Array(a.length+3))[0]=t,n[2]=a.length>>8,n[1]=15&a.length,n.set(a,3),n.buffer},t.prototype.oncopy=function(t){return console.log("Get clipboard text: "+t)},t.prototype.onpassword=function(){return new Promise((function(t,e){return e("onpassword is not implemented")}))},t.prototype.sendTextAsClipboard=function(t){if(this.socket)return console.log("send ",t),this.socket.send(this.buildCommand(7,t))},t.prototype.oncredential=function(){return new Promise((function(t,e){return e("oncredential is not implemented")}))},t.prototype.onerror=function(t){return console.log("Error",t)},t.prototype.onresize=function(){return console.log("resize")},t.prototype.consume=function(t){var e,n,a,i,s,o,r;switch(e=(n=new Uint8Array(t.data))[0],o=this,e){case 254:return n=n.subarray(1,n.length-1),a=new TextDecoder("utf-8"),this.onerror(a.decode(n));case 129:return console.log("Request for password"),this.enableEvent=!1,this.onpassword().then((function(t){return o.socket.send(o.buildCommand(2,t)),o.enableEvent=!0}));case 130:return console.log("Request for login"),this.enableEvent=!1,this.oncredential().then((function(t,e){var n;return(n=new Uint8Array(t.length+e.length+1)).set((new TextEncoder).encode(t),0),n.set(["\0"],t.length),n.set((new TextEncoder).encode(e),t.length+1),o.socket.send(o.buildCommand(3,n)),o.enableEvent=!0}));case 131:return r=n[1]|n[2]<<8,s=n[3]|n[4]<<8,i=n[5],this.initCanvas(r,s,i),this.socket.send(this.buildCommand(4,1)),this.onresize();case 132:return this.decoder.postMessage(n.buffer,[n.buffer]);case 133:return n=n.subarray(1),a=new TextDecoder("utf-8"),this.oncopy(a.decode(n)),this.socket.send(this.buildCommand(4,1));default:return console.log(e)}},t}(),window.WVNC=t}.call(this); \ No newline at end of file diff --git a/RemoteDesktop/build/debug/package.json b/RemoteDesktop/build/debug/package.json index 4daf952..7c7db2d 100644 --- a/RemoteDesktop/build/debug/package.json +++ b/RemoteDesktop/build/debug/package.json @@ -6,7 +6,7 @@ "author": "", "email": "" }, - "version":"0.0.1-a", + "version":"0.1.0-a", "category":"Other", "icon": "icon.png", "mimes":["none"] diff --git a/RemoteDesktop/build/release/RemoteDesktop.zip b/RemoteDesktop/build/release/RemoteDesktop.zip new file mode 100644 index 0000000..8fa829a Binary files /dev/null and b/RemoteDesktop/build/release/RemoteDesktop.zip differ diff --git a/RemoteDesktop/coffees/main.coffee b/RemoteDesktop/coffees/main.coffee index e120509..9d6dd67 100644 --- a/RemoteDesktop/coffees/main.coffee +++ b/RemoteDesktop/coffees/main.coffee @@ -1,113 +1,138 @@ class ConnectionDialog extends this.OS.GUI.BasicDialog constructor: () -> - super "ConnectionDialog", { - tags: [ - { tag: "afx-label", att: 'text="__(VNC server)" data-height="23" class="header"' }, - { tag: "input", att: 'data-height="30"' }, - { tag: "afx-label", att: 'text="__(Bits per pixel)" data-height="23" class="header"' }, - { tag: "afx-list-view", att: 'dropdown="true" data-height="30"' }, - { tag: "afx-label", att: 'text="__(Compression)" data-height="23" class="header"' }, - { tag: "afx-list-view", att: 'dropdown="true" data-height="30"' }, - { tag: "afx-label", att: 'text="__(JPEG quality)" data-height="23" class="header"' }, - { tag: "afx-slider", att: 'max="100" data-height="30"' }, - { tag: "div", att: ' data-height="5"' } - ], - width: 350, - height: 280, - resizable: false, - buttons: [ - { - label: "__(Connect)", - onclick: (d) -> - return unless d.handler - data = - server: (d.find "content1").value - bbp: ((d.find "content3").get "selected").value, - flag: ((d.find "content5").get "selected").value, - quality:((d.find "content7").get "value") - d.handler data - d.quit() - }, - { label: "__(Cancel)", onclick: (d) -> d.quit() } - ], - filldata: (d) -> - (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}] - (d.find "content5").set "items", [ - {text: "No compression", value:0}, - {text: "JPEG", value:1}, - {text: "zLib", value:2}, - {text: "JPEG & zLib", value:3, selected:true} - ] - (d.find "content7").set "value", 40 - } + super "ConnectionDialog", ConnectionDialog.scheme + + + main: () -> + super.main() + @find("bbp").data = [ + { text: "16 bits", value: 16, selected: true }, + { text: "32 bits", value: 32 } + ] + @find("compression").data = [ + {text: "No compression", value:0}, + {text: "JPEG", value:1}, + {text: "zLib", value:2}, + {text: "JPEG & zLib", value:3, selected:true} + ] + @find("jq").value = 40 + @find("bt-ok").onbtclick = (e) => + return unless @handle + data = + wvnc: (@find "txtWVNC").value + server: (@find "txtServer").value + bbp: (@find "bbp").selectedItem.data.value, + flag: (@find "compression").selectedItem.data.value, + quality:(@find "jq").value + @handle data + @quit() + + @find("bt-cancel").onbtclick = (e) => + @quit() + +ConnectionDialog.scheme = """ + + +
+ + + + + +
+ + +
+ + +
+ + + +
+ + +
+
+
+
+
+
+
+ +""" class CredentialDialog extends this.OS.GUI.BasicDialog constructor: () -> - super "ConnectionDialog", { - tags: [ - { tag: "afx-label", att: 'text="__(User name)" data-height="23" class="header"' }, - { tag: "input", att: 'data-height="30"' }, - { tag: "afx-label", att: 'text="__(Password)" data-height="23" class="header"' }, - { tag: "input", att: 'data-height="30" type="password"' }, - { tag: "div", att: ' data-height="5"' } - ], - width: 350, - height: 150, - resizable: false, - buttons: [ - { - label: "__(Ok)", - onclick: (d) -> - return d.quit() unless d.handler - data = - username: (d.find "content1").value - password: (d.find "content3").value - d.handler data - d.quit() - }, - { label: "__(Cancel)", onclick: (d) -> d.quit() } - ], - filldata: (d) -> - (d.find "content1").value = "demo" - (d.find "content3").value = "demo" - } + super "CredentialDialog", CredentialDialog.scheme + + main: () -> + @find("bt-ok").onbtclick = () => + return @quit() unless @handle + data = + username: (@find "txtUser").value + password: (@find "txtPass").value + @handle data + @quit() + + @find("bt-cancel").onbtclick = () => + @quit() -class RemoteDesktop extends this.OS.GUI.BaseApplication +CredentialDialog.scheme = """ + + + + + + + +
+ + +
+
+
+
+
+ +""" + +class RemoteDesktop extends this.OS.application.BaseApplication constructor: ( args ) -> super "RemoteDesktop", args main: () -> - me = @ @canvas = @find "screen" @container = @find "container" @client = new WVNC { - element: me.canvas, - ws: 'wss://localhost:9192/wvnc', - worker: "#{me._api.handler.get}/#{me.meta().path}/decoder.js" + element: @canvas, + worker: "#{@_api.handle.get}/#{@meta().path}/decoder.js" } - @client.onerror = (m) -> - me.error m - me.showConnectionDialog() - @client.onresize = ()-> - me.setScale() - @client.onpassword = ()-> - return new Promise (r,e)-> - me.openDialog "PromptDialog", (d) -> + @client.onerror = (m) => + @error m + @showConnectionDialog() + @client.onresize = ()=> + @setScale() + @client.onpassword = ()=> + return new Promise (r,e)=> + @openDialog "PromptDialog", { + title: __("VNC password"), + label: __("VNC password"), + value: "!x$@n9ph", + type: "password" + } + .then (d) -> r(d) - , __("VNC password"), { label: __("VNC password"), value: "demopass", type: "password" } - @client.oncredential = () -> - return new Promise (r,e) -> - me.openDialog new CredentialDialog, (d) -> + @client.oncredential = () => + return new Promise (r,e) => + @openDialog new CredentialDialog, { title: __("User credential") } + .then (d) -> r(d.username, d.password) - , __("User credential") - @on "resize", (e)-> me.setScale() - @on "focus", (e) -> $(me.canvas).focus() - @client.init().then () -> - me.showConnectionDialog() + @on "resize", (e)=> @setScale() + @on "focus", (e) => $(@canvas).focus() + @client.init().then () => + @showConnectionDialog() setScale: () -> return unless @client and @client.resolution @@ -118,15 +143,15 @@ class RemoteDesktop extends this.OS.GUI.BaseApplication if sx > sy then @client.setScale sy else @client.setScale sx menu: () -> - me = @ + [ { text: "__(Connection)", - child: [ + nodes: [ { text: "__(New Connection)", dataid: "#{@name}-new", }, { text: "__(Disconnect)", dataid: "#{@name}-close" } ], - onmenuselect: (e) -> me.actionConnection() + onchildselect: (e) => @actionConnection() } ] @@ -135,11 +160,15 @@ class RemoteDesktop extends this.OS.GUI.BaseApplication @showConnectionDialog() showConnectionDialog: () -> - me = @ - @openDialog new ConnectionDialog, (d) -> - me.client.connect d.server, d - , __("Connection") + + @openDialog new ConnectionDialog, { title: __("Connection")} + .then (d) => + @client.ws = d.wvnc + console.log d + @client.connect d.server, d cleanup: () -> @client.disconnect() if @client + + this.OS.register "RemoteDesktop", RemoteDesktop \ No newline at end of file diff --git a/RemoteDesktop/package.json b/RemoteDesktop/package.json index 4daf952..7c7db2d 100644 --- a/RemoteDesktop/package.json +++ b/RemoteDesktop/package.json @@ -6,7 +6,7 @@ "author": "", "email": "" }, - "version":"0.0.1-a", + "version":"0.1.0-a", "category":"Other", "icon": "icon.png", "mimes":["none"] diff --git a/RemoteDesktop/project.apj b/RemoteDesktop/project.apj deleted file mode 100644 index 3dec88e..0000000 --- a/RemoteDesktop/project.apj +++ /dev/null @@ -1 +0,0 @@ -{"name":"RemoteDesktop","root":"home://workspace/RemoteDesktop","css":["assets/main.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","assets/icon.png"]} \ No newline at end of file diff --git a/RemoteDesktop/project.json b/RemoteDesktop/project.json new file mode 100644 index 0000000..617a8b0 --- /dev/null +++ b/RemoteDesktop/project.json @@ -0,0 +1,8 @@ +{ + "name": "RemoteDesktop", + "root": "home://workspace/antosdk-apps/RemoteDesktop", + "css": ["assets/main.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", "assets/icon.png"] +} \ No newline at end of file diff --git a/packages.json b/packages.json index 7a56ea7..2031c04 100644 --- a/packages.json +++ b/packages.json @@ -98,6 +98,15 @@ "version": "0.0.7-a", "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Preview/build/release/Preview.zip" }, + { + "pkgname": "RemoteDesktop", + "name": "WVNC remote desktop", + "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/README.md", + "category": "Other", + "author": "", + "version": "0.1.0-a", + "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/build/release/RemoteDesktop.zip" + }, { "pkgname": "ShowCase", "name": "ShowCase",