soc.2009.telepathy: ef9a9a6a: Avoid processing a new channel twice by ...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Mon Jun 1 11:20:39 EDT 2009


-----------------------------------------------------------------
Revision: ef9a9a6a83b54a41fc97b194f25d9e629c4b0fdf
Ancestor: a964a284a503b6f71eed0af0dc6d068bd62ed04c
Author: sttwister at soc.pidgin.im
Date: 2009-06-01T14:49:43
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/ef9a9a6a83b54a41fc97b194f25d9e629c4b0fdf

Modified files:
        libpurple/protocols/telepathy/telepathy.c

ChangeLog: 

Avoid processing a new channel twice by the NewChannels signal

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	e650f4967f35304406c997fadd8ca06e51f87936
+++ libpurple/protocols/telepathy/telepathy.c	df9ad808c58bbb1ddb26ca0093c64cb0fb4aba8c
@@ -55,6 +55,9 @@ typedef struct
 	PurpleConnection *gc;
 	PurpleAccount *acct;
 
+	/* This flag avoids having a channel processed twice via both NewChannels and quering the Channels property */
+	gboolean listing_channels;
+
 	/* This will hold pointers to TpChannel for buddies that have an active conversation */
 	GHashTable *text_Channels;
 
@@ -306,7 +309,12 @@ new_channels_cb (TpConnection *proxy,
                  GObject *weak_object)
 {
 	int i;
+	PurplePlugin *plugin = user_data;
+	telepathy_data *data =plugin->extra;
 
+	if (data->listing_channels)
+		return;
+
 	purple_debug_info("telepathy", "NewChannels:\n");
 
 	for (i = 0; i < arg_Channels->len; i++)
@@ -330,6 +338,11 @@ get_channels_cb (TpProxy *proxy,
 	}
 	else
 	{
+		PurplePlugin *plugin = user_data;
+		telepathy_data *data = plugin->extra;
+
+		data->listing_channels = FALSE;
+
 		/* unpack the a(oa{sv}) struct */
 		const GPtrArray *channels = g_value_get_boxed(out_Value);
 		int i;
@@ -356,6 +369,8 @@ connection_ready_cb (TpConnection *conne
 	{
 		char **interfaces, **ptr;
 		GError *error = NULL;
+		PurplePlugin* plugin = user_data;
+		telepathy_data *data = plugin->extra;
 
 		purple_debug_info("telepathy", "Connection is ready. Interfaces implemented:\n");
 
@@ -373,10 +388,11 @@ connection_ready_cb (TpConnection *conne
 			purple_debug_error("telepathy", "Error while connecting to NewChannels signal: %s\n", error->message);
 			g_error_free(error);
 			error = NULL;
-			
 			return;
 		}
 
+		data->listing_channels = TRUE;
+			
 		/* query the Channels property of the Requests interface */
 		tp_cli_dbus_properties_call_get(connection, -1, TP_IFACE_CONNECTION_INTERFACE_REQUESTS, "Channels", get_channels_cb, user_data, NULL, NULL);
 


More information about the Commits mailing list