2015-08-03 20:07:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; VNC client for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
BTN_H equ 22
|
|
|
|
TEXT_ECX equ 00010000b shl 24 + 0
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
draw_gui:
|
2015-08-20 11:30:24 +02:00
|
|
|
mcall 67, 160, 160, 330, 100 ; resize and move the window
|
|
|
|
mcall 66, 1, 0 ; switch keyboard to ascii mode
|
|
|
|
.first_time:
|
2015-08-03 20:07:56 +02:00
|
|
|
mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY
|
|
|
|
|
|
|
|
.redraw:
|
|
|
|
mcall 12, 1 ; start window draw
|
|
|
|
; DRAW WINDOW
|
|
|
|
xor eax, eax ; function 0 _logon: define and draw window
|
|
|
|
mov ebx, 160 shl 16 + 330 ; [x start]:[x size]
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 160 shl 16 + 130 ; [y start]:[y size]
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, 0x34DDDDDD ; color of work area RRGGBB
|
|
|
|
mov edi, name ; WINDOW LABEL
|
|
|
|
mcall
|
|
|
|
|
2015-08-04 10:59:09 +02:00
|
|
|
cmp [status], STATUS_CONNECTING
|
2015-08-13 21:20:59 +02:00
|
|
|
ja .login?
|
2015-08-03 20:07:56 +02:00
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ebx, 10 shl 16 + 22
|
|
|
|
mov ecx, TEXT_ECX
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, serverstr
|
|
|
|
mov esi, userstr-serverstr
|
|
|
|
mcall 4 ; "server" text
|
|
|
|
|
|
|
|
invoke edit_box_draw, URLbox ; Server textbox
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
cmp [status], STATUS_CONNECTING
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ebx, 220 shl 16 + 85
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 57 shl 16 + BTN_H
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, 4
|
|
|
|
mov esi, 0xCCCCCC
|
|
|
|
mcall 8 ; Cancel button
|
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ebx, 240 shl 16 + 62
|
|
|
|
mov ecx, TEXT_ECX
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, cancelstr
|
|
|
|
mov esi, okstr-cancelstr
|
|
|
|
mcall 4 ; Cancel button text
|
|
|
|
|
|
|
|
jmp .redraw_done
|
|
|
|
|
|
|
|
@@:
|
|
|
|
cmp [status], STATUS_CONNECT
|
2015-08-04 10:59:09 +02:00
|
|
|
jne .redraw_done
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
mov ebx, 220 shl 16 + 85
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 57 shl 16 + BTN_H
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, 2
|
|
|
|
mov esi, 0xCCCCCC
|
|
|
|
mcall 8 ; Connect button
|
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ebx, 236 shl 16 + 62
|
|
|
|
mov ecx, TEXT_ECX
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, connectstr
|
|
|
|
mov esi, loginstr-connectstr
|
|
|
|
mcall 4 ; Connect button text
|
|
|
|
|
|
|
|
jmp .redraw_done
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
.login?:
|
2015-08-03 20:07:56 +02:00
|
|
|
cmp [status], STATUS_LOGIN
|
2015-08-04 10:59:09 +02:00
|
|
|
ja @f
|
2015-08-03 20:07:56 +02:00
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ebx, 10 shl 16 + 12
|
|
|
|
mov ecx, TEXT_ECX
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, userstr
|
|
|
|
mov esi, passstr-userstr
|
|
|
|
mcall 4 ; "user" text
|
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
add bl, 25
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, passstr
|
|
|
|
mov esi, connectstr-passstr ; "password" text
|
|
|
|
mcall
|
|
|
|
|
2015-08-04 10:59:09 +02:00
|
|
|
invoke edit_box_draw, USERbox ; username textbox
|
|
|
|
invoke edit_box_draw, PASSbox ; password textbox
|
|
|
|
|
|
|
|
cmp [status], STATUS_REQ_LOGIN
|
|
|
|
jne .redraw_done
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
mov ebx, 220 shl 16 + 85
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 67 shl 16 + BTN_H
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, 3
|
|
|
|
mov esi, 0xCCCCCC
|
|
|
|
mcall 8 ; Login button
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
mov ebx, 120 shl 16 + 85
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 67 shl 16 + BTN_H
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, 4
|
|
|
|
mov esi, 0xCCCCCC
|
|
|
|
mcall 8 ; Cancel button
|
|
|
|
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ebx, 240 shl 16 + 71
|
|
|
|
mov ecx, TEXT_ECX
|
|
|
|
mov edx, loginstr
|
|
|
|
mov esi, cancelstr-loginstr
|
|
|
|
mcall 4 ; Login button text
|
|
|
|
|
|
|
|
mov ebx, 140 shl 16 + 71
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, cancelstr
|
|
|
|
mov esi, okstr-cancelstr
|
|
|
|
mcall 4 ; Cancel button text
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
jmp .redraw_done
|
|
|
|
|
|
|
|
@@:
|
2015-08-04 10:59:09 +02:00
|
|
|
cmp [status], STATUS_DISCONNECTED
|
|
|
|
jb .redraw_done
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
mov ebx, 15 shl 16 + 10
|
|
|
|
mov ecx, 0x00ca0000 ; red ASCIIZ string
|
2015-08-03 20:07:56 +02:00
|
|
|
mov edx, [status]
|
|
|
|
sub edx, 10
|
|
|
|
mov edx, [err_msg+4*edx]
|
2015-08-13 21:20:59 +02:00
|
|
|
.restart:
|
|
|
|
xor esi, esi
|
|
|
|
.pr_loop:
|
|
|
|
cmp byte[edx+esi], 0
|
|
|
|
je .last
|
|
|
|
cmp byte[edx+esi], 0x0a
|
|
|
|
je .print
|
|
|
|
inc esi
|
|
|
|
jmp .pr_loop
|
|
|
|
.print:
|
|
|
|
mcall 4
|
|
|
|
add edx, esi
|
|
|
|
inc edx
|
|
|
|
add ebx, 10
|
|
|
|
jmp .restart
|
|
|
|
.last:
|
2015-08-03 20:07:56 +02:00
|
|
|
mcall 4 ; print error message to window
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
mov ebx, 220 shl 16 + 85
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, 47 shl 16 + BTN_H
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, 5
|
|
|
|
mov esi, 0xCCCCCC
|
|
|
|
mcall 8 ; OK button
|
|
|
|
|
|
|
|
mov ebx, 256 shl 16 + 52
|
2017-09-27 04:01:45 +02:00
|
|
|
mov ecx, TEXT_ECX
|
2015-08-13 21:20:59 +02:00
|
|
|
mov edx, okstr
|
|
|
|
mov esi, okstr_e-okstr
|
|
|
|
mcall 4 ; OK button text
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
.redraw_done:
|
2015-08-20 11:30:24 +02:00
|
|
|
and [work], not WORK_GUI
|
2015-08-03 20:07:56 +02:00
|
|
|
mcall 12, 2
|
|
|
|
|
|
|
|
.loop:
|
2015-08-20 11:30:24 +02:00
|
|
|
test [work], WORK_GUI
|
|
|
|
jnz .redraw
|
2015-08-03 20:07:56 +02:00
|
|
|
cmp [status], STATUS_CONNECTED
|
2015-08-24 16:29:14 +02:00
|
|
|
je connected
|
2015-08-03 20:07:56 +02:00
|
|
|
|
|
|
|
mcall 23, 10 ; wait for event
|
|
|
|
dec eax ; redraw request ?
|
|
|
|
jz .redraw
|
|
|
|
dec eax ; key in buffer ?
|
|
|
|
jz .key
|
|
|
|
dec eax ; button in buffer ?
|
|
|
|
jz .btn
|
|
|
|
sub eax, 3
|
|
|
|
jz .mouse
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
|
|
|
|
.key: ; key event handler
|
|
|
|
mcall 2 ; read key
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
cmp [status], STATUS_CONNECT
|
2015-08-03 20:07:56 +02:00
|
|
|
jne @f
|
|
|
|
test [URLbox.flags], ed_focus
|
|
|
|
jz mainloop
|
|
|
|
cmp ah, 13 ; enter (return) key
|
|
|
|
je .connect
|
|
|
|
invoke edit_box_key, URLbox
|
2015-08-13 21:20:59 +02:00
|
|
|
jmp .loop
|
2015-08-04 10:59:09 +02:00
|
|
|
@@:
|
|
|
|
cmp [status], STATUS_REQ_LOGIN
|
2015-08-13 21:20:59 +02:00
|
|
|
jne @f
|
2015-08-04 10:59:09 +02:00
|
|
|
cmp ah, 13 ; enter (return) key
|
|
|
|
je .login
|
|
|
|
invoke edit_box_key, USERbox
|
|
|
|
invoke edit_box_key, PASSbox
|
2015-08-13 21:20:59 +02:00
|
|
|
jmp .loop
|
|
|
|
@@:
|
|
|
|
cmp [status], STATUS_DISCONNECTED
|
|
|
|
jb @f
|
|
|
|
cmp ah, 13
|
|
|
|
je .ok
|
2015-08-03 20:07:56 +02:00
|
|
|
@@:
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
.btn:
|
|
|
|
mcall 17 ; get id
|
|
|
|
|
|
|
|
cmp ah, 1 ; close ?
|
|
|
|
jz .close
|
|
|
|
cmp ah, 2 ; connect ?
|
|
|
|
je .connect
|
|
|
|
cmp ah, 3 ; login ?
|
|
|
|
je .login
|
2015-08-13 21:20:59 +02:00
|
|
|
cmp ah, 4
|
|
|
|
je .cancel
|
|
|
|
cmp ah, 5
|
|
|
|
je .ok
|
2015-08-03 20:07:56 +02:00
|
|
|
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
.connect:
|
|
|
|
mov eax, [URLbox.pos]
|
|
|
|
mov byte[serveraddr+eax], 0
|
2015-08-13 21:20:59 +02:00
|
|
|
call open_connection
|
2015-08-03 20:07:56 +02:00
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
.login:
|
2015-08-04 10:59:09 +02:00
|
|
|
mov [status], STATUS_LOGIN
|
2015-08-20 11:30:24 +02:00
|
|
|
or [work], WORK_GUI
|
2015-08-04 10:59:09 +02:00
|
|
|
jmp .loop
|
2015-08-03 20:07:56 +02:00
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
.cancel:
|
|
|
|
mcall 18, 18, [thread_id] ; kill thread
|
|
|
|
.ok:
|
2015-08-20 11:30:24 +02:00
|
|
|
cmp [status], STATUS_LIB_ERR
|
|
|
|
je .close
|
|
|
|
|
2015-08-13 21:20:59 +02:00
|
|
|
and [URLbox.flags], not ed_disabled
|
2015-08-14 15:30:03 +02:00
|
|
|
mov [USERbox.size], 0
|
|
|
|
mov [PASSbox.size], 0
|
2015-08-13 21:20:59 +02:00
|
|
|
mov [status], STATUS_CONNECT
|
2015-08-20 11:30:24 +02:00
|
|
|
mov [name.dash], 0
|
|
|
|
mcall 71, 1, name ; reset window caption
|
|
|
|
or [work], WORK_GUI
|
2015-08-13 21:20:59 +02:00
|
|
|
jmp .loop
|
|
|
|
|
2015-08-03 20:07:56 +02:00
|
|
|
.mouse:
|
2015-08-13 21:20:59 +02:00
|
|
|
cmp [status], STATUS_CONNECT
|
2015-08-03 20:07:56 +02:00
|
|
|
jne @f
|
|
|
|
invoke edit_box_mouse, URLbox
|
2015-08-04 10:59:09 +02:00
|
|
|
@@:
|
|
|
|
cmp [status], STATUS_REQ_LOGIN
|
|
|
|
jne @f
|
|
|
|
invoke edit_box_mouse, USERbox
|
|
|
|
invoke edit_box_mouse, PASSbox
|
2015-08-03 20:07:56 +02:00
|
|
|
@@:
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
.close:
|
2015-08-05 11:37:00 +02:00
|
|
|
mov [status], STATUS_CLOSED
|
2015-08-13 21:20:59 +02:00
|
|
|
mcall -1
|
|
|
|
|
|
|
|
|
|
|
|
open_connection:
|
|
|
|
|
|
|
|
or [URLbox.flags], ed_disabled
|
|
|
|
mov [status], STATUS_CONNECTING
|
|
|
|
|
|
|
|
; Create network thread
|
|
|
|
mcall 51, 1, thread_start, thread_stack
|
|
|
|
cmp eax, -1
|
|
|
|
jne @f
|
|
|
|
mov [status], STATUS_THREAD_ERR
|
|
|
|
@@:
|
|
|
|
mov [thread_id], eax
|
2015-08-20 11:30:24 +02:00
|
|
|
or [work], WORK_GUI
|
2015-08-13 21:20:59 +02:00
|
|
|
|
|
|
|
ret
|