Rev 3545 | Rev 3981 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3545 | Rev 3563 | ||
---|---|---|---|
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 | ;; ;; |
6 | ;; ;; |
7 | ;; GNU GENERAL PUBLIC LICENSE ;; |
7 | ;; GNU GENERAL PUBLIC LICENSE ;; |
8 | ;; Version 2, June 1991 ;; |
8 | ;; Version 2, June 1991 ;; |
9 | ;; ;; |
9 | ;; ;; |
10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
11 | 11 | ||
12 | 12 | ||
13 | user_parser: |
13 | user_parser: |
14 | 14 | ||
15 | mov eax, [edit1.size] |
15 | mov eax, [edit1.size] |
- | 16 | test eax, eax |
|
- | 17 | jz sdts_ret ; ignore empty commands |
|
16 | mov word [usercommand + eax], 0x0a0d ; terminate the line |
18 | mov word [usercommand + eax], 0x0a0d ; terminate the line |
17 | 19 | ||
18 | cmp byte[usercommand], '/' ; is it a server command ? |
20 | cmp byte[usercommand], '/' ; is it a server command ? |
19 | je server_command |
21 | je server_command |
20 | 22 | ||
21 | ; Ignore data commands when not connected. |
23 | ; Ignore data commands when not connected. |
22 | cmp [status], STATUS_CONNECTED |
24 | cmp [status], STATUS_CONNECTED |
23 | jne sdts_ret |
25 | jne sdts_ret |
24 | 26 | ||
25 | ; Ok, we said something, print it to our textbox |
27 | ; Ok, we said something, print it to our textbox |
26 | 28 | ||
27 | ; TODO: dont send if it's a server window? |
29 | ; TODO: dont send if it's a server window? |
28 | 30 | ||
29 | push [window_open] ; print to the current window |
31 | push [window_open] ; print to the current window |
30 | pop [window_print] |
32 | pop [window_print] |
31 | call window_refresh |
33 | call window_refresh |
32 | 34 | ||
33 | if TIMESTAMP |
35 | if TIMESTAMP |
34 | call print_timestamp |
36 | call print_timestamp |
35 | end if |
37 | end if |
36 | 38 | ||
37 | mov bl, '<' |
39 | mov bl, '<' |
38 | call print_character |
40 | call print_character |
39 | 41 | ||
40 | mov esi, user_nick |
42 | mov esi, user_nick |
41 | call print_text2 |
43 | call print_text2 |
42 | 44 | ||
43 | mov bl,'>' |
45 | mov bl,'>' |
44 | call print_character |
46 | call print_character |
45 | mov bl,' ' |
47 | mov bl,' ' |
46 | call print_character |
48 | call print_character |
47 | 49 | ||
48 | mov eax, [edit1.size] |
50 | mov eax, [edit1.size] |
49 | mov byte[usercommand + eax],0 |
51 | mov byte[usercommand + eax],0 |
50 | 52 | ||
51 | mov esi, usercommand |
53 | mov esi, usercommand |
52 | call print_text2 |
54 | call print_text2 |
53 | 55 | ||
54 | mov bl, 10 |
56 | mov bl, 10 |
55 | call print_character |
57 | call print_character |
56 | 58 | ||
57 | ; and now send it to the server |
59 | ; and now send it to the server |
58 | 60 | ||
59 | mov dword[packetbuf], 'priv' |
61 | mov dword[packetbuf], 'priv' |
60 | mov dword[packetbuf+4], 'msg ' |
62 | mov dword[packetbuf+4], 'msg ' |
61 | 63 | ||
62 | mov esi, [window_open] |
64 | mov esi, [window_open] |
63 | add esi, window.name |
65 | add esi, window.name |
64 | mov edi, packetbuf+8 |
66 | mov edi, packetbuf+8 |
65 | mov ecx, MAX_WINDOWNAME_LEN |
67 | mov ecx, MAX_WINDOWNAME_LEN |
66 | .loop: |
68 | .loop: |
67 | lodsb |
69 | lodsb |
68 | test al, al |
70 | test al, al |
69 | jz .done |
71 | jz .done |
70 | stosb |
72 | stosb |
71 | dec ecx |
73 | dec ecx |
72 | jnz .loop |
74 | jnz .loop |
73 | .done: |
75 | .done: |
74 | 76 | ||
75 | mov ax, ' :' |
77 | mov ax, ' :' |
76 | stosw |
78 | stosw |
77 | 79 | ||
78 | mov esi, usercommand |
80 | mov esi, usercommand |
79 | mov ecx, [edit1.size] |
81 | mov ecx, [edit1.size] |
80 | inc ecx |
82 | inc ecx |
81 | call recode |
83 | call recode |
82 | 84 | ||
83 | mov al, 10 |
85 | mov al, 10 |
84 | stosb |
86 | stosb |
85 | 87 | ||
86 | lea esi, [edi - packetbuf] |
88 | lea esi, [edi - packetbuf] |
87 | mcall send, [socketnum], packetbuf, , 0 |
89 | mcall send, [socketnum], packetbuf, , 0 |
88 | 90 | ||
89 | sdts_ret: |
91 | sdts_ret: |
90 | 92 | ||
91 | ret |
93 | ret |
92 | 94 | ||
93 | 95 | ||
94 | 96 | ||
95 | user_commands: |
97 | user_commands: |
96 | dd 'nick', cmd_usr_nick |
98 | dd 'nick', cmd_usr_nick |
97 | dd 'real', cmd_usr_real |
99 | dd 'real', cmd_usr_real |
98 | dd 'serv', cmd_usr_server |
100 | dd 'serv', cmd_usr_server |
99 | dd 'help', cmd_usr_help |
101 | dd 'help', cmd_usr_help |
100 | dd 'code', cmd_usr_code |
102 | dd 'code', cmd_usr_code |
101 | ; TODO: All other commands require a connection to the server. |
103 | ; TODO: All other commands require a connection to the server. |
102 | dd 'quer', cmd_usr_quer |
104 | dd 'quer', cmd_usr_quer |
103 | dd 'quit', cmd_usr_quit |
105 | dd 'quit', cmd_usr_quit |
104 | 106 | ||
105 | .number = ($ - user_commands) / 8 |
107 | .number = ($ - user_commands) / 8 |
106 | 108 | ||
107 | 109 | ||
108 | 110 | ||
109 | server_command: |
111 | server_command: |
110 | 112 | ||
111 | mov eax, dword[usercommand+1] |
113 | mov eax, dword[usercommand+1] |
112 | or eax, 0x20202020 |
114 | or eax, 0x20202020 |
113 | 115 | ||
114 | mov edi, user_commands |
116 | mov edi, user_commands |
115 | mov ecx, user_commands.number |
117 | mov ecx, user_commands.number |
116 | .loop: |
118 | .loop: |
117 | scasd |
119 | scasd |
118 | je .got_cmd |
120 | je .got_cmd |
119 | add edi, 4 |
121 | add edi, 4 |
120 | dec ecx |
122 | dec ecx |
121 | jnz .loop |
123 | jnz .loop |
122 | jmp cmd_usr_send ; If none of the previous commands, just send to server |
124 | jmp cmd_usr_send ; If none of the previous commands, just send to server |
123 | 125 | ||
124 | .got_cmd: |
126 | .got_cmd: |
125 | jmp dword[edi] |
127 | jmp dword[edi] |
126 | 128 | ||
127 | 129 | ||
128 | 130 | ||
129 | 131 | ||
130 | 132 | ||
131 | cmd_usr_quit: |
133 | cmd_usr_quit: |
132 | 134 | ||
133 | cmp [edit1.size], 5 |
135 | cmp [edit1.size], 5 |
134 | je .ok |
136 | je .ok |
135 | jb cmd_usr_send |
137 | jb cmd_usr_send |
136 | cmp byte[usercommand+5], ' ' |
138 | cmp byte[usercommand+5], ' ' |
137 | jne cmd_usr_send |
139 | jne cmd_usr_send |
138 | 140 | ||
139 | .ok: |
141 | .ok: |
140 | call cmd_usr_send |
142 | call cmd_usr_send |
141 | 143 | ||
142 | mcall close, [socketnum] |
144 | mcall close, [socketnum] |
143 | 145 | ||
144 | mov ecx, MAX_WINDOWS |
146 | mov ecx, MAX_WINDOWS |
145 | mov edi, windows |
147 | mov edi, windows |
146 | .loop: |
148 | .loop: |
147 | mov [edi + window.flags], FLAG_CLOSE |
149 | mov [edi + window.flags], FLAG_CLOSE |
148 | add edi, sizeof.window |
150 | add edi, sizeof.window |
149 | dec ecx |
151 | dec ecx |
150 | jnz .loop |
152 | jnz .loop |
151 | 153 | ||
152 | ret |
154 | ret |
153 | 155 | ||
154 | 156 | ||
155 | 157 | ||
156 | 158 | ||
157 | cmd_usr_nick: |
159 | cmd_usr_nick: |
158 | 160 | ||
159 | cmp [edit1.size], 5 |
161 | cmp [edit1.size], 5 |
160 | je .justprint |
162 | je .justprint |
161 | cmp byte[usercommand+5], ' ' |
163 | cmp byte[usercommand+5], ' ' |
162 | jne cmd_usr_send |
164 | jne cmd_usr_send |
163 | 165 | ||
164 | mov ecx, MAX_NICK_LEN |
166 | mov ecx, MAX_NICK_LEN |
165 | mov esi, usercommand+6 |
167 | mov esi, usercommand+6 |
166 | mov edi, user_nick |
168 | mov edi, user_nick |
167 | .loop: |
169 | .loop: |
168 | lodsb |
170 | lodsb |
169 | cmp al, 13 |
171 | cmp al, 13 |
170 | je .done |
172 | je .done |
171 | stosb |
173 | stosb |
172 | dec ecx |
174 | dec ecx |
173 | jnz .loop |
175 | jnz .loop |
174 | .done: |
176 | .done: |
175 | xor al, al |
177 | xor al, al |
176 | stosb |
178 | stosb |
177 | 179 | ||
178 | cmp [socketnum], 0 |
180 | cmp [socketnum], 0 |
179 | je .justprint |
181 | je .justprint |
180 | 182 | ||
181 | lea esi, [edi - usercommand] |
183 | lea esi, [edi - usercommand] |
182 | mcall send, [socketnum], usercommand+1, , 0 |
184 | mcall send, [socketnum], usercommand+1, , 0 |
183 | 185 | ||
184 | .justprint: |
186 | .justprint: |
185 | mov esi, str_nickchange |
187 | mov esi, str_nickchange |
186 | call print_text2 |
188 | call print_text2 |
187 | mov esi, user_nick |
189 | mov esi, user_nick |
188 | call print_text2 |
190 | call print_text2 |
189 | mov esi, str_dotnewline |
191 | mov esi, str_dotnewline |
190 | call print_text2 |
192 | call print_text2 |
191 | 193 | ||
192 | ret |
194 | ret |
193 | 195 | ||
194 | 196 | ||
195 | 197 | ||
196 | cmd_usr_real: |
198 | cmd_usr_real: |
197 | 199 | ||
198 | cmp byte[usercommand+5], ' ' |
200 | cmp byte[usercommand+5], ' ' |
199 | jne cmd_usr_send |
201 | jne cmd_usr_send |
200 | 202 | ||
201 | mov ecx, MAX_REAL_LEN |
203 | mov ecx, MAX_REAL_LEN |
202 | mov esi, usercommand+6 |
204 | mov esi, usercommand+6 |
203 | mov edi, user_real_name |
205 | mov edi, user_real_name |
204 | .loop: |
206 | .loop: |
205 | lodsb |
207 | lodsb |
206 | cmp al, 13 |
208 | cmp al, 13 |
207 | je .done |
209 | je .done |
208 | stosb |
210 | stosb |
209 | dec ecx |
211 | dec ecx |
210 | jnz .loop |
212 | jnz .loop |
211 | .done: |
213 | .done: |
212 | xor al, al |
214 | xor al, al |
213 | stosb |
215 | stosb |
214 | 216 | ||
215 | mov esi, str_realchange |
217 | mov esi, str_realchange |
216 | call print_text2 |
218 | call print_text2 |
217 | mov esi, user_real_name |
219 | mov esi, user_real_name |
218 | call print_text2 |
220 | call print_text2 |
219 | mov esi, str_dotnewline |
221 | mov esi, str_dotnewline |
220 | call print_text2 |
222 | call print_text2 |
221 | 223 | ||
222 | ret |
224 | ret |
223 | 225 | ||
224 | 226 | ||
225 | 227 | ||
226 | cmd_usr_server: |
228 | cmd_usr_server: |
227 | 229 | ||
228 | mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv' |
230 | mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv' |
229 | or eax, 0x00002020 |
231 | or eax, 0x00002020 |
230 | and eax, 0x00ffffff |
232 | and eax, 0x00ffffff |
231 | cmp eax, 'er ' |
233 | cmp eax, 'er ' |
232 | jne cmd_usr_send |
234 | jne cmd_usr_send |
233 | 235 | ||
234 | mov ecx, [edit1.size] ; ok now set the address |
236 | mov ecx, [edit1.size] ; ok now set the address |
235 | sub ecx, 8 |
237 | sub ecx, 8 |
236 | 238 | ||
237 | mov esi, usercommand+8 |
239 | mov esi, usercommand+8 |
238 | push esi |
240 | push esi |
239 | mov edi, irc_server_name |
241 | mov edi, irc_server_name |
240 | rep movsb |
242 | rep movsb |
241 | xor al, al |
243 | xor al, al |
242 | stosb |
244 | stosb |
243 | pop esi |
245 | pop esi |
244 | 246 | ||
245 | ; set it also in window name |
247 | ; set it also in window name |
246 | mov ebx, [window_print] |
248 | mov ebx, [window_print] |
247 | call window_set_name |
249 | call window_set_name |
248 | 250 | ||
249 | ; now connect |
251 | ; now connect |
250 | call socket_connect |
252 | call socket_connect |
251 | 253 | ||
252 | ret |
254 | ret |
253 | 255 | ||
254 | 256 | ||
255 | cmd_usr_quer: |
257 | cmd_usr_quer: |
256 | 258 | ||
257 | mov ecx, MAX_WINDOWS |
259 | mov ecx, MAX_WINDOWS |
258 | mov ebx, windows |
260 | mov ebx, windows |
259 | .loop: |
261 | .loop: |
260 | cmp [ebx + window.data_ptr], 0 |
262 | cmp [ebx + window.data_ptr], 0 |
261 | je .found |
263 | je .found |
262 | add ebx, sizeof.window |
264 | add ebx, sizeof.window |
263 | dec ecx |
265 | dec ecx |
264 | jnz .loop |
266 | jnz .loop |
265 | 267 | ||
266 | ; error: no available channels ! FIXME |
268 | ; error: no available channels ! FIXME |
267 | 269 | ||
268 | ret |
270 | ret |
269 | 271 | ||
270 | 272 | ||
271 | .found: |
273 | .found: |
272 | call window_create |
274 | call window_create |
273 | test eax, eax |
275 | test eax, eax |
274 | jz .error |
276 | jz .error |
275 | mov [ebx + window.data_ptr], eax |
277 | mov [ebx + window.data_ptr], eax |
276 | 278 | ||
277 | mov esi, usercommand+7 |
279 | mov esi, usercommand+7 |
278 | call window_set_name |
280 | call window_set_name |
279 | 281 | ||
280 | mov [ebx + window.type], WINDOWTYPE_CHAT |
282 | mov [ebx + window.type], WINDOWTYPE_CHAT |
281 | mov [ebx + window.flags], 0 |
283 | mov [ebx + window.flags], 0 |
282 | 284 | ||
283 | .error: |
285 | .error: |
284 | 286 | ||
285 | ret |
287 | ret |
286 | 288 | ||
287 | 289 | ||
288 | 290 | ||
289 | cmd_usr_help: |
291 | cmd_usr_help: |
290 | 292 | ||
291 | mov esi, str_help |
293 | mov esi, str_help |
292 | call print_text2 |
294 | call print_text2 |
293 | 295 | ||
294 | ret |
296 | ret |
295 | 297 | ||
296 | 298 | ||
297 | 299 | ||
298 | cmd_usr_code: |
300 | cmd_usr_code: |
299 | 301 | ||
300 | ; TODO |
302 | ; TODO |
301 | 303 | ||
302 | ret |
304 | ret |
303 | 305 | ||
304 | 306 | ||
305 | 307 | ||
306 | cmd_usr_send: |
308 | cmd_usr_send: |
307 | 309 | ||
308 | mov esi, usercommand+1 |
310 | mov esi, usercommand+1 |
309 | mov ecx, [edit1.size] |
311 | mov ecx, [edit1.size] |
310 | inc ecx |
312 | inc ecx |
311 | mov edi, packetbuf |
313 | mov edi, packetbuf |
312 | call recode |
314 | call recode |
313 | 315 | ||
314 | lea esi, [edi - packetbuf] |
316 | lea esi, [edi - packetbuf] |
315 | mcall send, [socketnum], packetbuf, , 0 |
317 | mcall send, [socketnum], packetbuf, , 0 |
316 | 318 | ||
317 | ret' |
319 | ret' |
318 | > |
320 | > |