Rev 5750 | Rev 7017 | 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 |
5771 | hidnplayr | 166 | je connected |
5668 | hidnplayr | 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 | |
179 | |||
5668 | hidnplayr | 180 | .key: ; key event handler |
181 | mcall 2 ; read key |
||
182 | |||
5720 | hidnplayr | 183 | cmp [status], STATUS_CONNECT |
5668 | hidnplayr | 184 | jne @f |
5663 | hidnplayr | 185 | test [URLbox.flags], ed_focus |
186 | jz mainloop |
||
5668 | hidnplayr | 187 | cmp ah, 13 ; enter (return) key |
188 | je .connect |
||
5663 | hidnplayr | 189 | invoke edit_box_key, URLbox |
5720 | hidnplayr | 190 | jmp .loop |
5668 | hidnplayr | 191 | @@: |
5670 | hidnplayr | 192 | cmp [status], STATUS_REQ_LOGIN |
5720 | hidnplayr | 193 | jne @f |
5670 | hidnplayr | 194 | cmp ah, 13 ; enter (return) key |
195 | je .login |
||
196 | invoke edit_box_key, USERbox |
||
197 | invoke edit_box_key, PASSbox |
||
5720 | hidnplayr | 198 | jmp .loop |
5670 | hidnplayr | 199 | @@: |
5720 | hidnplayr | 200 | cmp [status], STATUS_DISCONNECTED |
201 | jb @f |
||
202 | cmp ah, 13 |
||
203 | je .ok |
||
204 | @@: |
||
5663 | hidnplayr | 205 | jmp .loop |
3545 | hidnplayr | 206 | |
5663 | hidnplayr | 207 | .btn: |
5668 | hidnplayr | 208 | mcall 17 ; get id |
3545 | hidnplayr | 209 | |
5668 | hidnplayr | 210 | cmp ah, 1 ; close ? |
5663 | hidnplayr | 211 | jz .close |
5668 | hidnplayr | 212 | cmp ah, 2 ; connect ? |
213 | je .connect |
||
214 | cmp ah, 3 ; login ? |
||
215 | je .login |
||
5720 | hidnplayr | 216 | cmp ah, 4 |
217 | je .cancel |
||
218 | cmp ah, 5 |
||
219 | je .ok |
||
3545 | hidnplayr | 220 | |
5663 | hidnplayr | 221 | jmp .loop |
3545 | hidnplayr | 222 | |
5668 | hidnplayr | 223 | .connect: |
224 | mov eax, [URLbox.pos] |
||
225 | mov byte[serveraddr+eax], 0 |
||
5720 | hidnplayr | 226 | call open_connection |
5668 | hidnplayr | 227 | jmp .loop |
228 | |||
229 | .login: |
||
5670 | hidnplayr | 230 | mov [status], STATUS_LOGIN |
5750 | hidnplayr | 231 | or [work], WORK_GUI |
5670 | hidnplayr | 232 | jmp .loop |
5668 | hidnplayr | 233 | |
5720 | hidnplayr | 234 | .cancel: |
235 | mcall 18, 18, [thread_id] ; kill thread |
||
236 | .ok: |
||
5750 | hidnplayr | 237 | cmp [status], STATUS_LIB_ERR |
238 | je .close |
||
239 | |||
5720 | hidnplayr | 240 | and [URLbox.flags], not ed_disabled |
5722 | hidnplayr | 241 | mov [USERbox.size], 0 |
242 | mov [PASSbox.size], 0 |
||
5720 | hidnplayr | 243 | mov [status], STATUS_CONNECT |
5750 | hidnplayr | 244 | mov [name.dash], 0 |
245 | mcall 71, 1, name ; reset window caption |
||
246 | or [work], WORK_GUI |
||
5720 | hidnplayr | 247 | jmp .loop |
248 | |||
5663 | hidnplayr | 249 | .mouse: |
5720 | hidnplayr | 250 | cmp [status], STATUS_CONNECT |
5668 | hidnplayr | 251 | jne @f |
5663 | hidnplayr | 252 | invoke edit_box_mouse, URLbox |
5668 | hidnplayr | 253 | @@: |
5670 | hidnplayr | 254 | cmp [status], STATUS_REQ_LOGIN |
255 | jne @f |
||
256 | invoke edit_box_mouse, USERbox |
||
257 | invoke edit_box_mouse, PASSbox |
||
258 | @@: |
||
5663 | hidnplayr | 259 | jmp .loop |
3545 | hidnplayr | 260 | |
5663 | hidnplayr | 261 | .close: |
5680 | hidnplayr | 262 | mov [status], STATUS_CLOSED |
5720 | hidnplayr | 263 | mcall -1 |
264 | |||
265 | |||
266 | open_connection: |
||
267 | |||
268 | or [URLbox.flags], ed_disabled |
||
269 | mov [status], STATUS_CONNECTING |
||
270 | |||
271 | ; Create network thread |
||
272 | mcall 51, 1, thread_start, thread_stack |
||
273 | cmp eax, -1 |
||
274 | jne @f |
||
275 | mov [status], STATUS_THREAD_ERR |
||
276 | @@: |
||
277 | mov [thread_id], eax |
||
5750 | hidnplayr | 278 | or [work], WORK_GUI |
5720 | hidnplayr | 279 | |
280 | ret |