Subversion Repositories Kolibri OS

Rev

Rev 5720 | Rev 5750 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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