soc.2009.telepathy: d1a77787: Check for local pending contacts on chan...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 7 19:20:22 EDT 2009


-----------------------------------------------------------------
Revision: d1a77787fb6cd0882bd5ba8f4619df02bacb9cba
Ancestor: a89bb829c6a66711ca7031eab32d8b7fa214753b
Author: sttwister at soc.pidgin.im
Date: 2009-07-07T23:16:53
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/d1a77787fb6cd0882bd5ba8f4619df02bacb9cba

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

ChangeLog: 

Check for local pending contacts on channel creation

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_list.c	be454069410216fcc209663e13732ef90adc5c5b
+++ libpurple/protocols/telepathy/telepathy_channel_list.c	aa2d7123e6527ff9e8be61df89dc9c070716bad1
@@ -148,7 +148,7 @@ request_authorization_cb (TpConnection *
 				n_failed);
 	}
 
-	/* Prompt the user for authorisation for each contact */
+	/* Prompt the user for authorization for each contact */
 	for (i = 0; i<n_contacts; ++i)
 	{
 		telepathy_authorization_request *request = g_new0(
@@ -229,6 +229,69 @@ members_changed_cb (TpChannel *proxy,
 	}
 }
 
+static void
+get_local_pending_members_with_info_cb (TpChannel *proxy,
+                                        const GPtrArray *out_Info,
+                                        const GError *error,
+                                        gpointer user_data,
+                                        GObject *weak_object)
+{
+	telepathy_connection *data = user_data;
+	int i;
+
+	if (error != NULL)
+	{
+		purple_debug_error("telepathy", "GetLocalPending error: %s\n",
+				error->message);
+		return;
+	}
+
+	purple_debug_error("telepathy", "%u contacts are local pending!\n",
+			out_Info->len);
+
+	for (i = 0; i<out_Info->len; ++i)
+	{
+		/* Each object in the array is (uuus) */
+		GValueArray *arr = g_ptr_array_index(out_Info, i);
+
+		GValue *val;
+		guint handle;
+		const gchar *message;
+
+		telepathy_authorization_request *request;
+
+		const TpContactFeature features[] = {
+			TP_CONTACT_FEATURE_ALIAS,
+			TP_CONTACT_FEATURE_PRESENCE
+		};
+
+
+		/* Extract the handle and message */
+		val = g_value_array_get_nth(arr, 0);
+		handle = g_value_get_uint(val);
+
+		val = g_value_array_get_nth(arr, 3);
+		message = g_value_get_string(val);
+
+		purple_debug_info("telepathy", "Contact %u is local pending\n",
+				handle);
+
+		/* We've got some buddies pending local acception.
+		 * First, we request a TpContact for that handle and the prompt the user.
+		 */
+
+		request = g_new0(telepathy_authorization_request, 1);
+
+		request->connection_data = data;
+		request->channel = proxy;
+
+		tp_connection_get_contacts_by_handle(data->connection,
+				1, &handle,
+				G_N_ELEMENTS (features), features,
+				request_authorization_cb, request, g_free, NULL);
+	}
+}
+
 void
 handle_list_channel (TpChannel *channel,
                      telepathy_connection *data)
@@ -342,5 +405,9 @@ handle_list_channel (TpChannel *channel,
 				error->message);
 		g_error_free(error);
 	}
+
+	/* See if there are any contacts pending local acception */
+	tp_cli_channel_interface_group_call_get_local_pending_members_with_info(channel, -1,
+			get_local_pending_members_with_info_cb, data, NULL, NULL);
 }
 


More information about the Commits mailing list