comparison plugins/icq/tcphandle.c @ 1309:0a766047b4fd

[gaim-migrate @ 1319] Yay, new icqlib committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 19 Dec 2000 10:08:29 +0000
parents 201ec77f3a60
children 4c510ca3563f
comparison
equal deleted inserted replaced
1308:4741b5a75b9f 1309:0a766047b4fd
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* 2 /*
3 $Id: tcphandle.c 1162 2000-11-28 02:22:42Z warmenhoven $ 3 $Id: tcphandle.c 1319 2000-12-19 10:08:29Z warmenhoven $
4 $Log$ 4 $Log$
5 Revision 1.1 2000/11/28 02:22:42 warmenhoven 5 Revision 1.2 2000/12/19 10:08:29 warmenhoven
6 icq. whoop de doo 6 Yay, new icqlib
7
8 Revision 1.14 2000/12/06 05:15:45 denis
9 Handling for mass TCP messages has been added based on patch by
10 Konstantin Klyagin <konst@konst.org.ua>
11
12 Revision 1.13 2000/08/13 19:44:41 denis
13 Cyrillic recoding on received URL description added.
7 14
8 Revision 1.12 2000/07/09 22:19:35 bills 15 Revision 1.12 2000/07/09 22:19:35 bills
9 added new *Close functions, use *Close functions instead of *Delete 16 added new *Close functions, use *Close functions instead of *Delete
10 where correct, and misc cleanup 17 where correct, and misc cleanup
11 18
131 (void)icq_PacketRead32(p); 138 (void)icq_PacketRead32(p);
132 (void)icq_PacketRead8(p); 139 (void)icq_PacketRead8(p);
133 status=icq_PacketRead16(p); 140 status=icq_PacketRead16(p);
134 command_type=icq_PacketRead16(p); 141 command_type=icq_PacketRead16(p);
135 142
136 switch(type) 143 switch(type & ~ICQ_TCP_MASS_MASK)
137 { 144 {
138 case ICQ_TCP_MSG_MSG: 145 case ICQ_TCP_MSG_MSG:
139 case ICQ_TCP_MSG_URL: 146 case ICQ_TCP_MSG_URL:
140 p->id=icq_PacketRead32(p); 147 p->id=icq_PacketRead32(p);
141 break; 148 break;
170 #endif 177 #endif
171 178
172 switch(command) 179 switch(command)
173 { 180 {
174 case ICQ_TCP_MESSAGE: 181 case ICQ_TCP_MESSAGE:
175 switch(type) 182 switch(type & ~ICQ_TCP_MASS_MASK)
176 { 183 {
177 case ICQ_TCP_MSG_MSG: 184 case ICQ_TCP_MSG_MSG:
178 icq_TCPOnMessageReceived(plink->icqlink, uin, message, p->id, plink); 185 icq_TCPOnMessageReceived(plink->icqlink, uin, message, p->id, plink);
179 break; 186 break;
180 187
195 break; 202 break;
196 } 203 }
197 break; 204 break;
198 205
199 case ICQ_TCP_ACK: 206 case ICQ_TCP_ACK:
200 switch(type) { 207 switch(type)
208 {
201 case ICQ_TCP_MSG_CHAT: 209 case ICQ_TCP_MSG_CHAT:
202 icq_HandleChatAck(plink, p, port); 210 icq_HandleChatAck(plink, p, port);
203 break; 211 break;
204 212
205 case ICQ_TCP_MSG_FILE: 213 case ICQ_TCP_MSG_FILE:
206 icq_HandleFileAck(plink, p, port); 214 icq_HandleFileAck(plink, p, port);
207 break; 215 break;
208 216
209 case ICQ_TCP_MSG_MSG: 217 case ICQ_TCP_MSG_MSG:
210 case ICQ_TCP_MSG_URL: 218 case ICQ_TCP_MSG_URL:
211 if(plink->icqlink->icq_RequestNotify) { 219 if(plink->icqlink->icq_RequestNotify)
220 {
212 icq_FmtLog(plink->icqlink, ICQ_LOG_MESSAGE, "received ack %d\n", p->id); 221 icq_FmtLog(plink->icqlink, ICQ_LOG_MESSAGE, "received ack %d\n", p->id);
213 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, p->id, ICQ_NOTIFY_ACK, status, 222 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, p->id, ICQ_NOTIFY_ACK, status,
214 (void *)message); 223 (void *)message);
215 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, p->id, ICQ_NOTIFY_SUCCESS, 0, 0); 224 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, p->id, ICQ_NOTIFY_SUCCESS, 0, 0);
216 } 225 }
217 break; 226 break;
218 } 227 }
219 break; 228 break;
220 229
221 case ICQ_TCP_CANCEL: 230 case ICQ_TCP_CANCEL:
222 /* icq_TCPProcessCancel(p); */ 231 /* icq_TCPProcessCancel(p); */
223 break; 232 break;
224 233
225 default: 234 default:
226 icq_FmtLog(plink->icqlink, ICQ_LOG_WARNING, 235 icq_FmtLog(plink->icqlink, ICQ_LOG_WARNING,
227 "unknown packet command %d!\n", command); 236 "unknown packet command %d!\n", command);
228 } 237 }
229 } 238 }
230 239
231 void icq_TCPProcessCancel(icq_Packet *p) 240 void icq_TCPProcessCancel(icq_Packet *p)
232 { 241 {
238 remove packet from queue 247 remove packet from queue
239 */ 248 */
240 } 249 }
241 250
242 int icq_TCPProcessHello(icq_Packet *p, icq_TCPLink *plink) 251 int icq_TCPProcessHello(icq_Packet *p, icq_TCPLink *plink)
243 { 252 {
244 /* TCP Hello packet */ 253 /* TCP Hello packet */
245 BYTE code; /* 0xFF - init packet code */ 254 BYTE code; /* 0xFF - init packet code */
246 DWORD version; /* tcp version */ 255 DWORD version; /* tcp version */
247 DWORD remote_port; /* remote message listen port */ 256 DWORD remote_port; /* remote message listen port */
248 DWORD remote_uin; /* remote uin */ 257 DWORD remote_uin; /* remote uin */
335 #ifdef TCP_PACKET_TRACE 344 #ifdef TCP_PACKET_TRACE
336 printf("tcp url packet received from %lu { sequence=%lx }\n", 345 printf("tcp url packet received from %lu { sequence=%lx }\n",
337 uin, id); 346 uin, id);
338 #endif /*TCP_PACKET_TRACE*/ 347 #endif /*TCP_PACKET_TRACE*/
339 348
340 if(link->icq_RecvURL) { 349 if(link->icq_RecvURL)
341 350 {
342 /* use the current system time for time received */ 351 /* use the current system time for time received */
343 time_t t=time(0); 352 time_t t=time(0);
344 struct tm *ptime=localtime(&t); 353 struct tm *ptime=localtime(&t);
345 icq_Packet *pack; 354 icq_Packet *pack;
346 char *pfe; 355 char *pfe;
347 icq_TCPLink *plink=icq_FindTCPLink(link, uin, TCP_LINK_MESSAGE); 356 icq_TCPLink *plink=icq_FindTCPLink(link, uin, TCP_LINK_MESSAGE);
348 357
349 /* the URL is split from the description by 0xFE */ 358 /* the URL is split from the description by 0xFE */
350 pfe=strchr(message, '\xFE'); 359 pfe=strchr(message, '\xFE');
351 *pfe=0; 360 *pfe=0;
361 icq_RusConv("wk", (char*)message);
352 (*link->icq_RecvURL)(link, uin, ptime->tm_hour, ptime->tm_min, 362 (*link->icq_RecvURL)(link, uin, ptime->tm_hour, ptime->tm_min,
353 ptime->tm_mday, ptime->tm_mon+1, ptime->tm_year+1900, pfe+1, message); 363 ptime->tm_mday, ptime->tm_mon+1, ptime->tm_year+1900, pfe+1, message);
354 364
355 /* send an acknowledgement to the remote client */ 365 /* send an acknowledgement to the remote client */
356 pack=icq_TCPCreateURLAck(plink,0); 366 pack=icq_TCPCreateURLAck(plink,0);
360 printf("tcp message ack sent to %lu { sequence=%lx }\n", uin, id); 370 printf("tcp message ack sent to %lu { sequence=%lx }\n", uin, id);
361 #endif 371 #endif
362 icq_PacketDelete(pack); 372 icq_PacketDelete(pack);
363 } 373 }
364 } 374 }
365
366