Mercurial > pidgin
changeset 16798:c4460fa22886
Change some of the PurplePresence stuff to reflect how it's actually used
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 03 May 2007 06:32:42 +0000 |
parents | cd5d62417d57 |
children | 49cc59b2490e |
files | libpurple/blist.c libpurple/status.c libpurple/status.h pidgin/gtkconv.c |
diffstat | 4 files changed, 14 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/blist.c Thu May 03 06:31:27 2007 +0000 +++ b/libpurple/blist.c Thu May 03 06:32:42 2007 +0000 @@ -1825,7 +1825,6 @@ /* Delete the node */ purple_buddy_icon_unref(buddy->icon); g_hash_table_destroy(buddy->node.settings); - purple_presence_remove_buddy(buddy->presence, buddy); purple_presence_destroy(buddy->presence); g_free(buddy->name); g_free(buddy->alias);
--- a/libpurple/status.c Thu May 03 06:31:27 2007 +0000 +++ b/libpurple/status.c Thu May 03 06:32:42 2007 +0000 @@ -91,8 +91,7 @@ { PurpleAccount *account; char *name; - size_t ref_count; - GList *buddies; + PurpleBuddy *buddy; } buddy; @@ -131,7 +130,8 @@ -200, /* extended away */ -400, /* mobile */ -10, /* idle, special case. */ - -5 /* idle time, special case. */ + -5, /* idle time, special case. */ + 10 /* Offline messageable */ }; static GHashTable *buddy_presences = NULL; @@ -658,13 +658,8 @@ } else if (context == PURPLE_PRESENCE_CONTEXT_BUDDY) { - const GList *l; - - for (l = purple_presence_get_buddies(presence); l != NULL; l = l->next) - { - notify_buddy_status_update((PurpleBuddy *)l->data, presence, + notify_buddy_status_update(purple_presence_get_buddy(presence), presence, old_status, new_status); - } } } @@ -1148,10 +1143,7 @@ g_free(key->name); g_free(key); } - - presence->u.buddy.ref_count++; - presence->u.buddy.buddies = g_list_append(presence->u.buddy.buddies, - buddy); + presence->u.buddy.buddy = buddy; return presence; } @@ -1165,9 +1157,6 @@ { PurpleStatusBuddyKey key; - if(presence->u.buddy.ref_count != 0) - return; - key.account = presence->u.buddy.account; key.name = presence->u.buddy.name; @@ -1189,27 +1178,6 @@ g_free(presence); } -/* - * TODO: Maybe we should cal purple_presence_destroy() after we - * decrement the ref count? I don't see why we should - * make other places do it manually when we can do it here. - */ -void -purple_presence_remove_buddy(PurplePresence *presence, PurpleBuddy *buddy) -{ - g_return_if_fail(presence != NULL); - g_return_if_fail(buddy != NULL); - g_return_if_fail(purple_presence_get_context(presence) == - PURPLE_PRESENCE_CONTEXT_BUDDY); - - if (g_list_find(presence->u.buddy.buddies, buddy) != NULL) - { - presence->u.buddy.buddies = g_list_remove(presence->u.buddy.buddies, - buddy); - presence->u.buddy.ref_count--; - } -} - void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status) { @@ -1345,11 +1313,8 @@ const GList *l; time_t current_time = time(NULL); - for (l = purple_presence_get_buddies(presence); l != NULL; l = l->next) - { - update_buddy_idle((PurpleBuddy *)l->data, presence, current_time, - old_idle, idle); - } + update_buddy_idle(purple_presence_get_buddy(presence), presence, current_time, + old_idle, idle); } else if(purple_presence_get_context(presence) == PURPLE_PRESENCE_CONTEXT_ACCOUNT) { @@ -1443,14 +1408,14 @@ return presence->u.chat.user; } -const GList * -purple_presence_get_buddies(const PurplePresence *presence) +PurpleBuddy * +purple_presence_get_buddy(const PurplePresence *presence) { g_return_val_if_fail(presence != NULL, NULL); g_return_val_if_fail(purple_presence_get_context(presence) == PURPLE_PRESENCE_CONTEXT_BUDDY, NULL); - return presence->u.buddy.buddies; + return presence->u.buddy.buddy; } const GList *
--- a/libpurple/status.h Thu May 03 06:31:27 2007 +0000 +++ b/libpurple/status.h Thu May 03 06:32:42 2007 +0000 @@ -760,16 +760,6 @@ void purple_presence_destroy(PurplePresence *presence); /** - * Removes a buddy from a presence. - * - * This must be done before destroying a buddy in a presence. - * - * @param presence The presence. - * @param buddy The buddy. - */ -void purple_presence_remove_buddy(PurplePresence *presence, PurpleBuddy *buddy); - -/** * Adds a status to a presence. * * @param presence The presence. @@ -869,13 +859,13 @@ const char *purple_presence_get_chat_user(const PurplePresence *presence); /** - * Returns a presence's list of buddies. + * Returns the presence's buddy. * * @param presence The presence. * - * @return The presence's list of buddies. + * @return The presence's buddy. */ -const GList *purple_presence_get_buddies(const PurplePresence *presence); +PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence); /** * Returns all the statuses in a presence.
--- a/pidgin/gtkconv.c Thu May 03 06:31:27 2007 +0000 +++ b/pidgin/gtkconv.c Thu May 03 06:32:42 2007 +0000 @@ -3389,7 +3389,7 @@ for (iter = g_list_last(list); iter != NULL; iter = iter->prev) { PurplePresence *pre = iter->data; - PurpleBuddy *buddy = purple_presence_get_buddies(pre)->data; + PurpleBuddy *buddy = purple_presence_get_buddy(pre); create_sendto_item(menu, sg, &group, buddy, purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); }