Subversion Repositories Kolibri OS

Rev

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

Rev 5680 Rev 5693
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      @f
29
        ja      @f
30
 
30
 
31
        mov     ebx, 25 shl 16 + 14
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_INITIAL
39
        cmp     [status], STATUS_INITIAL
40
        jne     .redraw_done
40
        jne     .redraw_done
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, 2
44
        mov     edx, 2
45
        mov     esi, 0xCCCCCC
45
        mov     esi, 0xCCCCCC
46
        mcall   8                               ; Connect button
46
        mcall   8                               ; Connect button
47
 
47
 
48
        mov     ebx, 240 shl 16 + 52
48
        mov     ebx, 240 shl 16 + 52
49
        mov     edx, connectstr
49
        mov     edx, connectstr
50
        mov     esi, loginstr-connectstr
50
        mov     esi, loginstr-connectstr
51
        mcall   4                               ; Connect button text
51
        mcall   4                               ; Connect button text
52
 
52
 
53
        jmp     .redraw_done
53
        jmp     .redraw_done
54
 
54
 
55
  @@:
55
  @@:
56
        cmp     [status], STATUS_LOGIN
56
        cmp     [status], STATUS_LOGIN
57
        ja      @f
57
        ja      @f
58
 
58
 
59
        mov     ebx, 25 shl 16 + 14
59
        mov     ebx, 25 shl 16 + 14
60
        xor     ecx, ecx
60
        xor     ecx, ecx
61
        mov     edx, userstr
61
        mov     edx, userstr
62
        mov     esi, passstr-userstr
62
        mov     esi, passstr-userstr
63
        mcall   4                               ; "user" text
63
        mcall   4                               ; "user" text
64
 
64
 
65
        add     bl, 20
65
        add     bl, 20
66
        mov     edx, passstr
66
        mov     edx, passstr
67
        mov     esi, connectstr-passstr         ; "password" text
67
        mov     esi, connectstr-passstr         ; "password" text
68
        mcall
68
        mcall
69
 
69
 
70
        invoke  edit_box_draw, USERbox          ; username textbox
70
        invoke  edit_box_draw, USERbox          ; username textbox
71
        invoke  edit_box_draw, PASSbox          ; password textbox
71
        invoke  edit_box_draw, PASSbox          ; password textbox
72
 
72
 
73
        cmp     [status], STATUS_REQ_LOGIN
73
        cmp     [status], STATUS_REQ_LOGIN
74
        jne     .redraw_done
74
        jne     .redraw_done
75
 
75
 
76
        mov     ebx, 220 shl 16 + 85
76
        mov     ebx, 220 shl 16 + 85
77
        mov     ecx, 47 shl 16 + 16
77
        mov     ecx, 47 shl 16 + 16
78
        mov     edx, 3
78
        mov     edx, 3
79
        mov     esi, 0xCCCCCC
79
        mov     esi, 0xCCCCCC
80
        mcall   8                               ; Login button
80
        mcall   8                               ; Login button
81
 
81
 
82
        mov     ebx, 240 shl 16 + 52
82
        mov     ebx, 240 shl 16 + 52
83
        mov     edx, loginstr
83
        mov     edx, loginstr
84
        mov     esi, loginstr_e-loginstr
84
        mov     esi, loginstr_e-loginstr
85
        mcall   4                               ; Login button text
85
        mcall   4                               ; Login button text
86
 
86
 
87
        jmp     .redraw_done
87
        jmp     .redraw_done
88
 
88
 
89
  @@:
89
  @@:
90
        cmp     [status], STATUS_DISCONNECTED
90
        cmp     [status], STATUS_DISCONNECTED
91
        jb      .redraw_done
91
        jb      .redraw_done
92
 
92
 
93
        mov     ebx, 25 shl 16 + 15
93
        mov     ebx, 25 shl 16 + 15
94
        mov     ecx, 0x80ca0000                 ; red ASCIIZ string
94
        mov     ecx, 0x80ca0000                 ; red ASCIIZ string
95
        mov     edx, [status]
95
        mov     edx, [status]
96
        sub     edx, 10
96
        sub     edx, 10
97
        mov     edx, [err_msg+4*edx]
97
        mov     edx, [err_msg+4*edx]
98
        mcall   4                               ; print error message to window
98
        mcall   4                               ; print error message to window
99
 
99
 
100
  .redraw_done:
100
  .redraw_done:
101
        mov     [update_gui], 0
101
        mov     [update_gui], 0
102
        mcall   12, 2
102
        mcall   12, 2
103
 
103
 
104
  .loop:
104
  .loop:
105
        cmp     [update_gui], 0
105
        cmp     [update_gui], 0
106
        jne     .redraw
106
        jne     .redraw
107
        cmp     [status], STATUS_CONNECTED
107
        cmp     [status], STATUS_CONNECTED
108
        je      .connected
108
        je      .connected
109
 
109
 
110
        mcall   23, 10                          ; wait for event
110
        mcall   23, 10                          ; wait for event
111
        dec     eax                             ; redraw request ?
111
        dec     eax                             ; redraw request ?
112
        jz      .redraw
112
        jz      .redraw
113
        dec     eax                             ; key in buffer ?
113
        dec     eax                             ; key in buffer ?
114
        jz      .key
114
        jz      .key
115
        dec     eax                             ; button in buffer ?
115
        dec     eax                             ; button in buffer ?
116
        jz      .btn
116
        jz      .btn
117
        sub     eax, 3
117
        sub     eax, 3
118
        jz      .mouse
118
        jz      .mouse
119
        jmp     .loop
119
        jmp     .loop
120
 
120
 
121
  .connected:
121
  .connected:
122
        ret
122
        ret
123
 
123
 
124
  .key:                                         ; key event handler
124
  .key:                                         ; key event handler
125
        mcall   2                               ; read key
125
        mcall   2                               ; read key
126
 
126
 
127
        cmp     [status], STATUS_INITIAL
127
        cmp     [status], STATUS_INITIAL
128
        jne     @f
128
        jne     @f
129
        test    [URLbox.flags], ed_focus
129
        test    [URLbox.flags], ed_focus
130
        jz      mainloop
130
        jz      mainloop
131
        cmp     ah, 13                          ; enter (return) key
131
        cmp     ah, 13                          ; enter (return) key
132
        je      .connect
132
        je      .connect
133
        invoke  edit_box_key, URLbox
133
        invoke  edit_box_key, URLbox
134
  @@:
134
  @@:
135
        cmp     [status], STATUS_REQ_LOGIN
135
        cmp     [status], STATUS_REQ_LOGIN
136
        jne     .loop
136
        jne     .loop
137
        cmp     ah, 13                          ; enter (return) key
137
        cmp     ah, 13                          ; enter (return) key
138
        je      .login
138
        je      .login
139
        invoke  edit_box_key, USERbox
139
        invoke  edit_box_key, USERbox
140
        invoke  edit_box_key, PASSbox
140
        invoke  edit_box_key, PASSbox
141
  @@:
141
  @@:
142
        jmp     .loop
142
        jmp     .loop
143
 
143
 
144
  .btn:
144
  .btn:
145
        mcall   17                              ; get id
145
        mcall   17                              ; get id
146
 
146
 
147
        cmp     ah, 1                           ; close ?
147
        cmp     ah, 1                           ; close ?
148
        jz      .close
148
        jz      .close
149
        cmp     ah, 2                           ; connect ?
149
        cmp     ah, 2                           ; connect ?
150
        je      .connect
150
        je      .connect
151
        cmp     ah, 3                           ; login ?
151
        cmp     ah, 3                           ; login ?
152
        je      .login
152
        je      .login
153
 
153
 
154
        jmp     .loop
154
        jmp     .loop
155
 
155
 
156
  .connect:
156
  .connect:
157
        mov     eax, [URLbox.pos]
157
        mov     eax, [URLbox.pos]
158
        mov     byte[serveraddr+eax], 0
158
        mov     byte[serveraddr+eax], 0
159
 
159
 
160
        mov     [status], STATUS_CONNECTING
160
        mov     [status], STATUS_CONNECTING
161
        inc     [update_gui]
161
        inc     [update_gui]
162
 
162
 
163
; Create network thread
163
; Create network thread
164
        mcall   51, 1, thread_start, thread_stack
164
        mcall   51, 1, thread_start, thread_stack
165
        cmp     eax, -1
165
        cmp     eax, -1
166
        jne     @f
166
        jne     @f
167
        mov     [status], STATUS_THREAD_ERR
167
        mov     [status], STATUS_THREAD_ERR
168
;        inc     [update_gui]
168
;        inc     [update_gui]
169
  @@:
169
  @@:
170
        jmp     .loop
170
        jmp     .loop
171
 
171
 
172
  .login:
172
  .login:
173
        mov     [status], STATUS_LOGIN
173
        mov     [status], STATUS_LOGIN
174
        inc     [update_gui]
174
        inc     [update_gui]
175
        jmp     .loop
175
        jmp     .loop
176
 
176
 
177
  .mouse:
177
  .mouse:
178
        cmp     [status], STATUS_INITIAL
178
        cmp     [status], STATUS_INITIAL
179
        jne     @f
179
        jne     @f
180
        invoke  edit_box_mouse, URLbox
180
        invoke  edit_box_mouse, URLbox
181
  @@:
181
  @@:
182
        cmp     [status], STATUS_REQ_LOGIN
182
        cmp     [status], STATUS_REQ_LOGIN
183
        jne     @f
183
        jne     @f
184
        invoke  edit_box_mouse, USERbox
184
        invoke  edit_box_mouse, USERbox
185
        invoke  edit_box_mouse, PASSbox
185
        invoke  edit_box_mouse, PASSbox
186
  @@:
186
  @@:
187
        jmp     .loop
187
        jmp     .loop
188
 
188
 
189
  .close:
189
  .close:
190
        mov     [status], STATUS_CLOSED
190
        mov     [status], STATUS_CLOSED
191
        mcall   -1
191
        mcall   -1