Subversion Repositories Kolibri OS

Rev

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