| 146 /* 013-014: client tag */ |
146 /* 013-014: client tag */ |
| 147 bytes += qq_get16(&bs->unknown3, data + bytes); |
147 bytes += qq_get16(&bs->unknown3, data + bytes); |
| 148 /* 015-030: unknown key */ |
148 /* 015-030: unknown key */ |
| 149 bytes += qq_getdata(&(bs->unknown_key[0]), QQ_KEY_LENGTH, data + bytes); |
149 bytes += qq_getdata(&(bs->unknown_key[0]), QQ_KEY_LENGTH, data + bytes); |
| 150 |
150 |
| 151 purple_debug_info("QQ_STATUS", |
151 purple_debug_info("QQ", "Status:%d, uid: %u, ip: %s:%d, U: %d - %d - %04X\n", |
| 152 "uid: %d, U1: %d, ip: %s:%d, U2:%d, status:%d, U3:%04X\n", |
152 bs->status, bs->uid, inet_ntoa(bs->ip), bs->port, |
| 153 bs->uid, bs->unknown1, inet_ntoa(bs->ip), bs->port, |
153 bs->unknown1, bs->unknown2, bs->unknown3); |
| 154 bs->unknown2, bs->status, bs->unknown3); |
|
| 155 |
154 |
| 156 return bytes; |
155 return bytes; |
| 157 } |
156 } |
| 158 |
157 |
| 159 /* process the reply packet for get_buddies_online packet */ |
158 /* process the reply packet for get_buddies_online packet */ |
| 218 (bytes - bytes_start), entry_len); |
219 (bytes - bytes_start), entry_len); |
| 219 continue; |
220 continue; |
| 220 } /* check if it is a valid entry */ |
221 } /* check if it is a valid entry */ |
| 221 |
222 |
| 222 if (bs.uid == qd->uid) { |
223 if (bs.uid == qd->uid) { |
| 223 purple_debug_warning("QQ", "I am in online list %d\n", bs.uid); |
224 purple_debug_warning("QQ", "I am in online list %u\n", bs.uid); |
| 224 } |
225 } |
| 225 |
226 |
| 226 /* update buddy information */ |
227 /* update buddy information */ |
| 227 bd = qq_buddy_data_find(gc, bs.uid); |
228 who = uid_to_purple_name(bs.uid); |
| |
229 buddy = purple_find_buddy(gc->account, who); |
| |
230 g_free(who); |
| |
231 if (buddy == NULL) { |
| |
232 /* create no-auth buddy */ |
| |
233 buddy = qq_buddy_new(gc, bs.uid); |
| |
234 } |
| |
235 bd = (buddy == NULL) ? NULL : (qq_buddy_data *)buddy->proto_data; |
| 228 if (bd == NULL) { |
236 if (bd == NULL) { |
| 229 purple_debug_error("QQ", |
237 purple_debug_error("QQ", |
| 230 "Got an online buddy %d, but not in my buddy list\n", bs.uid); |
238 "Got an online buddy %u, but not in my buddy list\n", bs.uid); |
| 231 continue; |
239 continue; |
| 232 } |
240 } |
| 233 /* we find one and update qq_buddy_data */ |
|
| 234 /* |
241 /* |
| 235 if(0 != fe->s->client_tag) |
242 if(0 != fe->s->client_tag) |
| 236 q_bud->client_tag = fe->s->client_tag; |
243 q_bud->client_tag = fe->s->client_tag; |
| 237 */ |
244 */ |
| 238 if (bd->status != bs.status || bd->comm_flag != packet.comm_flag) { |
245 if (bd->status != bs.status || bd->comm_flag != packet.comm_flag) { |
| 311 bytes_expected = 12 + nickname_len; |
318 bytes_expected = 12 + nickname_len; |
| 312 } |
319 } |
| 313 |
320 |
| 314 if (bd.uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
321 if (bd.uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
| 315 purple_debug_info("QQ", |
322 purple_debug_info("QQ", |
| 316 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); |
323 "Buddy entry, expect %d bytes, read %d bytes\n", |
| |
324 bytes_expected, bytes - buddy_bytes); |
| 317 g_free(bd.nickname); |
325 g_free(bd.nickname); |
| 318 continue; |
326 continue; |
| 319 } else { |
327 } else { |
| 320 count++; |
328 count++; |
| 321 } |
329 } |
| 385 /* 04: type 0x1:buddy 0x4:Qun */ |
393 /* 04: type 0x1:buddy 0x4:Qun */ |
| 386 bytes += qq_get8(&type, data + bytes); |
394 bytes += qq_get8(&type, data + bytes); |
| 387 /* 05: skip unknow 0x00 */ |
395 /* 05: skip unknow 0x00 */ |
| 388 bytes += 1; |
396 bytes += 1; |
| 389 if (uid == 0 || (type != 0x1 && type != 0x4)) { |
397 if (uid == 0 || (type != 0x1 && type != 0x4)) { |
| 390 purple_debug_info("QQ", "Buddy entry, uid=%d, type=%d", uid, type); |
398 purple_debug_info("QQ", "Buddy entry, uid=%u, type=%d", uid, type); |
| 391 continue; |
399 continue; |
| 392 } |
400 } |
| 393 if(0x1 == type) { /* a buddy */ |
401 if(0x1 == type) { /* a buddy */ |
| 394 /* don't do anything but count - buddies are handled by |
402 /* don't do anything but count - buddies are handled by |
| 395 * qq_request_get_buddies */ |
403 * qq_request_get_buddies */ |
| 396 ++i; |
404 ++i; |
| 397 } else { /* a group */ |
405 } else { /* a group */ |
| 398 rmd = qq_room_data_find(gc, uid); |
406 rmd = qq_room_data_find(gc, uid); |
| 399 if(rmd == NULL) { |
407 if(rmd == NULL) { |
| 400 purple_debug_info("QQ", "Unknow room id %d", uid); |
408 purple_debug_info("QQ", "Unknow room id %u", uid); |
| 401 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, uid); |
409 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, uid); |
| 402 } else { |
410 } else { |
| 403 rmd->my_role = QQ_ROOM_ROLE_YES; |
411 rmd->my_role = QQ_ROOM_ROLE_YES; |
| 404 } |
412 } |
| 405 ++j; |
413 ++j; |
| 547 /* 031-034: Unknow, maybe my uid */ |
557 /* 031-034: Unknow, maybe my uid */ |
| 548 /* This has a value of 0 when we've changed our status to |
558 /* This has a value of 0 when we've changed our status to |
| 549 * QQ_BUDDY_ONLINE_INVISIBLE */ |
559 * QQ_BUDDY_ONLINE_INVISIBLE */ |
| 550 bytes += qq_get32(&my_uid, data + bytes); |
560 bytes += qq_get32(&my_uid, data + bytes); |
| 551 |
561 |
| 552 bd = qq_buddy_data_find(gc, bs.uid); |
562 /* update buddy information */ |
| |
563 who = uid_to_purple_name(bs.uid); |
| |
564 buddy = purple_find_buddy(gc->account, who); |
| |
565 g_free(who); |
| |
566 if (buddy == NULL) { |
| |
567 /* create no-auth buddy */ |
| |
568 buddy = qq_buddy_new(gc, bs.uid); |
| |
569 } |
| |
570 bd = (buddy == NULL) ? NULL : (qq_buddy_data *) buddy->proto_data; |
| 553 if (bd == NULL) { |
571 if (bd == NULL) { |
| 554 purple_debug_warning("QQ", "Get status of unknown buddy %d\n", bs.uid); |
572 purple_debug_warning("QQ", "Got status of no-auth buddy %u\n", bs.uid); |
| 555 return; |
573 return; |
| 556 } |
574 } |
| 557 |
575 |
| 558 if(bs.ip.s_addr != 0) { |
576 if(bs.ip.s_addr != 0) { |
| 559 bd->ip.s_addr = bs.ip.s_addr; |
577 bd->ip.s_addr = bs.ip.s_addr; |
| 579 { |
597 { |
| 580 gchar *who; |
598 gchar *who; |
| 581 gchar *status_id; |
599 gchar *status_id; |
| 582 |
600 |
| 583 g_return_if_fail(uid != 0); |
601 g_return_if_fail(uid != 0); |
| 584 |
|
| 585 who = uid_to_purple_name(uid); |
|
| 586 |
602 |
| 587 /* purple supports signon and idle time |
603 /* purple supports signon and idle time |
| 588 * but it is not much use for QQ, I do not use them */ |
604 * but it is not much use for QQ, I do not use them */ |
| 589 /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ |
605 /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ |
| 590 status_id = "available"; |
606 status_id = "available"; |
| 610 default: |
626 default: |
| 611 status_id = "invisible"; |
627 status_id = "invisible"; |
| 612 purple_debug_error("QQ", "unknown status: 0x%X\n", status); |
628 purple_debug_error("QQ", "unknown status: 0x%X\n", status); |
| 613 break; |
629 break; |
| 614 } |
630 } |
| 615 purple_debug_info("QQ", "Update buddy %s status as %s\n", who, status_id); |
631 |
| |
632 purple_debug_info("QQ", "buddy %u status = %s\n", uid, status_id); |
| |
633 who = uid_to_purple_name(uid); |
| 616 purple_prpl_got_user_status(gc->account, who, status_id, NULL); |
634 purple_prpl_got_user_status(gc->account, who, status_id, NULL); |
| 617 |
635 |
| 618 if (flag & QQ_COMM_FLAG_MOBILE && status != QQ_BUDDY_OFFLINE) |
636 if (flag & QQ_COMM_FLAG_MOBILE && status != QQ_BUDDY_OFFLINE) |
| 619 purple_prpl_got_user_status(gc->account, who, "mobile", NULL); |
637 purple_prpl_got_user_status(gc->account, who, "mobile", NULL); |
| 620 else |
638 else |