Subversion Repositories Kolibri OS

Rev

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