Subversion Repositories Kolibri OS

Rev

Rev 5693 | Rev 5722 | 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      .login?
  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_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
  57.         jne     .redraw_done
  58.  
  59.         mov     ebx, 220 shl 16 + 85
  60.         mov     ecx, 47 shl 16 + 16
  61.         mov     edx, 2
  62.         mov     esi, 0xCCCCCC
  63.         mcall   8                               ; Connect button
  64.  
  65.         mov     ebx, 240 shl 16 + 52
  66.         mov     edx, connectstr
  67.         mov     esi, loginstr-connectstr
  68.         mcall   4                               ; Connect button text
  69.  
  70.         jmp     .redraw_done
  71.  
  72.   .login?:
  73.         cmp     [status], STATUS_LOGIN
  74.         ja      @f
  75.  
  76.         mov     ebx, 25 shl 16 + 14
  77.         xor     ecx, ecx
  78.         mov     edx, userstr
  79.         mov     esi, passstr-userstr
  80.         mcall   4                               ; "user" text
  81.  
  82.         add     bl, 20
  83.         mov     edx, passstr
  84.         mov     esi, connectstr-passstr         ; "password" text
  85.         mcall
  86.  
  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.  
  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
  98.  
  99.         mov     ebx, 240 shl 16 + 52
  100.         mov     edx, loginstr
  101.         mov     esi, cancelstr-loginstr
  102.         mcall   4                               ; Login button text
  103.  
  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.  
  115.         jmp     .redraw_done
  116.  
  117.   @@:
  118.         cmp     [status], STATUS_DISCONNECTED
  119.         jb      .redraw_done
  120.  
  121.         mov     ebx, 15 shl 16 + 10
  122.         mov     ecx, 0x00ca0000                 ; red ASCIIZ string
  123.         mov     edx, [status]
  124.         sub     edx, 10
  125.         mov     edx, [err_msg+4*edx]
  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:
  142.         mcall   4                               ; print error message to window
  143.  
  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.  
  155.   .redraw_done:
  156.         mov     [update_gui], 0
  157.         mcall   12, 2
  158.  
  159.   .loop:
  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 ?
  167.         jz      .redraw
  168.         dec     eax                             ; key in buffer ?
  169.         jz      .key
  170.         dec     eax                             ; button in buffer ?
  171.         jz      .btn
  172.         sub     eax, 3
  173.         jz      .mouse
  174.         jmp     .loop
  175.  
  176.   .connected:
  177.         ret
  178.  
  179.   .key:                                         ; key event handler
  180.         mcall   2                               ; read key
  181.  
  182.         cmp     [status], STATUS_CONNECT
  183.         jne     @f
  184.         test    [URLbox.flags], ed_focus
  185.         jz      mainloop
  186.         cmp     ah, 13                          ; enter (return) key
  187.         je      .connect
  188.         invoke  edit_box_key, URLbox
  189.         jmp     .loop
  190.   @@:
  191.         cmp     [status], STATUS_REQ_LOGIN
  192.         jne     @f
  193.         cmp     ah, 13                          ; enter (return) key
  194.         je      .login
  195.         invoke  edit_box_key, USERbox
  196.         invoke  edit_box_key, PASSbox
  197.         jmp     .loop
  198.   @@:
  199.         cmp     [status], STATUS_DISCONNECTED
  200.         jb      @f
  201.         cmp     ah, 13
  202.         je      .ok
  203.   @@:
  204.         jmp     .loop
  205.  
  206.   .btn:
  207.         mcall   17                              ; get id
  208.  
  209.         cmp     ah, 1                           ; close ?
  210.         jz      .close
  211.         cmp     ah, 2                           ; connect ?
  212.         je      .connect
  213.         cmp     ah, 3                           ; login ?
  214.         je      .login
  215.         cmp     ah, 4
  216.         je      .cancel
  217.         cmp     ah, 5
  218.         je      .ok
  219.  
  220.         jmp     .loop
  221.  
  222.   .connect:
  223.         mov     eax, [URLbox.pos]
  224.         mov     byte[serveraddr+eax], 0
  225.         call    open_connection
  226.         jmp     .loop
  227.  
  228.   .login:
  229.         mov     [status], STATUS_LOGIN
  230.         inc     [update_gui]
  231.         jmp     .loop
  232.  
  233.   .cancel:
  234.         mcall   18, 18, [thread_id]             ; kill thread
  235.   .ok:
  236.         and     [URLbox.flags], not ed_disabled
  237.         mov     [status], STATUS_CONNECT
  238.         inc     [update_gui]
  239.         jmp     .loop
  240.  
  241.   .mouse:
  242.         cmp     [status], STATUS_CONNECT
  243.         jne     @f
  244.         invoke  edit_box_mouse, URLbox
  245.   @@:
  246.         cmp     [status], STATUS_REQ_LOGIN
  247.         jne     @f
  248.         invoke  edit_box_mouse, USERbox
  249.         invoke  edit_box_mouse, PASSbox
  250.   @@:
  251.         jmp     .loop
  252.  
  253.   .close:
  254.         mov     [status], STATUS_CLOSED
  255.         mcall   -1
  256.  
  257.  
  258. open_connection:
  259.  
  260.         or      [URLbox.flags], ed_disabled
  261.         mov     [status], STATUS_CONNECTING
  262.  
  263. ; Create network thread
  264.         mcall   51, 1, thread_start, thread_stack
  265.         cmp     eax, -1
  266.         jne     @f
  267.         mov     [status], STATUS_THREAD_ERR
  268.   @@:
  269.         mov     [thread_id], eax
  270.         inc     [update_gui]
  271.  
  272.         ret