/soc/2012/tomkiewicz/gg: 740174b22496: Gadu-Gadu: retrieve buddy...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Mon Aug 20 04:21:59 EDT 2012


Changeset: 740174b22496230a70bb4e20f29f9e16b80cc9ca
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-08-20 10:21 +0200
Branch:	 soc.2012.gg
URL: http://hg.pidgin.im/soc/2012/tomkiewicz/gg/rev/740174b22496

Description:

Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188

diffstat:

 libpurple/protocols/gg/gg.c          |   6 +++-
 libpurple/protocols/gg/pubdir-prpl.c |  44 ++++++++++++++++++++++++++++++++---
 libpurple/protocols/gg/pubdir-prpl.h |   1 +
 3 files changed, 45 insertions(+), 6 deletions(-)

diffs (105 lines):

diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -51,6 +51,7 @@
 #include "multilogon.h"
 #include "status.h"
 #include "servconn.h"
+#include "pubdir-prpl.h"
 
 /* ---------------------------------------------------------------------- */
 
@@ -1463,6 +1464,7 @@ static void ggp_add_buddy(PurpleConnecti
 		ggp_status_fake_to_self(gc);
 	
 	ggp_roster_add_buddy(gc, buddy, group, message);
+	ggp_pubdir_request_buddy_alias(gc, buddy);
 }
 
 static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
@@ -1726,8 +1728,8 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,				/* send_attention */
 	NULL,				/* get_attention_types */
 	ggp_get_account_text_table,	/* get_account_text_table */
-	NULL,                           /* initiate_media */
-	NULL,                            /* can_do_media */
+	NULL,				/* initiate_media */
+	NULL,				/* can_do_media */
 	NULL,				/* get_moods */
 	NULL,				/* set_public_alias */
 	NULL				/* get_public_alias */
diff --git a/libpurple/protocols/gg/pubdir-prpl.c b/libpurple/protocols/gg/pubdir-prpl.c
--- a/libpurple/protocols/gg/pubdir-prpl.c
+++ b/libpurple/protocols/gg/pubdir-prpl.c
@@ -33,6 +33,9 @@ static void ggp_pubdir_get_info_got_data
 static void ggp_pubdir_get_info_prpl_got(PurpleConnection *gc,
 	int records_count, const ggp_pubdir_record *records, void *_uin);
 
+static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
+	int records_count, const ggp_pubdir_record *records, void *_uin);
+
 /******************************************************************************/
 
 void ggp_pubdir_record_free(ggp_pubdir_record *records, int count)
@@ -174,10 +177,6 @@ static void ggp_pubdir_get_info_got_data
 			record->label = g_strdup(name);
 		else if (surname)
 			record->label = g_strdup(surname);
-		else
-			purple_debug_warning("gg",
-				"ggp_pubdir_get_info_got_data: "
-				"invalid record\n");
 		
 		if (g_strcmp0(record->label, ggp_uin_to_str(record->uin)) == 0)
 		{
@@ -302,3 +301,40 @@ static void ggp_pubdir_get_info_prpl_got
 	purple_notify_userinfo(gc, ggp_uin_to_str(uin), info, NULL, NULL);
 	purple_notify_user_info_destroy(info);
 }
+
+void ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy)
+{
+	uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
+
+	purple_debug_info("gg", "ggp_pubdir_request_buddy_alias: %u\n", uin);
+
+	ggp_pubdir_get_info(gc, uin, ggp_pubdir_request_buddy_alias_got, (void*)uin);
+}
+
+static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
+	int records_count, const ggp_pubdir_record *records, void *_uin)
+{
+	uin_t uin = (uin_t)_uin;
+	const gchar *alias;
+	
+	if (records_count < 0)
+	{
+		purple_debug_error("gg", "ggp_pubdir_request_buddy_alias_got: "
+			"couldn't get info for %u\n", uin);
+		return;
+	}
+	g_assert(uin == records[0].uin);
+	
+	alias = records[0].label;
+	if (!alias)
+	{
+		purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
+			"public alias for %u is not available\n", uin);
+		return;
+	}
+
+	purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
+		"public alias for %u is \"%s\"\n", uin, alias);
+	
+	serv_got_alias(gc, ggp_uin_to_str(uin), alias);
+}
diff --git a/libpurple/protocols/gg/pubdir-prpl.h b/libpurple/protocols/gg/pubdir-prpl.h
--- a/libpurple/protocols/gg/pubdir-prpl.h
+++ b/libpurple/protocols/gg/pubdir-prpl.h
@@ -26,5 +26,6 @@ void ggp_pubdir_get_info(PurpleConnectio
 	ggp_pubdir_request_cb cb, void *user_data);
 
 void ggp_pubdir_get_info_prpl(PurpleConnection *gc, const char *name);
+void ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy);
 
 #endif /* _GGP_PUBDIR_PRPL_H */



More information about the Commits mailing list