forked from KolibriOS/kolibrios
IRCc 0.26: Fixed bug when nickname was already in use, fixed bug in encoding of user typed text.
git-svn-id: svn://kolibrios.org@6027 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
97df225ad2
commit
3e023d2d81
@ -13,13 +13,14 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
version equ '0.25'
|
version equ '0.26'
|
||||||
|
|
||||||
; connection status
|
; connection status
|
||||||
STATUS_DISCONNECTED = 0
|
STATUS_DISCONNECTED = 0
|
||||||
STATUS_RESOLVING = 1
|
STATUS_RESOLVING = 1
|
||||||
STATUS_CONNECTING = 2
|
STATUS_CONNECTING = 2
|
||||||
STATUS_CONNECTED = 3
|
STATUS_CONNECTED = 3
|
||||||
|
STATUS_LOGGED_IN = 4
|
||||||
|
|
||||||
; window flags
|
; window flags
|
||||||
FLAG_UPDATED = 1 shl 0
|
FLAG_UPDATED = 1 shl 0
|
||||||
@ -473,8 +474,9 @@ str_refused db 3, '5* Connection refused', 10, 0
|
|||||||
str_srv_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_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* You are not connected', 10, 0
|
||||||
str_notchannel db 3, '5* You are not on a channel', 10, 0
|
str_notchannel db 3, '5* You are not on a channel', 10, 0
|
||||||
|
str_notloggedin db 3, '5* You are not logged in to the server', 10, 0
|
||||||
|
|
||||||
str_1 db 3, '13 -', 0
|
str_1 db 3, '13 -', 0
|
||||||
str_2 db '- ', 0
|
str_2 db '- ', 0
|
||||||
@ -571,16 +573,19 @@ import boxlib,\
|
|||||||
scrollbar_mouse,'scrollbar_v_mouse'
|
scrollbar_mouse,'scrollbar_v_mouse'
|
||||||
|
|
||||||
; width, left, top
|
; width, left, top
|
||||||
edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_always_focus, 25, 25
|
edit1 edit_box 0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0x000000, USERCMD_MAX_SIZE, input_text, mouse_dd, ed_always_focus, 25, 25
|
||||||
; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol
|
; xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol
|
||||||
scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
|
scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
|
||||||
scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
|
scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
|
||||||
|
|
||||||
usercommand db '/server chat.freenode.net', 0
|
input_text db '/server chat.freenode.net', 0
|
||||||
rb MAX_COMMAND_LEN
|
rb MAX_COMMAND_LEN
|
||||||
|
|
||||||
I_END:
|
I_END:
|
||||||
|
|
||||||
|
user_command rb MAX_COMMAND_LEN*4
|
||||||
|
.size dd ?
|
||||||
|
|
||||||
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence
|
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence
|
||||||
utf8_char dd ? ; first bits of current UTF8 character
|
utf8_char dd ? ; first bits of current UTF8 character
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ server_parser:
|
|||||||
|
|
||||||
server_commands:
|
server_commands:
|
||||||
|
|
||||||
dd '001 ', cmd_justprint
|
dd '001 ', cmd_welcome
|
||||||
dd '002 ', cmd_justprint
|
dd '002 ', cmd_justprint
|
||||||
dd '003 ', cmd_justprint
|
dd '003 ', cmd_justprint
|
||||||
dd '004 ', cmd_justprint
|
dd '004 ', cmd_justprint
|
||||||
@ -80,7 +80,9 @@ server_commands:
|
|||||||
dd '375 ', cmd_justprint ; start of motd
|
dd '375 ', cmd_justprint ; start of motd
|
||||||
dd '376 ', cmd_justprint ; end of motd
|
dd '376 ', cmd_justprint ; end of motd
|
||||||
dd '421 ', cmd_justprint ; unknown command
|
dd '421 ', cmd_justprint ; unknown command
|
||||||
|
dd '432 ', cmd_justprint ; erroneous nickname
|
||||||
dd '433 ', cmd_justprint ; nickname already in use
|
dd '433 ', cmd_justprint ; nickname already in use
|
||||||
|
dd '436 ', cmd_justprint ; nickname collision
|
||||||
|
|
||||||
dd 'join', cmd_join
|
dd 'join', cmd_join
|
||||||
dd 'kick', cmd_kick
|
dd 'kick', cmd_kick
|
||||||
@ -170,7 +172,9 @@ skip_parameter:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cmd_welcome:
|
||||||
|
|
||||||
|
mov [status], STATUS_LOGGED_IN
|
||||||
|
|
||||||
cmd_justprint:
|
cmd_justprint:
|
||||||
|
|
||||||
@ -185,6 +189,7 @@ cmd_justprint:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd_notice:
|
cmd_notice:
|
||||||
|
|
||||||
if TIMESTAMP
|
if TIMESTAMP
|
||||||
@ -466,11 +471,11 @@ cmd_dcc:
|
|||||||
ctcp_reply:
|
ctcp_reply:
|
||||||
|
|
||||||
push esi
|
push esi
|
||||||
mov dword [usercommand], 'NOTI'
|
mov dword[user_command], 'NOTI'
|
||||||
mov dword [usercommand+4], 'CE '
|
mov dword[user_command+4], 'CE '
|
||||||
|
|
||||||
mov esi, servercommand+1
|
mov esi, servercommand+1
|
||||||
mov edi, usercommand+7
|
mov edi, user_command+7
|
||||||
.nickloop:
|
.nickloop:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, '!'
|
cmp al, '!'
|
||||||
@ -502,8 +507,8 @@ ctcp_reply:
|
|||||||
mov ax, 0x0a0d
|
mov ax, 0x0a0d
|
||||||
stosw
|
stosw
|
||||||
|
|
||||||
lea esi, [edi - usercommand]
|
lea esi, [edi - user_command]
|
||||||
mcall send, [socketnum], usercommand, , 0
|
mcall send, [socketnum], user_command, , 0
|
||||||
.fail:
|
.fail:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -13,19 +13,25 @@
|
|||||||
|
|
||||||
user_parser:
|
user_parser:
|
||||||
|
|
||||||
mov ebp, [window_active] ; print to the current window
|
mov ebp, [window_active] ; print to the current window
|
||||||
mov [window_print], ebp
|
mov [window_print], ebp
|
||||||
|
|
||||||
mov eax, [edit1.size]
|
mov ecx, [edit1.size]
|
||||||
test eax, eax
|
test ecx, ecx
|
||||||
jz .ret ; ignore empty commands
|
jz .ret ; ignore empty commands
|
||||||
mov word[usercommand + eax], 0x0a0d ; terminate the line
|
|
||||||
|
|
||||||
cmp byte[usercommand], '/' ; is it a server command ?
|
mov esi, input_text
|
||||||
|
mov edi, user_command
|
||||||
|
call recode ; Convert to UTF-8
|
||||||
|
mov word[edi], 0x0a0d ; terminate the line
|
||||||
|
sub edi, user_command
|
||||||
|
mov [user_command.size], edi
|
||||||
|
|
||||||
|
cmp byte[user_command], '/' ; is it a server command ?
|
||||||
je .command
|
je .command
|
||||||
|
|
||||||
cmp [status], STATUS_CONNECTED
|
cmp [status], STATUS_LOGGED_IN
|
||||||
jne .not_connected
|
jne .not_loggedin
|
||||||
|
|
||||||
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
||||||
je .send_privmsg
|
je .send_privmsg
|
||||||
@ -48,10 +54,9 @@ user_parser:
|
|||||||
mov al, ' '
|
mov al, ' '
|
||||||
call print_char
|
call print_char
|
||||||
|
|
||||||
mov eax, [edit1.size]
|
mov eax, [user_command.size]
|
||||||
mov byte[usercommand + eax],0
|
mov byte[user_command + eax],0
|
||||||
|
mov esi, user_command
|
||||||
mov esi, usercommand
|
|
||||||
call print_asciiz
|
call print_asciiz
|
||||||
|
|
||||||
mov al, 10
|
mov al, 10
|
||||||
@ -76,10 +81,10 @@ user_parser:
|
|||||||
mov ax, ' :'
|
mov ax, ' :'
|
||||||
stosw
|
stosw
|
||||||
|
|
||||||
mov esi, usercommand
|
mov esi, user_command
|
||||||
mov ecx, [edit1.size]
|
mov ecx, [user_command.size]
|
||||||
inc ecx
|
; inc ecx
|
||||||
call recode
|
rep movsb
|
||||||
|
|
||||||
; end the command with a CRLF
|
; end the command with a CRLF
|
||||||
mov ax, 0x0a0d
|
mov ax, 0x0a0d
|
||||||
@ -93,13 +98,13 @@ user_parser:
|
|||||||
|
|
||||||
; Text begins with a '/' lets try to find the command in the lookup table.
|
; Text begins with a '/' lets try to find the command in the lookup table.
|
||||||
.command:
|
.command:
|
||||||
mov eax, dword[usercommand+1] ; skip '/'
|
mov eax, dword[user_command+1] ; skip '/'
|
||||||
or eax, 0x20202020 ; convert to lowercase
|
or eax, 0x20202020 ; convert to lowercase
|
||||||
|
|
||||||
mov edi, user_commands
|
mov edi, user_commands
|
||||||
mov ecx, user_commands.number
|
mov ecx, user_commands.number
|
||||||
cmp [status], STATUS_CONNECTED
|
cmp [status], STATUS_CONNECTED
|
||||||
je .cmd_loop
|
jae .cmd_loop
|
||||||
mov ecx, user_commands.number2
|
mov ecx, user_commands.number2
|
||||||
.cmd_loop:
|
.cmd_loop:
|
||||||
scasd
|
scasd
|
||||||
@ -109,7 +114,7 @@ user_parser:
|
|||||||
jnz .cmd_loop
|
jnz .cmd_loop
|
||||||
|
|
||||||
cmp [status], STATUS_CONNECTED
|
cmp [status], STATUS_CONNECTED
|
||||||
jne .not_connected
|
jb .not_connected
|
||||||
|
|
||||||
; Commands shorter then 3 chars are placed here
|
; Commands shorter then 3 chars are placed here
|
||||||
and eax, 0x00ffffff
|
and eax, 0x00ffffff
|
||||||
@ -122,6 +127,11 @@ user_parser:
|
|||||||
.got_cmd:
|
.got_cmd:
|
||||||
jmp dword[edi]
|
jmp dword[edi]
|
||||||
|
|
||||||
|
.not_loggedin:
|
||||||
|
mov esi, str_notloggedin
|
||||||
|
call print_asciiz
|
||||||
|
ret
|
||||||
|
|
||||||
.not_connected:
|
.not_connected:
|
||||||
mov esi, str_notconnected
|
mov esi, str_notconnected
|
||||||
call print_asciiz
|
call print_asciiz
|
||||||
@ -156,7 +166,7 @@ user_commands:
|
|||||||
|
|
||||||
cmd_usr_msg:
|
cmd_usr_msg:
|
||||||
|
|
||||||
lea esi, [usercommand+5]
|
lea esi, [user_command+5]
|
||||||
|
|
||||||
mov dword[packetbuf], 'PRIV'
|
mov dword[packetbuf], 'PRIV'
|
||||||
mov dword[packetbuf+4], 'MSG '
|
mov dword[packetbuf+4], 'MSG '
|
||||||
@ -226,9 +236,9 @@ cmd_usr_msg:
|
|||||||
cmd_usr_quit:
|
cmd_usr_quit:
|
||||||
|
|
||||||
mov esi, quit_msg
|
mov esi, quit_msg
|
||||||
cmp byte[usercommand+5], ' '
|
cmp byte[user_command+5], ' '
|
||||||
jne quit_server
|
jne quit_server
|
||||||
lea esi, [usercommand+6]
|
lea esi, [user_command+6]
|
||||||
|
|
||||||
; esi = quit message
|
; esi = quit message
|
||||||
quit_server:
|
quit_server:
|
||||||
@ -282,19 +292,19 @@ quit_server:
|
|||||||
|
|
||||||
cmd_usr_nick:
|
cmd_usr_nick:
|
||||||
|
|
||||||
cmp [edit1.size], 5
|
cmp [user_command.size], 5
|
||||||
je .justprint
|
je .justprint
|
||||||
cmp byte[usercommand+5], ' '
|
cmp byte[user_command+5], ' '
|
||||||
jne .fail
|
jne .fail
|
||||||
cmp [socketnum], 0
|
cmp [socketnum], 0
|
||||||
je .dontsend
|
je .dontsend
|
||||||
|
|
||||||
; Request nickname change to server
|
; Request nickname change to server
|
||||||
mov dword[usercommand+1], 'NICK'
|
mov dword[user_command+1], 'NICK'
|
||||||
mov esi, [edit1.size]
|
mov esi, [user_command.size]
|
||||||
mov word[usercommand + esi], 0x0a0d
|
mov word[user_command + esi], 0x0a0d
|
||||||
inc esi
|
inc esi
|
||||||
mcall send, [socketnum], usercommand+1, , 0
|
mcall send, [socketnum], user_command+1, , 0
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
ret
|
ret
|
||||||
@ -302,7 +312,7 @@ cmd_usr_nick:
|
|||||||
; We arent logged in yet, directly change user_nick field and print notification to user.
|
; We arent logged in yet, directly change user_nick field and print notification to user.
|
||||||
.dontsend:
|
.dontsend:
|
||||||
mov ecx, MAX_NICK_LEN
|
mov ecx, MAX_NICK_LEN
|
||||||
mov esi, usercommand+6
|
mov esi, user_command+6
|
||||||
mov edi, user_nick
|
mov edi, user_nick
|
||||||
@@:
|
@@:
|
||||||
lodsb
|
lodsb
|
||||||
@ -331,11 +341,11 @@ cmd_usr_nick:
|
|||||||
|
|
||||||
cmd_usr_real:
|
cmd_usr_real:
|
||||||
|
|
||||||
cmp byte[usercommand+5], ' '
|
cmp byte[user_command+5], ' '
|
||||||
jne cmd_usr_send
|
jne cmd_usr_send
|
||||||
|
|
||||||
mov ecx, MAX_REAL_LEN
|
mov ecx, MAX_REAL_LEN
|
||||||
mov esi, usercommand+6
|
mov esi, user_command+6
|
||||||
mov edi, user_real_name
|
mov edi, user_real_name
|
||||||
.loop:
|
.loop:
|
||||||
lodsb
|
lodsb
|
||||||
@ -363,7 +373,7 @@ cmd_usr_real:
|
|||||||
|
|
||||||
cmd_usr_server:
|
cmd_usr_server:
|
||||||
|
|
||||||
mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv'
|
mov eax, dword[user_command+5] ; check for 'er ', we only checked 'serv'
|
||||||
or eax, 0x00002020
|
or eax, 0x00002020
|
||||||
and eax, 0x00ffffff
|
and eax, 0x00ffffff
|
||||||
cmp eax, 'er '
|
cmp eax, 'er '
|
||||||
@ -373,10 +383,10 @@ cmd_usr_server:
|
|||||||
mov [window_print], windows
|
mov [window_print], windows
|
||||||
mov [window_active], windows
|
mov [window_active], windows
|
||||||
|
|
||||||
mov ecx, [edit1.size] ; ok now set the address
|
mov ecx, [user_command.size] ; ok now set the address
|
||||||
sub ecx, 8
|
sub ecx, 8
|
||||||
|
|
||||||
mov esi, usercommand+8
|
mov esi, user_command+8
|
||||||
.now:
|
.now:
|
||||||
push esi
|
push esi
|
||||||
mov edi, irc_server_name
|
mov edi, irc_server_name
|
||||||
@ -404,7 +414,7 @@ cmd_usr_server:
|
|||||||
|
|
||||||
cmd_usr_quer:
|
cmd_usr_quer:
|
||||||
|
|
||||||
mov esi, usercommand+7
|
mov esi, user_command+7
|
||||||
call window_open
|
call window_open
|
||||||
; test ebx, ebx
|
; test ebx, ebx
|
||||||
; jz .fail
|
; jz .fail
|
||||||
@ -433,7 +443,7 @@ cmd_usr_code:
|
|||||||
; User typed a part command
|
; User typed a part command
|
||||||
cmd_usr_part:
|
cmd_usr_part:
|
||||||
|
|
||||||
cmp byte[usercommand+5], 13 ; parameters given?
|
cmp byte[user_command+5], 13 ; parameters given?
|
||||||
jne cmd_usr_send ; yes, send command straight to server
|
jne cmd_usr_send ; yes, send command straight to server
|
||||||
|
|
||||||
; close active window
|
; close active window
|
||||||
@ -492,10 +502,10 @@ cmd_usr_part_channel:
|
|||||||
|
|
||||||
cmd_usr_ctcp:
|
cmd_usr_ctcp:
|
||||||
|
|
||||||
cmp byte[usercommand+5], ' '
|
cmp byte[user_command+5], ' '
|
||||||
jne cmd_usr_send
|
jne cmd_usr_send
|
||||||
|
|
||||||
mov esi, usercommand+6
|
mov esi, user_command+6
|
||||||
; prepare a 'PRIVMSG '
|
; prepare a 'PRIVMSG '
|
||||||
mov dword[packetbuf], 'PRIV'
|
mov dword[packetbuf], 'PRIV'
|
||||||
mov dword[packetbuf+4], 'MSG '
|
mov dword[packetbuf+4], 'MSG '
|
||||||
@ -575,7 +585,7 @@ cmd_usr_me:
|
|||||||
stosb
|
stosb
|
||||||
|
|
||||||
; copy the message itself (including first space)
|
; copy the message itself (including first space)
|
||||||
mov esi, usercommand+3
|
mov esi, user_command+3
|
||||||
@@:
|
@@:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 13
|
cmp al, 13
|
||||||
@ -605,7 +615,7 @@ cmd_usr_me:
|
|||||||
mov esi, user_nick
|
mov esi, user_nick
|
||||||
call print_asciiz
|
call print_asciiz
|
||||||
|
|
||||||
mov esi, usercommand+3
|
mov esi, user_command+3
|
||||||
mov bl, 13
|
mov bl, 13
|
||||||
call print_string
|
call print_string
|
||||||
|
|
||||||
@ -616,17 +626,15 @@ cmd_usr_me:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
; The user typed some undefined command, just recode it and send to the server
|
; The user typed some undefined command, just send it to the server
|
||||||
cmd_usr_send:
|
cmd_usr_send:
|
||||||
|
|
||||||
mov esi, usercommand+1
|
mov esi, [user_command.size]
|
||||||
mov ecx, [edit1.size]
|
mov eax, [user_command.size]
|
||||||
inc ecx
|
add eax, user_command+1
|
||||||
mov edi, packetbuf
|
mov word[eax], 0x0d0a
|
||||||
call recode
|
inc esi
|
||||||
|
mcall send, [socketnum], user_command+1, , 0
|
||||||
lea esi, [edi - packetbuf]
|
|
||||||
mcall send, [socketnum], packetbuf, , 0
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user