mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-26 16:37:30 +03:00
Fixed QUIT command, cleaned up userparser, small bugfixes.
git-svn-id: svn://kolibrios.org@4710 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
42177203d6
commit
09143c58e9
@ -13,7 +13,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
version equ '0.21'
|
version equ '0.22'
|
||||||
|
|
||||||
; connection status
|
; connection status
|
||||||
STATUS_DISCONNECTED = 0
|
STATUS_DISCONNECTED = 0
|
||||||
@ -334,7 +334,7 @@ exit:
|
|||||||
cmp [socketnum], 0
|
cmp [socketnum], 0
|
||||||
je @f
|
je @f
|
||||||
mov esi, quit_msg
|
mov esi, quit_msg
|
||||||
call cmd_usr_quit_server
|
call quit_server
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -462,9 +462,11 @@ str_connecting db 3, '3* Connecting to ', 0
|
|||||||
str_sockerr db 3, '5* Socket error', 10, 0
|
str_sockerr db 3, '5* Socket error', 10, 0
|
||||||
str_dnserr db 3, '5* Unable to resolve hostname', 10, 0
|
str_dnserr db 3, '5* Unable to resolve hostname', 10, 0
|
||||||
str_refused db 3, '5* Connection refused', 10, 0
|
str_refused db 3, '5* Connection refused', 10, 0
|
||||||
str_disconnected db 3, '5* Server disconnected', 10, 0
|
str_srv_disconnected db 3, '5* Server disconnected', 10, 0
|
||||||
|
str_disconnected db 3, '5* Disconnected', 10, 0
|
||||||
str_reconnect db 3, '5* Connection reset by user', 10, 0
|
str_reconnect db 3, '5* Connection reset by user', 10, 0
|
||||||
str_notconnected db 3, '5* Not connected to server', 10, 0
|
str_notconnected db 3, '5* Not connected to server', 10, 0
|
||||||
|
str_notchannel db 3, '5* You are not on a channel', 10, 0
|
||||||
|
|
||||||
str_1 db 3, '13 -', 0
|
str_1 db 3, '13 -', 0
|
||||||
str_2 db '- ', 0
|
str_2 db '- ', 0
|
||||||
|
@ -109,7 +109,7 @@ socket_connect:
|
|||||||
call print_asciiz
|
call print_asciiz
|
||||||
|
|
||||||
mov esi, quit_msg
|
mov esi, quit_msg
|
||||||
call cmd_usr_quit.with_message
|
call quit_server
|
||||||
|
|
||||||
jmp socket_connect
|
jmp socket_connect
|
||||||
|
|
||||||
@ -250,7 +250,10 @@ socket_receive:
|
|||||||
|
|
||||||
|
|
||||||
.disconnected:
|
.disconnected:
|
||||||
mov esi, str_disconnected
|
if TIMESTAMP
|
||||||
|
call print_timestamp
|
||||||
|
end if
|
||||||
|
mov esi, str_srv_disconnected
|
||||||
call print_asciiz
|
call print_asciiz
|
||||||
|
|
||||||
mov [status], STATUS_DISCONNECTED
|
mov [status], STATUS_DISCONNECTED
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
user_parser:
|
user_parser:
|
||||||
|
|
||||||
push [window_active] ; print to the current window
|
mov ebp, [window_active] ; print to the current window
|
||||||
pop [window_print]
|
mov [window_print], ebp
|
||||||
|
|
||||||
mov eax, [edit1.size]
|
mov eax, [edit1.size]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -22,15 +22,17 @@ user_parser:
|
|||||||
mov word[usercommand + eax], 0x0a0d ; terminate the line
|
mov word[usercommand + eax], 0x0a0d ; terminate the line
|
||||||
|
|
||||||
cmp byte[usercommand], '/' ; is it a server command ?
|
cmp byte[usercommand], '/' ; is it a server command ?
|
||||||
je server_command
|
je .command
|
||||||
|
|
||||||
; Ignore data commands when not connected.
|
|
||||||
cmp [status], STATUS_CONNECTED
|
cmp [status], STATUS_CONNECTED
|
||||||
jne .notconnected
|
jne .not_connected
|
||||||
|
|
||||||
; Ok, we said something, print it to our textbox
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
||||||
; TODO: dont send if it's a server window?
|
je .send_privmsg
|
||||||
|
cmp [ebp + window.type], WINDOWTYPE_CHAT
|
||||||
|
jne .not_channel
|
||||||
|
|
||||||
|
.send_privmsg:
|
||||||
if TIMESTAMP
|
if TIMESTAMP
|
||||||
call print_timestamp
|
call print_timestamp
|
||||||
end if
|
end if
|
||||||
@ -59,8 +61,7 @@ user_parser:
|
|||||||
mov dword[packetbuf], 'PRIV'
|
mov dword[packetbuf], 'PRIV'
|
||||||
mov dword[packetbuf+4], 'MSG '
|
mov dword[packetbuf+4], 'MSG '
|
||||||
|
|
||||||
mov esi, [window_active]
|
lea esi, [ebp + window.name]
|
||||||
add esi, window.name
|
|
||||||
mov edi, packetbuf+8
|
mov edi, packetbuf+8
|
||||||
mov ecx, MAX_WINDOWNAME_LEN
|
mov ecx, MAX_WINDOWNAME_LEN
|
||||||
.loop:
|
.loop:
|
||||||
@ -86,18 +87,53 @@ user_parser:
|
|||||||
|
|
||||||
lea esi, [edi - packetbuf]
|
lea esi, [edi - packetbuf]
|
||||||
mcall send, [socketnum], packetbuf, , 0
|
mcall send, [socketnum], packetbuf, , 0
|
||||||
.ret:
|
|
||||||
|
|
||||||
|
.ret:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.notconnected:
|
; Text begins with a '/' lets try to find the command in the lookup table.
|
||||||
|
.command:
|
||||||
|
mov eax, dword[usercommand+1] ; skip '/'
|
||||||
|
or eax, 0x20202020 ; convert to lowercase
|
||||||
|
|
||||||
|
mov edi, user_commands
|
||||||
|
mov ecx, user_commands.number
|
||||||
|
cmp [status], STATUS_CONNECTED
|
||||||
|
je .cmd_loop
|
||||||
|
mov ecx, user_commands.number2
|
||||||
|
.cmd_loop:
|
||||||
|
scasd
|
||||||
|
je .got_cmd
|
||||||
|
add edi, 4
|
||||||
|
dec ecx
|
||||||
|
jnz .cmd_loop
|
||||||
|
|
||||||
|
cmp [status], STATUS_CONNECTED
|
||||||
|
jne .not_connected
|
||||||
|
|
||||||
|
; Commands shorter then 3 chars are placed here
|
||||||
|
and eax, 0x00ffffff
|
||||||
|
cmp eax, 'me '
|
||||||
|
je cmd_usr_me
|
||||||
|
|
||||||
|
; If none of the listed commands, send text straight to server
|
||||||
|
jmp cmd_usr_send
|
||||||
|
|
||||||
|
.got_cmd:
|
||||||
|
jmp dword[edi]
|
||||||
|
|
||||||
|
.not_connected:
|
||||||
mov esi, str_notconnected
|
mov esi, str_notconnected
|
||||||
call print_asciiz
|
call print_asciiz
|
||||||
|
ret
|
||||||
|
|
||||||
|
.not_channel:
|
||||||
|
mov esi, str_notchannel
|
||||||
|
call print_asciiz
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
; user commands lookup table
|
||||||
user_commands:
|
user_commands:
|
||||||
dd 'nick', cmd_usr_nick
|
dd 'nick', cmd_usr_nick
|
||||||
dd 'real', cmd_usr_real
|
dd 'real', cmd_usr_real
|
||||||
@ -117,42 +153,6 @@ user_commands:
|
|||||||
.number = ($ - user_commands) / 8
|
.number = ($ - user_commands) / 8
|
||||||
|
|
||||||
|
|
||||||
server_command:
|
|
||||||
|
|
||||||
mov eax, dword[usercommand+1] ; skip '/'
|
|
||||||
or eax, 0x20202020 ; convert to lowercase
|
|
||||||
|
|
||||||
mov edi, user_commands
|
|
||||||
mov ecx, user_commands.number
|
|
||||||
cmp [status], STATUS_CONNECTED
|
|
||||||
je .loop
|
|
||||||
mov ecx, user_commands.number2
|
|
||||||
.loop:
|
|
||||||
scasd
|
|
||||||
je .got_cmd
|
|
||||||
add edi, 4
|
|
||||||
dec ecx
|
|
||||||
jnz .loop
|
|
||||||
|
|
||||||
cmp [status], STATUS_CONNECTED
|
|
||||||
jne .notconnected
|
|
||||||
; Commands shorter then 3 chars are placed here
|
|
||||||
and eax, 0x00ffffff
|
|
||||||
cmp eax, 'me '
|
|
||||||
je cmd_usr_me
|
|
||||||
|
|
||||||
jmp cmd_usr_send ; If none of the previous commands, just send to server
|
|
||||||
|
|
||||||
.got_cmd:
|
|
||||||
jmp dword[edi]
|
|
||||||
|
|
||||||
.notconnected:
|
|
||||||
mov esi, str_notconnected
|
|
||||||
call print_asciiz
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd_usr_msg:
|
cmd_usr_msg:
|
||||||
|
|
||||||
@ -224,34 +224,14 @@ cmd_usr_msg:
|
|||||||
|
|
||||||
|
|
||||||
cmd_usr_quit:
|
cmd_usr_quit:
|
||||||
|
|
||||||
mov esi, quit_msg
|
mov esi, quit_msg
|
||||||
|
|
||||||
cmp byte[usercommand+5], ' '
|
cmp byte[usercommand+5], ' '
|
||||||
jne .with_message
|
jne quit_server
|
||||||
lea esi, [usercommand+6]
|
lea esi, [usercommand+6]
|
||||||
.with_message:
|
|
||||||
call cmd_usr_quit_server
|
|
||||||
|
|
||||||
mcall close, [socketnum]
|
|
||||||
mov [status], STATUS_DISCONNECTED
|
|
||||||
|
|
||||||
mov ecx, MAX_WINDOWS
|
|
||||||
mov edi, windows
|
|
||||||
.loop:
|
|
||||||
mov [window_print], edi
|
|
||||||
push edi ecx
|
|
||||||
call window_close
|
|
||||||
pop ecx edi
|
|
||||||
add edi, sizeof.window
|
|
||||||
dec ecx
|
|
||||||
jnz .loop
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; esi = quit message
|
; esi = quit message
|
||||||
cmd_usr_quit_server:
|
quit_server:
|
||||||
|
|
||||||
; User wants to close a channel, send PART command to server
|
; User wants to close a channel, send PART command to server
|
||||||
mov dword[packetbuf], 'QUIT'
|
mov dword[packetbuf], 'QUIT'
|
||||||
@ -274,6 +254,27 @@ cmd_usr_quit_server:
|
|||||||
lea esi, [edi - packetbuf] ; calculate length
|
lea esi, [edi - packetbuf] ; calculate length
|
||||||
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
||||||
|
|
||||||
|
mov ebp, windows
|
||||||
|
.window_loop:
|
||||||
|
cmp [ebp + window.type], WINDOWTYPE_NONE
|
||||||
|
je .next_window
|
||||||
|
mov [window_print], ebp
|
||||||
|
if TIMESTAMP
|
||||||
|
call print_timestamp
|
||||||
|
end if
|
||||||
|
mov esi, str_disconnected
|
||||||
|
call print_asciiz
|
||||||
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
||||||
|
jne .next_window
|
||||||
|
call user_remove_all
|
||||||
|
.next_window:
|
||||||
|
add ebp, sizeof.window
|
||||||
|
cmp ebp, windows + (MAX_WINDOWS * sizeof.window)
|
||||||
|
jb .window_loop
|
||||||
|
|
||||||
|
mov [status], STATUS_DISCONNECTED
|
||||||
|
mcall close, [socketnum]
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -368,6 +369,10 @@ cmd_usr_server:
|
|||||||
cmp eax, 'er '
|
cmp eax, 'er '
|
||||||
jne cmd_usr_send
|
jne cmd_usr_send
|
||||||
|
|
||||||
|
; Server window is always first window in the list, switch to it.
|
||||||
|
mov [window_print], windows
|
||||||
|
mov [window_active], windows
|
||||||
|
|
||||||
mov ecx, [edit1.size] ; ok now set the address
|
mov ecx, [edit1.size] ; ok now set the address
|
||||||
sub ecx, 8
|
sub ecx, 8
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Written by hidnplayr@kolibrios.org ;;
|
;; Written by hidnplayr@kolibrios.org ;;
|
||||||
@ -22,7 +22,7 @@ align 4
|
|||||||
user_add:
|
user_add:
|
||||||
|
|
||||||
cmp [ebx + window.users], MAX_USERS
|
cmp [ebx + window.users], MAX_USERS
|
||||||
jae fail
|
jae .fail
|
||||||
|
|
||||||
mov edi, [ebx + window.data_ptr]
|
mov edi, [ebx + window.data_ptr]
|
||||||
add edi, window_data.names
|
add edi, window_data.names
|
||||||
@ -115,7 +115,7 @@ user_add:
|
|||||||
|
|
||||||
inc [ebx + window.users]
|
inc [ebx + window.users]
|
||||||
or [ebx + window.flags], FLAG_UPDATED
|
or [ebx + window.flags], FLAG_UPDATED
|
||||||
|
.fail:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ align 4
|
|||||||
user_remove:
|
user_remove:
|
||||||
|
|
||||||
call user_find
|
call user_find
|
||||||
jz fail
|
jz .fail
|
||||||
|
|
||||||
lea esi, [edi + MAX_NICK_LEN]
|
lea esi, [edi + MAX_NICK_LEN]
|
||||||
mov ecx, [ebx + window.data_ptr]
|
mov ecx, [ebx + window.data_ptr]
|
||||||
@ -139,7 +139,7 @@ user_remove:
|
|||||||
|
|
||||||
dec [ebx + window.users]
|
dec [ebx + window.users]
|
||||||
or [ebx + window.flags], FLAG_UPDATED
|
or [ebx + window.flags], FLAG_UPDATED
|
||||||
|
.fail:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ user_find:
|
|||||||
|
|
||||||
mov eax, [ebx + window.users]
|
mov eax, [ebx + window.users]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz fail
|
jz .fail
|
||||||
mov edi, [ebx + window.data_ptr]
|
mov edi, [ebx + window.data_ptr]
|
||||||
add edi, window_data.names
|
add edi, window_data.names
|
||||||
|
|
||||||
@ -169,16 +169,28 @@ user_find:
|
|||||||
add edi, MAX_NICK_LEN
|
add edi, MAX_NICK_LEN
|
||||||
dec eax
|
dec eax
|
||||||
jnz .loop
|
jnz .loop
|
||||||
jmp fail
|
jmp .fail
|
||||||
|
|
||||||
.got_it:
|
.got_it:
|
||||||
pop edi esi
|
pop edi esi
|
||||||
test edi, edi ; to clear zero flag
|
test edi, edi ; to clear zero flag
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.fail:
|
||||||
fail:
|
|
||||||
|
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
user_remove_all:
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
|
mov edi, [window_print]
|
||||||
|
mov [edi + window.users], eax
|
||||||
|
mov [edi + window.selected], eax
|
||||||
|
mov edi, [edi + window.data_ptr]
|
||||||
|
add edi, window_data.names
|
||||||
|
mov ecx, MAX_NICK_LEN * MAX_USERS / 4
|
||||||
|
rep stosd
|
||||||
|
|
||||||
|
ret
|
Loading…
Reference in New Issue
Block a user