Rev 4477 | Rev 4623 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4477 | Rev 4617 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2014. 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 ;; |
9 | ;; Version 2, June 1991 ;; |
9 | ;; Version 2, June 1991 ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | 12 | ||
13 | 13 | ||
14 | user_parser: |
14 | user_parser: |
15 | 15 | ||
16 | push [window_active] ; print to the current window |
16 | push [window_active] ; print to the current window |
17 | pop [window_print] |
17 | pop [window_print] |
18 | 18 | ||
19 | mov eax, [edit1.size] |
19 | mov eax, [edit1.size] |
20 | test eax, eax |
20 | test eax, eax |
21 | jz .ret ; ignore empty commands |
21 | jz .ret ; ignore empty commands |
22 | mov word [usercommand + eax], 0x0a0d ; terminate the line |
22 | mov word[usercommand + eax], 0x0a0d ; terminate the line |
23 | 23 | ||
24 | cmp byte[usercommand], '/' ; is it a server command ? |
24 | cmp byte[usercommand], '/' ; is it a server command ? |
25 | je server_command |
25 | je server_command |
26 | 26 | ||
27 | ; Ignore data commands when not connected. |
27 | ; Ignore data commands when not connected. |
28 | cmp [status], STATUS_CONNECTED |
28 | cmp [status], STATUS_CONNECTED |
29 | jne .notconnected |
29 | jne .notconnected |
30 | 30 | ||
31 | ; Ok, we said something, print it to our textbox |
31 | ; Ok, we said something, print it to our textbox |
32 | ; TODO: dont send if it's a server window? |
32 | ; TODO: dont send if it's a server window? |
33 | 33 | ||
34 | if TIMESTAMP |
34 | if TIMESTAMP |
35 | call print_timestamp |
35 | call print_timestamp |
36 | end if |
36 | end if |
37 | 37 | ||
38 | mov bl, '<' |
38 | mov bl, '<' |
39 | call print_character |
39 | call print_character |
40 | 40 | ||
41 | mov esi, user_nick |
41 | mov esi, user_nick |
42 | call print_text2 |
42 | call print_text2 |
43 | 43 | ||
44 | mov bl, '>' |
44 | mov bl, '>' |
45 | call print_character |
45 | call print_character |
46 | mov bl, ' ' |
46 | mov bl, ' ' |
47 | call print_character |
47 | call print_character |
48 | 48 | ||
49 | mov eax, [edit1.size] |
49 | mov eax, [edit1.size] |
50 | mov byte[usercommand + eax],0 |
50 | mov byte[usercommand + eax],0 |
51 | 51 | ||
52 | mov esi, usercommand |
52 | mov esi, usercommand |
53 | call print_text2 |
53 | call print_text2 |
54 | 54 | ||
55 | mov bl, 10 |
55 | mov bl, 10 |
56 | call print_character |
56 | call print_character |
57 | 57 | ||
58 | ; and now send it to the server |
58 | ; and now send it to the server |
59 | mov dword[packetbuf], 'PRIV' |
59 | mov dword[packetbuf], 'PRIV' |
60 | mov dword[packetbuf+4], 'MSG ' |
60 | mov dword[packetbuf+4], 'MSG ' |
61 | 61 | ||
62 | mov esi, [window_active] |
62 | mov esi, [window_active] |
63 | add esi, window.name |
63 | add esi, window.name |
64 | mov edi, packetbuf+8 |
64 | mov edi, packetbuf+8 |
65 | mov ecx, MAX_WINDOWNAME_LEN |
65 | mov ecx, MAX_WINDOWNAME_LEN |
66 | .loop: |
66 | .loop: |
67 | lodsb |
67 | lodsb |
68 | test al, al |
68 | test al, al |
69 | jz .done |
69 | jz .done |
70 | stosb |
70 | stosb |
71 | dec ecx |
71 | dec ecx |
72 | jnz .loop |
72 | jnz .loop |
73 | .done: |
73 | .done: |
74 | 74 | ||
75 | mov ax, ' :' |
75 | mov ax, ' :' |
76 | stosw |
76 | stosw |
77 | 77 | ||
78 | mov esi, usercommand |
78 | mov esi, usercommand |
79 | mov ecx, [edit1.size] |
79 | mov ecx, [edit1.size] |
80 | inc ecx |
80 | inc ecx |
81 | call recode |
81 | call recode |
82 | 82 | ||
83 | ; end the command with a CRLF |
83 | ; end the command with a CRLF |
84 | mov ax, 0x0a0d |
84 | mov ax, 0x0a0d |
85 | stosw |
85 | stosw |
86 | 86 | ||
87 | lea esi, [edi - packetbuf] |
87 | lea esi, [edi - packetbuf] |
88 | mcall send, [socketnum], packetbuf, , 0 |
88 | mcall send, [socketnum], packetbuf, , 0 |
89 | .ret: |
89 | .ret: |
90 | 90 | ||
91 | ret |
91 | ret |
92 | 92 | ||
93 | .notconnected: |
93 | .notconnected: |
94 | mov esi, str_notconnected |
94 | mov esi, str_notconnected |
95 | call print_text2 |
95 | call print_text2 |
96 | 96 | ||
97 | ret |
97 | ret |
98 | 98 | ||
99 | 99 | ||
100 | 100 | ||
101 | user_commands: |
101 | user_commands: |
102 | dd 'nick', cmd_usr_nick |
102 | dd 'nick', cmd_usr_nick |
103 | dd 'real', cmd_usr_real |
103 | dd 'real', cmd_usr_real |
104 | dd 'serv', cmd_usr_server |
104 | dd 'serv', cmd_usr_server |
105 | dd 'help', cmd_usr_help |
105 | dd 'help', cmd_usr_help |
106 | dd 'code', cmd_usr_code |
106 | dd 'code', cmd_usr_code |
107 | 107 | ||
108 | .number2 = ($ - user_commands) / 8 |
108 | .number2 = ($ - user_commands) / 8 |
109 | 109 | ||
110 | ; All following commands require a connection to the server. |
110 | ; All following commands require a connection to the server. |
111 | dd 'quer', cmd_usr_quer |
111 | dd 'quer', cmd_usr_quer |
112 | dd 'quit', cmd_usr_quit |
112 | dd 'quit', cmd_usr_quit |
113 | dd 'part', cmd_usr_part |
113 | dd 'part', cmd_usr_part |
114 | dd 'ctcp', cmd_usr_ctcp |
114 | dd 'ctcp', cmd_usr_ctcp |
115 | dd 'msg ', cmd_usr_msg |
115 | dd 'msg ', cmd_usr_msg |
116 | 116 | ||
117 | .number = ($ - user_commands) / 8 |
117 | .number = ($ - user_commands) / 8 |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | server_command: |
121 | server_command: |
122 | 122 | ||
123 | mov eax, dword[usercommand+1] ; skip '/' |
123 | mov eax, dword[usercommand+1] ; skip '/' |
124 | or eax, 0x20202020 ; convert to lowercase |
124 | or eax, 0x20202020 ; convert to lowercase |
125 | 125 | ||
126 | mov edi, user_commands |
126 | mov edi, user_commands |
127 | mov ecx, user_commands.number |
127 | mov ecx, user_commands.number |
128 | cmp [status], STATUS_CONNECTED |
128 | cmp [status], STATUS_CONNECTED |
129 | jne .loop |
129 | jne .loop |
130 | mov ecx, user_commands.number2 |
130 | mov ecx, user_commands.number2 |
131 | .loop: |
131 | .loop: |
132 | scasd |
132 | scasd |
133 | je .got_cmd |
133 | je .got_cmd |
134 | add edi, 4 |
134 | add edi, 4 |
135 | dec ecx |
135 | dec ecx |
136 | jnz .loop |
136 | jnz .loop |
137 | 137 | ||
138 | cmp [status], STATUS_CONNECTED |
138 | cmp [status], STATUS_CONNECTED |
139 | jne .notconnected |
139 | jne .notconnected |
140 | 140 | ||
141 | jmp cmd_usr_send ; If none of the previous commands, just send to server |
141 | jmp cmd_usr_send ; If none of the previous commands, just send to server |
142 | 142 | ||
143 | .got_cmd: |
143 | .got_cmd: |
144 | jmp dword[edi] |
144 | jmp dword[edi] |
145 | 145 | ||
146 | .notconnected: |
146 | .notconnected: |
147 | mov esi, str_notconnected |
147 | mov esi, str_notconnected |
148 | call print_text2 |
148 | call print_text2 |
149 | 149 | ||
150 | ret |
150 | ret |
151 | 151 | ||
152 | 152 | ||
153 | 153 | ||
154 | cmd_usr_msg: |
154 | cmd_usr_msg: |
155 | 155 | ||
156 | lea esi, [usercommand+5] |
156 | lea esi, [usercommand+5] |
157 | 157 | ||
158 | mov dword[packetbuf], 'PRIV' |
158 | mov dword[packetbuf], 'PRIV' |
159 | mov dword[packetbuf+4], 'MSG ' |
159 | mov dword[packetbuf+4], 'MSG ' |
160 | lea edi, [packetbuf+8] |
160 | lea edi, [packetbuf+8] |
161 | 161 | ||
162 | @@: |
162 | @@: |
163 | lodsb |
163 | lodsb |
164 | test al, al |
164 | test al, al |
165 | jz .fail |
165 | jz .fail |
166 | cmp al, 10 |
166 | cmp al, 10 |
167 | je .fail |
167 | je .fail |
168 | cmp al, 13 |
168 | cmp al, 13 |
169 | je .fail |
169 | je .fail |
170 | stosb |
170 | stosb |
171 | cmp al, ' ' |
171 | cmp al, ' ' |
172 | jne @r |
172 | jne @r |
173 | 173 | ||
174 | mov al, ':' |
174 | mov al, ':' |
175 | stosb |
175 | stosb |
176 | 176 | ||
177 | push edi |
177 | push edi |
178 | @@: |
178 | @@: |
179 | lodsb |
179 | lodsb |
180 | test al, al |
180 | test al, al |
181 | jz @f |
181 | jz @f |
182 | cmp al, 10 |
182 | cmp al, 10 |
183 | je @f |
183 | je @f |
184 | cmp al, 13 |
184 | cmp al, 13 |
185 | je @f |
185 | je @f |
186 | stosb |
186 | stosb |
187 | jmp @r |
187 | jmp @r |
188 | @@: |
188 | @@: |
189 | ; end the command with a CRLF |
189 | ; end the command with a CRLF |
190 | mov ax, 0x0a0d |
190 | mov ax, 0x0a0d |
191 | stosw |
191 | stosw |
192 | mov byte[edi], 0 |
192 | mov byte[edi], 0 |
193 | 193 | ||
194 | lea esi, [edi - packetbuf] |
194 | lea esi, [edi - packetbuf] |
195 | mcall send, [socketnum], packetbuf, , 0 |
195 | mcall send, [socketnum], packetbuf, , 0 |
196 | 196 | ||
197 | ; now print to the window |
197 | ; now print to the window |
198 | if TIMESTAMP |
198 | if TIMESTAMP |
199 | call print_timestamp |
199 | call print_timestamp |
200 | end if |
200 | end if |
201 | 201 | ||
202 | mov esi, msg_header |
202 | mov esi, msg_header |
203 | call print_text2 |
203 | call print_text2 |
204 | 204 | ||
205 | mov eax, packetbuf+8 |
205 | mov eax, packetbuf+8 |
206 | mov dl, ' ' |
206 | mov dl, ' ' |
207 | call print_text |
207 | call print_text |
208 | 208 | ||
209 | mov bl, '*' |
209 | mov bl, '*' |
210 | call print_character |
210 | call print_character |
211 | 211 | ||
212 | mov bl, ' ' |
212 | mov bl, ' ' |
213 | call print_character |
213 | call print_character |
214 | 214 | ||
215 | pop esi |
215 | pop esi |
216 | call print_text2 |
216 | call print_text2 |
217 | 217 | ||
218 | .fail: |
218 | .fail: |
219 | ret |
219 | ret |
220 | 220 | ||
221 | 221 | ||
222 | 222 | ||
223 | cmd_usr_quit: |
223 | cmd_usr_quit: |
224 | mov esi, quit_msg |
224 | mov esi, quit_msg |
225 | 225 | ||
226 | cmp byte[usercommand+5], ' ' |
226 | cmp byte[usercommand+5], ' ' |
227 | jne .with_message |
227 | jne .with_message |
228 | lea esi, [usercommand+6] |
228 | lea esi, [usercommand+6] |
229 | .with_message: |
229 | .with_message: |
230 | call cmd_usr_quit_server |
230 | call cmd_usr_quit_server |
231 | 231 | ||
232 | mcall close, [socketnum] |
232 | mcall close, [socketnum] |
233 | mov [status], STATUS_DISCONNECTED |
233 | mov [status], STATUS_DISCONNECTED |
234 | 234 | ||
235 | mov ecx, MAX_WINDOWS |
235 | mov ecx, MAX_WINDOWS |
236 | mov edi, windows |
236 | mov edi, windows |
237 | .loop: |
237 | .loop: |
238 | mov [window_print], edi |
238 | mov [window_print], edi |
239 | push edi ecx |
239 | push edi ecx |
240 | call window_close |
240 | call window_close |
241 | pop ecx edi |
241 | pop ecx edi |
242 | add edi, sizeof.window |
242 | add edi, sizeof.window |
243 | dec ecx |
243 | dec ecx |
244 | jnz .loop |
244 | jnz .loop |
245 | 245 | ||
246 | ret |
246 | ret |
247 | 247 | ||
248 | 248 | ||
249 | 249 | ||
250 | ; esi = quit message |
250 | ; esi = quit message |
251 | cmd_usr_quit_server: |
251 | cmd_usr_quit_server: |
252 | 252 | ||
253 | ; User wants to close a channel, send PART command to server |
253 | ; User wants to close a channel, send PART command to server |
254 | mov dword[packetbuf], 'QUIT' |
254 | mov dword[packetbuf], 'QUIT' |
255 | mov word[packetbuf+4], ' :' |
255 | mov word[packetbuf+4], ' :' |
256 | lea edi, [packetbuf+6] |
256 | lea edi, [packetbuf+6] |
257 | ; Append our quit msg |
257 | ; Append our quit msg |
258 | @@: |
258 | @@: |
259 | lodsb |
259 | lodsb |
260 | cmp al, 13 |
260 | cmp al, 13 |
261 | je @f |
261 | je @f |
262 | test al, al |
262 | test al, al |
263 | jz @f |
263 | jz @f |
264 | stosb |
264 | stosb |
265 | jmp @r |
265 | jmp @r |
266 | @@: |
266 | @@: |
267 | ; end the command with a CRLF |
267 | ; end the command with a CRLF |
268 | mov ax, 0x0a0d |
268 | mov ax, 0x0a0d |
269 | stosw |
269 | stosw |
270 | 270 | ||
271 | lea esi, [edi - packetbuf] ; calculate length |
271 | lea esi, [edi - packetbuf] ; calculate length |
272 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
272 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
273 | 273 | ||
274 | ret |
274 | ret |
275 | 275 | ||
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | cmd_usr_nick: |
279 | cmd_usr_nick: |
280 | 280 | ||
281 | cmp [edit1.size], 5 |
281 | cmp [edit1.size], 5 |
282 | je .dontsend |
282 | je .dontsend |
283 | cmp byte[usercommand+5], ' ' |
283 | cmp byte[usercommand+5], ' ' |
284 | jne .fail |
284 | jne .fail |
285 | cmp [socketnum], 0 |
285 | cmp [socketnum], 0 |
286 | je .dontsend |
286 | je .dontsend |
- | 287 | ||
287 | 288 | ; Request nickname change to server |
|
288 | mov dword[usercommand+1], 'NICK' |
289 | mov dword[usercommand+1], 'NICK' |
289 | mov esi, [edit1.size] |
290 | mov esi, [edit1.size] |
290 | mov word[usercommand + esi], 0x0a0d |
291 | mov word[usercommand + esi], 0x0a0d |
291 | inc esi |
292 | inc esi |
292 | mcall send, [socketnum], usercommand+1, , 0 |
293 | mcall send, [socketnum], usercommand+1, , 0 |
293 | 294 | ||
294 | .fail: |
295 | .fail: |
295 | 296 | ||
296 | ret |
297 | ret |
- | 298 | ||
297 | 299 | ; We arent logged in yet, directly change user_nick field and print notification to user. |
|
298 | .dontsend: |
300 | .dontsend: |
299 | mov ecx, MAX_NICK_LEN |
301 | mov ecx, MAX_NICK_LEN |
300 | mov esi, usercommand+6 |
302 | mov esi, usercommand+6 |
301 | mov edi, user_nick |
303 | mov edi, user_nick |
302 | @@: |
304 | @@: |
303 | lodsb |
305 | lodsb |
304 | cmp al, 13 |
306 | cmp al, 13 |
305 | je @f |
307 | je @f |
306 | stosb |
308 | stosb |
307 | dec ecx |
309 | dec ecx |
308 | jnz @r |
310 | jnz @r |
309 | @@: |
311 | @@: |
310 | xor al, al |
312 | xor al, al |
311 | stosb |
313 | stosb |
312 | 314 | ||
313 | mov esi, str_nickchange |
315 | mov esi, str_nickchange |
314 | call print_text2 |
316 | call print_text2 |
315 | mov esi, user_nick |
317 | mov esi, user_nick |
316 | call print_text2 |
318 | call print_text2 |
317 | mov esi, str_dotnewline |
319 | mov esi, str_dotnewline |
318 | call print_text2 |
320 | call print_text2 |
319 | 321 | ||
320 | ret |
322 | ret |
321 | 323 | ||
322 | 324 | ||
323 | 325 | ||
324 | cmd_usr_real: |
326 | cmd_usr_real: |
325 | 327 | ||
326 | cmp byte[usercommand+5], ' ' |
328 | cmp byte[usercommand+5], ' ' |
327 | jne cmd_usr_send |
329 | jne cmd_usr_send |
328 | 330 | ||
329 | mov ecx, MAX_REAL_LEN |
331 | mov ecx, MAX_REAL_LEN |
330 | mov esi, usercommand+6 |
332 | mov esi, usercommand+6 |
331 | mov edi, user_real_name |
333 | mov edi, user_real_name |
332 | .loop: |
334 | .loop: |
333 | lodsb |
335 | lodsb |
334 | cmp al, 13 |
336 | cmp al, 13 |
335 | je .done |
337 | je .done |
336 | stosb |
338 | stosb |
337 | dec ecx |
339 | dec ecx |
338 | jnz .loop |
340 | jnz .loop |
339 | .done: |
341 | .done: |
340 | xor al, al |
342 | xor al, al |
341 | stosb |
343 | stosb |
342 | 344 | ||
343 | mov esi, str_realchange |
345 | mov esi, str_realchange |
344 | call print_text2 |
346 | call print_text2 |
345 | mov esi, user_real_name |
347 | mov esi, user_real_name |
346 | call print_text2 |
348 | call print_text2 |
347 | mov esi, str_dotnewline |
349 | mov esi, str_dotnewline |
348 | call print_text2 |
350 | call print_text2 |
349 | 351 | ||
350 | ret |
352 | ret |
351 | 353 | ||
352 | 354 | ||
353 | 355 | ||
354 | cmd_usr_server: |
356 | cmd_usr_server: |
355 | 357 | ||
356 | mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv' |
358 | mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv' |
357 | or eax, 0x00002020 |
359 | or eax, 0x00002020 |
358 | and eax, 0x00ffffff |
360 | and eax, 0x00ffffff |
359 | cmp eax, 'er ' |
361 | cmp eax, 'er ' |
360 | jne cmd_usr_send |
362 | jne cmd_usr_send |
361 | 363 | ||
362 | mov ecx, [edit1.size] ; ok now set the address |
364 | mov ecx, [edit1.size] ; ok now set the address |
363 | sub ecx, 8 |
365 | sub ecx, 8 |
364 | 366 | ||
365 | mov esi, usercommand+8 |
367 | mov esi, usercommand+8 |
366 | .now: |
368 | .now: |
367 | push esi |
369 | push esi |
368 | mov edi, irc_server_name |
370 | mov edi, irc_server_name |
369 | .loop: ; copy until zero byte, or ecx reaches zero. |
371 | .loop: ; copy until zero byte, or ecx reaches zero. |
370 | lodsb |
372 | lodsb |
371 | stosb |
373 | stosb |
372 | test al, al |
374 | test al, al |
373 | jz .done |
375 | jz .done |
374 | dec ecx |
376 | dec ecx |
375 | jnz .loop |
377 | jnz .loop |
376 | xor al, al |
378 | xor al, al |
377 | stosb |
379 | stosb |
378 | .done: |
380 | .done: |
379 | pop esi |
381 | pop esi |
380 | 382 | ||
381 | ; set it also in window name |
383 | ; set it also in window name |
382 | mov ebx, [window_print] |
384 | mov ebx, [window_print] |
383 | call window_set_name |
385 | call window_set_name |
384 | 386 | ||
385 | ; now connect |
387 | ; now connect |
386 | call socket_connect |
388 | call socket_connect |
387 | 389 | ||
388 | ret |
390 | ret |
389 | 391 | ||
390 | 392 | ||
391 | cmd_usr_quer: |
393 | cmd_usr_quer: |
392 | 394 | ||
393 | mov esi, usercommand+7 |
395 | mov esi, usercommand+7 |
394 | call window_open |
396 | call window_open |
395 | 397 | ||
396 | ret |
398 | ret |
397 | 399 | ||
398 | 400 | ||
399 | 401 | ||
400 | cmd_usr_help: |
402 | cmd_usr_help: |
401 | 403 | ||
402 | mov esi, str_help |
404 | mov esi, str_help |
403 | call print_text2 |
405 | call print_text2 |
404 | 406 | ||
405 | ret |
407 | ret |
406 | 408 | ||
407 | 409 | ||
408 | 410 | ||
409 | cmd_usr_code: |
411 | cmd_usr_code: |
410 | 412 | ||
411 | ; TODO |
413 | ; TODO |
412 | 414 | ||
413 | ret |
415 | ret |
414 | 416 | ||
415 | 417 | ||
416 | 418 | ||
417 | ; User typed a part command |
419 | ; User typed a part command |
418 | cmd_usr_part: |
420 | cmd_usr_part: |
419 | 421 | ||
420 | cmp byte[usercommand+5], 13 ; parameters given? |
422 | cmp byte[usercommand+5], 13 ; parameters given? |
421 | jne cmd_usr_send ; yes, send command straight to server |
423 | jne cmd_usr_send ; yes, send command straight to server |
422 | 424 | ||
423 | ; close active window |
425 | ; close active window |
424 | cmd_usr_close_window: |
426 | cmd_usr_close_window: |
425 | 427 | ||
426 | mov esi, [window_active] |
428 | mov esi, [window_active] |
427 | mov [window_print], esi |
429 | mov [window_print], esi |
428 | cmp [esi + window.type], WINDOWTYPE_SERVER |
430 | cmp [esi + window.type], WINDOWTYPE_SERVER |
429 | je .not_channel |
431 | je .not_channel |
430 | 432 | ||
431 | lea esi, [esi + window.name] |
433 | lea esi, [esi + window.name] |
432 | call cmd_usr_part_channel |
434 | call cmd_usr_part_channel |
433 | call window_close |
435 | call window_close |
434 | ret |
436 | ret |
435 | 437 | ||
436 | .not_channel: |
438 | .not_channel: |
437 | cmp [esi + window.type], WINDOWTYPE_CHAT |
439 | cmp [esi + window.type], WINDOWTYPE_CHAT |
438 | jne .not_chat |
440 | jne .not_chat |
439 | 441 | ||
440 | call window_close |
442 | call window_close |
441 | .not_chat: |
443 | .not_chat: |
442 | 444 | ||
443 | ret |
445 | ret |
444 | 446 | ||
445 | 447 | ||
446 | 448 | ||
447 | ; Send part command to server |
449 | ; Send part command to server |
448 | ; esi must point to channel name (ASCIIZ) |
450 | ; esi must point to channel name (ASCIIZ) |
449 | cmd_usr_part_channel: |
451 | cmd_usr_part_channel: |
450 | 452 | ||
451 | ; User wants to close a channel, send PART command to server |
453 | ; User wants to close a channel, send PART command to server |
452 | mov dword[packetbuf], 'PART' |
454 | mov dword[packetbuf], 'PART' |
453 | mov byte[packetbuf+4], ' ' |
455 | mov byte[packetbuf+4], ' ' |
454 | lea edi, [packetbuf+5] |
456 | lea edi, [packetbuf+5] |
455 | @@: |
457 | @@: |
456 | lodsb |
458 | lodsb |
457 | test al, al |
459 | test al, al |
458 | jz @f |
460 | jz @f |
459 | cmp al, 13 |
461 | cmp al, 13 |
460 | je @f |
462 | je @f |
461 | cmp al, 10 |
463 | cmp al, 10 |
462 | je @f |
464 | je @f |
463 | stosb |
465 | stosb |
464 | jmp @r |
466 | jmp @r |
465 | @@: |
467 | @@: |
466 | ; end the command with a CRLF |
468 | ; end the command with a CRLF |
467 | mov ax, 0x0a0d |
469 | mov ax, 0x0a0d |
468 | stosw |
470 | stosw |
469 | 471 | ||
470 | lea esi, [edi - packetbuf] ; calculate length |
472 | lea esi, [edi - packetbuf] ; calculate length |
471 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
473 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
472 | 474 | ||
473 | ret |
475 | ret |
474 | 476 | ||
475 | 477 | ||
476 | 478 | ||
477 | cmd_usr_ctcp: |
479 | cmd_usr_ctcp: |
478 | 480 | ||
479 | cmp byte[usercommand+5], ' ' |
481 | cmp byte[usercommand+5], ' ' |
480 | jne cmd_usr_send |
482 | jne cmd_usr_send |
481 | 483 | ||
482 | mov esi, usercommand+6 |
484 | mov esi, usercommand+6 |
483 | ; prepare a 'PRIVMSG ' |
485 | ; prepare a 'PRIVMSG ' |
484 | mov dword[packetbuf], 'PRIV' |
486 | mov dword[packetbuf], 'PRIV' |
485 | mov dword[packetbuf+4], 'MSG ' |
487 | mov dword[packetbuf+4], 'MSG ' |
486 | lea edi, [packetbuf+8] |
488 | lea edi, [packetbuf+8] |
487 | 489 | ||
488 | ; append the destination (nickname/channel) |
490 | ; append the destination (nickname/channel) |
489 | @@: |
491 | @@: |
490 | lodsb |
492 | lodsb |
491 | test al, al |
493 | test al, al |
492 | jz .fail |
494 | jz .fail |
493 | cmp al, ' ' |
495 | cmp al, ' ' |
494 | je @f |
496 | je @f |
495 | stosb |
497 | stosb |
496 | jmp @r |
498 | jmp @r |
497 | @@: |
499 | @@: |
498 | 500 | ||
499 | mov ax, ' :' |
501 | mov ax, ' :' |
500 | stosw |
502 | stosw |
501 | mov al, 0x01 |
503 | mov al, 0x01 |
502 | stosb |
504 | stosb |
503 | 505 | ||
504 | ; copy the message itself |
506 | ; copy the message itself |
505 | @@: |
507 | @@: |
506 | lodsb |
508 | lodsb |
507 | test al, al |
509 | test al, al |
508 | jz @f |
510 | jz @f |
509 | cmp al, 13 |
511 | cmp al, 13 |
510 | je @f |
512 | je @f |
511 | cmp al, 10 |
513 | cmp al, 10 |
512 | je @f |
514 | je @f |
513 | stosb |
515 | stosb |
514 | jmp @r |
516 | jmp @r |
515 | @@: |
517 | @@: |
516 | 518 | ||
517 | ; end of message |
519 | ; end of message |
518 | mov al, 0x01 |
520 | mov al, 0x01 |
519 | stosb |
521 | stosb |
520 | mov ax, 0x0a0d |
522 | mov ax, 0x0a0d |
521 | stosw |
523 | stosw |
522 | 524 | ||
523 | ; now send it away |
525 | ; now send it away |
524 | lea esi, [edi - packetbuf] ; calculate length |
526 | lea esi, [edi - packetbuf] ; calculate length |
525 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
527 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
526 | 528 | ||
527 | ;; TODO: print to window |
529 | ;; TODO: print to window |
528 | 530 | ||
529 | .fail: |
531 | .fail: |
530 | 532 | ||
531 | ret |
533 | ret |
532 | 534 | ||
533 | 535 | ||
534 | 536 | ||
535 | ; The user typed some undefined command, just recode it and send to the server |
537 | ; The user typed some undefined command, just recode it and send to the server |
536 | cmd_usr_send: |
538 | cmd_usr_send: |
537 | 539 | ||
538 | mov esi, usercommand+1 |
540 | mov esi, usercommand+1 |
539 | mov ecx, [edit1.size] |
541 | mov ecx, [edit1.size] |
540 | inc ecx |
542 | inc ecx |
541 | mov edi, packetbuf |
543 | mov edi, packetbuf |
542 | call recode |
544 | call recode |
543 | 545 | ||
544 | lea esi, [edi - packetbuf] |
546 | lea esi, [edi - packetbuf] |
545 | mcall send, [socketnum], packetbuf, , 0 |
547 | mcall send, [socketnum], packetbuf, , 0 |
546 | 548 | ||
547 | ret' |
549 | ret' |
548 | > |
550 | > |