diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-10 14:05:42 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-10-10 14:05:42 +0200 | 
| commit | a21a8ac4fbd5a234bc8d31d9d487c74a81383c8a (patch) | |
| tree | d8445a5409dfe11de56433f59cfa063952734d86 /protocols/jabber/jabber_util.c | |
| parent | 6a1128d1333cf79f1ef9fb1f55b1b8fec67caf2a (diff) | |
Added resource selection (based on priority or time of last message) to
budd_by_jid(), added a full_jid property to easily address that resource
without having to rebuild the full JID every time and implemented typing
notification shite.
Diffstat (limited to 'protocols/jabber/jabber_util.c')
| -rw-r--r-- | protocols/jabber/jabber_util.c | 27 | 
1 files changed, 22 insertions, 5 deletions
| diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index f4cd40d4..357743d3 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -246,7 +246,8 @@ struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_ji  	}  	*s = '/'; -	new->resource = g_strdup( s + 1 ); +	new->full_jid = g_strdup( full_jid ); +	new->resource = strchr( new->full_jid, '/' ) + 1;  	return new;  } @@ -267,8 +268,24 @@ struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid  	}  	else  	{ -		/* TODO: Add selection. */ -		return g_hash_table_lookup( jd->buddies, jid ); +		struct jabber_buddy *best_prio, *best_time; +		char *set; +		 +		best_prio = best_time = bud = g_hash_table_lookup( jd->buddies, jid ); +		for( ; bud; bud = bud->next ) +		{ +			if( bud->priority > best_prio->priority ) +				best_prio = bud; +			if( bud->last_act > best_time->last_act ) +				best_time = bud; +		} +		 +		if( ( set = set_getstr( &gc->acc->set, "resource_select" ) ) == NULL ) +			return NULL; +		else if( strcmp( set, "activity" ) == 0 ) +			return best_time; +		else /* if( strcmp( set, "priority" ) == 0 ) */ +			return best_prio;  	}  	*s = '/'; @@ -294,7 +311,7 @@ int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid )  		{  			g_hash_table_remove( jd->buddies, bud->handle );  			g_free( bud->handle ); -			g_free( bud->resource ); +			g_free( bud->full_jid );  			g_free( bud->away_message );  			g_free( bud );  		} @@ -313,7 +330,7 @@ int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid )  					   item, because we're removing the first. */  					g_hash_table_replace( jd->buddies, bi->handle, bi->next ); -				g_free( bi->resource ); +				g_free( bi->full_jid );  				g_free( bi->away_message );  				g_free( bi );  			} | 
