Mercurial > pidgin
comparison libpurple/protocols/qq/buddy_list.c @ 24608:b22f6fb98cca
Change QQ number to unsigned long
author | Hu Yong <ccpaging@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 07:00:27 +0000 |
parents | d35672443baa |
children | 80deea528c4b |
comparison
equal
deleted
inserted
replaced
24607:9d46ae47b4f8 | 24608:b22f6fb98cca |
---|---|
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", |
152 "uid: %d, U1: %d, ip: %s:%d, U2:%d, status:%d, U3:%04X\n", | 152 "uid: %u, U1: %d, ip: %s:%d, U2:%d, status:%d, U3:%04X\n", |
153 bs->uid, bs->unknown1, inet_ntoa(bs->ip), bs->port, | 153 bs->uid, bs->unknown1, inet_ntoa(bs->ip), bs->port, |
154 bs->unknown2, bs->status, bs->unknown3); | 154 bs->unknown2, bs->status, bs->unknown3); |
155 | 155 |
156 return bytes; | 156 return bytes; |
157 } | 157 } |
161 { | 161 { |
162 qq_data *qd; | 162 qq_data *qd; |
163 gint bytes, bytes_start; | 163 gint bytes, bytes_start; |
164 gint count; | 164 gint count; |
165 guint8 position; | 165 guint8 position; |
166 gchar *who; | |
167 PurpleBuddy *buddy; | |
166 qq_buddy_data *bd; | 168 qq_buddy_data *bd; |
167 int entry_len = 38; | 169 int entry_len = 38; |
168 | 170 |
169 qq_buddy_status bs; | 171 qq_buddy_status bs; |
170 struct { | 172 struct { |
218 (bytes - bytes_start), entry_len); | 220 (bytes - bytes_start), entry_len); |
219 continue; | 221 continue; |
220 } /* check if it is a valid entry */ | 222 } /* check if it is a valid entry */ |
221 | 223 |
222 if (bs.uid == qd->uid) { | 224 if (bs.uid == qd->uid) { |
223 purple_debug_warning("QQ", "I am in online list %d\n", bs.uid); | 225 purple_debug_warning("QQ", "I am in online list %u\n", bs.uid); |
224 } | 226 } |
225 | 227 |
226 /* update buddy information */ | 228 /* update buddy information */ |
227 bd = qq_buddy_data_find(gc, bs.uid); | 229 who = uid_to_purple_name(bs.uid); |
230 buddy = purple_find_buddy(gc->account, who); | |
231 g_free(who); | |
232 if (buddy == NULL) { | |
233 /* create no-auth buddy */ | |
234 buddy = qq_buddy_new(gc, bs.uid); | |
235 } | |
236 bd = (buddy == NULL) ? NULL : (qq_buddy_data *)buddy->proto_data; | |
228 if (bd == NULL) { | 237 if (bd == NULL) { |
229 purple_debug_error("QQ", | 238 purple_debug_error("QQ", |
230 "Got an online buddy %d, but not in my buddy list\n", bs.uid); | 239 "Got an online buddy %u, but not in my buddy list\n", bs.uid); |
231 continue; | 240 continue; |
232 } | 241 } |
233 /* we find one and update qq_buddy_data */ | |
234 /* | 242 /* |
235 if(0 != fe->s->client_tag) | 243 if(0 != fe->s->client_tag) |
236 q_bud->client_tag = fe->s->client_tag; | 244 q_bud->client_tag = fe->s->client_tag; |
237 */ | 245 */ |
238 if (bd->status != bs.status || bd->comm_flag != packet.comm_flag) { | 246 if (bd->status != bs.status || bd->comm_flag != packet.comm_flag) { |
311 bytes_expected = 12 + nickname_len; | 319 bytes_expected = 12 + nickname_len; |
312 } | 320 } |
313 | 321 |
314 if (bd.uid == 0 || (bytes - buddy_bytes) != bytes_expected) { | 322 if (bd.uid == 0 || (bytes - buddy_bytes) != bytes_expected) { |
315 purple_debug_info("QQ", | 323 purple_debug_info("QQ", |
316 "Buddy entry, expect %d bytes, read %d bytes\n", bytes_expected, bytes - buddy_bytes); | 324 "Buddy entry, expect %d bytes, read %d bytes\n", |
325 bytes_expected, bytes - buddy_bytes); | |
317 g_free(bd.nickname); | 326 g_free(bd.nickname); |
318 continue; | 327 continue; |
319 } else { | 328 } else { |
320 count++; | 329 count++; |
321 } | 330 } |
385 /* 04: type 0x1:buddy 0x4:Qun */ | 394 /* 04: type 0x1:buddy 0x4:Qun */ |
386 bytes += qq_get8(&type, data + bytes); | 395 bytes += qq_get8(&type, data + bytes); |
387 /* 05: skip unknow 0x00 */ | 396 /* 05: skip unknow 0x00 */ |
388 bytes += 1; | 397 bytes += 1; |
389 if (uid == 0 || (type != 0x1 && type != 0x4)) { | 398 if (uid == 0 || (type != 0x1 && type != 0x4)) { |
390 purple_debug_info("QQ", "Buddy entry, uid=%d, type=%d", uid, type); | 399 purple_debug_info("QQ", "Buddy entry, uid=%u, type=%d", uid, type); |
391 continue; | 400 continue; |
392 } | 401 } |
393 if(0x1 == type) { /* a buddy */ | 402 if(0x1 == type) { /* a buddy */ |
394 /* don't do anything but count - buddies are handled by | 403 /* don't do anything but count - buddies are handled by |
395 * qq_request_get_buddies */ | 404 * qq_request_get_buddies */ |
396 ++i; | 405 ++i; |
397 } else { /* a group */ | 406 } else { /* a group */ |
398 rmd = qq_room_data_find(gc, uid); | 407 rmd = qq_room_data_find(gc, uid); |
399 if(rmd == NULL) { | 408 if(rmd == NULL) { |
400 purple_debug_info("QQ", "Unknow room id %d", uid); | 409 purple_debug_info("QQ", "Unknow room id %u", uid); |
401 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, uid); | 410 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_INFO, uid); |
402 } else { | 411 } else { |
403 rmd->my_role = QQ_ROOM_ROLE_YES; | 412 rmd->my_role = QQ_ROOM_ROLE_YES; |
404 } | 413 } |
405 ++j; | 414 ++j; |
526 void qq_process_buddy_change_status(guint8 *data, gint data_len, PurpleConnection *gc) | 535 void qq_process_buddy_change_status(guint8 *data, gint data_len, PurpleConnection *gc) |
527 { | 536 { |
528 qq_data *qd; | 537 qq_data *qd; |
529 gint bytes; | 538 gint bytes; |
530 guint32 my_uid; | 539 guint32 my_uid; |
540 gchar *who; | |
541 PurpleBuddy *buddy; | |
531 qq_buddy_data *bd; | 542 qq_buddy_data *bd; |
532 qq_buddy_status bs; | 543 qq_buddy_status bs; |
533 | 544 |
534 g_return_if_fail(data != NULL && data_len != 0); | 545 g_return_if_fail(data != NULL && data_len != 0); |
535 | 546 |
547 /* 031-034: Unknow, maybe my uid */ | 558 /* 031-034: Unknow, maybe my uid */ |
548 /* This has a value of 0 when we've changed our status to | 559 /* This has a value of 0 when we've changed our status to |
549 * QQ_BUDDY_ONLINE_INVISIBLE */ | 560 * QQ_BUDDY_ONLINE_INVISIBLE */ |
550 bytes += qq_get32(&my_uid, data + bytes); | 561 bytes += qq_get32(&my_uid, data + bytes); |
551 | 562 |
552 bd = qq_buddy_data_find(gc, bs.uid); | 563 /* update buddy information */ |
564 who = uid_to_purple_name(bs.uid); | |
565 buddy = purple_find_buddy(gc->account, who); | |
566 g_free(who); | |
567 if (buddy == NULL) { | |
568 /* create no-auth buddy */ | |
569 buddy = qq_buddy_new(gc, bs.uid); | |
570 } | |
571 bd = (buddy == NULL) ? NULL : (qq_buddy_data *) buddy->proto_data; | |
553 if (bd == NULL) { | 572 if (bd == NULL) { |
554 purple_debug_warning("QQ", "Get status of unknown buddy %d\n", bs.uid); | 573 purple_debug_warning("QQ", "Get status of unknown buddy %u\n", bs.uid); |
555 return; | 574 return; |
556 } | 575 } |
557 | 576 |
558 if(bs.ip.s_addr != 0) { | 577 if(bs.ip.s_addr != 0) { |
559 bd->ip.s_addr = bs.ip.s_addr; | 578 bd->ip.s_addr = bs.ip.s_addr; |
579 { | 598 { |
580 gchar *who; | 599 gchar *who; |
581 gchar *status_id; | 600 gchar *status_id; |
582 | 601 |
583 g_return_if_fail(uid != 0); | 602 g_return_if_fail(uid != 0); |
584 | |
585 who = uid_to_purple_name(uid); | |
586 | 603 |
587 /* purple supports signon and idle time | 604 /* purple supports signon and idle time |
588 * but it is not much use for QQ, I do not use them */ | 605 * 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); */ | 606 /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ |
590 status_id = "available"; | 607 status_id = "available"; |
610 default: | 627 default: |
611 status_id = "invisible"; | 628 status_id = "invisible"; |
612 purple_debug_error("QQ", "unknown status: 0x%X\n", status); | 629 purple_debug_error("QQ", "unknown status: 0x%X\n", status); |
613 break; | 630 break; |
614 } | 631 } |
615 purple_debug_info("QQ", "Update buddy %s status as %s\n", who, status_id); | 632 |
633 purple_debug_info("QQ", "Update buddy %u status as %s\n", uid, status_id); | |
634 who = uid_to_purple_name(uid); | |
616 purple_prpl_got_user_status(gc->account, who, status_id, NULL); | 635 purple_prpl_got_user_status(gc->account, who, status_id, NULL); |
617 | 636 |
618 if (flag & QQ_COMM_FLAG_MOBILE && status != QQ_BUDDY_OFFLINE) | 637 if (flag & QQ_COMM_FLAG_MOBILE && status != QQ_BUDDY_OFFLINE) |
619 purple_prpl_got_user_status(gc->account, who, "mobile", NULL); | 638 purple_prpl_got_user_status(gc->account, who, "mobile", NULL); |
620 else | 639 else |