diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-15 01:05:49 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-15 01:05:49 +0100 | 
| commit | ff27648aee17e649cdd1e47f503271e4fccbff43 (patch) | |
| tree | 14e4bd404e2d59d0c56c6b744a04c3b90fc6b82b | |
| parent | d97f51b59a3ac6d9557ebd1e42a45928fe064b4b (diff) | |
Read group info.
| -rw-r--r-- | protocols/msn/msn.c | 12 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 13 | ||||
| -rw-r--r-- | protocols/msn/msn_util.c | 32 | ||||
| -rw-r--r-- | protocols/msn/soap.c | 18 | 
4 files changed, 67 insertions, 8 deletions
| diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 679ac65e..00c01dc3 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -106,14 +106,20 @@ static void msn_logout( struct im_connection *ic )  		msn_msgq_purge( ic, &md->msgq ); -		while( md->groupcount > 0 ) -			g_free( md->grouplist[--md->groupcount] ); -		g_free( md->grouplist );  		g_free( md->tokens[0] );  		g_free( md->tokens[1] );  		g_free( md->tokens[2] );  		g_free( md->lock_key ); +		while( md->groups ) +		{ +			struct msn_group *mg = md->groups->data; +			g_free( mg->id ); +			g_free( mg->name ); +			g_free( mg ); +			md->groups = g_slist_remove( md->groups, mg ); +		} +		  		g_tree_destroy( md->domaintree );  		md->domaintree = NULL; diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 862d1ef7..c7529803 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -90,12 +90,9 @@ struct msn_data  	GSList *switchboards;  	int sb_failures;  	time_t first_sb_failure; -	GSList *filetransfers;  	const struct msn_away_state *away_state; -	int buddycount; -	int groupcount; -	char **grouplist; +	GSList *groups;  	GTree *domaintree;  }; @@ -174,6 +171,12 @@ struct msn_buddy_data  	msn_buddy_flags_t flags;  }; +struct msn_group +{ +	char *name; +	char *id; +}; +  /* Bitfield values for msn_status_code.flags */  #define STATUS_FATAL            1  #define STATUS_SB_FATAL         2 @@ -210,6 +213,8 @@ void msn_msgq_purge( struct im_connection *ic, GSList **list );  gboolean msn_set_display_name( struct im_connection *ic, const char *rawname );  char *msn_p11_challenge( char *challenge );  gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); +struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ); +struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id );  /* tables.c */  const struct msn_away_state *msn_away_state_by_number( int number ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 069e68b8..cf8ab4db 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -565,3 +565,35 @@ gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ )  	return ret;  } + +struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ) +{ +	struct msn_data *md = ic->proto_data; +	GSList *l; +	 +	for( l = md->groups; l; l = l->next ) +	{ +		struct msn_group *mg = l->data; +		 +		if( g_strcasecmp( mg->name, name ) == 0 ) +			return mg; +	} +	 +	return NULL; +} + +struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ) +{ +	struct msn_data *md = ic->proto_data; +	GSList *l; +	 +	for( l = md->groups; l; l = l->next ) +	{ +		struct msn_group *mg = l->data; +		 +		if( g_strcasecmp( mg->id, id ) == 0 ) +			return mg; +	} +	 +	return NULL; +} diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 5d641542..b8762ce1 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -631,6 +631,7 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data  	struct xt_node *p;  	char *id = NULL, *name = NULL;  	struct msn_soap_req_data *soap_req = data; +	struct msn_data *md = soap_req->ic->proto_data;  	if( ( p = xt_find_path( node, "../groupId" ) ) )  		id = p->text; @@ -638,6 +639,14 @@ static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data  	if( ( p = xt_find_node( node->children, "name" ) ) )  		name = p->text; +	if( id && name ) +	{ +		struct msn_group *mg = g_new0( struct msn_group, 1 ); +		mg->id = g_strdup( id ); +		mg->name = g_strdup( name ); +		md->groups = g_slist_prepend( md->groups, mg ); +	} +	  	printf( "%s %s\n", id, name );  	return XT_HANDLED; @@ -648,9 +657,11 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da  	bee_user_t *bu;  	struct msn_buddy_data *bd;  	struct xt_node *p; -	char *id = NULL, *type = NULL, *handle = NULL, *display_name = NULL; +	char *id = NULL, *type = NULL, *handle = NULL, +	     *display_name = NULL, *group_id = NULL;  	struct msn_soap_req_data *soap_req = data;  	struct im_connection *ic = soap_req->ic; +	struct msn_group *group;  	if( ( p = xt_find_path( node, "../contactId" ) ) )  		id = p->text; @@ -660,6 +671,8 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da  		handle = p->text;  	if( ( p = xt_find_node( node->children, "displayName" ) ) )  		display_name = p->text; +	if( ( p = xt_find_path( node, "groupIds/guid" ) ) ) +		group_id = p->text;  	if( type && g_strcasecmp( type, "me" ) == 0 )  	{ @@ -684,6 +697,9 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da  	imcb_rename_buddy( ic, handle, display_name ); +	if( group_id && ( group = msn_group_by_id( ic, group_id ) ) ) +		imcb_add_buddy( ic, handle, group->name ); +	  	printf( "%s %s %s %s\n", id, type, handle, display_name );  	return XT_HANDLED; | 
