soc.2009.telepathy: 644787a5: Fetch buddy list from server

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Mon May 18 16:10:30 EDT 2009


-----------------------------------------------------------------
Revision: 644787a5bc320e9718ce3fc4d197e8da285d126b
Ancestor: 2752c2ec1fb8dff0d15c09bcc16e51819d2a3151
Author: sttwister at soc.pidgin.im
Date: 2009-05-18T20:07:27
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/644787a5bc320e9718ce3fc4d197e8da285d126b

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

ChangeLog: 

Fetch buddy list from server

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	ca75aba2ba51bb785028d9ad45ece74b019702e6
+++ libpurple/protocols/telepathy/telepathy.c	d4baf8d77de9c947578044c80b9a062cc955ff8c
@@ -53,6 +53,7 @@ typedef struct
 	TpConnectionManagerProtocol *protocol;
 	TpConnection *connection;
 	PurpleConnection *gc;
+	PurpleAccount *acct;
 
 	/* Set when calling ListChannels, unset when callback fires.
 	 * This avoids processing a channel twice (via NewChannel signal also). */
@@ -148,11 +149,7 @@ contact_notify_cb (TpContact *contact,
 		   GParamSpec *pspec,
 		   gpointer user_data)
 {
-	purple_debug_info("telepathy", "  - %s (%s)\t\t%s - %s\n",
-			tp_contact_get_alias (contact),
-			tp_contact_get_identifier (contact),
-			tp_contact_get_presence_status (contact),
-			tp_contact_get_presence_message (contact));
+	/* TODO: Update presence and status for user */
 }
 
 
@@ -178,9 +175,22 @@ contacts_ready_cb (TpConnection *connect
 		for (i = 0; i<n_contacts; ++i)
 		{
 			TpContact *contact = contacts[i];
+			PurpleBuddy *buddy;
+			PurplePlugin *plugin = user_data;
+			telepathy_data *data = plugin->extra;
 
 			purple_debug_info("telepathy", "  Contact ready: %s\n", tp_contact_get_alias(contact));
 
+			buddy = purple_find_buddy(data->acct, tp_contact_get_identifier(contact));
+
+			if (buddy == NULL)
+			{
+				purple_debug_info("telepathy", "New user detected!!!\n");
+				buddy = purple_buddy_new(data->acct, tp_contact_get_identifier(contact), tp_contact_get_alias(contact));
+			}
+
+			purple_blist_add_buddy(buddy, NULL, NULL, NULL);
+
 			g_object_ref(contact);
 
 			g_signal_connect(contact, "notify", G_CALLBACK (contact_notify_cb), user_data);
@@ -405,6 +415,8 @@ connection_ready_cb (TpConnection *conne
 			g_error_free(error);
 			error = NULL;
 
+			purple_debug_info("telepathy", "Falling back to NewChannel signal...\n");
+
 			/* fallback to the old NewChannel method */
 			tp_cli_connection_connect_to_new_channel(connection, new_channel_cb, user_data, NULL, NULL, &error);
 
@@ -621,6 +633,7 @@ telepathy_login(PurpleAccount *acct)
 	int i;
 
 	data->gc = gc;
+	data->acct = acct;
 
 	purple_debug_info("telepathy", "Logging in as %s\n", acct->username);
 


More information about the Commits mailing list