soc.2009.telepathy: 22606536: Can now also remove buddies

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 7 20:00:36 EDT 2009


-----------------------------------------------------------------
Revision: 226065363716dbf4ac6737af6abf47aa49f11b6f
Ancestor: cd7c148608605667653b6ad197498de6ccdd31e1
Author: sttwister at soc.pidgin.im
Date: 2009-07-07T23:48:19
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/226065363716dbf4ac6737af6abf47aa49f11b6f

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

ChangeLog: 

Can now also remove buddies

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	9230aa1a6a06237b3cfdbadec44c5ea0533dff6a
+++ libpurple/protocols/telepathy/telepathy.c	334fd4c6d00512ed40eb60f4715d3de09cc2628c
@@ -526,6 +526,22 @@ static void
 }
 
 static void
+telepathy_remove_buddy (PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
+{
+	const gchar* buddy_name = purple_buddy_get_name(buddy);
+	telepathy_connection *connection_data = purple_connection_get_protocol_data(gc);
+	
+	gchar const *ids[] = { buddy_name, NULL };
+
+	purple_debug_info("telepathy", "Removing buddy %s\n", buddy_name);
+
+	tp_connection_request_handles(connection_data->connection, -1,
+			TP_HANDLE_TYPE_CONTACT, ids,
+			remove_contact_cb, connection_data,
+			NULL, NULL);
+}
+
+static void
 telepathy_set_buddy_icon (PurpleConnection *gc, PurpleStoredImage *img)
 {
 	telepathy_connection *data = purple_connection_get_protocol_data(gc);
@@ -601,7 +617,7 @@ static PurplePluginProtocolInfo telepath
 	NULL,              /* change_passwd */
 	telepathy_add_buddy,                  /* add_buddy */
 	NULL,                /* add_buddies */
-	NULL,               /* remove_buddy */
+	telepathy_remove_buddy,               /* remove_buddy */
 	NULL,             /* remove_buddies */
 	NULL,                 /* add_permit */
 	NULL,                   /* add_deny */
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.c	fb8d9df512702440bc7f1793d8aafae811548369
+++ libpurple/protocols/telepathy/telepathy_contact.c	d5f4d553ba71886b163f66d110b2d4ac212b1183
@@ -33,6 +33,73 @@ static void
 }
 
 static void
+remove_members_cb (TpChannel *proxy,
+                   const GError *error,
+                   gpointer user_data,
+                   GObject *weak_object)
+{
+	if (error != NULL)
+	{
+		purple_debug_error("telepathy", "RemoveMembers error: %s\n", error->message);
+	}
+	else
+	{
+		purple_debug_info("telepathy", "Member removed!\n");
+	}
+}
+
+void
+remove_contact_cb (TpConnection *connection,
+                   TpHandleType handle_type,
+                   guint n_handles,
+                   const TpHandle *handles,
+                   const gchar * const *ids,
+                   const GError *error,
+                   gpointer user_data,
+                   GObject *weak_object)
+{
+	telepathy_connection *data = user_data;
+	telepathy_group *stored_list;
+	GArray *arr;
+	int i;
+
+	if (error != NULL)
+	{
+		purple_debug_error("telepathy",
+				"RequestHandle (remove_contact_cb): %s\n", error->message);
+		return;
+	}
+
+	/* we are going to remove the handle from the stored list */
+	stored_list = g_hash_table_lookup(data->lists, "stored");
+	
+	arr = g_array_new(0, 0, sizeof(TpHandle));
+
+	purple_debug_info("telepathy", "Got handle for removing buddy (%u)!\n",
+		handles[0]);
+
+	for (i = 0; i<n_handles; ++i)
+	{
+	    g_array_append_val(arr, handles[i]);
+	}
+
+	if (stored_list == NULL)
+	{
+		purple_debug_error("telepathy", "There's no stored list cached!\n");
+	}
+	else
+	{
+		tp_cli_channel_interface_group_call_remove_members(stored_list->channel, -1,
+				arr, NULL,
+				remove_members_cb, data,
+				NULL, NULL);
+
+	}
+
+	g_array_free(arr, TRUE);
+}
+
+static void
 add_member_cb (TpChannel *proxy,
                const GError *error,
                gpointer user_data,
@@ -119,6 +186,7 @@ add_contact_to_group_cb (TpConnection *c
 				group_contacts_ready_cb,
 				group, NULL, NULL);
 
+		g_array_free(arr, TRUE);
 	}
 }
 
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.h	5380d078690e97d175b11600960be10269ca83e3
+++ libpurple/protocols/telepathy/telepathy_contact.h	7da7a66101912e8d7d046760a9732966ef385c92
@@ -36,6 +36,16 @@ void
 destroy_contact(telepathy_contact *contact_data);
 
 void
+remove_contact_cb (TpConnection *connection,
+                   TpHandleType handle_type,
+                   guint n_handles,
+                   const TpHandle *handles,
+                   const gchar * const *ids,
+                   const GError *error,
+                   gpointer user_data,
+                   GObject *weak_object);
+
+void
 add_contact_to_group_cb (TpConnection *connection,
                          TpHandleType handle_type,
                          guint n_handles,


More information about the Commits mailing list