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