Subversion Repositories Kolibri OS

Rev

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