Subversion Repositories Kolibri OS

Rev

Rev 2196 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. red_logon:
  2.     call draw_window_logon       ; at first, draw the window
  3.  
  4. still_logon:                     ; main cycle of application begins here
  5.     mov  eax,10     ; wait here for event
  6.     mcall
  7.  
  8. checkevent_logon:         ; Check what event was called _logon: this will be used to return from textbox focus
  9.  
  10.     dec  eax        ; redraw request ?
  11.     jz   red_logon
  12.     dec  eax        ; key in buffer ?
  13.     jz   key_logon
  14.     dec  eax        ; button in buffer ?
  15.     jz   button_logon
  16.  
  17.     jmp  still_logon
  18.  
  19.   key_logon:             ; key event handler
  20.     mov  al,2            ; eax was zero so will now be 2
  21.     mcall                ; just read it and ignore
  22.  
  23.     cmp  ah,13
  24.     jne  still_logon     ; return to main loop
  25.  
  26.     ret                  ; enter key was pressed => return to logon
  27.  
  28.   button_logon:          ; eax was zero so will now be 17
  29.     mov  al,17           ; get id
  30.     mcall
  31.  
  32.     cmp  ah,1            ; close ?
  33.     jz   close_logon
  34.     cmp  ah,2            ; logon ?
  35.     je   connect_logon
  36.     cmp  ah,5            ; first ?
  37.     jz   dstbtn_logon
  38.  
  39.   srcbtn_logon:
  40.     mov  dword[addr],first
  41.     jmp  rk_logon
  42.  
  43.   dstbtn_logon:
  44.     mov  dword[addr],second
  45.  
  46.   rk_logon:
  47.     mov  edi,[addr]      ; load the address of the string
  48.     xor  al,al           ; mov  al,0          ; the symbol we will search for
  49.     mov  ecx,STRLEN+1    ; length of the string (+1)
  50.     cld                  ; search forward
  51.   repne  scasb           ; do search now
  52.     inc  ecx             ; we've found a zero or ecx became 0
  53.     mov  eax,STRLEN+1
  54.     sub  eax,ecx         ; eax = address of <0> character
  55.     mov  [temp],eax      ; position
  56.  
  57.     cmp  dword[addr],dword second
  58.     jne  @f
  59.     mov  dword [passlen],eax
  60.    @@:
  61.  
  62.     call print_text_logon
  63.  
  64.     mov  edi,[addr]      ; address of string
  65.     add  edi,[temp]      ; cursor position
  66.  
  67.   .waitev_logon:
  68.     mov  eax,10          ; wait for event
  69.     mcall
  70.     cmp  eax,2           ; button presed ?
  71.     jne  checkevent_logon    ; a key is pressed or redraw is nessesary, goto checkevent
  72.     mcall                ; eax = 2, read button
  73.     shr  eax,8
  74.     cmp  eax,8
  75.     jnz  .nobs_logon     ; BACKSPACE
  76.     cmp  edi,[addr]
  77.     jz   .waitev_logon
  78.     dec  edi
  79.     mov  byte[edi],0
  80.  
  81.     cmp  dword[addr],second
  82.     jne  @f
  83.     dec  [passlen]
  84.    @@:
  85.  
  86.     call print_text_logon
  87.     jmp  .waitev_logon
  88.   .nobs_logon:
  89.     cmp  eax,13        ; ENTER
  90.     je   still_logon
  91.     cmp  eax,192
  92.     jne  .noclear_logon
  93.     xor  al,al
  94.     mov  edi,[addr]
  95.     mov  ecx,STRLEN
  96.     rep  stosb
  97.     mov  edi,[addr]
  98.     call print_text_logon
  99.     jmp  .waitev_logon
  100.  
  101.   .noclear_logon:
  102.     mov  [edi],al
  103.  
  104.     cmp  dword[addr],second
  105.     jne  @f
  106.     inc  [passlen]
  107.    @@:
  108.  
  109.     call print_text_logon
  110.  
  111.     inc  edi
  112.     mov  esi,[addr]
  113.     add  esi,STRLEN
  114.     cmp  esi,edi
  115.     jnz  .waitev_logon
  116.  
  117.     jmp  still_logon
  118.  
  119.  
  120. ; print strings (source & destination)
  121. print_text_logon:
  122. pusha
  123.  
  124.     mov  eax, 8
  125.     mov  ebx, 105*65536+200
  126.     mov  ecx, 31*65536+13
  127.     mov  edx, 4
  128.     mov  esi, 0xEBEBEB
  129.     mcall
  130.  
  131.     cmp  byte[mode],0
  132.     je   @f
  133.  
  134.     mov  ecx, 49*65536+12
  135.     inc  edx
  136.     mcall
  137.  
  138.    @@:
  139.     mov  eax, 4                         ; function 4 _logon: write text to window
  140.     mov  ebx, 107*65536+34              ; [x start] *65536 + [y start]
  141.     xor  ecx, ecx                       ; color of text RRGGBB
  142.     mov  edx, first                     ; pointer to text beginning
  143.     mov  esi, STRLEN                    ; text length
  144.     mcall
  145.  
  146.     cmp  byte[mode],0
  147.     je   dont_draw_pass
  148.  
  149.     add  ebx,16
  150.     mov  edi,[passlen]
  151.  
  152.    @@:
  153.     cmp  edi,0
  154.     jle  dont_draw_pass
  155.  
  156.     dec  edi
  157.     mov  edx, passchar
  158.     mov  esi, 1
  159.     mcall
  160.     add  ebx,6*65536
  161.     jmp  @r
  162.  
  163.   dont_draw_pass:
  164.  
  165. popa
  166.     ret
  167.  
  168. close_logon:
  169.     or  eax,-1
  170.     mcall
  171.  
  172. connect_logon:
  173.     ret
  174.  
  175. draw_window_logon:
  176.  
  177.     mcall 12, 1      ; start window draw
  178.     pusha
  179.                                         ; DRAW WINDOW
  180.     xor  eax, eax                       ; function 0 _logon: define and draw window
  181.     mov  ebx, 160*65536+330             ; [x start] *65536 + [x size]
  182.     mov  ecx, 160*65536+100             ; [y start] *65536 + [y size]
  183.     mov  edx, 0x13DDDDDD                ; color of work area RRGGBB
  184.     mov  edi, title                     ; WINDOW LABEL
  185.     mcall
  186.  
  187.     mov  eax, 8                         ; LOGON BUTTON
  188.     mov  ebx, 220*65536+85
  189.     mov  ecx, 63*65536+16
  190.     mov  edx, 2
  191.     mov  esi, 0xCCCCCC
  192.     mcall
  193.  
  194.    
  195.     call print_text_logon
  196.                                        
  197.     cmp  byte[mode], 0
  198.     je   servermode_
  199.  
  200.     mov  eax, 4                         ; function 4 write text to window
  201.     mov  ebx, 25*65536+33               ; [x start] *65536 + [y start]
  202.     xor  ecx, ecx
  203.     mov  edx, userstr                   ; pointer to text beginning
  204.     mov  esi, passstr-userstr           ; text length
  205.     mcall
  206.  
  207.     add  bl,19
  208.     mov  edx, passstr                   ; pointer to text beginning
  209.     mov  esi, connect-passstr           ; text length
  210.     mcall
  211.  
  212.     jmp  drawtherest_
  213.  
  214.    servermode_:
  215.  
  216.     mov  eax, 4                         ; function 4 write text to window
  217.     mov  ebx, 25*65536+33               ; [x start] *65536 + [y start]
  218.     xor  ecx, ecx
  219.     mov  edx, serverstr                 ; pointer to text beginning
  220.     mov  esi, userstr-serverstr         ; text length
  221.     mcall
  222.  
  223.    drawtherest_:
  224.  
  225.     mov  ebx, 240*65536+67              ; [x start] *65536 + [y start]
  226.     mov  edx, connect                   ; pointer to text beginning
  227.     mov  esi, connect_e-connect         ; text length
  228.     mcall
  229.  
  230.     popa
  231.     inc   ebx
  232.     mcall
  233.  
  234.     ret
  235.  
  236.  
  237. ; DATA AREA
  238. title  db 'Kolibrios VNC client by HIDNPLAYR',0
  239.  
  240. first:        db '192.168.1.5'
  241.               rb STRLEN
  242. second:       rb STRLEN
  243.  
  244. passchar      db '*'
  245. passlen       dd 0
  246.  
  247. addr          dd 0
  248. temp          dd 0
  249. mode          db 0 ; 0 = connection details, 1 = authentication
  250.  
  251. serverstr:    db 'server:'
  252. userstr:      db 'username:'
  253. passstr:      db 'password:'
  254. connect:      db 'connect !'
  255. connect_e:
  256.  
  257. I_END_logon:
  258.