forked from KolibriOS/kolibrios
Added alphabetic sorting for users in IRCc
git-svn-id: svn://kolibrios.org@3233 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5690f9671b
commit
1373a38089
@ -261,7 +261,7 @@ draw_windownames:
|
||||
inc edx
|
||||
add ebx, 125 shl 16
|
||||
add edi, sizeof.window
|
||||
cmp [edi + + window.data_ptr], 0
|
||||
cmp [edi + window.data_ptr], 0
|
||||
jne .more_btn
|
||||
|
||||
mov eax, 4
|
||||
|
@ -117,6 +117,7 @@ include "serverparser.inc"
|
||||
include "userparser.inc"
|
||||
include "socket.inc"
|
||||
include "gui.inc"
|
||||
include "users.inc"
|
||||
|
||||
|
||||
START:
|
||||
@ -154,7 +155,6 @@ START:
|
||||
rep stosd
|
||||
|
||||
; allocate window data block
|
||||
|
||||
call window_create
|
||||
mov ebx, windows
|
||||
mov [ebx + window.data_ptr], eax
|
||||
@ -343,8 +343,8 @@ str_welcome db 10
|
||||
db 10
|
||||
db 'Type /help for help',10,0
|
||||
|
||||
str_nickchange db 10,'Nickname is now ',0
|
||||
str_realchange db 10,'Real name is now ',0
|
||||
str_nickchange db 'Nickname is now ',0
|
||||
str_realchange db 'Real name is now ',0
|
||||
str_dotnewline db '.',10, 0
|
||||
str_newline db 10, 0
|
||||
str_connecting db 10,'* Connecting to ',0
|
||||
|
@ -303,6 +303,7 @@ end if
|
||||
ret
|
||||
|
||||
.action:
|
||||
add esi, 8
|
||||
push esi
|
||||
if TIMESTAMP
|
||||
call print_timestamp
|
||||
@ -319,7 +320,6 @@ end if
|
||||
call print_character
|
||||
|
||||
pop esi
|
||||
add esi, 8
|
||||
call print_text2
|
||||
|
||||
mov bl, 10
|
||||
@ -513,8 +513,9 @@ cmd_part:
|
||||
mov esi, str_newline
|
||||
call print_text2
|
||||
|
||||
;;; TODO: dec [window.users], remove username from the userlist
|
||||
|
||||
mov ebx, [window_print]
|
||||
mov esi, servercommand+1
|
||||
call user_remove
|
||||
|
||||
ret
|
||||
|
||||
@ -595,7 +596,9 @@ cmd_join:
|
||||
mov esi, str_newline
|
||||
call print_text2
|
||||
|
||||
;;; TODO: inc [window.users], add username to the userlist
|
||||
mov ebx, [window_print]
|
||||
mov esi, servercommand+1
|
||||
call user_add
|
||||
|
||||
ret
|
||||
|
||||
@ -606,10 +609,27 @@ cmd_nick:
|
||||
; NOTE: This command applies to a user, and thus has no specific channel
|
||||
add esi, 5 ; skip 'NICK '
|
||||
|
||||
cmp byte[esi], ':' ; TODO: skip all spaces and semicolons?
|
||||
jne @f
|
||||
inc esi
|
||||
@@:
|
||||
|
||||
; Change the nick in the current userlist. TODO: check other channels too!
|
||||
push esi
|
||||
mov ebx, [window_print]
|
||||
|
||||
mov esi, servercommand+1
|
||||
call user_remove
|
||||
|
||||
mov esi, [esp]
|
||||
call user_add
|
||||
|
||||
call redraw_channel_list
|
||||
|
||||
; Is it me who changed nick?
|
||||
mov edi, servercommand+1
|
||||
call compare_to_nick
|
||||
pop esi
|
||||
jne .not_me
|
||||
|
||||
mov ecx, MAX_NICK_LEN-1
|
||||
@ -627,11 +647,9 @@ cmd_nick:
|
||||
xor al, al
|
||||
stosb
|
||||
pop esi
|
||||
|
||||
.not_me:
|
||||
|
||||
; TODO: if we reach here: change nick in userlist(s)
|
||||
|
||||
; Now print a message on the current channel
|
||||
push esi
|
||||
mov esi, action_header_short
|
||||
call print_text2
|
||||
@ -685,7 +703,9 @@ cmd_kick:
|
||||
mov esi, str_newline
|
||||
call print_text2
|
||||
|
||||
;;; TODO: dec [window.users], remove username from the userlist
|
||||
mov ebx, [window_print]
|
||||
mov esi, servercommand+1
|
||||
call user_remove
|
||||
|
||||
ret
|
||||
|
||||
@ -704,7 +724,10 @@ cmd_quit:
|
||||
mov esi, has_quit_irc
|
||||
call print_text2
|
||||
|
||||
;;; TODO: dec [window.users], remove username from the userlist
|
||||
; TODO: check other channels on same server too!
|
||||
mov ebx, [window_print]
|
||||
mov esi, servercommand+1
|
||||
call user_remove
|
||||
|
||||
ret
|
||||
|
||||
@ -747,47 +770,24 @@ cmd_353: ; channel usernames reply
|
||||
; now find window ptr and check if this is the first 353 message
|
||||
mov ebx, [window_print]
|
||||
test [ebx + window.flags], FLAG_RECEIVING_NAMES
|
||||
jnz .start
|
||||
jnz .add
|
||||
|
||||
or [ebx + window.flags], FLAG_RECEIVING_NAMES
|
||||
mov [ebx + window.users], 0
|
||||
; mov [ebx + window.users], 0
|
||||
; TODO: remove all users?
|
||||
|
||||
.start:
|
||||
mov eax, [ebx + window.users]
|
||||
xor edx, edx
|
||||
mov ecx, MAX_NICK_LEN
|
||||
mul ecx
|
||||
; eax is now offset
|
||||
add eax, [ebx + window.data_ptr]
|
||||
lea edi, [eax + window_data.names]
|
||||
mov edx, edi
|
||||
.add:
|
||||
push esi
|
||||
call user_add
|
||||
pop esi
|
||||
|
||||
lea ecx, [eax + window_data.names]
|
||||
add ecx, MAX_NICK_LEN + MAX_USERS
|
||||
|
||||
.newname:
|
||||
cmp edi, ecx ; check buffer overflow
|
||||
jae .done
|
||||
inc [ebx + window.users]
|
||||
.namesloop:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .done
|
||||
cmp al, ' ' ; names list is separated with spaces
|
||||
je .next
|
||||
stosb
|
||||
jmp .namesloop
|
||||
.next:
|
||||
add edx, MAX_NICK_LEN
|
||||
mov edi, edx
|
||||
.loop3:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .done
|
||||
cmp al, ' '
|
||||
je .loop3
|
||||
stosb
|
||||
jmp .newname
|
||||
jne .namesloop
|
||||
jmp .add
|
||||
|
||||
.done:
|
||||
call redraw_channel_list
|
||||
@ -807,10 +807,11 @@ cmd_366: ; channel usernames end
|
||||
mov ebx, [window_print]
|
||||
and [ebx + window.flags], not FLAG_RECEIVING_NAMES
|
||||
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
cmd_topic:
|
||||
|
||||
add esi, 4 ; skip '332 '
|
||||
@ -830,7 +831,6 @@ cmd_topic:
|
||||
mov esi, str_newline
|
||||
call print_text2
|
||||
|
||||
.fail:
|
||||
ret
|
||||
|
||||
|
||||
@ -857,8 +857,12 @@ cmd_333:
|
||||
mov esi, str_setby
|
||||
call print_text2
|
||||
|
||||
pop esi
|
||||
call print_text2
|
||||
; pop esi
|
||||
; call print_text2
|
||||
|
||||
pop eax
|
||||
mov dl, '!'
|
||||
call print_text
|
||||
|
||||
mov esi, str_newline
|
||||
call print_text2
|
||||
|
164
kernel/branches/net/applications/ircc/users.inc
Normal file
164
kernel/branches/net/applications/ircc/users.inc
Normal file
@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
; esi is ptr to nick
|
||||
; ebx is ptr to window
|
||||
align 4
|
||||
user_add:
|
||||
|
||||
cmp [ebx + window.users], MAX_USERS
|
||||
jae fail
|
||||
|
||||
mov edi, [ebx + window.data_ptr]
|
||||
add edi, window_data.names
|
||||
mov ebp, [ebx + window.users]
|
||||
inc ebp ; CHECKME
|
||||
|
||||
push esi edi
|
||||
.restart:
|
||||
mov ecx, MAX_NICK_LEN
|
||||
.loop1:
|
||||
lodsb
|
||||
cmp al, '@'
|
||||
jne @f
|
||||
mov al, ' ' ; give @ highest priority
|
||||
@@:
|
||||
cmp al, 'A'
|
||||
jb @f
|
||||
cmp al, 'Z'
|
||||
ja @f
|
||||
add al, 'a' - 'A' ; convert to lowercase
|
||||
@@:
|
||||
dec ecx
|
||||
jz .got_it
|
||||
|
||||
.loop2:
|
||||
mov dl, [edi]
|
||||
cmp dl, 0
|
||||
je .got_it
|
||||
cmp dl, '@'
|
||||
jne @f
|
||||
mov dl, ' ' ; give @ highest priority
|
||||
@@:
|
||||
cmp dl, 'A'
|
||||
jb @f
|
||||
cmp dl, 'Z'
|
||||
ja @f
|
||||
add dl, 'a' - 'A' ; convert to lowercase
|
||||
@@:
|
||||
cmp al, dl
|
||||
jb .got_it
|
||||
je .check_next
|
||||
|
||||
pop edi esi
|
||||
add edi, MAX_NICK_LEN
|
||||
push esi edi
|
||||
|
||||
dec ebp
|
||||
jnz .restart
|
||||
|
||||
.check_next:
|
||||
inc edi
|
||||
jmp .loop1
|
||||
|
||||
.got_it:
|
||||
pop edi esi
|
||||
|
||||
; OK, insert it here..
|
||||
|
||||
; mov all trailing usernames by MAX_NICK_LEN bytes
|
||||
push esi edi
|
||||
mov esi, [ebx + window.data_ptr]
|
||||
add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1)
|
||||
|
||||
mov ecx, esi
|
||||
sub ecx, edi
|
||||
add ecx, MAX_NICK_LEN
|
||||
shr ecx, 2
|
||||
lea edi, [esi + MAX_NICK_LEN]
|
||||
std
|
||||
rep movsd
|
||||
cld
|
||||
pop edi esi
|
||||
|
||||
; Now insert our new username
|
||||
mov ecx, MAX_NICK_LEN-1
|
||||
.fill:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
je .done
|
||||
cmp al, '!'
|
||||
je .done
|
||||
stosb
|
||||
loop .fill
|
||||
.done:
|
||||
xor al, al
|
||||
stosb
|
||||
|
||||
inc [ebx + window.users]
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; esi is ptr to nick
|
||||
; ebx is ptr to window
|
||||
align 4
|
||||
user_remove:
|
||||
|
||||
call user_find
|
||||
jz fail
|
||||
|
||||
lea esi, [edi + MAX_NICK_LEN]
|
||||
mov ecx, [ebx + window.data_ptr]
|
||||
add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS
|
||||
sub ecx, esi
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
|
||||
dec [ebx + window.users]
|
||||
xor eax, eax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; IN:
|
||||
; esi is ptr to nick
|
||||
; ebx is ptr to window
|
||||
; OUT:
|
||||
; edi is ptr to nick in userlist
|
||||
align 4
|
||||
user_find:
|
||||
|
||||
mov eax, [ebx + window.users]
|
||||
test eax, eax
|
||||
jz fail
|
||||
mov edi, [ebx + window.data_ptr]
|
||||
add edi, window_data.names
|
||||
|
||||
.loop:
|
||||
push esi edi
|
||||
mov ecx, MAX_NICK_LEN
|
||||
repe cmpsb
|
||||
cmp byte[edi-1], 0
|
||||
je .got_it
|
||||
; TODO: check byte[esi] too!
|
||||
pop edi esi
|
||||
add edi, MAX_NICK_LEN
|
||||
dec eax
|
||||
jnz .loop
|
||||
jmp fail
|
||||
|
||||
.got_it:
|
||||
pop edi esi
|
||||
test edi, edi ; to clear zero flag
|
||||
|
||||
ret
|
||||
|
||||
|
||||
fail:
|
||||
|
||||
xor edi, edi
|
||||
ret
|
Loading…
Reference in New Issue
Block a user