Subversion Repositories Kolibri OS

Rev

Rev 4143 | Rev 4596 | 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
;;  IRC client for KolibriOS                                       ;;
6
;;  IRC client for KolibriOS                                       ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org,                           ;;
8
;;   Written by hidnplayr@kolibrios.org,                           ;;
Line 11... Line 11...
11
;;         GNU GENERAL PUBLIC LICENSE                              ;;
11
;;         GNU GENERAL PUBLIC LICENSE                              ;;
12
;;          Version 2, June 1991                                   ;;
12
;;          Version 2, June 1991                                   ;;
13
;;                                                                 ;;
13
;;                                                                 ;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 15... Line 15...
15
 
15
 
Line 16... Line 16...
16
version equ '0.15'
16
version equ '0.16'
17
 
17
 
18
; connection status
18
; connection status
19
STATUS_DISCONNECTED     = 0
19
STATUS_DISCONNECTED     = 0
Line 50... Line 50...
50
TOP_Y                   = 24
50
TOP_Y                   = 24
51
BOTTOM_Y                = 15
51
BOTTOM_Y                = 15
Line 52... Line 52...
52
 
52
 
53
MAX_WINDOWS             = 20
53
MAX_WINDOWS             = 20
54
MAX_USERS               = 4096
54
MAX_USERS               = 4096
Line 55... Line 55...
55
TEXT_BUFFERSIZE         = 4096;*1024
55
TEXT_BUFFERSIZE         = 1024*1024
56
 
56
 
57
MAX_NICK_LEN            = 32
57
MAX_NICK_LEN            = 32
Line 95... Line 95...
95
include "../../macros.inc"
95
include "../../macros.inc"
96
include "../../proc32.inc"
96
include "../../proc32.inc"
97
include "../../dll.inc"
97
include "../../dll.inc"
98
include "../../network.inc"
98
include "../../network.inc"
99
include "../../struct.inc"
99
include "../../struct.inc"
100
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
100
include "../../develop/libraries/box_lib/trunk/box_lib.mac"
Line 101... Line 101...
101
 
101
 
102
struct  window
102
struct  window
103
        data_ptr        dd ?
103
        data_ptr        dd ?
104
        flags           db ?
104
        flags           db ?
Line 167... Line 167...
167
        mov     ecx, 600/4
167
        mov     ecx, 600/4
168
        rep     stosd
168
        rep     stosd
Line 169... Line 169...
169
 
169
 
170
; allocate window data block
170
; allocate window data block
171
        mov     ebx, windows
171
        mov     ebx, windows
172
        call    window_create
172
        call    window_create_textbox
173
        test    eax, eax
173
        test    eax, eax
174
        jz      error
174
        jz      error
Line 175... Line 175...
175
        mov     [ebx + window.type], WINDOWTYPE_SERVER
175
        mov     [ebx + window.type], WINDOWTYPE_SERVER
Line 200... Line 200...
200
 
200
 
201
; Welcome user
201
; Welcome user
202
        mov     esi, str_welcome
202
        mov     esi, str_welcome
Line -... Line 203...
-
 
203
        call    print_text2
-
 
204
 
-
 
205
; Check if parameter contains an URL
-
 
206
        cmp     byte[param], 0
-
 
207
        je      @f
-
 
208
        mov     esi, param
-
 
209
        mov     ecx, 1024
-
 
210
        call    cmd_usr_server.now
203
        call    print_text2
211
  @@:
-
 
212
 
Line 204... Line 213...
204
 
213
; Draw window a first time, so we can figure out skin size
205
        call    draw_window     ; Draw window a first time, so we can figure out skin size
214
        call    draw_window
Line 206... Line 215...
206
 
215
 
207
redraw:
-
 
208
        call    draw_window
216
redraw:
Line 209... Line 217...
209
 
217
        call    draw_window
210
still:
218
 
Line 211... Line 219...
211
; wait here for event
219
mainloop:
Line 233... Line 241...
233
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
241
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
234
        jne     .no_update
242
        jne     .no_update
235
        call    draw_channel_list
243
        call    draw_channel_list
236
  .no_update:
244
  .no_update:
Line 237... Line 245...
237
 
245
 
Line 238... Line 246...
238
        jmp     still
246
        jmp     mainloop
Line 239... Line 247...
239
 
247
 
240
button:
248
button:
Line 246... Line 254...
246
        je      exit
254
        je      exit
Line 247... Line 255...
247
 
255
 
248
        cmp     ax, WINDOW_BTN_CLOSE
256
        cmp     ax, WINDOW_BTN_CLOSE
249
        jne     @f
257
        jne     @f
250
        call    cmd_usr_close_window
258
        call    cmd_usr_close_window
Line 251... Line 259...
251
        jmp     still
259
        jmp     mainloop
252
 
260
 
253
  @@:
261
  @@:
Line 268... Line 276...
268
 
276
 
Line 269... Line 277...
269
        call    draw_channel_list
277
        call    draw_channel_list
270
 
278
 
271
        pop     eax
279
        pop     eax
-
 
280
        test    eax, 1 shl 25   ; Right mouse button pressed?
-
 
281
        jz      mainloop
Line 272... Line 282...
272
        test    eax, 1 shl 25   ; Right mouse button pressed?
282
 
273
        jz      still
283
; TODO: check if selected nick is my nick!
274
 
284
 
275
; Right mouse BTN was pressed, open chat window
285
; Right mouse BTN was pressed, open chat window
Line 282... Line 292...
282
        call    window_open
292
        call    window_open
283
        push    [window_print]
293
        push    [window_print]
284
        pop     [window_active]
294
        pop     [window_active]
285
        call    redraw
295
        call    redraw
Line 286... Line 296...
286
 
296
 
Line 287... Line 297...
287
        jmp     still
297
        jmp     mainloop
288
 
298
 
289
  @@:
299
  @@:
Line 304... Line 314...
304
        mov     [window_active], edx
314
        mov     [window_active], edx
Line 305... Line 315...
305
 
315
 
306
        mov     [scroll2.position], 1           ;;; FIXME
316
        mov     [scroll2.position], 1           ;;; FIXME
Line 307... Line 317...
307
        call    draw_window
317
        call    draw_window
Line 308... Line 318...
308
 
318
 
Line 309... Line 319...
309
        jmp     still
319
        jmp     mainloop
310
 
320
 
Line 330... Line 340...
330
        call    [edit_box_key]
340
        call    [edit_box_key]
Line 331... Line 341...
331
 
341
 
332
;        cmp     ah, 178
342
;        cmp     ah, 178
333
;        jne     .no_up
343
;        jne     .no_up
334
;
344
;
335
;        jmp     still
345
;        jmp     mainloop
336
;
346
;
337
;
347
;
338
;  .no_up:
348
;  .no_up:
339
;        cmp     ah, 177
349
;        cmp     ah, 177
340
;        jne     .no_down
350
;        jne     .no_down
341
;
351
;
342
;        jmp     still
352
;        jmp     mainloop
343
;
353
;
344
;  .no_down:
354
;  .no_down:
345
        cmp     ah, 13          ; enter
355
        cmp     ah, 13          ; enter
Line 355... Line 365...
355
        push    dword edit1
365
        push    dword edit1
356
        call    [edit_box_draw]
366
        call    [edit_box_draw]
Line 357... Line 367...
357
 
367
 
Line 358... Line 368...
358
        call    draw_channel_text
368
        call    draw_channel_text
359
 
369
 
Line 360... Line 370...
360
        jmp     still
370
        jmp     mainloop
Line 361... Line 371...
361
  no_send2:
371
  no_send2:
362
 
372
 
363
        jmp     still
373
        jmp     mainloop
Line -... Line 374...
-
 
374
 
-
 
375
mouse:
-
 
376
        push    dword edit1
-
 
377
        call    [edit_box_mouse]
364
 
378
 
365
mouse:
379
;        mcall   37, 7
366
        push    dword edit1
380
;        movsx   eax, ax
367
        call    [edit_box_mouse]
381
;        add     [scroll2.position], eax
368
 
382
 
Line 384... Line 398...
384
        mov     eax, [edi + window.text_lines]
398
        mov     eax, [edi + window.text_lines]
385
        cmp     eax, [textbox_height]
399
        cmp     eax, [textbox_height]
386
        jbe     @f
400
        jbe     @f
387
        push    dword scroll2
401
        push    dword scroll2
388
        call    [scrollbar_mouse]
402
        call    [scrollbar_mouse]
389
;        mov     edi, [window_active]
403
        mov     edi, [window_active]
390
        mov     edx, [scroll2.position]
404
        mov     edx, [scroll2.position]
391
        sub     edx, [edi + window.text_line_print]
405
        sub     edx, [edi + window.text_line_print]
392
        je      @f
406
        je      @f
393
        call    draw_channel_text.scroll_to_pos
407
        call    draw_channel_text.scroll_to_pos
394
  @@:
408
  @@:
Line 395... Line 409...
395
 
409
 
Line 396... Line 410...
396
        jmp     still
410
        jmp     mainloop
Line 397... Line 411...
397
 
411
 
Line 415... Line 429...
415
ctcp_header             db 3,'13-> [',0
429
ctcp_header             db 3, '13-> [', 0
416
msg_header              db 3,'7-> *',0
430
msg_header              db 3, '7-> *', 0
417
ctcp_version            db '] VERSION',10,0
431
ctcp_version            db '] VERSION', 10, 0
418
ctcp_ping               db '] PING',10,0
432
ctcp_ping               db '] PING', 10, 0
419
ctcp_time               db '] TIME',10,0
433
ctcp_time               db '] TIME', 10, 0
-
 
434
 
420
has_left_channel        db ' has left ', 0
435
has_left_channel        db ' has left ', 0
421
joins_channel           db ' has joined ', 0
436
joins_channel           db ' has joined ', 0
422
is_now_known_as         db ' is now known as ', 0
437
is_now_known_as         db ' is now known as ', 0
423
has_quit_irc            db ' has quit IRC', 10, 0
438
has_quit_irc            db ' has quit IRC', 10, 0
-
 
439
 
424
sets_mode               db ' sets mode ', 0
440
sets_mode               db ' sets mode ', 0
425
kicked                  db ' is kicked from ', 0
441
kicked                  db ' is kicked from ', 0
-
 
442
str_nickchange          db 'Nickname is now ', 0
-
 
443
str_realchange          db 'Real name is now ', 0
426
str_talking             db 'Now talking in ',0
444
str_talking             db 'Now talking in ', 0
427
str_topic               db 'Topic is ',0
445
str_topic               db 'Topic is "', 0
-
 
446
str_topic_end           db '".', 10, 0
428
str_setby               db 'Set by ',0
447
str_setby               db 'Set by ', 0
429
str_reconnect           db 'Connection reset by user.',10,0
-
 
Line -... Line 448...
-
 
448
 
430
 
449
str_connecting          db 3, '3* Connecting to ', 0
-
 
450
str_sockerr             db 3, '5* Socket error', 10, 0
-
 
451
str_dnserr              db 3, '5* Unable to resolve hostname', 10, 0
-
 
452
str_refused             db 3, '5* Connection refused', 10, 0
-
 
453
str_disconnected        db 3, '5* Server disconnected', 10, 0
431
str_version             db 'VERSION '
454
str_reconnect           db 3, '5* Connection reset by user', 10, 0
Line 432... Line 455...
432
str_programname         db 'KolibriOS IRC client ', version, 0
455
str_notconnected        db 3, '5* Not connected to server', 10, 0
433
 
456
 
434
str_user                db 'user', 0
457
str_dotnewline          db '.',10, 0
435
str_nick                db 'nick', 0
458
str_newline             db 10, 0
436
str_real                db 'realname', 0
-
 
Line 437... Line 459...
437
str_email               db 'email', 0
459
str_1                   db 3, '13 -', 0
438
str_quitmsg             db 'quitmsg', 0
460
str_2                   db '- ', 0
-
 
461
 
-
 
462
str_help                db 10, 'following commands are available:', 10
439
 
463
                        db 10
-
 
464
                        db '/nick         : change nickname to ', 10
Line 440... Line 465...
440
default_nick            db 'kolibri_user', 0
465
                        db '/real    : change real name to ', 10
441
default_real            db 'Kolibri User', 0
466
                        db '/server 
: connect to server
', 10
442
default_quit            db 'KolibriOS forever', 0
467
                        db '/code         : change codepage to cp866, cp1251, or utf8', 10, 0
443
 
468
 
444
str_welcome             db 3,'3 ___',3,'7__________',3,'6_________  ',3,'4         __   __               __',10
469
str_welcome             db 3, '3 ___', 3, '7__________', 3, '6_________  ', 3, '4         __   __               __', 10
445
                        db 3,'3|   \',3,'7______   \',3,'6_   ___ \ ',3,'4   ____ |  | |__| ____   _____/  |_',10
470
                        db 3, '3|   \', 3, '7______   \', 3, '6_   ___ \ ', 3, '4   ____ |  | |__| ____   _____/  |_', 10
446
                        db 3,'3|   |',3,'7|       _/',3,'6    \  \/ ',3,'4 _/ ___\|  | |  |/ __ \ /    \   __\',10
471
                        db 3, '3|   |', 3, '7|       _/', 3, '6    \  \/ ', 3, '4 _/ ___\|  | |  |/ __ \ /    \   __\', 10
447
                        db 3,'3|   |',3,'7|    |   \',3,'6     \____',3,'4 \  \___|  |_|  \  ___/|   |  \  |',10
472
                        db 3, '3|   |', 3, '7|    |   \', 3, '6     \____', 3, '4 \  \___|  |_|  \  ___/|   |  \  |', 10
448
                        db 3,'3|___|',3,'7|____|_  /\',3,'6______  /',3,'4  \___  >____/__|\___  >___|  /__|',10
473
                        db 3, '3|___|', 3, '7|____|_  /', 3, '6\______  /', 3, '4  \___  >____/__|\___  >___|  /__|', 10
449
                        db 3,'3     ',3,'7      \/   ',3,'6     \/  ',3,'4     \/             \/     \/',10
474
                        db 3, '3     ', 3, '7       \/ ', 3, '6       \/ ', 3, '4      \/             \/     \/', 10
Line 450... Line -...
450
                        db 10
-
 
451
                        db 'Welcome to the KolibriOS IRC client v',version,10
-
 
452
                        db 10
-
 
453
                        db 'Type /help for help',10,10,0
475
                        db 10
454
 
-
 
455
str_nickchange          db 'Nickname is now ',0
476
                        db 'Welcome to the KolibriOS IRC client v', version, 10
456
str_realchange          db 'Real name is now ',0
-
 
457
str_dotnewline          db '.',10, 0
-
 
458
str_newline             db 10, 0
-
 
459
str_connecting          db 3,'3* Connecting to ',0
-
 
460
str_help                db 10,'following commands are available:',10
-
 
Line 461... Line 477...
461
                        db 10
477
                        db 10
462
                        db '/nick         : change nickname to ',10
478
                        db 'Type /help for help', 10, 10, 0
-
 
479
 
-
 
480
str_version             db 'VERSION '
-
 
481
str_programname         db 'KolibriOS IRC client v', version, 0
Line 463... Line 482...
463
                        db '/real    : change real name to ',10
482
 
464
                        db '/server 
: connect to server
',10
483
str_user                db 'user', 0
465
                        db '/code         : change codepage to cp866, cp1251, or utf8',10,0
484
str_nick                db 'nick', 0
Line 466... Line 485...
466
 
485
str_real                db 'realname', 0
467
str_1                   db 3,'13 -',0
486
str_email               db 'email', 0
468
str_2                   db '- ',0
487
str_quitmsg             db 'quitmsg', 0
469
 
488
 
Line 488... Line 507...
488
                        dd 0x7f7f7f     ; 14 grey
507
                        dd 0x7f7f7f     ; 14 grey
489
                        dd 0xd4d0c4     ; 15 light grey (silver)
508
                        dd 0xd4d0c4     ; 15 light grey (silver)
Line 490... Line 509...
490
 
509
 
491
sockaddr1:
510
sockaddr1:
492
        dw AF_INET4
511
        dw AF_INET4
493
.port   dw 0x0b1a       ; 6667
512
.port   dw 0x0b1a       ; 6667          FIXMEEEEEE
494
.ip     dd 0
513
.ip     dd 0
Line 495... Line 514...
495
        rb 10
514
        rb 10
Line 525... Line 544...
525
        edit_box_key,   'edit_box_key',\
544
        edit_box_key,   'edit_box_key',\
526
        edit_box_mouse, 'edit_box_mouse',\
545
        edit_box_mouse, 'edit_box_mouse',\
527
        scrollbar_draw, 'scrollbar_v_draw',\
546
        scrollbar_draw, 'scrollbar_v_draw',\
528
        scrollbar_mouse,'scrollbar_v_mouse'
547
        scrollbar_mouse,'scrollbar_v_mouse'
Line 529... Line -...
529
 
-
 
530
I_END:
-
 
531
 
548
 
532
        ;         width, left, top
549
        ;         width, left, top
533
edit1   edit_box  0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25
550
edit1   edit_box  0, 0, 0, 0xffffff, 0x6f9480, 0, 0, 0, USERCMD_MAX_SIZE, usercommand, mouse_dd, ed_focus, 25, 25
534
        ;         xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol
551
        ;         xsize, xpos, ysize, ypos, btn_height, max, cur, pos, bgcol, frcol, linecol
535
scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
552
scroll1 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
Line 536... Line 553...
536
scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
553
scroll2 scrollbar SCROLLBAR_WIDTH, 0, 0, TOP_Y, SCROLLBAR_WIDTH, 0, 0, 0, 0, 0, 0, 1
537
 
554
 
Line -... Line 555...
-
 
555
usercommand     db '/server chat.freenode.net', 0
-
 
556
                rb MAX_COMMAND_LEN
538
usercommand     db '/server chat.freenode.net', 0
557
 
539
                rb MAX_COMMAND_LEN
558
I_END:
540
 
-
 
541
utf8_bytes_rest dd ?            ; bytes rest in current UTF8 sequence
-
 
-
 
559
 
542
utf8_char       dd ?            ; first bits of current UTF8 character
560
utf8_bytes_rest dd ?            ; bytes rest in current UTF8 sequence
543
gai_reqdata     rb 32           ; buffer for getaddrinfo_start/process
561
utf8_char       dd ?            ; first bits of current UTF8 character
544
ip_list         dd ?            ; will be filled as pointer to addrinfo list
562
 
Line 545... Line -...
545
packetbuf       rb 1024         ; buffer for packets to server
-
 
546
path            rb 1024
-
 
547
param           rb 1024
563
packetbuf       rb 1024         ; buffer for packets to server
Line 548... Line 564...
548
 
564
path            rb 1024
549
socketnum       dd ?
565
param           rb 1024
550
 
566
 
-
 
567
servercommand   rb 600
Line 551... Line 568...
551
servercommand   rb 600
568
 
Line 552... Line 569...
552
 
569
thread_info     rb 1024
-
 
570
xsize           dd ?
Line 553... Line 571...
553
thread_info     rb 1024
571
ysize           dd ?
554
xsize           dd ?
572
mouse_dd        dd ?
555
ysize           dd ?
573
 
Line -... Line 574...
-
 
574
colors          system_colors
556
 
575
 
Line 557... Line -...
557
colors          system_colors
-
 
558
 
-
 
559
irc_server_name rb MAX_SERVER_NAME
576
irc_server_name rb MAX_SERVER_NAME      ; TODO: move this server URL into window struct