IRCc 0.31: Clear data on exit, print unknown CTCP commands to window, replace some magic numbers with constants (thanks floppy121).

git-svn-id: svn://kolibrios.org@7300 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2018-07-01 14:29:23 +00:00
parent 82e469a233
commit 321ff86117
6 changed files with 163 additions and 49 deletions

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -56,6 +56,9 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and
test [thread_info.wnd_state], 100b ; skip if window is rolled up
jne .exit
cmp [window_active], 0
je .no_window
; calculate available space for textbox and coordinates for scrollbars
mov eax, [ysize]
sub eax, TOP_Y + INPUTBOX_HEIGHT - 1
@ -128,6 +131,7 @@ draw_window: ; Completely redraw the window, recalculate all coordinates and
mov edx, [colors.work_graph]
mcall 38
.not_channel:
.no_window:
; draw editbox
mov eax, [ysize]

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; IRC client for KolibriOS ;;
@ -13,7 +13,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
version equ '0.30'
version equ '0.31'
; connection status
STATUS_DISCONNECTED = 0
@ -62,6 +62,7 @@ TEXT_BUFFERSIZE = 1024*1024
MAX_NICK_LEN = 32
MAX_REAL_LEN = 32 ; realname
QUIT_MSG_LEN = 250
MAX_SERVER_NAME = 256
MAX_CHANNEL_LEN = 40
@ -69,6 +70,11 @@ MAX_CHANNELS = 37
MAX_COMMAND_LEN = 512
PACKETBUF_SIZE = 1024
PATH_SIZE = 1024
PARAM_SIZE = 1024
SERVERCOMMAND_SIZE = 600
TIMESTAMP = 3 ; 3 = hh:mm:ss, 2 = hh:mm, 0 = no timestamp
MAX_WINDOWNAME_LEN = 256
@ -154,7 +160,7 @@ START:
; find path to main settings file (ircc.ini)
mov edi, path ; Calculate the length of zero-terminated string
xor al, al
mov ecx, 1024
mov ecx, PATH_SIZE
repne scasb
dec edi
mov eax, '.ini'
@ -170,14 +176,14 @@ START:
; clear command area too
mov edi, servercommand
mov ecx, 600/4
mov ecx, SERVERCOMMAND_SIZE/4
rep stosd
; allocate window data block
mov ebx, windows
call window_create_textbox
test eax, eax
jz error
jz exit
mov [ebx + window.type], WINDOWTYPE_SERVER
; get system colors
@ -212,7 +218,7 @@ START:
cmp byte[param], 0
je @f
mov esi, param
mov ecx, 1024
mov ecx, PARAM_SIZE
call cmd_usr_server.now
@@:
@ -255,7 +261,7 @@ button:
ror eax, 8
cmp ax, 1 ; close program
je exit
je quit
cmp ax, WINDOW_BTN_CLOSE
jne @f
@ -318,10 +324,10 @@ button:
@@:
sub ax, WINDOW_BTN_START
jb exit
jb quit
cmp ax, MAX_WINDOWS
ja exit
ja quit
; Save users scrollbar position
push [scroll1.position]
@ -335,7 +341,7 @@ button:
mov dx, ax
add edx, windows
cmp [edx + window.type], WINDOWTYPE_NONE
je exit
je quit
mov [window_active], edx
push [edx + window.text_line_print]
@ -347,15 +353,35 @@ button:
call draw_window
jmp mainloop
exit:
quit:
cmp [socketnum], 0
je @f
mov esi, quit_msg
call quit_server
@@:
error:
exit:
; Close all open windows
call window_close_all
; Erase RAM areas which could contain the connection details
xor eax, eax
mov edi, irc_server_name
mov ecx, MAX_SERVER_NAME
rep stosb
mov edi, user_nick
mov ecx, MAX_NICK_LEN
rep stosb
mov edi, user_real_name
mov ecx, MAX_REAL_LEN
rep stosb
mov edi, sockaddr1
mov ecx, SOCKADDR1_SIZE
rep stosb
mcall -1
@ -459,6 +485,7 @@ part_header db 3, '5* ', 0
topic_header db 3, '3* ', 0
action_header db 3, '6* ', 0
ctcp_header db 3, '13-> [', 0
ctcp_header_recv db 3, '13', 0
msg_header db 3, '7-> *', 0
ctcp_version db '] VERSION', 10, 0
ctcp_ping db '] PING', 10, 0
@ -505,9 +532,9 @@ str_help db 'The following commands are available:', 10
db '/part <channel> : part from a channel', 10
db '/quit : quit server', 10
db '/msg <user> : send a private message', 10
db '/ctcp <user> : send a message using client to client protocol', 10
db '/ctcp <user> : send a message using client-to-client protocol', 10
db 10
db 'Other commands are send straight to server.', 10
db 'Other commands are sent straight to a server', 10
db 10, 0
str_welcome db 3, '3 ___', 3, '7__________', 3, '6_________ ', 3, '4 __ __ __', 10
@ -555,6 +582,7 @@ sockaddr1:
.ip dd 0
rb 10
SOCKADDR1_SIZE = 18
status dd STATUS_DISCONNECTED
@ -601,11 +629,11 @@ user_command rb MAX_COMMAND_LEN*4
utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence
utf8_char dd ? ; first bits of current UTF8 character
packetbuf rb 1024 ; buffer for packets to server
path rb 1024
param rb 1024
packetbuf rb PACKETBUF_SIZE ; buffer for packets to server
path rb PATH_SIZE
param rb PARAM_SIZE
servercommand rb 600
servercommand rb SERVERCOMMAND_SIZE
thread_info process_information
xsize dd ?
@ -622,7 +650,7 @@ socketnum dd ? ; TODO: same for socket
user_nick rb MAX_NICK_LEN
user_real_name rb MAX_REAL_LEN
quit_msg rb 250
quit_msg rb QUIT_MSG_LEN
windows rb MAX_WINDOWS*sizeof.window

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -328,9 +328,38 @@ cmd_ctcp:
cmp eax, 'dcc ' ; TODO
je cmd_dcc
; Unknown CTCP command: TODO: just print to window??
; Unknown CTCP command - just print to window
.fail:
.just_print:
push esi
if TIMESTAMP
call print_timestamp
end if
mov esi, ctcp_header_recv
call print_asciiz
mov al, '<'
call print_char
mov esi, servercommand+1 ; print nickname
mov bl, '!'
call print_string
mov al, '>'
call print_char
mov al, ' '
call print_char
pop esi
mov bl, 1
call print_string
mov al, 10
call print_char
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -213,7 +213,7 @@ socket_receive:
; FIXME: make this a proper stream!
.nextpacket:
mcall recv, [socketnum], packetbuf, 1024, MSG_DONTWAIT ; read a packet
mcall recv, [socketnum], packetbuf, PACKETBUF_SIZE, MSG_DONTWAIT ; read a packet
inc eax ; check if we got any data
jz .done ; TODO: handle errors!
dec eax

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -204,9 +204,6 @@ cmd_usr_msg:
stosw
mov byte[edi], 0
lea esi, [edi - packetbuf]
mcall send, [socketnum], packetbuf, , 0
; now print to the window
if TIMESTAMP
call print_timestamp
@ -226,7 +223,13 @@ cmd_usr_msg:
call print_char
pop esi
push esi
call print_asciiz
pop esi
lea esi, [edi - packetbuf]
mcall send, [socketnum], packetbuf, , 0
.fail:
ret
@ -527,6 +530,8 @@ cmd_usr_ctcp:
mov al, 0x01
stosb
push edi esi
; copy the message itself
@@:
lodsb
@ -545,13 +550,35 @@ cmd_usr_ctcp:
stosb
mov ax, 0x0a0d
stosw
mov byte[edi], 0
; now print to the window
if TIMESTAMP
call print_timestamp
end if
mov esi, ctcp_header
call print_asciiz
mov esi, packetbuf+8
mov bl, ' '
call print_string
mov al, ']'
call print_char
mov al, ' '
call print_char
pop esi
call print_asciiz
pop esi
; now send it away
lea esi, [edi - packetbuf] ; calculate length
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
;; TODO: print to window
.fail:
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -81,6 +81,16 @@ window_set_name:
ret
window_close_all:
.loop:
call window_close
cmp [window_print], 0
jne .loop
ret
window_close: ; closes the 'print' window
@ -97,20 +107,36 @@ window_close: ; closes the 'print' window
xor al, al
rep stosb
; free the window data block
; Clear the window data block to erase the chat history and nicknames
mov edi, [esp]
mov ecx, sizeof.window_data ; TEXT_BUFFERSIZE + MAX_NICK_LEN * MAX_USERS
rep stosb
; And now free the window data block
pop ecx
mcall 68, 13
; We closed this window so we need to show another
; Is there still a window in the active position?
mov edi, [window_active]
cmp [edi + window.data_ptr], 0
jne @f
jne .redraw
; Did we just close the last window?
cmp edi, windows
je .closed_last
; Nope, move one window to the left
sub edi, sizeof.window
mov [window_active], edi
mov [window_print], edi
@@:
jmp .redraw
.closed_last:
xor edi, edi
mov [window_active], edi
mov [window_print], edi
; At last, redraw everything
.redraw:
call draw_window
ret