| 82 |
82 |
| 83 /* position starts with 0x0000, |
83 /* position starts with 0x0000, |
| 84 * server may return a position tag if list is too long for one packet */ |
84 * server may return a position tag if list is too long for one packet */ |
| 85 void qq_request_get_buddies_list(PurpleConnection *gc, guint16 position, gint update_class) |
85 void qq_request_get_buddies_list(PurpleConnection *gc, guint16 position, gint update_class) |
| 86 { |
86 { |
| |
87 qq_data *qd; |
| 87 guint8 raw_data[16] = {0}; |
88 guint8 raw_data[16] = {0}; |
| 88 gint bytes = 0; |
89 gint bytes = 0; |
| |
90 |
| |
91 qd = (qq_data *) gc->proto_data; |
| 89 |
92 |
| 90 /* 000-001 starting position, can manually specify */ |
93 /* 000-001 starting position, can manually specify */ |
| 91 bytes += qq_put16(raw_data + bytes, position); |
94 bytes += qq_put16(raw_data + bytes, position); |
| 92 /* before Mar 18, 2004, any value can work, and we sent 00 |
95 /* before Mar 18, 2004, any value can work, and we sent 00 |
| 93 * I do not know what data QQ server is expecting, as QQ2003iii 0304 itself |
96 * I do not know what data QQ server is expecting, as QQ2003iii 0304 itself |
| 94 * even can sending packets 00 and get no response. |
97 * even can sending packets 00 and get no response. |
| 95 * Now I tested that 00,00,00,00,00,01 work perfectly |
98 * Now I tested that 00,00,00,00,00,01 work perfectly |
| 96 * March 22, found the 00,00,00 starts to work as well */ |
99 * March 22, found the 00,00,00 starts to work as well */ |
| 97 bytes += qq_put8(raw_data + bytes, 0x00); |
100 bytes += qq_put8(raw_data + bytes, 0x00); |
| 98 |
101 if (qd->client_version >= 2007) { |
| |
102 bytes += qq_put16(raw_data + bytes, 0x0000); |
| |
103 } |
| |
104 |
| 99 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_LIST, raw_data, bytes, update_class, 0); |
105 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDIES_LIST, raw_data, bytes, update_class, 0); |
| 100 } |
106 } |
| 101 |
107 |
| 102 /* get all list, buddies & Quns with groupsid support */ |
108 /* get all list, buddies & Quns with groupsid support */ |
| 103 void qq_request_get_buddies_and_rooms(PurpleConnection *gc, guint32 position, gint update_class) |
109 void qq_request_get_buddies_and_rooms(PurpleConnection *gc, guint32 position, gint update_class) |
| 175 bytes += qq_get8(&position, data + bytes); |
181 bytes += qq_get8(&position, data + bytes); |
| 176 |
182 |
| 177 count = 0; |
183 count = 0; |
| 178 while (bytes < data_len) { |
184 while (bytes < data_len) { |
| 179 if (data_len - bytes < QQ_ONLINE_BUDDY_ENTRY_LEN) { |
185 if (data_len - bytes < QQ_ONLINE_BUDDY_ENTRY_LEN) { |
| 180 purple_debug_error("QQ", "[buddies online] only %d, need %d", |
186 purple_debug_error("QQ", "[buddies online] only %d, need %d\n", |
| 181 (data_len - bytes), QQ_ONLINE_BUDDY_ENTRY_LEN); |
187 (data_len - bytes), QQ_ONLINE_BUDDY_ENTRY_LEN); |
| 182 break; |
188 break; |
| 183 } |
189 } |
| 184 memset(&bo, 0 ,sizeof(bo)); |
190 memset(&bo, 0 ,sizeof(bo)); |
| 185 |
191 |
| 290 |
296 |
| 291 pascal_len = convert_as_pascal_string(data + bytes, &q_bud->nickname, QQ_CHARSET_DEFAULT); |
297 pascal_len = convert_as_pascal_string(data + bytes, &q_bud->nickname, QQ_CHARSET_DEFAULT); |
| 292 bytes += pascal_len; |
298 bytes += pascal_len; |
| 293 qq_filter_str(q_bud->nickname); |
299 qq_filter_str(q_bud->nickname); |
| 294 |
300 |
| |
301 /* Fixme: merge following as 32bit flag */ |
| 295 bytes += qq_get16(&unknown, data + bytes); |
302 bytes += qq_get16(&unknown, data + bytes); |
| 296 bytes += qq_get8(&q_bud->ext_flag, data + bytes); |
303 bytes += qq_get8(&q_bud->ext_flag, data + bytes); |
| 297 bytes += qq_get8(&q_bud->comm_flag, data + bytes); |
304 bytes += qq_get8(&q_bud->comm_flag, data + bytes); |
| 298 |
305 |
| 299 bytes_expected = 12 + pascal_len; |
306 if (qd->client_version >= 2007) { |
| |
307 bytes += 4; /* skip 4 bytes */ |
| |
308 bytes_expected = 16 + pascal_len; |
| |
309 } else { |
| |
310 bytes_expected = 12 + pascal_len; |
| |
311 } |
| |
312 |
| 300 |
313 |
| 301 if (q_bud->uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
314 if (q_bud->uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
| 302 purple_debug_info("QQ", |
315 purple_debug_info("QQ", |
| 303 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); |
316 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); |
| 304 g_free(q_bud->nickname); |
317 g_free(q_bud->nickname); |
| 388 group = qq_room_search_id(gc, uid); |
401 group = qq_room_search_id(gc, uid); |
| 389 if(group == NULL) { |
402 if(group == NULL) { |
| 390 purple_debug_info("QQ", |
403 purple_debug_info("QQ", |
| 391 "Not find room id %d in qq_process_get_buddies_and_rooms\n", uid); |
404 "Not find room id %d in qq_process_get_buddies_and_rooms\n", uid); |
| 392 qq_set_pending_id(&qd->adding_groups_from_server, uid, TRUE); |
405 qq_set_pending_id(&qd->adding_groups_from_server, uid, TRUE); |
| |
406 //group = g_newa(qq_group, 1); |
| |
407 //group->id = uid; |
| |
408 qq_send_room_cmd_mess(gc, QQ_ROOM_CMD_GET_INFO, uid, NULL, 0, |
| |
409 0, 0); |
| 393 } else { |
410 } else { |
| 394 group->my_role = QQ_ROOM_ROLE_YES; |
411 group->my_role = QQ_ROOM_ROLE_YES; |
| 395 qq_group_refresh(gc, group); |
412 qq_group_refresh(gc, group); |
| 396 } |
413 } |
| 397 ++j; |
414 ++j; |
| 467 if (!qd->is_login) |
485 if (!qd->is_login) |
| 468 return; |
486 return; |
| 469 |
487 |
| 470 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) { |
488 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) { |
| 471 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE; |
489 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE; |
| |
490 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) |
| |
491 { |
| |
492 if (qd->client_version >= 2007) { |
| |
493 away_cmd = QQ_BUDDY_ONLINE_BUSY; |
| |
494 } else { |
| |
495 away_cmd = QQ_BUDDY_ONLINE_INVISIBLE; |
| |
496 } |
| 472 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY) |
497 } else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY) |
| 473 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY) |
498 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY) |
| 474 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) { |
499 || purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_UNAVAILABLE)) { |
| 475 away_cmd = QQ_BUDDY_ONLINE_AWAY; |
500 away_cmd = QQ_BUDDY_ONLINE_AWAY; |
| 476 } else { |
501 } else { |
| 477 away_cmd = QQ_BUDDY_ONLINE_NORMAL; |
502 away_cmd = QQ_BUDDY_ONLINE_NORMAL; |
| 478 } |
503 } |
| 479 |
504 |
| 480 misc_status = 0x00000000; |
505 misc_status = 0x00000000; |
| 481 fake_video = purple_prefs_get_bool("/plugins/prpl/qq/show_fake_video"); |
506 fake_video = purple_prefs_get_bool("/plugins/prpl/qq/show_fake_video"); |
| 482 if (fake_video) |
507 if (fake_video) |
| 483 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO; |
508 misc_status |= QQ_MISC_STATUS_HAVING_VIIDEO; |
| 484 |
509 |
| 485 if (qd->client_version > 2005) { |
510 if (qd->client_version >= 2007) { |
| 486 bytes = 0; |
511 bytes = 0; |
| 487 bytes += qq_put8(raw_data + bytes, away_cmd); |
512 bytes += qq_put8(raw_data + bytes, away_cmd); |
| 488 /* status version */ |
513 /* status version */ |
| 489 bytes += qq_put16(raw_data + bytes, 0); |
514 bytes += qq_put16(raw_data + bytes, 0); |
| 490 bytes += qq_put16(raw_data + bytes, 0); |
515 bytes += qq_put16(raw_data + bytes, 0); |