soc.2009.telepathy: 69614766: Cache groups for later use. Added a sket...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Fri Jun 19 10:16:04 EDT 2009


-----------------------------------------------------------------
Revision: 69614766dec19dbbaa3ddcd99f5c7cb349f9594d
Ancestor: 7a0b649d7beb2d299a565891eed9e4de70085276
Author: sttwister at soc.pidgin.im
Date: 2009-06-19T14:14:23
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/69614766dec19dbbaa3ddcd99f5c7cb349f9594d

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_connection.c
        libpurple/protocols/telepathy/telepathy_connection.h
        libpurple/protocols/telepathy/telepathy_contact.c

ChangeLog: 

Cache groups for later use. Added a sketch for add_buddy

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	0db440d678ebf25365170f4831d9ad96ee3df8c6
+++ libpurple/protocols/telepathy/telepathy.c	143ec3282e28a0aa35195e1823b862636eaadaaa
@@ -40,6 +40,7 @@
 
 #include "telepathy_avatar.h"
 #include "telepathy_channel.h"
+#include "telepathy_channel_list.h"
 #include "telepathy_channel_text.h"
 #include "telepathy_connection.h"
 #include "telepathy_contact.h"
@@ -478,6 +479,31 @@ static void
 }
 
 static void
+telepathy_add_buddy (PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
+{
+	const gchar* buddy_name = purple_buddy_get_name(buddy);
+	const gchar* group_name = purple_group_get_name(group);
+
+	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 (tp_group == NULL)
+	{
+		purple_debug_info("telepathy", "Group %s does not exist. Creating it!\n",
+				group_name);
+
+		/* TODO: Create a new group for the buddy! */
+	}
+	else
+	{
+		/* TODO: Request a handle for the new buddy and add it to the group */
+	}
+}
+
+static void
 telepathy_set_buddy_icon (PurpleConnection *gc, PurpleStoredImage *img)
 {
 	telepathy_connection *data = purple_connection_get_protocol_data(gc);
@@ -551,7 +577,7 @@ static PurplePluginProtocolInfo telepath
 	telepathy_set_status,                 /* set_status */
 	NULL,                   /* set_idle */
 	NULL,              /* change_passwd */
-	NULL,                  /* add_buddy */
+	telepathy_add_buddy,                  /* add_buddy */
 	NULL,                /* add_buddies */
 	NULL,               /* remove_buddy */
 	NULL,             /* remove_buddies */
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_list.c	dea5894e4316434a1a8f6553717e8dea3d76757f
+++ libpurple/protocols/telepathy/telepathy_channel_list.c	8650da8195b3836719381470ad56cf8ef908c7a2
@@ -26,6 +26,12 @@ void
 #include "telepathy_contact.h"
 
 void
+destroy_group(telepathy_group *tp_group)
+{
+	g_free(tp_group);	
+}
+
+void
 handle_list_channel (TpChannel *channel,
                      telepathy_connection *data)
 {
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_list.h	889f520fc1896209dc1f214ed12dacc588876258
+++ libpurple/protocols/telepathy/telepathy_channel_list.h	e6934ac0bd473b436d91883f90c4acb15866f78b
@@ -32,6 +32,8 @@ typedef struct
 
 } telepathy_group;
 
+void
+destroy_group(telepathy_group *tp_group);
 
 void
 handle_list_channel (TpChannel *channel,
============================================================
--- libpurple/protocols/telepathy/telepathy_connection.c	f3c079f3499d8926582ed5dac3d782932756d700
+++ libpurple/protocols/telepathy/telepathy_connection.c	74790eeb13411f3e0695fcb245ce1720a49fda21
@@ -30,6 +30,7 @@
 #include "telepathy_avatar.h"
 #include "telepathy_channel.h"
 #include "telepathy_channel_text.h"
+#include "telepathy_channel_list.h"
 #include "telepathy_contact.h"
 
 void
@@ -53,6 +54,7 @@ status_changed_cb (TpConnection *proxy,
 
 		data->text_Channels = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) destroy_text_channel);
 		data->contacts = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) destroy_contact);
+		data->groups = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) destroy_group);
 	}
 	else if (arg_Status == TP_CONNECTION_STATUS_DISCONNECTED)
 	{
============================================================
--- libpurple/protocols/telepathy/telepathy_connection.h	5d102e163e859228142e40a25054c14af7a10ab1
+++ libpurple/protocols/telepathy/telepathy_connection.h	85d90fc7fc9c404528d1e0a1616d0d1b459cbdc9
@@ -44,6 +44,9 @@ typedef struct
 	
 	/* This will map contact handles to telepathy_contact */
 	GHashTable *contacts;
+
+	/* This will map group name to telepathy_group structs */
+	GHashTable *groups;
 	
 } telepathy_connection;
 
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.c	05502690e0f19e4758b11c66149d8dee0aa83303
+++ libpurple/protocols/telepathy/telepathy_contact.c	97e6a619e3c824dfeea54e1d30a42ae0bdee2a28
@@ -166,6 +166,7 @@ group_contacts_ready_cb (TpConnection *c
 	if (error != NULL)
 	{
 		purple_debug_error("telepathy", "Contacts ready error: %s\n", error->message);
+		g_free(data);
 	}
 	else
 	{
@@ -181,10 +182,10 @@ group_contacts_ready_cb (TpConnection *c
 		}
 
 		handle_contacts(data->connection_data, n_contacts, contacts, n_failed, group);
-	}
 
-	/* this isn't used anywhere else except this callback */
-	g_free(data);
+		g_hash_table_insert(data->connection_data->groups,
+				g_strdup(group_name), data);
+	}
 }
 
 /* this the ContactsReady callback for list channels */


More information about the Commits mailing list