Subversion Repositories Kolibri OS

Rev

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