Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188 soc.2012.gg
authorTomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
Mon, 20 Aug 2012 10:21:22 +0200
branchsoc.2012.gg
changeset740174b22496 pushlog
parent 2a2560bb1445
child 3b4cbb0e10d6
Gadu-Gadu: retrieve buddy public alias after adding to blist. Fixes #2188
libpurple/protocols/gg/gg.c
libpurple/protocols/gg/pubdir-prpl.c
libpurple/protocols/gg/pubdir-prpl.h
     1.1 --- a/libpurple/protocols/gg/gg.c
     1.2 +++ b/libpurple/protocols/gg/gg.c
     1.3 @@ -51,6 +51,7 @@
     1.4  #include "multilogon.h"
     1.5  #include "status.h"
     1.6  #include "servconn.h"
     1.7 +#include "pubdir-prpl.h"
     1.8  
     1.9  /* ---------------------------------------------------------------------- */
    1.10  
    1.11 @@ -1463,6 +1464,7 @@
    1.12  		ggp_status_fake_to_self(gc);
    1.13  	
    1.14  	ggp_roster_add_buddy(gc, buddy, group, message);
    1.15 +	ggp_pubdir_request_buddy_alias(gc, buddy);
    1.16  }
    1.17  
    1.18  static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
    1.19 @@ -1726,8 +1728,8 @@
    1.20  	NULL,				/* send_attention */
    1.21  	NULL,				/* get_attention_types */
    1.22  	ggp_get_account_text_table,	/* get_account_text_table */
    1.23 -	NULL,                           /* initiate_media */
    1.24 -	NULL,                            /* can_do_media */
    1.25 +	NULL,				/* initiate_media */
    1.26 +	NULL,				/* can_do_media */
    1.27  	NULL,				/* get_moods */
    1.28  	NULL,				/* set_public_alias */
    1.29  	NULL				/* get_public_alias */
     2.1 --- a/libpurple/protocols/gg/pubdir-prpl.c
     2.2 +++ b/libpurple/protocols/gg/pubdir-prpl.c
     2.3 @@ -33,6 +33,9 @@
     2.4  static void ggp_pubdir_get_info_prpl_got(PurpleConnection *gc,
     2.5  	int records_count, const ggp_pubdir_record *records, void *_uin);
     2.6  
     2.7 +static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
     2.8 +	int records_count, const ggp_pubdir_record *records, void *_uin);
     2.9 +
    2.10  /******************************************************************************/
    2.11  
    2.12  void ggp_pubdir_record_free(ggp_pubdir_record *records, int count)
    2.13 @@ -174,10 +177,6 @@
    2.14  			record->label = g_strdup(name);
    2.15  		else if (surname)
    2.16  			record->label = g_strdup(surname);
    2.17 -		else
    2.18 -			purple_debug_warning("gg",
    2.19 -				"ggp_pubdir_get_info_got_data: "
    2.20 -				"invalid record\n");
    2.21  		
    2.22  		if (g_strcmp0(record->label, ggp_uin_to_str(record->uin)) == 0)
    2.23  		{
    2.24 @@ -302,3 +301,40 @@
    2.25  	purple_notify_userinfo(gc, ggp_uin_to_str(uin), info, NULL, NULL);
    2.26  	purple_notify_user_info_destroy(info);
    2.27  }
    2.28 +
    2.29 +void ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy)
    2.30 +{
    2.31 +	uin_t uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
    2.32 +
    2.33 +	purple_debug_info("gg", "ggp_pubdir_request_buddy_alias: %u\n", uin);
    2.34 +
    2.35 +	ggp_pubdir_get_info(gc, uin, ggp_pubdir_request_buddy_alias_got, (void*)uin);
    2.36 +}
    2.37 +
    2.38 +static void ggp_pubdir_request_buddy_alias_got(PurpleConnection *gc,
    2.39 +	int records_count, const ggp_pubdir_record *records, void *_uin)
    2.40 +{
    2.41 +	uin_t uin = (uin_t)_uin;
    2.42 +	const gchar *alias;
    2.43 +	
    2.44 +	if (records_count < 0)
    2.45 +	{
    2.46 +		purple_debug_error("gg", "ggp_pubdir_request_buddy_alias_got: "
    2.47 +			"couldn't get info for %u\n", uin);
    2.48 +		return;
    2.49 +	}
    2.50 +	g_assert(uin == records[0].uin);
    2.51 +	
    2.52 +	alias = records[0].label;
    2.53 +	if (!alias)
    2.54 +	{
    2.55 +		purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
    2.56 +			"public alias for %u is not available\n", uin);
    2.57 +		return;
    2.58 +	}
    2.59 +
    2.60 +	purple_debug_info("gg", "ggp_pubdir_request_buddy_alias_got: "
    2.61 +		"public alias for %u is \"%s\"\n", uin, alias);
    2.62 +	
    2.63 +	serv_got_alias(gc, ggp_uin_to_str(uin), alias);
    2.64 +}
     3.1 --- a/libpurple/protocols/gg/pubdir-prpl.h
     3.2 +++ b/libpurple/protocols/gg/pubdir-prpl.h
     3.3 @@ -26,5 +26,6 @@
     3.4  	ggp_pubdir_request_cb cb, void *user_data);
     3.5  
     3.6  void ggp_pubdir_get_info_prpl(PurpleConnection *gc, const char *name);
     3.7 +void ggp_pubdir_request_buddy_alias(PurpleConnection *gc, PurpleBuddy *buddy);
     3.8  
     3.9  #endif /* _GGP_PUBDIR_PRPL_H */