Subversion Repositories Kolibri OS

Rev

Rev 5722 | 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.   .connected:
  180.         ret
  181.  
  182.   .key:                                         ; key event handler
  183.         mcall   2                               ; read key
  184.  
  185.         cmp     [status], STATUS_CONNECT
  186.         jne     @f
  187.         test    [URLbox.flags], ed_focus
  188.         jz      mainloop
  189.         cmp     ah, 13                          ; enter (return) key
  190.         je      .connect
  191.         invoke  edit_box_key, URLbox
  192.         jmp     .loop
  193.   @@:
  194.         cmp     [status], STATUS_REQ_LOGIN
  195.         jne     @f
  196.         cmp     ah, 13                          ; enter (return) key
  197.         je      .login
  198.         invoke  edit_box_key, USERbox
  199.         invoke  edit_box_key, PASSbox
  200.         jmp     .loop
  201.   @@:
  202.         cmp     [status], STATUS_DISCONNECTED
  203.         jb      @f
  204.         cmp     ah, 13
  205.         je      .ok
  206.   @@:
  207.         jmp     .loop
  208.  
  209.   .btn:
  210.         mcall   17                              ; get id
  211.  
  212.         cmp     ah, 1                           ; close ?
  213.         jz      .close
  214.         cmp     ah, 2                           ; connect ?
  215.         je      .connect
  216.         cmp     ah, 3                           ; login ?
  217.         je      .login
  218.         cmp     ah, 4
  219.         je      .cancel
  220.         cmp     ah, 5
  221.         je      .ok
  222.  
  223.         jmp     .loop
  224.  
  225.   .connect:
  226.         mov     eax, [URLbox.pos]
  227.         mov     byte[serveraddr+eax], 0
  228.         call    open_connection
  229.         jmp     .loop
  230.  
  231.   .login:
  232.         mov     [status], STATUS_LOGIN
  233.         or      [work], WORK_GUI
  234.         jmp     .loop
  235.  
  236.   .cancel:
  237.         mcall   18, 18, [thread_id]             ; kill thread
  238.   .ok:
  239.         cmp     [status], STATUS_LIB_ERR
  240.         je      .close
  241.  
  242.         and     [URLbox.flags], not ed_disabled
  243.         mov     [USERbox.size], 0
  244.         mov     [PASSbox.size], 0
  245.         mov     [status], STATUS_CONNECT
  246.         mov     [name.dash], 0
  247.         mcall   71, 1, name                     ; reset window caption
  248.         or      [work], WORK_GUI
  249.         jmp     .loop
  250.  
  251.   .mouse:
  252.         cmp     [status], STATUS_CONNECT
  253.         jne     @f
  254.         invoke  edit_box_mouse, URLbox
  255.   @@:
  256.         cmp     [status], STATUS_REQ_LOGIN
  257.         jne     @f
  258.         invoke  edit_box_mouse, USERbox
  259.         invoke  edit_box_mouse, PASSbox
  260.   @@:
  261.         jmp     .loop
  262.  
  263.   .close:
  264.         mov     [status], STATUS_CLOSED
  265.         mcall   -1
  266.  
  267.  
  268. open_connection:
  269.  
  270.         or      [URLbox.flags], ed_disabled
  271.         mov     [status], STATUS_CONNECTING
  272.  
  273. ; Create network thread
  274.         mcall   51, 1, thread_start, thread_stack
  275.         cmp     eax, -1
  276.         jne     @f
  277.         mov     [status], STATUS_THREAD_ERR
  278.   @@:
  279.         mov     [thread_id], eax
  280.         or      [work], WORK_GUI
  281.  
  282.         ret