Rev 3981 | Rev 4477 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3981 | Rev 4143 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. 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 | ;; ;; |
7 | ;; ;; |
7 | ;; GNU GENERAL PUBLIC LICENSE ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
8 | ;; Version 2, June 1991 ;; |
9 | ;; Version 2, June 1991 ;; |
9 | ;; ;; |
10 | ;; ;; |
10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 11... | Line 12... | ||
11 | 12 | ||
Line -... | Line 13... | ||
- | 13 | ||
- | 14 | user_parser: |
|
- | 15 | ||
12 | 16 | push [window_active] ; print to the current window |
|
13 | user_parser: |
17 | pop [window_print] |
14 | 18 | ||
15 | mov eax, [edit1.size] |
19 | mov eax, [edit1.size] |
Line 23... | Line 27... | ||
23 | ; Ignore data commands when not connected. |
27 | ; Ignore data commands when not connected. |
24 | cmp [status], STATUS_CONNECTED |
28 | cmp [status], STATUS_CONNECTED |
25 | jne sdts_ret |
29 | jne sdts_ret |
Line 26... | Line 30... | ||
26 | 30 | ||
27 | ; Ok, we said something, print it to our textbox |
- | |
28 | 31 | ; Ok, we said something, print it to our textbox |
|
Line 29... | Line -... | ||
29 | ; TODO: dont send if it's a server window? |
- | |
30 | - | ||
31 | push [window_active] ; print to the current window |
- | |
32 | pop [window_print] |
- | |
33 | call window_refresh |
32 | ; TODO: dont send if it's a server window? |
34 | 33 | ||
35 | if TIMESTAMP |
34 | if TIMESTAMP |
Line 36... | Line 35... | ||
36 | call print_timestamp |
35 | call print_timestamp |
Line 55... | Line 54... | ||
55 | 54 | ||
56 | mov bl, 10 |
55 | mov bl, 10 |
Line 57... | Line 56... | ||
57 | call print_character |
56 | call print_character |
58 | - | ||
59 | ; and now send it to the server |
57 | |
60 | 58 | ; and now send it to the server |
|
Line 61... | Line 59... | ||
61 | mov dword[packetbuf], 'priv' |
59 | mov dword[packetbuf], 'PRIV' |
62 | mov dword[packetbuf+4], 'msg ' |
60 | mov dword[packetbuf+4], 'MSG ' |
63 | 61 | ||
64 | mov esi, [window_active] |
62 | mov esi, [window_active] |
Line 80... | Line 78... | ||
80 | mov esi, usercommand |
78 | mov esi, usercommand |
81 | mov ecx, [edit1.size] |
79 | mov ecx, [edit1.size] |
82 | inc ecx |
80 | inc ecx |
83 | call recode |
81 | call recode |
Line -... | Line 82... | ||
- | 82 | ||
84 | 83 | ; end the command with a CRLF |
|
85 | mov al, 10 |
84 | mov ax, 0x0a0d |
Line 86... | Line 85... | ||
86 | stosb |
85 | stosw |
87 | 86 | ||
Line 88... | Line 87... | ||
88 | lea esi, [edi - packetbuf] |
87 | lea esi, [edi - packetbuf] |
Line 98... | Line 97... | ||
98 | dd 'nick', cmd_usr_nick |
97 | dd 'nick', cmd_usr_nick |
99 | dd 'real', cmd_usr_real |
98 | dd 'real', cmd_usr_real |
100 | dd 'serv', cmd_usr_server |
99 | dd 'serv', cmd_usr_server |
101 | dd 'help', cmd_usr_help |
100 | dd 'help', cmd_usr_help |
102 | dd 'code', cmd_usr_code |
101 | dd 'code', cmd_usr_code |
- | 102 | ||
103 | ; TODO: All other commands require a connection to the server. |
103 | ; All following commands require a connection to the server. TODO: verify connection |
104 | dd 'quer', cmd_usr_quer |
104 | dd 'quer', cmd_usr_quer |
105 | dd 'quit', cmd_usr_quit |
105 | dd 'quit', cmd_usr_quit |
106 | dd 'part', cmd_usr_part |
106 | dd 'part', cmd_usr_part |
- | 107 | dd 'ctcp', cmd_usr_ctcp |
|
- | 108 | dd 'msg ', cmd_usr_msg |
|
Line 107... | Line 109... | ||
107 | 109 | ||
Line 129... | Line 131... | ||
129 | 131 | ||
- | 132 | ||
- | 133 | ||
Line -... | Line 134... | ||
- | 134 | ||
- | 135 | ||
- | 136 | cmd_usr_msg: |
|
- | 137 | ||
- | 138 | lea esi, [usercommand+5] |
|
- | 139 | ||
- | 140 | mov dword[packetbuf], 'PRIV' |
|
- | 141 | mov dword[packetbuf+4], 'MSG ' |
|
- | 142 | lea edi, [packetbuf+8] |
|
- | 143 | ||
- | 144 | @@: |
|
- | 145 | lodsb |
|
- | 146 | test al, al |
|
- | 147 | jz .fail |
|
- | 148 | cmp al, 10 |
|
- | 149 | je .fail |
|
- | 150 | cmp al, 13 |
|
- | 151 | je .fail |
|
- | 152 | stosb |
|
- | 153 | cmp al, ' ' |
|
- | 154 | jne @r |
|
- | 155 | ||
- | 156 | mov al, ':' |
|
- | 157 | stosb |
|
- | 158 | ||
- | 159 | push edi |
|
- | 160 | @@: |
|
- | 161 | lodsb |
|
- | 162 | test al, al |
|
- | 163 | jz @f |
|
- | 164 | cmp al, 10 |
|
- | 165 | je @f |
|
- | 166 | cmp al, 13 |
|
- | 167 | je @f |
|
- | 168 | stosb |
|
- | 169 | jmp @r |
|
- | 170 | @@: |
|
- | 171 | ; end the command with a CRLF |
|
- | 172 | mov ax, 0x0a0d |
|
- | 173 | stosw |
|
- | 174 | mov byte[edi], 0 |
|
- | 175 | ||
- | 176 | lea esi, [edi - packetbuf] |
|
- | 177 | mcall send, [socketnum], packetbuf, , 0 |
|
- | 178 | ||
- | 179 | ; now print to the window |
|
- | 180 | if TIMESTAMP |
|
- | 181 | call print_timestamp |
|
- | 182 | end if |
|
- | 183 | ||
- | 184 | mov esi, msg_header |
|
- | 185 | call print_text2 |
|
- | 186 | ||
- | 187 | mov eax, packetbuf+8 |
|
- | 188 | mov dl, ' ' |
|
- | 189 | call print_text |
|
- | 190 | ||
- | 191 | mov bl, '*' |
|
- | 192 | call print_character |
|
- | 193 | ||
- | 194 | mov bl, ' ' |
|
- | 195 | call print_character |
|
- | 196 | ||
- | 197 | pop esi |
|
- | 198 | call print_text2 |
|
- | 199 | ||
130 | 200 | .fail: |
|
Line 131... | Line 201... | ||
131 | 201 | ret |
|
132 | 202 | ||
133 | 203 | ||
134 | cmd_usr_quit: |
204 | |
135 | 205 | cmd_usr_quit: |
|
Line 136... | Line 206... | ||
136 | mov esi, quit_msg |
206 | mov esi, quit_msg |
- | 207 | ||
Line 137... | Line 208... | ||
137 | 208 | cmp byte[usercommand+5], ' ' |
|
138 | cmp byte[usercommand+5], ' ' |
209 | jne .with_message |
139 | jne .default_msg |
210 | lea esi, [usercommand+6] |
140 | lea esi,[usercommand+6] |
211 | .with_message: |
- | 212 | call cmd_usr_quit_server |
|
- | 213 | ||
- | 214 | mcall close, [socketnum] |
|
141 | .default_msg: |
215 | mov [status], STATUS_DISCONNECTED |
142 | call cmd_usr_quit_server |
216 | |
143 | 217 | mov ecx, MAX_WINDOWS |
|
Line 144... | Line 218... | ||
144 | mcall close, [socketnum] |
218 | mov edi, windows |
Line 163... | Line 237... | ||
163 | mov word[packetbuf+4], ' :' |
237 | mov word[packetbuf+4], ' :' |
164 | lea edi, [packetbuf+6] |
238 | lea edi, [packetbuf+6] |
165 | ; Append our quit msg |
239 | ; Append our quit msg |
166 | @@: |
240 | @@: |
167 | lodsb |
241 | lodsb |
- | 242 | cmp al, 13 |
|
168 | stosb |
243 | je @f |
169 | test al, al |
244 | test al, al |
- | 245 | jz @f |
|
- | 246 | stosb |
|
170 | jnz @r |
247 | jmp @r |
- | 248 | @@: |
|
171 | ; end the command with a CRLF |
249 | ; end the command with a CRLF |
172 | dec edi |
- | |
173 | mov ax, 0x0a0d |
250 | mov ax, 0x0a0d |
174 | stosw |
251 | stosw |
Line 175... | Line 252... | ||
175 | 252 | ||
176 | lea esi, [edi - packetbuf] ; calculate length |
253 | lea esi, [edi - packetbuf] ; calculate length |
Line 182... | Line 259... | ||
182 | 259 | ||
Line 183... | Line 260... | ||
183 | 260 | ||
184 | cmd_usr_nick: |
261 | cmd_usr_nick: |
185 | 262 | ||
- | 263 | cmp [edit1.size], 5 |
|
- | 264 | je .dontsend |
|
186 | cmp [edit1.size], 5 |
265 | cmp byte[usercommand+5], ' ' |
- | 266 | jne .fail |
|
- | 267 | cmp [socketnum], 0 |
|
- | 268 | je .dontsend |
|
- | 269 | ||
- | 270 | mov dword[usercommand+1], 'NICK' |
|
- | 271 | mov esi, [edit1.size] |
|
Line -... | Line 272... | ||
- | 272 | mov word[usercommand + esi], 0x0a0d |
|
- | 273 | inc esi |
|
- | 274 | mcall send, [socketnum], usercommand+1, , 0 |
|
- | 275 | ||
- | 276 | .fail: |
|
187 | je .justprint |
277 | |
188 | cmp byte[usercommand+5], ' ' |
278 | ret |
189 | jne cmd_usr_send |
279 | |
190 | 280 | .dontsend: |
|
191 | mov ecx, MAX_NICK_LEN |
281 | mov ecx, MAX_NICK_LEN |
192 | mov esi, usercommand+6 |
282 | mov esi, usercommand+6 |
193 | mov edi, user_nick |
283 | mov edi, user_nick |
194 | .loop: |
284 | @@: |
195 | lodsb |
285 | lodsb |
196 | cmp al, 13 |
286 | cmp al, 13 |
197 | je .done |
287 | je @f |
198 | stosb |
288 | stosb |
199 | dec ecx |
289 | dec ecx |
Line 200... | Line -... | ||
200 | jnz .loop |
- | |
201 | .done: |
- | |
202 | xor al, al |
- | |
203 | stosb |
- | |
204 | - | ||
205 | cmp [socketnum], 0 |
- | |
206 | je .justprint |
- | |
207 | 290 | jnz @r |
|
208 | lea esi, [edi - usercommand] |
291 | @@: |
209 | mcall send, [socketnum], usercommand+1, , 0 |
292 | xor al, al |
210 | 293 | stosb |
|
211 | .justprint: |
294 | |
Line 297... | Line 380... | ||
297 | 380 | ||
298 | .found: |
381 | .found: |
299 | call window_create |
382 | call window_create |
300 | test eax, eax |
383 | test eax, eax |
301 | jz .error |
384 | jz .error |
Line 302... | Line 385... | ||
302 | mov [ebx + window.data_ptr], eax |
385 | mov [ebx + window.type], WINDOWTYPE_CHAT |
303 | 386 | ||
Line 304... | Line -... | ||
304 | mov esi, usercommand+7 |
- | |
305 | call window_set_name |
- | |
Line 306... | Line 387... | ||
306 | 387 | mov esi, usercommand+7 |
|
Line 307... | Line 388... | ||
307 | mov [ebx + window.type], WINDOWTYPE_CHAT |
388 | call window_set_name |
Line 332... | Line 413... | ||
332 | 413 | ||
333 | ; User typed a part command |
414 | ; User typed a part command |
Line 334... | Line 415... | ||
334 | cmd_usr_part: |
415 | cmd_usr_part: |
335 | 416 | ||
Line -... | Line 417... | ||
- | 417 | cmp byte[usercommand+5], 13 ; parameters given? |
|
- | 418 | jne cmd_usr_send ; yes, send command straight to server |
|
- | 419 | ||
336 | cmp byte[usercommand+5], 13 ; parameters given? |
420 | ; close active window |
- | 421 | cmd_usr_close_window: |
|
337 | jne cmd_usr_send |
422 | |
338 | 423 | mov esi, [window_active] |
|
Line -... | Line 424... | ||
- | 424 | mov [window_print], esi |
|
- | 425 | cmp [esi + window.type], WINDOWTYPE_SERVER |
|
- | 426 | je .not_channel |
|
- | 427 | ||
- | 428 | lea esi, [esi + window.name] |
|
- | 429 | call cmd_usr_part_channel |
|
339 | mov esi, [window_active] ; window is not a server window? |
430 | call window_close |
- | 431 | ret |
|
- | 432 | ||
- | 433 | .not_channel: |
|
340 | cmp [esi + window.type], WINDOWTYPE_SERVER |
434 | cmp [esi + window.type], WINDOWTYPE_CHAT |
Line 341... | Line 435... | ||
341 | je @f |
435 | jne .not_chat |
Line -... | Line 436... | ||
- | 436 | ||
- | 437 | call window_close |
|
342 | 438 | .not_chat: |
|
343 | call window_close ; OK, close currently open (channel/chat/..) window |
439 | |
344 | @@: |
440 | ret |
Line 345... | Line 441... | ||
345 | 441 | ||
346 | ret |
442 | |
347 | 443 | ||
348 | ; Send part command to server |
444 | ; Send part command to server |
349 | ; esi must point to channel name (ASCIIZ) |
445 | ; esi must point to channel name (ASCIIZ) |
350 | cmd_usr_part_channel: |
446 | cmd_usr_part_channel: |
351 | - | ||
352 | ; User wants to close a channel, send PART command to server |
447 | |
- | 448 | ; User wants to close a channel, send PART command to server |
|
- | 449 | mov dword[packetbuf], 'PART' |
|
- | 450 | mov byte[packetbuf+4], ' ' |
|
- | 451 | lea edi, [packetbuf+5] |
|
- | 452 | @@: |
|
- | 453 | lodsb |
|
353 | mov dword[packetbuf], 'PART' |
454 | test al, al |
- | 455 | jz @f |
|
354 | mov byte[packetbuf+4], ' ' |
456 | cmp al, 13 |
355 | lea edi, [packetbuf+5] |
- | |
356 | @@: |
457 | je @f |
357 | lodsb |
458 | cmp al, 10 |
Line 358... | Line 459... | ||
358 | stosb |
459 | je @f |
359 | test al, al |
460 | stosb |
Line 360... | Line 461... | ||
360 | jnz @r |
461 | jmp @r |
Line -... | Line 462... | ||
- | 462 | @@: |
|
- | 463 | ; end the command with a CRLF |
|
- | 464 | mov ax, 0x0a0d |
|
- | 465 | stosw |
|
- | 466 | ||
- | 467 | lea esi, [edi - packetbuf] ; calculate length |
|
- | 468 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
|
- | 469 | ||
- | 470 | ret |
|
- | 471 | ||
- | 472 | ||
- | 473 | cmd_usr_ctcp: |
|
- | 474 | ||
- | 475 | cmp byte[usercommand+5], ' ' |
|
- | 476 | jne cmd_usr_send |
|
- | 477 | ||
- | 478 | mov esi, usercommand+6 |
|
- | 479 | ; prepare a 'PRIVMSG ' |
|
- | 480 | mov dword[packetbuf], 'PRIV' |
|
- | 481 | mov dword[packetbuf+4], 'MSG ' |
|
- | 482 | lea edi, [packetbuf+8] |
|
- | 483 | ||
- | 484 | ; append the destination (nickname/channel) |
|
- | 485 | @@: |
|
- | 486 | lodsb |
|
- | 487 | test al, al |
|
- | 488 | jz .fail |
|
- | 489 | cmp al, ' ' |
|
- | 490 | je @f |
|
- | 491 | stosb |
|
- | 492 | jmp @r |
|
- | 493 | @@: |
|
- | 494 | ||
- | 495 | mov ax, ' :' |
|
- | 496 | stosw |
|
- | 497 | mov al, 0x01 |
|
- | 498 | stosb |
|
- | 499 | ||
- | 500 | ; copy the message itself |
|
- | 501 | @@: |
|
- | 502 | lodsb |
|
- | 503 | test al, al |
|
- | 504 | jz @f |
|
- | 505 | cmp al, 13 |
|
- | 506 | je @f |
|
- | 507 | cmp al, 10 |
|
- | 508 | je @f |
|
- | 509 | stosb |
|
- | 510 | jmp @r |
|
- | 511 | @@: |
|
- | 512 | ||
- | 513 | ; end of message |
|
- | 514 | mov al, 0x01 |
|
- | 515 | stosb |
|
- | 516 | mov ax, 0x0a0d |
|
- | 517 | stosw |
|
- | 518 | ||
361 | ; end the command with a CRLF |
519 | ; now send it away |
362 | dec edi |
520 | lea esi, [edi - packetbuf] ; calculate length |
Line 363... | Line 521... | ||
363 | mov ax, 0x0a0d |
521 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
364 | stosw |
522 | |
Line 381... | Line 539... | ||
381 | lea esi, [edi - packetbuf] |
539 | lea esi, [edi - packetbuf] |
382 | mcall send, [socketnum], packetbuf, , 0 |
540 | mcall send, [socketnum], packetbuf, , 0 |
Line 383... | Line 541... | ||
383 | 541 | ||
Line -... | Line 542... | ||
- | 542 | ret' |
|
- | 543 | > |
|
- | 544 | ||
- | 545 |