Subversion Repositories Kolibri OS

Rev

Rev 7017 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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