Mercurial > pidgin
comparison libpurple/blist.c @ 25827:0e08c847517d
Update some casts (that the script didn't fix correctly) to GObject macros.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 14 Nov 2008 05:32:35 +0000 |
parents | 2b8c85f74ede |
children | 0331bc480515 |
comparison
equal
deleted
inserted
replaced
25826:d1a4088528ce | 25827:0e08c847517d |
---|---|
811 purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status) | 811 purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status) |
812 { | 812 { |
813 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); | 813 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
814 PurplePresence *presence; | 814 PurplePresence *presence; |
815 PurpleStatus *status; | 815 PurpleStatus *status; |
816 PurpleBlistNode *cnode; | |
816 | 817 |
817 g_return_if_fail(buddy != NULL); | 818 g_return_if_fail(buddy != NULL); |
818 | 819 |
819 presence = purple_buddy_get_presence(buddy); | 820 presence = purple_buddy_get_presence(buddy); |
820 status = purple_presence_get_active_status(presence); | 821 status = purple_presence_get_active_status(presence); |
825 if (purple_status_is_online(status) && | 826 if (purple_status_is_online(status) && |
826 !purple_status_is_online(old_status)) { | 827 !purple_status_is_online(old_status)) { |
827 | 828 |
828 purple_signal_emit(purple_blist_get_handle(), "buddy-signed-on", buddy); | 829 purple_signal_emit(purple_blist_get_handle(), "buddy-signed-on", buddy); |
829 | 830 |
830 ((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online++; | 831 cnode = buddy->node.parent; |
831 if (((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online == 1) | 832 if (++(PURPLE_CONTACT(cnode)->online) == 1) |
832 ((PurpleGroup *)((PurpleBlistNode *)buddy)->parent->parent)->online++; | 833 PURPLE_GROUP(cnode->parent)->online++; |
833 } else if (!purple_status_is_online(status) && | 834 } else if (!purple_status_is_online(status) && |
834 purple_status_is_online(old_status)) { | 835 purple_status_is_online(old_status)) { |
836 | |
835 purple_blist_node_set_int(&buddy->node, "last_seen", time(NULL)); | 837 purple_blist_node_set_int(&buddy->node, "last_seen", time(NULL)); |
836 purple_signal_emit(purple_blist_get_handle(), "buddy-signed-off", buddy); | 838 purple_signal_emit(purple_blist_get_handle(), "buddy-signed-off", buddy); |
837 ((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online--; | 839 |
838 if (((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online == 0) | 840 cnode = buddy->node.parent; |
839 ((PurpleGroup *)((PurpleBlistNode *)buddy)->parent->parent)->online--; | 841 if (--(PURPLE_CONTACT(cnode)->online) == 0) |
842 PURPLE_GROUP(cnode->parent)->online--; | |
840 } else { | 843 } else { |
841 purple_signal_emit(purple_blist_get_handle(), | 844 purple_signal_emit(purple_blist_get_handle(), |
842 "buddy-status-changed", buddy, old_status, | 845 "buddy-status-changed", buddy, old_status, |
843 status); | 846 status); |
844 } | 847 } |
1387 if (node && PURPLE_BLIST_NODE_IS_BUDDY(node)) { | 1390 if (node && PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
1388 c = (PurpleContact*)node->parent; | 1391 c = (PurpleContact*)node->parent; |
1389 g = (PurpleGroup*)node->parent->parent; | 1392 g = (PurpleGroup*)node->parent->parent; |
1390 } else if (contact) { | 1393 } else if (contact) { |
1391 c = contact; | 1394 c = contact; |
1392 g = (PurpleGroup *)((PurpleBlistNode *)c)->parent; | 1395 g = PURPLE_GROUP(PURPLE_BLIST_NODE(c)->parent); |
1393 } else { | 1396 } else { |
1394 g = group; | 1397 g = group; |
1395 if (g == NULL) | 1398 if (g == NULL) |
1396 g = purple_group_new(_("Buddies")); | 1399 g = purple_group_new(_("Buddies")); |
1397 /* Add group to blist if isn't already on it. Fixes #2752. */ | 1400 /* Add group to blist if isn't already on it. Fixes #2752. */ |
1469 cnode->child = bnode; | 1472 cnode->child = bnode; |
1470 bnode->parent = cnode; | 1473 bnode->parent = cnode; |
1471 } | 1474 } |
1472 | 1475 |
1473 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { | 1476 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { |
1474 ((PurpleContact*)bnode->parent)->online++; | 1477 if (++(PURPLE_CONTACT(bnode->parent)->online) == 1) |
1475 if (((PurpleContact*)bnode->parent)->online == 1) | 1478 PURPLE_GROUP(bnode->parent->parent)->online++; |
1476 ((PurpleGroup*)bnode->parent->parent)->online++; | |
1477 } | 1479 } |
1478 if (purple_account_is_connected(buddy->account)) { | 1480 if (purple_account_is_connected(buddy->account)) { |
1479 ((PurpleContact*)bnode->parent)->currentsize++; | 1481 if (++(PURPLE_CONTACT(bnode->parent)->currentsize) == 1) |
1480 if (((PurpleContact*)bnode->parent)->currentsize == 1) | 1482 PURPLE_GROUP(bnode->parent->parent)->currentsize++; |
1481 ((PurpleGroup*)bnode->parent->parent)->currentsize++; | 1483 } |
1482 } | 1484 PURPLE_CONTACT(bnode->parent)->totalsize++; |
1483 ((PurpleContact*)bnode->parent)->totalsize++; | |
1484 | 1485 |
1485 hb = g_new(struct _purple_hbuddy, 1); | 1486 hb = g_new(struct _purple_hbuddy, 1); |
1486 hb->name = g_strdup(purple_normalize(buddy->account, buddy->name)); | 1487 hb->name = g_strdup(purple_normalize(buddy->account, buddy->name)); |
1487 hb->account = buddy->account; | 1488 hb->account = buddy->account; |
1488 hb->group = ((PurpleBlistNode*)buddy)->parent->parent; | 1489 hb->group = ((PurpleBlistNode*)buddy)->parent->parent; |
1594 PurpleBlistNode *gnode, *cnode, *bnode; | 1595 PurpleBlistNode *gnode, *cnode, *bnode; |
1595 | 1596 |
1596 g_return_if_fail(contact != NULL); | 1597 g_return_if_fail(contact != NULL); |
1597 g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT((PurpleBlistNode*)contact)); | 1598 g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT((PurpleBlistNode*)contact)); |
1598 | 1599 |
1599 if ((PurpleBlistNode*)contact == node) | 1600 if (PURPLE_BLIST_NODE(contact) == node) |
1600 return; | 1601 return; |
1601 | 1602 |
1602 if (node && (PURPLE_BLIST_NODE_IS_CONTACT(node) || | 1603 if (node && (PURPLE_BLIST_NODE_IS_CONTACT(node) || |
1603 PURPLE_BLIST_NODE_IS_CHAT(node))) | 1604 PURPLE_BLIST_NODE_IS_CHAT(node))) |
1604 g = (PurpleGroup*)node->parent; | 1605 g = (PurpleGroup*)node->parent; |
2339 | 2340 |
2340 PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy) | 2341 PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy) |
2341 { | 2342 { |
2342 g_return_val_if_fail(buddy != NULL, NULL); | 2343 g_return_val_if_fail(buddy != NULL, NULL); |
2343 | 2344 |
2344 return (PurpleContact*)((PurpleBlistNode*)buddy)->parent; | 2345 return PURPLE_CONTACT(PURPLE_BLIST_NODE(buddy)->parent); |
2345 } | 2346 } |
2346 | 2347 |
2347 PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy) | 2348 PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy) |
2348 { | 2349 { |
2349 g_return_val_if_fail(buddy != NULL, NULL); | 2350 g_return_val_if_fail(buddy != NULL, NULL); |