Mercurial > pidgin.yaz
changeset 17794:612dc5149964
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 08 Jun 2007 15:28:00 +0000 |
parents | b13850d13391 |
children | 2af1f8ccd396 |
files | libpurple/protocols/bonjour/bonjour.c libpurple/protocols/bonjour/buddy.c libpurple/protocols/bonjour/jabber.c libpurple/protocols/bonjour/jabber.h |
diffstat | 4 files changed, 20 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c Fri Jun 08 06:28:31 2007 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Fri Jun 08 15:28:00 2007 +0000 @@ -267,6 +267,7 @@ bonjour_convo_closed(PurpleConnection *connection, const char *who) { PurpleBuddy *buddy = purple_find_buddy(connection->account, who); + BonjourBuddy *bb; if (buddy == NULL) { @@ -277,7 +278,9 @@ return; } - bonjour_jabber_close_conversation(buddy); + bb = buddy->proto_data; + bonjour_jabber_close_conversation(bb->conversation); + bb->conversation = NULL; } static char *
--- a/libpurple/protocols/bonjour/buddy.c Fri Jun 08 06:28:31 2007 +0000 +++ b/libpurple/protocols/bonjour/buddy.c Fri Jun 08 15:28:00 2007 +0000 @@ -178,11 +178,8 @@ g_free(buddy->node); g_free(buddy->ver); - if (buddy->conversation != NULL) - { - g_free(buddy->conversation->buddy_name); - g_free(buddy->conversation); - } + bonjour_jabber_close_conversation(buddy->conversation); + buddy->conversation = NULL; #ifdef USE_BONJOUR_APPLE if (buddy->txt_query != NULL)
--- a/libpurple/protocols/bonjour/jabber.c Fri Jun 08 06:28:31 2007 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Fri Jun 08 15:28:00 2007 +0000 @@ -109,11 +109,10 @@ #endif static BonjourJabberConversation * -bonjour_jabber_conv_new(const char *name) { +bonjour_jabber_conv_new() { BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1); bconv->socket = -1; - bconv->buddy_name = g_strdup(name); bconv->watcher_id = -1; return bconv; @@ -368,8 +367,8 @@ char *closed_conv_message; /* Close the socket, clear the watcher and free memory */ - if (bb->conversation != NULL) - bonjour_jabber_close_conversation(pb); + bonjour_jabber_close_conversation(bb->conversation); + bb->conversation = NULL; /* Inform the user that the conversation has been closed */ conversation = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pb->name, account); @@ -428,7 +427,7 @@ /* Check if the conversation has been previously started */ if (bb->conversation == NULL) { - bb->conversation = bonjour_jabber_conv_new(pb->name); + bb->conversation = bonjour_jabber_conv_new(); bb->conversation->socket = client_socket; if (bb->conversation->stream_started == FALSE) { @@ -545,7 +544,7 @@ if (socket < 0) return -10001; - bb->conversation = bonjour_jabber_conv_new(pb->name); + bb->conversation = bonjour_jabber_conv_new(); bb->conversation->socket = socket; bb->conversation->watcher_id = purple_input_add(bb->conversation->socket, PURPLE_INPUT_READ, _client_socket_handler, pb); @@ -596,7 +595,8 @@ _("Unable to send the message, the conversation couldn't be started."), PURPLE_MESSAGE_SYSTEM, time(NULL)); - bonjour_jabber_close_conversation(pb); + bonjour_jabber_close_conversation(bb->conversation); + bb->conversation = NULL; g_free(message); g_free(stream_start); @@ -618,11 +618,8 @@ } void -bonjour_jabber_close_conversation(PurpleBuddy *pb) +bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) { - BonjourBuddy *bb = pb->proto_data; - BonjourJabberConversation *bconv = bb->conversation; - if (bconv != NULL) { /* Close the socket and remove the watcher */ @@ -636,9 +633,7 @@ purple_input_remove(bconv->watcher_id); /* Free all the data related to the conversation */ - g_free(bconv->buddy_name); g_free(bconv); - bb->conversation = NULL; } } @@ -657,8 +652,11 @@ GSList *buddies, *l; buddies = purple_find_buddies(data->account, purple_account_get_username(data->account)); - for (l = buddies; l; l = l->next) - bonjour_jabber_close_conversation(l->data); + for (l = buddies; l; l = l->next) { + BonjourBuddy *bb = ((PurpleBuddy*) l->data)->proto_data; + bonjour_jabber_close_conversation(bb->conversation); + bb->conversation = NULL; + } g_slist_free(buddies); } }
--- a/libpurple/protocols/bonjour/jabber.h Fri Jun 08 06:28:31 2007 +0000 +++ b/libpurple/protocols/bonjour/jabber.h Fri Jun 08 15:28:00 2007 +0000 @@ -40,7 +40,6 @@ { gint socket; gint watcher_id; - gchar* buddy_name; gboolean stream_started; } BonjourJabberConversation; @@ -54,7 +53,7 @@ int bonjour_jabber_send_message(BonjourJabber *data, const gchar *to, const gchar *body); -void bonjour_jabber_close_conversation(PurpleBuddy *gb); +void bonjour_jabber_close_conversation(BonjourJabberConversation *bconv); void bonjour_jabber_stop(BonjourJabber *data);