soc.2009.telepathy: 00febdf0: Basic support for adding a buddy to a gr...
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Wed Jun 24 07:55:59 EDT 2009
-----------------------------------------------------------------
Revision: 00febdf0882aacae6de2fade5817b286ff4f0534
Ancestor: 69614766dec19dbbaa3ddcd99f5c7cb349f9594d
Author: sttwister at soc.pidgin.im
Date: 2009-06-24T11:48:48
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/00febdf0882aacae6de2fade5817b286ff4f0534
Modified files:
libpurple/protocols/telepathy/telepathy.c
libpurple/protocols/telepathy/telepathy_contact.c
libpurple/protocols/telepathy/telepathy_contact.h
ChangeLog:
Basic support for adding a buddy to a group
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c 143ec3282e28a0aa35195e1823b862636eaadaaa
+++ libpurple/protocols/telepathy/telepathy.c ab4068f8ae82bcf7347c32f0e71b534dc64891f2
@@ -499,7 +499,16 @@ telepathy_add_buddy (PurpleConnection *g
}
else
{
- /* TODO: Request a handle for the new buddy and add it to the group */
+ GPtrArray *arr = g_ptr_array_sized_new(2);
+
+ g_ptr_array_add(arr, (gchar *)buddy_name);
+ g_ptr_array_add(arr, NULL);
+
+ tp_connection_request_handles(connection_data->connection, -1,
+ TP_HANDLE_TYPE_CONTACT,
+ (const char * const *)arr->pdata,
+ add_contact_to_group_cb, tp_group,
+ NULL, NULL);
}
}
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.c 97e6a619e3c824dfeea54e1d30a42ae0bdee2a28
+++ libpurple/protocols/telepathy/telepathy_contact.c f775f56da55200410c0bf68b29706b414a799991
@@ -32,7 +32,76 @@ destroy_contact(telepathy_contact *conta
g_free(contact_data);
}
+static void
+add_member_cb (TpChannel *proxy,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ if (error != NULL)
+ {
+ purple_debug_error("telepathy", "AddMember error: %s\n", error->message);
+ }
+ else
+ {
+ purple_debug_info("telepathy", "Member added to %s!\n",
+ tp_channel_get_identifier(proxy));
+ }
+}
+
void
+add_contact_to_group_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)
+{
+ if (error != NULL)
+ {
+ purple_debug_error("telepathy",
+ "RequestHandle (add_contact_to_group_cb): %s\n", error->message);
+ }
+ else
+ {
+ telepathy_group *group = user_data;
+
+ const TpContactFeature features[] = {
+ TP_CONTACT_FEATURE_ALIAS,
+ TP_CONTACT_FEATURE_PRESENCE
+ };
+
+ int i;
+ GArray *arr = g_array_new(0, 0, sizeof(TpHandle));
+
+ purple_debug_info("telepathy", "Contact added!\n");
+
+ for (i = 0; i<n_handles; ++i)
+ {
+ g_array_append_val(arr, handles[i]);
+ }
+
+ /* TODO: Also add to the subscribe list */
+
+ /* this will add the buddy to the specified group */
+ tp_cli_channel_interface_group_call_add_members(group->channel, -1,
+ arr, "putzi!",
+ add_member_cb, group->connection_data,
+ NULL, NULL);
+
+ /* this will return a TpContact so we can bind it to a PurpleBuddy */
+ tp_connection_get_contacts_by_handle (connection,
+ n_handles, handles,
+ G_N_ELEMENTS (features), features,
+ group_contacts_ready_cb,
+ group, NULL, NULL);
+
+ }
+}
+
+void
contact_notify_cb (TpContact *contact,
GParamSpec *pspec,
gpointer user_data)
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.h 95d4b16d635c033886107217341da3e29c397329
+++ libpurple/protocols/telepathy/telepathy_contact.h 5380d078690e97d175b11600960be10269ca83e3
@@ -36,6 +36,16 @@ void
destroy_contact(telepathy_contact *contact_data);
void
+add_contact_to_group_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
contact_notify_cb (TpContact *contact,
GParamSpec *pspec,
gpointer user_data);
More information about the Commits
mailing list