Mercurial > pidgin
comparison src/protocols/oscar/icq.c @ 4624:a964972cb361
[gaim-migrate @ 4915]
Thanks to CmdrChalumpa for a lot of this code.
Vincas: I think I've improved on your methods a bit, too.
I employed some Kiaras-Furo shading, and--
Strongbad: I'll improve on your methods!
I replied to your patch with a lil more detail.
Thanks!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 28 Feb 2003 04:26:37 +0000 |
parents | 858979ab3867 |
children | 819ba05f5b1b |
comparison
equal
deleted
inserted
replaced
4623:a44382e8e6be | 4624:a964972cb361 |
---|---|
113 { | 113 { |
114 aim_conn_t *conn; | 114 aim_conn_t *conn; |
115 aim_frame_t *fr; | 115 aim_frame_t *fr; |
116 aim_snacid_t snacid; | 116 aim_snacid_t snacid; |
117 int bslen; | 117 int bslen; |
118 struct aim_icq_info *info; | |
118 | 119 |
119 if (!uin || uin[0] < '0' || uin[0] > '9') | 120 if (!uin || uin[0] < '0' || uin[0] > '9') |
120 return -EINVAL; | 121 return -EINVAL; |
121 | 122 |
122 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | 123 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
140 aimbs_putle16(&fr->data, snacid); /* eh. */ | 141 aimbs_putle16(&fr->data, snacid); /* eh. */ |
141 aimbs_putle16(&fr->data, 0x04b2); /* shrug. */ | 142 aimbs_putle16(&fr->data, 0x04b2); /* shrug. */ |
142 aimbs_putle32(&fr->data, atoi(uin)); | 143 aimbs_putle32(&fr->data, atoi(uin)); |
143 | 144 |
144 aim_tx_enqueue(sess, fr); | 145 aim_tx_enqueue(sess, fr); |
146 | |
147 /* Keep track of this request and the ICQ number and request ID */ | |
148 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); | |
149 info->reqid = snacid; | |
150 info->uin = atoi(sess->sn); | |
151 info->next = sess->icq_info; | |
152 sess->icq_info = info; | |
145 | 153 |
146 return 0; | 154 return 0; |
147 } | 155 } |
148 | 156 |
149 faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin) | 157 faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin) |
217 aimbs_putraw(&fr->data, xml, strlen(xml) + 1); | 225 aimbs_putraw(&fr->data, xml, strlen(xml) + 1); |
218 | 226 |
219 aim_tx_enqueue(sess, fr); | 227 aim_tx_enqueue(sess, fr); |
220 | 228 |
221 return 0; | 229 return 0; |
230 } | |
231 | |
232 static void aim_icq_freeinfo(struct aim_icq_info *info) { | |
233 if (!info) | |
234 return; | |
235 free(info->nick); | |
236 free(info->first); | |
237 free(info->last); | |
238 free(info->email); | |
239 free(info->homecity); | |
240 free(info->homestate); | |
241 free(info->homephone); | |
242 free(info->homefax); | |
243 free(info->homeaddr); | |
244 free(info->mobile); | |
245 free(info->homezip); | |
246 free(info->personalwebpage); | |
247 free(info->email2); | |
248 free(info->workcity); | |
249 free(info->workstate); | |
250 free(info->workphone); | |
251 free(info->workfax); | |
252 free(info->workaddr); | |
253 free(info->workzip); | |
254 free(info->workcompany); | |
255 free(info->workdivision); | |
256 free(info->workposition); | |
257 free(info->workwebpage); | |
258 free(info->info); | |
259 free(info); | |
222 } | 260 } |
223 | 261 |
224 /** | 262 /** |
225 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet. | 263 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet. |
226 */ | 264 */ |
280 fu16_t subtype; | 318 fu16_t subtype; |
281 struct aim_icq_info *info; | 319 struct aim_icq_info *info; |
282 aim_rxcallback_t userfunc; | 320 aim_rxcallback_t userfunc; |
283 | 321 |
284 subtype = aimbs_getle16(&qbs); | 322 subtype = aimbs_getle16(&qbs); |
285 info = (struct aim_icq_info *)malloc(sizeof(struct aim_icq_info)); | |
286 memset(info, 0, sizeof(struct aim_icq_info)); | |
287 aim_bstream_advance(&qbs, 1); /* 0x0a */ | 323 aim_bstream_advance(&qbs, 1); /* 0x0a */ |
324 | |
325 /* find other data from the same request */ | |
326 for (info = sess->icq_info; info && (info->reqid != reqid); info = info->next); | |
327 if (!info) { | |
328 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); | |
329 info->reqid = reqid; | |
330 info->next = sess->icq_info; | |
331 sess->icq_info = info; | |
332 } | |
288 | 333 |
289 switch (subtype) { | 334 switch (subtype) { |
290 case 0x00aa: { /* password change status */ | 335 case 0x00aa: { /* password change status */ |
291 aimbs_getle8(&qbs); /* 0x000a for success */ | 336 aimbs_getle8(&qbs); /* 0x000a for success */ |
292 } break; | 337 } break; |
293 | 338 |
294 case 0x00c8: { /* info summary (useful stuff) */ | 339 case 0x00c8: { /* general and "home" information */ |
295 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 340 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
296 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 341 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
297 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 342 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
298 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 343 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
299 info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 344 info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
300 info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 345 info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
301 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 346 info->homephone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
302 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 347 info->homefax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
303 info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 348 info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
304 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 349 info->mobile = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
305 info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 350 info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
306 info->homecountry = aimbs_getle16(&qbs); | 351 info->homecountry = aimbs_getle16(&qbs); |
307 } break; | 352 /* 1 byte timezone */ |
308 | 353 /* 1 byte hide email flag */ |
309 case 0x00dc: { /* personal web page */ | 354 } break; |
310 aim_bstream_advance(&qbs, 3); | 355 |
356 case 0x00dc: { /* personal information */ | |
357 info->age = aimbs_getle8(&qbs); | |
358 info->unknown = aimbs_getle8(&qbs); | |
359 info->gender = aimbs_getle8(&qbs); | |
311 info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 360 info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
312 } break; | 361 info->birthyear = aimbs_getle16(&qbs); |
313 | 362 info->birthmonth = aimbs_getle8(&qbs); |
314 case 0x00eb: { /* email address(es) */ | 363 info->birthday = aimbs_getle8(&qbs); |
315 aim_bstream_advance(&qbs, 2); /* Number of email addresses? */ | 364 info->language1 = aimbs_getle8(&qbs); |
316 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 365 info->language2 = aimbs_getle8(&qbs); |
317 } break; | 366 info->language3 = aimbs_getle8(&qbs); |
318 | 367 } break; |
368 | |
369 /* XXX - Look into the webpage thing for this, too */ | |
319 case 0x00d2: { /* work information */ | 370 case 0x00d2: { /* work information */ |
320 info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 371 info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
321 info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 372 info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
322 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 373 info->workphone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
323 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); | 374 info->workfax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
324 info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 375 info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
325 info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 376 info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
326 info->workcountry = aimbs_getle16(&qbs); | 377 info->workcountry = aimbs_getle16(&qbs); |
327 info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 378 info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
328 info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 379 info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
330 aim_bstream_advance(&qbs, 2); /* Number of webpage addresses? */ | 381 aim_bstream_advance(&qbs, 2); /* Number of webpage addresses? */ |
331 info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 382 info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
332 } break; | 383 } break; |
333 | 384 |
334 case 0x00e6: { /* additional personal information */ | 385 case 0x00e6: { /* additional personal information */ |
335 info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 386 info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs)-1); |
387 } break; | |
388 | |
389 /* XXX - Find out the structure of this. Probably make a 2d array of strings */ | |
390 case 0x00eb: { /* email address(es) */ | |
391 info->numaddresses = aimbs_getle16(&qbs); | |
392 info->email2 = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
336 } break; | 393 } break; |
337 | 394 |
338 case 0x00f0: { /* personal interests */ | 395 case 0x00f0: { /* personal interests */ |
339 } break; | 396 } break; |
340 | 397 |
353 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | 410 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
354 /* Then 0x00 02 00 00 00 00 00 */ | 411 /* Then 0x00 02 00 00 00 00 00 */ |
355 } break; | 412 } break; |
356 } /* End switch statement */ | 413 } /* End switch statement */ |
357 | 414 |
358 if (subtype == 0x019a) { | 415 if (!(snac->flags & 0x0001)) { |
359 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_SIMPLEINFO))) | 416 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO))) |
360 ret = userfunc(sess, rx, info); | 417 ret = userfunc(sess, rx, info); |
361 } else { | 418 |
362 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALLINFO))) | 419 if (sess->icq_info == info) { |
363 ret = userfunc(sess, rx, info); | 420 sess->icq_info = info->next; |
421 } else { | |
422 struct aim_icq_info *cur; | |
423 for (cur=sess->icq_info; (cur->next && (cur->next!=info)); cur=cur->next); | |
424 if (cur->next) | |
425 cur->next = cur->next->next; | |
426 } | |
427 aim_icq_freeinfo(info); | |
364 } | 428 } |
365 | |
366 free(info->nick); | |
367 free(info->first); | |
368 free(info->last); | |
369 free(info->email); | |
370 free(info->personalwebpage); | |
371 free(info->info); | |
372 free(info->homecity); | |
373 free(info->homestate); | |
374 free(info->homeaddr); | |
375 free(info->homezip); | |
376 free(info->workcity); | |
377 free(info->workstate); | |
378 free(info->workaddr); | |
379 free(info->workzip); | |
380 free(info->workcompany); | |
381 free(info->workdivision); | |
382 free(info->workposition); | |
383 free(info->workwebpage); | |
384 free(info); | |
385 } | 429 } |
386 | 430 |
387 aim_freetlvchain(&tl); | 431 aim_freetlvchain(&tl); |
388 | 432 |
389 return ret; | 433 return ret; |