Subversion Repositories Kolibri OS

Rev

Rev 4143 | Rev 4595 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4143 Rev 4477
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;   Written by hidnplayr@kolibrios.org                            ;;
6
;;   Written by hidnplayr@kolibrios.org                            ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
Line 58... Line 58...
58
        dd      '366 ', cmd_366         ; end of names list
58
        dd      '366 ', cmd_366         ; end of names list
59
        dd      '372 ', cmd_372         ; motd
59
        dd      '372 ', cmd_372         ; motd
60
        dd      '375 ', cmd_375         ; start of motd
60
        dd      '375 ', cmd_375         ; start of motd
61
        dd      '376 ', cmd_376         ; end of motd
61
        dd      '376 ', cmd_376         ; end of motd
62
        dd      '421 ', cmd_421         ; unknown command
62
        dd      '421 ', cmd_421         ; unknown command
-
 
63
        dd      '433 ', cmd_433         ; nickname already in use
63
        dd      'join', cmd_join
64
        dd      'join', cmd_join
64
        dd      'kick', cmd_kick
65
        dd      'kick', cmd_kick
65
        dd      'mode', cmd_mode
66
        dd      'mode', cmd_mode
66
        dd      'nick', cmd_nick
67
        dd      'nick', cmd_nick
67
        dd      'part', cmd_part
68
        dd      'part', cmd_part
Line 81... Line 82...
81
        mov     esi, user_nick
82
        mov     esi, user_nick
82
  .loop:
83
  .loop:
83
        lodsb
84
        lodsb
84
        cmp     al, ' '
85
        cmp     al, ' '
85
        jbe     .done
86
        jbe     .done
-
 
87
        test    al, al
-
 
88
        jz      .done
86
        cmp     al, 'a'
89
        cmp     al, 'a'
87
        jb      .ok
90
        jb      .ok
88
        cmp     al, 'z'
91
        cmp     al, 'z'
89
        ja      .ok
92
        ja      .ok
90
        sub     al, 0x20
93
        sub     al, 0x20
Line 114... Line 117...
114
        ret
117
        ret
Line 115... Line 118...
115
 
118
 
116
 
119
 
Line 117... Line 120...
117
 
120
 
118
align 4
121
align 4
119
skip_nick:
122
skip_parameter:
120
 
123
 
121
; First: skip the NICK (maybe we should verify it?)
124
; First: skip the parameter
122
  .nick:
125
  .part1:
123
        lodsb
-
 
124
        cmp     al, ' '
126
        lodsb
Line 125... Line 127...
125
        je      .skip
127
        cmp     al, ' '
126
        cmp     al, ':'
128
        je      .part2
127
        je      .skip
129
        cmp     al, ':'
128
        jmp     .nick
130
        jne     .part1
129
 
131
 
130
; skip all leading spaces and semicolons
132
; Now, skip all trailing spaces and semicolons
131
  .skip:
133
  .part2:
132
        lodsb
134
        lodsb
Line 133... Line 135...
133
        cmp     al, ' '
135
        cmp     al, ' '
Line 145... Line 147...
145
cmd_328:
147
cmd_328:
146
cmd_421:
148
cmd_421:
147
cmd_372:
149
cmd_372:
148
cmd_375:
150
cmd_375:
149
cmd_376:
151
cmd_376:
-
 
152
cmd_433:
150
        add     esi, 4
153
        add     esi, 4
151
        jmp     cmd_notice.loop
154
        jmp     cmd_notice.loop
Line 152... Line 155...
152
 
155
 
Line 226... Line 229...
226
        mov     eax, dword[esi+4]
229
        mov     eax, dword[esi+4]
227
        or      eax, 0x20202020
230
        or      eax, 0x20202020
228
        cmp     eax, 'msg '
231
        cmp     eax, 'msg '
229
        jne     .fail
232
        jne     .fail
230
        add     esi, 8          ; skip 'PRIVMSG '
233
        add     esi, 8          ; skip 'PRIVMSG '
-
 
234
 
-
 
235
        mov     edi, esi
-
 
236
        call    compare_to_nick
-
 
237
        jne     .channel
-
 
238
 
-
 
239
; private chat message
-
 
240
        push    esi
-
 
241
        mov     esi, servercommand+1
-
 
242
        call    window_open
-
 
243
        pop     esi
231
        call    window_open     ; esi now points to end of destination name
244
        call    skip_parameter  ; our own nickname
Line 232... Line 245...
232
 
245
 
233
        cmp     byte[esi], 1    ; Client to Client protocol?
246
        cmp     byte[esi], 1    ; Client to Client protocol?
Line -... Line 247...
-
 
247
        je      cmd_ctcp
-
 
248
 
-
 
249
        jmp     .print
-
 
250
 
-
 
251
  .channel:
-
 
252
        call    window_open
234
        je      cmd_ctcp
253
 
235
 
254
  .print:
236
; nope, just plain old privmsg, print it using ' message' format
255
; nope, just plain old privmsg, print it using ' message' format
237
        if TIMESTAMP
256
        if TIMESTAMP
Line 264... Line 283...
264
 
283
 
Line 265... Line -...
265
 
-
 
266
 
-
 
267
cmd_ctcp:
284
 
268
 
285
 
269
        cmp     byte [esi+4], ' '
286
cmd_ctcp:
Line 270... Line 287...
270
        jne     .fail
287
 
Line 278... Line 295...
278
        je      .time
295
        je      .time
279
        cmp     eax, 'ping'
296
        cmp     eax, 'ping'
280
        je      .ping
297
        je      .ping
281
        cmp     eax, 'acti'
298
        cmp     eax, 'acti'
282
        je      .action
299
        je      .action
283
;        cmp     eax, 'dcc '    ; TODO
300
        cmp     eax, 'dcc '    ; TODO
284
;        je      cmd_dcc
301
        je      cmd_dcc
Line 285... Line 302...
285
 
302
 
Line 286... Line 303...
286
; Unknown CTCP command: TODO: just print to window??
303
; Unknown CTCP command: TODO: just print to window??
Line 411... Line 428...
411
 
428
 
Line 412... Line 429...
412
        ret
429
        ret
Line -... Line 430...
-
 
430
 
-
 
431
  .send:
-
 
432
 
413
 
433
        call    window_open
Line 414... Line 434...
414
  .send:
434
        mov     [ebx + window.type], WINDOWTYPE_DCC
Line 470... Line 490...
470
        add     esi, 5  ; skip 'PART '
490
        add     esi, 5  ; skip 'PART '
Line 471... Line 491...
471
 
491
 
472
; Is it me who parted?
492
; Is it me who parted?
473
        mov     edi, servercommand+1
493
        mov     edi, servercommand+1
474
        call    compare_to_nick
494
        call    compare_to_nick
Line 475... Line 495...
475
        jne     .dont_close
495
        jne     .not_me
476
 
496
 
477
; yes, close the window (if its open)
497
; yes, close the window (if its open)
478
        call    window_find
498
        call    window_find
Line 484... Line 504...
484
 
504
 
Line 485... Line 505...
485
        ret
505
        ret
486
 
506
 
487
 
507
 
488
; somebody else parted, just print message
-
 
489
  .dont_close:
508
; somebody else parted, just print message
Line -... Line 509...
-
 
509
  .not_me:
-
 
510
        push    esi
-
 
511
        call    window_open
-
 
512
 
490
        push    esi
513
        if TIMESTAMP
491
        call    skip_nick
514
        call    print_timestamp
Line 492... Line 515...
492
        call    window_open
515
        end if
493
 
516
 
Line 523... Line 546...
523
        add     esi, 5  ; skip 'JOIN '
546
        add     esi, 5  ; skip 'JOIN '
Line 524... Line 547...
524
 
547
 
525
; compare nick: did we join a channel?
548
; compare nick: did we join a channel?
526
        mov     edi, servercommand+1
549
        mov     edi, servercommand+1
527
        call    compare_to_nick
-
 
528
        jne     .no_new_window
-
 
529
 
-
 
530
; create channel window - search for empty slot
-
 
531
        mov     ebx, windows
-
 
532
        mov     ecx, MAX_WINDOWS
-
 
533
  .loop:
-
 
534
        cmp     [ebx + window.data_ptr], 0
-
 
535
        je      .free_found
-
 
536
        add     ebx, sizeof.window
-
 
537
        dec     ecx
550
        call    compare_to_nick
538
        jnz     .loop
-
 
539
; Error: no more available windows!! ;;;;; TODO
-
 
540
 
-
 
Line 541... Line 551...
541
        ret
551
        jne     .not_me
542
 
552
 
543
  .free_found:
553
        push    esi
544
        call    window_create
554
        call    window_open
545
        test    eax, eax
555
        test    eax, eax
546
        jz      .fail
-
 
547
        mov     [ebx + window.type], WINDOWTYPE_CHANNEL
-
 
548
 
-
 
549
        call    window_set_name
556
        jz      .fail
550
 
-
 
Line 551... Line 557...
551
        mov     [window_active], ebx
557
        mov     [ebx + window.type], WINDOWTYPE_CHANNEL
552
        mov     [window_print], ebx
558
        mov     [window_active], ebx
553
 
559
 
Line 554... Line -...
554
        if TIMESTAMP
-
 
555
        call    print_timestamp
560
        if TIMESTAMP
556
        end if
561
        call    print_timestamp
Line 557... Line 562...
557
 
562
        end if
558
        push    esi
563
 
Line 571... Line 576...
571
 
576
 
Line 572... Line 577...
572
        call    draw_window
577
        call    draw_window
Line 573... Line 578...
573
 
578
 
574
        ret
579
        ret
575
 
580
 
Line 576... Line 581...
576
  .no_new_window:
581
  .not_me:
577
        push    esi
582
        push    esi
Line 599... Line 604...
599
 
604
 
600
        mov     ebx, [window_print]
605
        mov     ebx, [window_print]
601
        mov     esi, servercommand+1
606
        mov     esi, servercommand+1
Line 602... Line 607...
602
        call    user_add
607
        call    user_add
Line -... Line 608...
-
 
608
 
-
 
609
        ret
603
 
610
 
Line 709... Line 716...
709
; TODO: mark channel as disconnected
716
; TODO: mark channel as disconnected
Line 710... Line 717...
710
 
717
 
711
  .not_me:
718
  .not_me:
712
; find the channel user has been kicked from
719
; find the channel user has been kicked from
713
        push    esi
720
        push    esi
714
        call    skip_nick
721
        call    skip_parameter
Line 715... Line 722...
715
        call    window_open
722
        call    window_open
716
 
723
 
717
        if TIMESTAMP
724
        if TIMESTAMP
Line 800... Line 807...
800
        jne     .fail
807
        jne     .fail
801
        add     esi, 5  ; skip 'MODE '
808
        add     esi, 5  ; skip 'MODE '
802
        call    window_find
809
        call    window_find
803
        test    ebx, ebx
810
        test    ebx, ebx
804
        jz      .fail
811
        jz      .fail
805
 
-
 
806
; skip channel name
-
 
807
  @@:
-
 
808
        lodsb
-
 
809
        test    al, al
-
 
810
        jz      .fail
-
 
811
        cmp     al, 10
-
 
812
        je      .fail
-
 
813
        cmp     al, 13
-
 
814
        je      .fail
-
 
815
        cmp     al, ' '
812
        mov     [window_print], ebx
816
        jne     @r
-
 
817
        push    esi
813
        push    esi
Line 818... Line 814...
818
 
814
 
819
        if TIMESTAMP
815
        if TIMESTAMP
820
        call    print_timestamp
816
        call    print_timestamp
Line 844... Line 840...
844
 
840
 
Line 845... Line 841...
845
 
841
 
846
cmd_353:                ; channel usernames reply
842
cmd_353:                ; channel usernames reply
847
 
843
 
848
        add     esi, 4  ; skip '353 '
844
        add     esi, 4  ; skip '353 '
849
        call    skip_nick
845
        call    skip_parameter
Line 850... Line 846...
850
        inc     esi     ; channel type '*', '=' or '@'
846
        inc     esi     ; channel type '*', '=' or '@'
Line 883... Line 879...
883
 
879
 
Line 884... Line 880...
884
 
880
 
885
cmd_366:        ; channel usernames end
881
cmd_366:        ; channel usernames end
886
 
882
 
Line 887... Line 883...
887
        add     esi, 4          ; skip '366 '
883
        add     esi, 4          ; skip '366 '
888
        call    skip_nick
884
        call    skip_parameter
Line 897... Line 893...
897
 
893
 
Line 898... Line 894...
898
 
894
 
899
cmd_topic:
895
cmd_topic:
900
 
896
 
Line 901... Line 897...
901
        add     esi, 4          ; skip '332 '
897
        add     esi, 4          ; skip '332 '
902
        call    skip_nick
898
        call    skip_parameter
903
        call    window_open
899
        call    window_open
Line 914... Line 910...
914
        call    print_text2
910
        call    print_text2
Line 915... Line 911...
915
 
911
 
916
        pop     esi
912
        pop     esi
Line 917... Line 913...
917
        call    print_text2
913
        call    print_text2
918
 
914
 
Line 919... Line 915...
919
        mov     esi, str_newline
915
        mov     esi, str_topic_end
Line 920... Line 916...
920
        call    print_text2
916
        call    print_text2
Line 921... Line 917...
921
 
917
 
922
        ret
918
        ret
923
 
919
 
Line 924... Line -...
924
 
-
 
925
cmd_333:
-
 
926
 
-
 
927
        add     esi, 4          ; skip '333 '
-
 
928
        call    skip_nick               ;;;;
-
 
929
        call    window_open
-
 
930
 
-
 
931
;        mov     ecx, 2  ; number of spaces to find    ;;; CHECKME
-
 
932
;  .loop:
-
 
933
;        lodsb
-
 
934
;        test    al, al
920
 
935
;        je      .fail
921
cmd_333:
936
;        cmp     al, ' '
922
 
Line 937... Line 923...
937
;        jne     .loop
923
        add     esi, 4          ; skip '333 '
Line 965... Line 951...
965
cmd_322:        ; LIST
951
cmd_322:        ; LIST
Line 966... Line 952...
966
 
952
 
Line 967... Line 953...
967
        add     esi, 4
953
        add     esi, 4
968
 
954
 
969
        mov     [window_print], windows         ; FIXME
955
        mov     [window_print], windows         ; FIXME
970
        call    skip_nick
956
        call    skip_parameter
971
        mov     eax, esi
957
        mov     eax, esi
972
        mov     dl, 13
958
        mov     dl, 13
973
        call    print_text
959
        call    print_text