soc.2009.telepathy: 5eda1931: Create group for a new buddy if it doesn...
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Sun Jul 5 05:30:30 EDT 2009
-----------------------------------------------------------------
Revision: 5eda19313b5b9c60d11f31a67c3050f6055a4270
Ancestor: 46c4461f453d4d6f65b95c80bbc328cf94038da7
Author: sttwister at soc.pidgin.im
Date: 2009-07-05T09:26:47
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/5eda19313b5b9c60d11f31a67c3050f6055a4270
Modified files:
libpurple/protocols/telepathy/telepathy.c
libpurple/protocols/telepathy/telepathy_channel_list.c
libpurple/protocols/telepathy/telepathy_channel_list.h
libpurple/protocols/telepathy/telepathy_contact.c
ChangeLog:
Create group for a new buddy if it doesn't exist
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c 07faa1062322794c4aac159c7c3a6656b85c1dfd
+++ libpurple/protocols/telepathy/telepathy.c 9c390c47560fca4a09feb0ff25626f3e2d0cbb6a
@@ -469,21 +469,48 @@ telepathy_add_buddy (PurpleConnection *g
const gchar* buddy_name = purple_buddy_get_name(buddy);
const gchar* group_name = purple_group_get_name(group);
+ /* When adding a buddy to a new group, the PurpleGroup will automatically be created,
+ * but we still have to check if there's an equivalent Telepathy channel.
+ */
+
telepathy_connection *connection_data = purple_connection_get_protocol_data(gc);
telepathy_group *tp_group = g_hash_table_lookup(connection_data->groups, group_name);
purple_debug_info("telepathy", "Adding buddy %s to group %s\n",
buddy_name, group_name);
+ /* If there's no channel present, we'll have to create it before requesting a handle
+ * for the contact.
+ */
if (tp_group == NULL)
{
+ telepathy_connection *data = purple_connection_get_protocol_data(gc);
+
+ /* Request a contact list channel representing a group witht the specified name */
+ GHashTable *request = tp_asv_new (
+ TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING,
+ TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
+ TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_UINT,
+ TP_HANDLE_TYPE_GROUP,
+ TP_IFACE_CHANNEL ".TargetID", G_TYPE_STRING,
+ group_name,
+ NULL);
+
purple_debug_info("telepathy", "Group %s does not exist. Creating it!\n",
group_name);
- /* TODO: Create a new group for the buddy! */
+ tp_cli_connection_interface_requests_call_create_channel(data->connection, -1,
+ request, create_group_channel_cb, g_strdup(buddy_name), g_free,
+ NULL);
+
+ g_hash_table_destroy(request);
}
else
{
+ /* Since the channel is created, all we have to do is request a handle and add
+ * it to the relevant lists
+ */
+
gchar const *ids[] = { buddy_name, NULL };
tp_connection_request_handles(connection_data->connection, -1,
@@ -700,7 +727,7 @@ get_human_name(const gchar *telepathy_na
*purple_type_out = PURPLE_PREF_BOOLEAN;
else
{
- purple_debug_warning("telepathy", "Unknown DBus signature \"%s\" for option \"%s\"",
+ purple_debug_warning("telepathy", "Unknown DBus signature \"%s\" for option \"%s\"\n",
dbus_type, telepathy_name);
return NULL;
}
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_list.c 8650da8195b3836719381470ad56cf8ef908c7a2
+++ libpurple/protocols/telepathy/telepathy_channel_list.c 043a39d975c9d60555156c9864a80822a8ae3e55
@@ -20,6 +20,8 @@
#include "telepathy_channel_list.h"
+#include <telepathy-glib/interfaces.h>
+
#include "debug.h"
#include "telepathy_avatar.h"
@@ -32,6 +34,36 @@ void
}
void
+create_group_channel_cb (TpConnection *proxy,
+ const gchar *out_Channel,
+ GHashTable *out_Properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ /* the name of the buddy to add is stored in user_data */
+ gchar *buddy_name = user_data;
+ gchar const *ids[] = { buddy_name, NULL };
+
+ if (error != NULL)
+ {
+ purple_debug_error("telepathy", "CreateChannel for group error: %s\n",
+ error->message);
+ return;
+ }
+
+ purple_debug_info("telepathy", "Group channel created: %s\n", out_Channel);
+
+ /* TODO: Add the buddy to the newly created group
+
+ tp_connection_request_handles(proxy, -1,
+ TP_HANDLE_TYPE_CONTACT, ids,
+ add_contact_to_group_cb, tp_group,
+ NULL, NULL);
+ */
+}
+
+void
handle_list_channel (TpChannel *channel,
telepathy_connection *data)
{
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_list.h e6934ac0bd473b436d91883f90c4acb15866f78b
+++ libpurple/protocols/telepathy/telepathy_channel_list.h a427580edb95a22cd97ba505f29ba9dd1980b1d8
@@ -36,6 +36,14 @@ void
destroy_group(telepathy_group *tp_group);
void
+create_group_channel_cb (TpConnection *proxy,
+ const gchar *out_Channel,
+ GHashTable *out_Properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object);
+
+void
handle_list_channel (TpChannel *channel,
telepathy_connection *data);
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.c 8e5c51ffbc211baa529dbe13e79a5f46b046548d
+++ libpurple/protocols/telepathy/telepathy_contact.c d1e7cf5590501a842b89efacec6b77951688132a
@@ -67,7 +67,7 @@ add_contact_to_group_cb (TpConnection *c
else
{
telepathy_group *group = user_data;
- telepathy_group *subscribe_list = user_data;
+ telepathy_group *subscribe_list;
const TpContactFeature features[] = {
TP_CONTACT_FEATURE_ALIAS,
@@ -98,7 +98,7 @@ add_contact_to_group_cb (TpConnection *c
{
/* add buddy to the subscribe list */
tp_cli_channel_interface_group_call_add_members(
- group->channel, -1,
+ subscribe_list->channel, -1,
arr, NULL,
add_member_cb, group->connection_data,
NULL, NULL);
More information about the Commits
mailing list