2018-10-01 16:39:17 +02:00
|
|
|
class ConnectionDialog extends this.OS.GUI.BasicDialog
|
|
|
|
constructor: () ->
|
2020-07-10 16:09:23 +02:00
|
|
|
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 = """
|
|
|
|
<afx-app-window width='350' height='270'>
|
|
|
|
<afx-hbox>
|
|
|
|
<div data-width="5"></div>
|
|
|
|
<afx-vbox>
|
|
|
|
<afx-label text="__(WVNC Websocket)" data-height="25" class="header" ></afx-label>
|
|
|
|
<input data-height="25" data-id="txtWVNC" value="wss://localhost/wvnc"></input>
|
|
|
|
<afx-label text="__(VNC Server)" data-height="25" class="header" ></afx-label>
|
|
|
|
<input data-height="25" data-id="txtServer" value="192.168.1.10:5900"></input>
|
|
|
|
<div data-height="5"></div>
|
|
|
|
<afx-label text="__(Bits per pixel)" data-height="25" class="header" ></afx-label>
|
|
|
|
<afx-list-view dropdown = "true" data-id ="bbp" data-height="25" ></afx-list-view>
|
|
|
|
<div data-height="5"></div>
|
|
|
|
<afx-label text="__(Compression)" data-height="25" class="header" ></afx-label>
|
|
|
|
<afx-list-view dropdown = "true" data-id ="compression" data-height="25" ></afx-list-view>
|
|
|
|
<div data-height="5"></div>
|
|
|
|
<afx-label text="__(JPEG quality)" data-height="25" class="header" ></afx-label>
|
|
|
|
<afx-slider data-id ="jq" data-height="25" ></afx-slider>
|
|
|
|
<afx-hbox data-height = '30'>
|
|
|
|
<div style=' text-align:right;'>
|
|
|
|
<afx-button data-id = "bt-ok" text = "__(Connect)"></afx-button>
|
|
|
|
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
|
|
|
|
</div>
|
|
|
|
<div data-width="5"></div>
|
|
|
|
</afx-hbox>
|
|
|
|
</afx-vbox>
|
|
|
|
<div data-width="5"></div>
|
|
|
|
</afx-hbox>
|
|
|
|
</afx-app-window>
|
|
|
|
|
|
|
|
"""
|
2018-10-01 16:39:17 +02:00
|
|
|
|
2018-10-02 12:01:09 +02:00
|
|
|
class CredentialDialog extends this.OS.GUI.BasicDialog
|
|
|
|
constructor: () ->
|
2020-07-10 16:09:23 +02:00
|
|
|
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()
|
|
|
|
|
|
|
|
CredentialDialog.scheme = """
|
|
|
|
<afx-app-window width='350' height='150'>
|
|
|
|
<afx-vbox>
|
|
|
|
<afx-label text="__(Username)" data-height="25" class="header" ></afx-label>
|
|
|
|
<input data-height="30" data-id="txtUser"></input>
|
|
|
|
<afx-label text="__(Password)" data-height="25" class="header" ></afx-label>
|
|
|
|
<input type="password" data-height="30" data-id="txtPass"></input>
|
|
|
|
<afx-hbox data-height = '30'>
|
|
|
|
<div style=' text-align:right;'>
|
|
|
|
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
|
|
|
|
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
|
|
|
|
</div>
|
|
|
|
<div data-width="5"></div>
|
|
|
|
</afx-hbox>
|
|
|
|
</afx-vbox>
|
|
|
|
</afx-app-window>
|
|
|
|
|
|
|
|
"""
|
2018-10-02 12:01:09 +02:00
|
|
|
|
2020-07-10 16:09:23 +02:00
|
|
|
class RemoteDesktop extends this.OS.application.BaseApplication
|
2018-10-01 16:39:17 +02:00
|
|
|
constructor: ( args ) ->
|
|
|
|
super "RemoteDesktop", args
|
|
|
|
|
|
|
|
main: () ->
|
|
|
|
@canvas = @find "screen"
|
2018-10-01 22:50:32 +02:00
|
|
|
@container = @find "container"
|
|
|
|
@client = new WVNC {
|
2020-07-10 16:09:23 +02:00
|
|
|
element: @canvas,
|
|
|
|
worker: "#{@_api.handle.get}/#{@meta().path}/decoder.js"
|
2018-10-01 16:39:17 +02:00
|
|
|
}
|
2020-07-10 16:09:23 +02:00
|
|
|
@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) ->
|
2018-10-01 19:13:47 +02:00
|
|
|
r(d)
|
2018-10-02 12:01:09 +02:00
|
|
|
|
2020-07-10 16:09:23 +02:00
|
|
|
@client.oncredential = () =>
|
|
|
|
return new Promise (r,e) =>
|
|
|
|
@openDialog new CredentialDialog, { title: __("User credential") }
|
|
|
|
.then (d) ->
|
2018-10-02 12:01:09 +02:00
|
|
|
r(d.username, d.password)
|
2020-07-10 16:09:23 +02:00
|
|
|
@on "resize", (e)=> @setScale()
|
|
|
|
@on "focus", (e) => $(@canvas).focus()
|
|
|
|
@client.init().then () =>
|
|
|
|
@showConnectionDialog()
|
2018-10-01 16:39:17 +02:00
|
|
|
|
2018-10-01 22:50:32 +02:00
|
|
|
setScale: () ->
|
|
|
|
return unless @client and @client.resolution
|
|
|
|
w = $(@container).width()
|
|
|
|
h = $(@container).height()
|
|
|
|
sx = w / @client.resolution.w
|
|
|
|
sy = h / @client.resolution.h
|
|
|
|
if sx > sy then @client.setScale sy else @client.setScale sx
|
|
|
|
|
2018-10-02 12:01:09 +02:00
|
|
|
menu: () ->
|
2020-07-10 16:09:23 +02:00
|
|
|
|
2018-10-02 12:01:09 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
text: "__(Connection)",
|
2020-07-10 16:09:23 +02:00
|
|
|
nodes: [
|
2018-10-02 12:01:09 +02:00
|
|
|
{ text: "__(New Connection)", dataid: "#{@name}-new", },
|
|
|
|
{ text: "__(Disconnect)", dataid: "#{@name}-close" }
|
|
|
|
],
|
2020-07-10 16:09:23 +02:00
|
|
|
onchildselect: (e) => @actionConnection()
|
2018-10-02 12:01:09 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
actionConnection: (e) ->
|
|
|
|
@client.disconnect() if @client
|
|
|
|
@showConnectionDialog()
|
|
|
|
|
2018-10-01 16:39:17 +02:00
|
|
|
showConnectionDialog: () ->
|
2020-07-10 16:09:23 +02:00
|
|
|
|
|
|
|
@openDialog new ConnectionDialog, { title: __("Connection")}
|
|
|
|
.then (d) =>
|
|
|
|
@client.ws = d.wvnc
|
|
|
|
console.log d
|
|
|
|
@client.connect d.server, d
|
2018-10-01 19:13:47 +02:00
|
|
|
|
|
|
|
cleanup: () ->
|
|
|
|
@client.disconnect() if @client
|
2020-07-10 16:09:23 +02:00
|
|
|
|
|
|
|
|
2018-10-01 16:39:17 +02:00
|
|
|
this.OS.register "RemoteDesktop", RemoteDesktop
|