Rev 5771 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5663 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;; VNC client for KolibriOS ;; |
||
7 | ;; ;; |
||
8 | ;; Written by hidnplayr@kolibrios.org ;; |
||
9 | ;; ;; |
||
10 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
11 | ;; Version 2, June 1991 ;; |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3545 | hidnplayr | 14 | |
7017 | leency | 15 | BTN_H equ 22 |
16 | TEXT_ECX equ 00010000b shl 24 + 0 |
||
17 | |||
5668 | hidnplayr | 18 | draw_gui: |
5750 | hidnplayr | 19 | mcall 67, 160, 160, 330, 100 ; resize and move the window |
20 | mcall 66, 1, 0 ; switch keyboard to ascii mode |
||
21 | .first_time: |
||
5663 | hidnplayr | 22 | mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY |
3545 | hidnplayr | 23 | |
5663 | hidnplayr | 24 | .redraw: |
5668 | hidnplayr | 25 | mcall 12, 1 ; start window draw |
5663 | hidnplayr | 26 | ; DRAW WINDOW |
27 | xor eax, eax ; function 0 _logon: define and draw window |
||
28 | mov ebx, 160 shl 16 + 330 ; [x start]:[x size] |
||
7017 | leency | 29 | mov ecx, 160 shl 16 + 130 ; [y start]:[y size] |
5663 | hidnplayr | 30 | mov edx, 0x34DDDDDD ; color of work area RRGGBB |
31 | mov edi, name ; WINDOW LABEL |
||
32 | mcall |
||
3545 | hidnplayr | 33 | |
5670 | hidnplayr | 34 | cmp [status], STATUS_CONNECTING |
5720 | hidnplayr | 35 | ja .login? |
5668 | hidnplayr | 36 | |
7017 | leency | 37 | mov ebx, 10 shl 16 + 22 |
38 | mov ecx, TEXT_ECX |
||
5668 | hidnplayr | 39 | mov edx, serverstr |
40 | mov esi, userstr-serverstr |
||
41 | mcall 4 ; "server" text |
||
42 | |||
43 | invoke edit_box_draw, URLbox ; Server textbox |
||
44 | |||
5720 | hidnplayr | 45 | cmp [status], STATUS_CONNECTING |
46 | jne @f |
||
47 | |||
48 | mov ebx, 220 shl 16 + 85 |
||
7017 | leency | 49 | mov ecx, 57 shl 16 + BTN_H |
5720 | hidnplayr | 50 | mov edx, 4 |
51 | mov esi, 0xCCCCCC |
||
52 | mcall 8 ; Cancel button |
||
53 | |||
7017 | leency | 54 | mov ebx, 240 shl 16 + 62 |
55 | mov ecx, TEXT_ECX |
||
5720 | hidnplayr | 56 | mov edx, cancelstr |
57 | mov esi, okstr-cancelstr |
||
58 | mcall 4 ; Cancel button text |
||
59 | |||
60 | jmp .redraw_done |
||
61 | |||
62 | @@: |
||
63 | cmp [status], STATUS_CONNECT |
||
5670 | hidnplayr | 64 | jne .redraw_done |
65 | |||
5663 | hidnplayr | 66 | mov ebx, 220 shl 16 + 85 |
7017 | leency | 67 | mov ecx, 57 shl 16 + BTN_H |
5663 | hidnplayr | 68 | mov edx, 2 |
69 | mov esi, 0xCCCCCC |
||
5668 | hidnplayr | 70 | mcall 8 ; Connect button |
3545 | hidnplayr | 71 | |
7017 | leency | 72 | mov ebx, 236 shl 16 + 62 |
73 | mov ecx, TEXT_ECX |
||
5668 | hidnplayr | 74 | mov edx, connectstr |
75 | mov esi, loginstr-connectstr |
||
76 | mcall 4 ; Connect button text |
||
3545 | hidnplayr | 77 | |
5668 | hidnplayr | 78 | jmp .redraw_done |
79 | |||
5720 | hidnplayr | 80 | .login?: |
5668 | hidnplayr | 81 | cmp [status], STATUS_LOGIN |
5670 | hidnplayr | 82 | ja @f |
5668 | hidnplayr | 83 | |
7017 | leency | 84 | mov ebx, 10 shl 16 + 12 |
85 | mov ecx, TEXT_ECX |
||
5668 | hidnplayr | 86 | mov edx, userstr |
87 | mov esi, passstr-userstr |
||
88 | mcall 4 ; "user" text |
||
3545 | hidnplayr | 89 | |
7017 | leency | 90 | add bl, 25 |
5668 | hidnplayr | 91 | mov edx, passstr |
92 | mov esi, connectstr-passstr ; "password" text |
||
5663 | hidnplayr | 93 | mcall |
3545 | hidnplayr | 94 | |
5670 | hidnplayr | 95 | invoke edit_box_draw, USERbox ; username textbox |
96 | invoke edit_box_draw, PASSbox ; password textbox |
||
97 | |||
98 | cmp [status], STATUS_REQ_LOGIN |
||
99 | jne .redraw_done |
||
100 | |||
5668 | hidnplayr | 101 | mov ebx, 220 shl 16 + 85 |
7017 | leency | 102 | mov ecx, 67 shl 16 + BTN_H |
5668 | hidnplayr | 103 | mov edx, 3 |
104 | mov esi, 0xCCCCCC |
||
105 | mcall 8 ; Login button |
||
3545 | hidnplayr | 106 | |
5720 | hidnplayr | 107 | mov ebx, 120 shl 16 + 85 |
7017 | leency | 108 | mov ecx, 67 shl 16 + BTN_H |
5720 | hidnplayr | 109 | mov edx, 4 |
110 | mov esi, 0xCCCCCC |
||
111 | mcall 8 ; Cancel button |
||
112 | |||
7017 | leency | 113 | mov ebx, 240 shl 16 + 71 |
114 | mov ecx, TEXT_ECX |
||
115 | mov edx, loginstr |
||
116 | mov esi, cancelstr-loginstr |
||
117 | mcall 4 ; Login button text |
||
118 | |||
119 | mov ebx, 140 shl 16 + 71 |
||
5720 | hidnplayr | 120 | mov edx, cancelstr |
121 | mov esi, okstr-cancelstr |
||
122 | mcall 4 ; Cancel button text |
||
123 | |||
5668 | hidnplayr | 124 | jmp .redraw_done |
3545 | hidnplayr | 125 | |
5668 | hidnplayr | 126 | @@: |
5670 | hidnplayr | 127 | cmp [status], STATUS_DISCONNECTED |
128 | jb .redraw_done |
||
129 | |||
5720 | hidnplayr | 130 | mov ebx, 15 shl 16 + 10 |
131 | mov ecx, 0x00ca0000 ; red ASCIIZ string |
||
5668 | hidnplayr | 132 | mov edx, [status] |
133 | sub edx, 10 |
||
134 | mov edx, [err_msg+4*edx] |
||
5720 | hidnplayr | 135 | .restart: |
136 | xor esi, esi |
||
137 | .pr_loop: |
||
138 | cmp byte[edx+esi], 0 |
||
139 | je .last |
||
140 | cmp byte[edx+esi], 0x0a |
||
141 | je .print |
||
142 | inc esi |
||
143 | jmp .pr_loop |
||
144 | .print: |
||
145 | mcall 4 |
||
146 | add edx, esi |
||
147 | inc edx |
||
148 | add ebx, 10 |
||
149 | jmp .restart |
||
150 | .last: |
||
5668 | hidnplayr | 151 | mcall 4 ; print error message to window |
3545 | hidnplayr | 152 | |
5720 | hidnplayr | 153 | mov ebx, 220 shl 16 + 85 |
7017 | leency | 154 | mov ecx, 47 shl 16 + BTN_H |
5720 | hidnplayr | 155 | mov edx, 5 |
156 | mov esi, 0xCCCCCC |
||
157 | mcall 8 ; OK button |
||
158 | |||
159 | mov ebx, 256 shl 16 + 52 |
||
7017 | leency | 160 | mov ecx, TEXT_ECX |
5720 | hidnplayr | 161 | mov edx, okstr |
162 | mov esi, okstr_e-okstr |
||
163 | mcall 4 ; OK button text |
||
164 | |||
5668 | hidnplayr | 165 | .redraw_done: |
5750 | hidnplayr | 166 | and [work], not WORK_GUI |
5668 | hidnplayr | 167 | mcall 12, 2 |
3545 | hidnplayr | 168 | |
5663 | hidnplayr | 169 | .loop: |
5750 | hidnplayr | 170 | test [work], WORK_GUI |
171 | jnz .redraw |
||
5668 | hidnplayr | 172 | cmp [status], STATUS_CONNECTED |
5771 | hidnplayr | 173 | je connected |
5668 | hidnplayr | 174 | |
175 | mcall 23, 10 ; wait for event |
||
176 | dec eax ; redraw request ? |
||
5663 | hidnplayr | 177 | jz .redraw |
5668 | hidnplayr | 178 | dec eax ; key in buffer ? |
5663 | hidnplayr | 179 | jz .key |
5668 | hidnplayr | 180 | dec eax ; button in buffer ? |
5663 | hidnplayr | 181 | jz .btn |
182 | sub eax, 3 |
||
183 | jz .mouse |
||
184 | jmp .loop |
||
3545 | hidnplayr | 185 | |
186 | |||
5668 | hidnplayr | 187 | .key: ; key event handler |
188 | mcall 2 ; read key |
||
189 | |||
5720 | hidnplayr | 190 | cmp [status], STATUS_CONNECT |
5668 | hidnplayr | 191 | jne @f |
5663 | hidnplayr | 192 | test [URLbox.flags], ed_focus |
193 | jz mainloop |
||
5668 | hidnplayr | 194 | cmp ah, 13 ; enter (return) key |
195 | je .connect |
||
5663 | hidnplayr | 196 | invoke edit_box_key, URLbox |
5720 | hidnplayr | 197 | jmp .loop |
5668 | hidnplayr | 198 | @@: |
5670 | hidnplayr | 199 | cmp [status], STATUS_REQ_LOGIN |
5720 | hidnplayr | 200 | jne @f |
5670 | hidnplayr | 201 | cmp ah, 13 ; enter (return) key |
202 | je .login |
||
203 | invoke edit_box_key, USERbox |
||
204 | invoke edit_box_key, PASSbox |
||
5720 | hidnplayr | 205 | jmp .loop |
5670 | hidnplayr | 206 | @@: |
5720 | hidnplayr | 207 | cmp [status], STATUS_DISCONNECTED |
208 | jb @f |
||
209 | cmp ah, 13 |
||
210 | je .ok |
||
211 | @@: |
||
5663 | hidnplayr | 212 | jmp .loop |
3545 | hidnplayr | 213 | |
5663 | hidnplayr | 214 | .btn: |
5668 | hidnplayr | 215 | mcall 17 ; get id |
3545 | hidnplayr | 216 | |
5668 | hidnplayr | 217 | cmp ah, 1 ; close ? |
5663 | hidnplayr | 218 | jz .close |
5668 | hidnplayr | 219 | cmp ah, 2 ; connect ? |
220 | je .connect |
||
221 | cmp ah, 3 ; login ? |
||
222 | je .login |
||
5720 | hidnplayr | 223 | cmp ah, 4 |
224 | je .cancel |
||
225 | cmp ah, 5 |
||
226 | je .ok |
||
3545 | hidnplayr | 227 | |
5663 | hidnplayr | 228 | jmp .loop |
3545 | hidnplayr | 229 | |
5668 | hidnplayr | 230 | .connect: |
231 | mov eax, [URLbox.pos] |
||
232 | mov byte[serveraddr+eax], 0 |
||
5720 | hidnplayr | 233 | call open_connection |
5668 | hidnplayr | 234 | jmp .loop |
235 | |||
236 | .login: |
||
5670 | hidnplayr | 237 | mov [status], STATUS_LOGIN |
5750 | hidnplayr | 238 | or [work], WORK_GUI |
5670 | hidnplayr | 239 | jmp .loop |
5668 | hidnplayr | 240 | |
5720 | hidnplayr | 241 | .cancel: |
242 | mcall 18, 18, [thread_id] ; kill thread |
||
243 | .ok: |
||
5750 | hidnplayr | 244 | cmp [status], STATUS_LIB_ERR |
245 | je .close |
||
246 | |||
5720 | hidnplayr | 247 | and [URLbox.flags], not ed_disabled |
5722 | hidnplayr | 248 | mov [USERbox.size], 0 |
249 | mov [PASSbox.size], 0 |
||
5720 | hidnplayr | 250 | mov [status], STATUS_CONNECT |
5750 | hidnplayr | 251 | mov [name.dash], 0 |
252 | mcall 71, 1, name ; reset window caption |
||
253 | or [work], WORK_GUI |
||
5720 | hidnplayr | 254 | jmp .loop |
255 | |||
5663 | hidnplayr | 256 | .mouse: |
5720 | hidnplayr | 257 | cmp [status], STATUS_CONNECT |
5668 | hidnplayr | 258 | jne @f |
5663 | hidnplayr | 259 | invoke edit_box_mouse, URLbox |
5668 | hidnplayr | 260 | @@: |
5670 | hidnplayr | 261 | cmp [status], STATUS_REQ_LOGIN |
262 | jne @f |
||
263 | invoke edit_box_mouse, USERbox |
||
264 | invoke edit_box_mouse, PASSbox |
||
265 | @@: |
||
5663 | hidnplayr | 266 | jmp .loop |
3545 | hidnplayr | 267 | |
5663 | hidnplayr | 268 | .close: |
5680 | hidnplayr | 269 | mov [status], STATUS_CLOSED |
5720 | hidnplayr | 270 | mcall -1 |
271 | |||
272 | |||
273 | open_connection: |
||
274 | |||
275 | or [URLbox.flags], ed_disabled |
||
276 | mov [status], STATUS_CONNECTING |
||
277 | |||
278 | ; Create network thread |
||
279 | mcall 51, 1, thread_start, thread_stack |
||
280 | cmp eax, -1 |
||
281 | jne @f |
||
282 | mov [status], STATUS_THREAD_ERR |
||
283 | @@: |
||
284 | mov [thread_id], eax |
||
5750 | hidnplayr | 285 | or [work], WORK_GUI |
5720 | hidnplayr | 286 | |
287 | ret |