diff options
| -rw-r--r-- | irc_im.c | 35 | ||||
| -rw-r--r-- | protocols/bee.h | 1 | ||||
| -rw-r--r-- | protocols/bee_chat.c | 54 | 
3 files changed, 39 insertions, 51 deletions
| @@ -337,6 +337,37 @@ static gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_u  	return TRUE;  } +static gboolean bee_irc_chat_name_hint( bee_t *bee, struct groupchat *c, const char *name ) +{ +	irc_t *irc = bee->ui_data; +	irc_channel_t *ic = c->ui_data; +	char stripped[MAX_NICK_LENGTH+1], *full_name; +	 +	/* Don't rename a channel if the user's in it already. */ +	if( ic->flags & IRC_CHANNEL_JOINED ) +		return FALSE; +	 +	strncpy( stripped, name, MAX_NICK_LENGTH ); +	stripped[MAX_NICK_LENGTH] = '\0'; +	nick_strip( stripped ); +	if( set_getbool( &bee->set, "lcnicks" ) ) +		nick_lc( stripped ); +	 +	full_name = g_strdup_printf( "&%s", stripped ); +	 +	if( stripped[0] && irc_channel_by_name( irc, full_name ) == NULL ) +	{ +		g_free( ic->name ); +		ic->name = full_name; +	} +	else +	{ +		g_free( full_name ); +	} +	 +	return TRUE; +} +  /* IRC->IM */  static gboolean bee_irc_channel_chat_privmsg( irc_channel_t *ic, const char *msg )  { @@ -361,8 +392,9 @@ static gboolean bee_irc_channel_chat_part( irc_channel_t *ic, const char *msg )  static const struct irc_channel_funcs irc_channel_im_chat_funcs = {  	bee_irc_channel_chat_privmsg, -	NULL, +	NULL, /* join */  	bee_irc_channel_chat_part, +	NULL, /* topic */  }; @@ -406,6 +438,7 @@ const struct bee_ui_funcs irc_ui_funcs = {  	bee_irc_chat_msg,  	bee_irc_chat_add_user,  	bee_irc_chat_remove_user, +	bee_irc_chat_name_hint,  	bee_irc_ft_in_start,  	bee_irc_ft_out_start, diff --git a/protocols/bee.h b/protocols/bee.h index 982bb914..c1b95881 100644 --- a/protocols/bee.h +++ b/protocols/bee.h @@ -84,6 +84,7 @@ typedef struct bee_ui_funcs  	gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at );  	gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );  	gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); +	gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name );  	struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );  	gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft ); diff --git a/protocols/bee_chat.c b/protocols/bee_chat.c index b523e544..36e4c453 100644 --- a/protocols/bee_chat.c +++ b/protocols/bee_chat.c @@ -51,33 +51,10 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )  void imcb_chat_name_hint( struct groupchat *c, const char *name )  { -#if 0 -	if( !c->joined ) -	{ -		struct im_connection *ic = c->ic; -		char stripped[MAX_NICK_LENGTH+1], *full_name; -		 -		strncpy( stripped, name, MAX_NICK_LENGTH ); -		stripped[MAX_NICK_LENGTH] = '\0'; -		nick_strip( stripped ); -		if( set_getbool( &ic->irc->set, "lcnicks" ) ) -			nick_lc( stripped ); -		 -		full_name = g_strdup_printf( "&%s", stripped ); -		 -		if( stripped[0] && -		    nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && -		    irc_chat_by_channel( ic->irc, full_name ) == NULL ) -		{ -			g_free( c->channel ); -			c->channel = full_name; -		} -		else -		{ -			g_free( full_name ); -		} -	} -#endif +	bee_t *bee = c->ic->bee; +	 +	if( bee->ui->chat_name_hint ) +		bee->ui->chat_name_hint( bee, c, name );  }  void imcb_chat_free( struct groupchat *c ) @@ -224,29 +201,6 @@ void imcb_chat_remove_buddy( struct groupchat *c, const char *handle, const char  		bee->ui->chat_remove_user( bee, c, bu );  } -#if 0 -static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ) -{ -	GList *i; -	 -	/* Find the handle in the room userlist and shoot it */ -	i = b->in_room; -	while( i ) -	{ -		if( g_strcasecmp( handle, i->data ) == 0 ) -		{ -			g_free( i->data ); -			b->in_room = g_list_remove( b->in_room, i->data ); -			return( 1 ); -		} -		 -		i = i->next; -	} -	 -	return 0; -} -#endif -  int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags )  {  	struct im_connection *ic = c->ic; | 
