Mercurial > pidgin
comparison libpurple/protocols/qq/buddy_opt.c @ 24145:ec3f7d3e0445
2008.10.04 - lonicerae <lonicerae(at)gmail.com>
* fixed a bug in qq_base.c
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:49:38 +0000 |
parents | a95c7e71064c |
children | ce94189f15ad |
comparison
equal
deleted
inserted
replaced
24144:a95c7e71064c | 24145:ec3f7d3e0445 |
---|---|
344 who = buddy->name; | 344 who = buddy->name; |
345 g_return_if_fail(who != NULL); | 345 g_return_if_fail(who != NULL); |
346 | 346 |
347 uid = purple_name_to_uid(who); | 347 uid = purple_name_to_uid(who); |
348 g_return_if_fail(uid > 0); | 348 g_return_if_fail(uid > 0); |
349 | 349 |
350 if (uid == qd->uid) { | 350 if (uid == qd->uid) { |
351 return; | 351 return; |
352 } | 352 } |
353 | 353 |
354 add_req = g_new0(qq_add_request, 1); | 354 add_req = g_new0(qq_add_request, 1); |
499 return g; | 499 return g; |
500 } | 500 } |
501 | 501 |
502 /* we add new buddy, if the received packet is from someone not in my list | 502 /* we add new buddy, if the received packet is from someone not in my list |
503 * return the PurpleBuddy that is just created */ | 503 * return the PurpleBuddy that is just created */ |
504 PurpleBuddy *qq_create_buddy(PurpleConnection *gc, guint32 uid, | 504 PurpleBuddy *qq_create_buddy(PurpleConnection *gc, guint32 uid, gboolean is_known, gboolean create) |
505 gboolean is_known, gboolean is_create_data) | 505 { |
506 { | 506 PurpleBuddy *buddy; |
507 PurpleBuddy *purple_buddy; | |
508 PurpleGroup *group; | 507 PurpleGroup *group; |
509 qq_data *qd; | 508 qq_data *qd; |
510 qq_buddy *buddy; | 509 qq_buddy *q_bud; |
511 gchar *buddy_name, *group_name; | 510 gchar *buddy_name, *group_name; |
512 | 511 |
513 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); | 512 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); |
514 qd = (qq_data *) gc->proto_data; | 513 qd = (qq_data *) gc->proto_data; |
515 | 514 |
521 } | 520 } |
522 | 521 |
523 group = qq_create_group(group_name); | 522 group = qq_create_group(group_name); |
524 | 523 |
525 buddy_name = uid_to_purple_name(uid); | 524 buddy_name = uid_to_purple_name(uid); |
526 purple_buddy = purple_find_buddy(gc->account, buddy_name); | 525 buddy = purple_find_buddy(gc->account, buddy_name); |
527 /* remove old, we can not simply return here | 526 /* remove old, we can not simply return here |
528 * because there might be old local copy of this buddy */ | 527 * because there might be old local copy of this buddy */ |
529 if (purple_buddy != NULL) | 528 if (buddy != NULL) |
530 purple_blist_remove_buddy(purple_buddy); | 529 purple_blist_remove_buddy(buddy); |
531 | 530 |
532 purple_buddy = purple_buddy_new(gc->account, buddy_name, NULL); | 531 buddy = purple_buddy_new(gc->account, buddy_name, NULL); |
533 if ( !is_known) { | 532 if ( !is_known) { |
534 if (purple_privacy_check(gc->account, buddy_name)) { | 533 if (purple_privacy_check(gc->account, buddy_name)) { |
535 purple_privacy_deny(gc->account, buddy_name, TRUE, FALSE); | 534 purple_privacy_deny(gc->account, buddy_name, TRUE, FALSE); |
536 } else { | 535 } else { |
537 purple_privacy_deny_add(gc->account, buddy_name, TRUE); | 536 purple_privacy_deny_add(gc->account, buddy_name, TRUE); |
538 } | 537 } |
539 } | 538 } |
540 | 539 |
541 if (!is_create_data) | 540 if (!create) |
542 purple_buddy->proto_data = NULL; | 541 buddy->proto_data = NULL; |
543 else { | 542 else { |
544 buddy = g_new0(qq_buddy, 1); | 543 q_bud = g_new0(qq_buddy, 1); |
545 buddy->uid = uid; | 544 q_bud->uid = uid; |
546 purple_buddy->proto_data = buddy; | 545 buddy->proto_data = q_bud; |
547 qd->buddies = g_list_append(qd->buddies, buddy); | 546 qd->buddies = g_list_append(qd->buddies, q_bud); |
548 qq_request_buddy_info(gc, uid, 0, 0); | 547 qq_request_buddy_info(gc, qd->uid, 0, 0); |
549 qq_request_get_buddies_online(gc, 0, 0); | 548 qq_request_get_buddies_online(gc, 0, 0); |
550 if (qd->client_version >= 2007) { | 549 if (qd->client_version >= 2007) { |
551 qq_request_get_level_2007(gc, uid); | 550 qq_request_get_level_2007(gc, q_bud->uid); |
552 } else { | 551 } else { |
553 qq_request_get_level(gc, uid); | 552 qq_request_get_level(gc, q_bud->uid); |
554 } | 553 } |
555 } | 554 } |
556 | 555 |
557 purple_blist_add_buddy(purple_buddy, NULL, group, NULL); | 556 purple_blist_add_buddy(buddy, NULL, group, NULL); |
558 purple_debug_warning("QQ", "Add new buddy: [%s]\n", buddy_name); | 557 purple_debug_warning("QQ", "Add new buddy: [%s]\n", buddy_name); |
559 | 558 |
560 g_free(buddy_name); | 559 g_free(buddy_name); |
561 g_free(group_name); | 560 g_free(group_name); |
562 | 561 |
563 return purple_buddy; | 562 return buddy; |
564 } | 563 } |
565 | 564 |
566 qq_buddy *qq_get_buddy(PurpleConnection *gc, guint32 uid) | 565 qq_buddy *qq_get_buddy(PurpleConnection *gc, guint32 uid) |
567 { | 566 { |
568 gchar *purple_name; | 567 gchar *purple_name; |
573 if (purple_name == NULL) return NULL; | 572 if (purple_name == NULL) return NULL; |
574 | 573 |
575 purple_buddy = purple_find_buddy(purple_connection_get_account(gc), purple_name); | 574 purple_buddy = purple_find_buddy(purple_connection_get_account(gc), purple_name); |
576 g_free(purple_name); | 575 g_free(purple_name); |
577 if (purple_buddy == NULL) return NULL; | 576 if (purple_buddy == NULL) return NULL; |
578 | 577 |
579 if (purple_buddy->proto_data == NULL) { | 578 if (purple_buddy->proto_data == NULL) { |
580 purple_debug_error("QQ", "Can not find buddy data of %d\n", uid); | 579 purple_debug_error("QQ", "Null data of buddy %d\n", uid); |
581 return NULL; | 580 return NULL; |
582 } | 581 } |
583 return (qq_buddy *) purple_buddy->proto_data; | 582 return (qq_buddy *) purple_buddy->proto_data; |
584 } | 583 } |
585 | 584 |