soc.2009.telepathy: 4fb564fb: Handle text channel closing and fix offl...
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Tue Jun 2 19:36:14 EDT 2009
-----------------------------------------------------------------
Revision: 4fb564fb052ef16165a56c220f929554d9a90eac
Ancestor: eceff070b74ca40fd80266ab1eacc8ba2e43ca13
Author: sttwister at soc.pidgin.im
Date: 2009-06-02T23:31:35
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/4fb564fb052ef16165a56c220f929554d9a90eac
Modified files:
libpurple/protocols/telepathy/telepathy.c
ChangeLog:
Handle text channel closing and fix offline messages
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c f6aeb64609c74451bb59dd56b15d21f9a9574a68
+++ libpurple/protocols/telepathy/telepathy.c 2fffdc2e070da3ca45841d37aa72a294f5ca7a91
@@ -286,12 +286,11 @@ list_pending_messages_cb (TpChannel *pr
/* unpack the relevant info from (uuuuus) */
GValueArray *arr = g_ptr_array_index(out_Pending_Messages, i);
- guint contact_Handle = g_value_get_uint(g_value_array_get_nth(arr, 2));
guint timestamp = g_value_get_uint(g_value_array_get_nth(arr, 1));
gchar *msg = (gchar *)g_value_get_string(g_value_array_get_nth(arr, 5));
- TpContact * contact = g_hash_table_lookup(data->contacts, (gpointer)contact_Handle);
- gchar *from = (gchar *)tp_contact_get_identifier(contact);
+ /* get the identifier from channel instead of contact since contact might not be ready for offline messages */
+ gchar *from = (gchar *)tp_channel_get_identifier(proxy);
/* if a conversation was not yet establish, create a new one */
PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, data->acct);
@@ -339,6 +338,32 @@ static void
}
static void
+text_channel_invalidated_cb (TpProxy *self,
+ guint domain,
+ gint code,
+ gchar *message,
+ gpointer user_data)
+{
+ PurplePlugin *plugin = user_data;
+ telepathy_data *data = plugin->extra;
+
+ /* remove the cached TpChannel proxy when the channel closes */
+ const gchar *who = tp_channel_get_identifier((TpChannel *)self);
+
+ telepathy_text_channel *tp_channel = NULL;
+
+ if (data->text_Channels)
+ tp_channel = g_hash_table_lookup(data->text_Channels, who);
+
+ purple_debug_info("telepathy", "Text channel with %s closed!\n", who);
+
+ if (tp_channel)
+ {
+ tp_channel->channel = NULL;
+ }
+}
+
+static void
handle_text_channel (TpChannel *channel,
PurplePlugin *plugin)
{
@@ -371,6 +396,8 @@ handle_text_channel (TpChannel *channel,
purple_debug_error("telepathy", "Error connecting to Received signal: %s\n", error->message);
}
+ g_signal_connect(channel, "invalidated", G_CALLBACK(text_channel_invalidated_cb), plugin);
+
tp_cli_channel_type_text_call_list_pending_messages(channel, -1, TRUE, list_pending_messages_cb, plugin, NULL, NULL);
/* send pending messages */
More information about the Commits
mailing list