Subversion Repositories Kolibri OS

Rev

Rev 5680 | Rev 5720 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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