diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-08 01:25:15 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-08 01:25:15 +0100 | 
| commit | 27e2c66f28bc196d766ac179aa5eae0d190565d5 (patch) | |
| tree | a47343b0b79a120a8a5e9d8af98d0c8e7bf19ef3 | |
| parent | f1a089067fcc4fcae05cdbfa0f51a8a3cc8f6783 (diff) | |
Support for receiving messages in chatrooms.
| -rw-r--r-- | irc_im.c | 23 | ||||
| -rw-r--r-- | protocols/bee.h | 4 | ||||
| -rw-r--r-- | protocols/bee_chat.c | 44 | 
3 files changed, 37 insertions, 34 deletions
| @@ -244,12 +244,27 @@ gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c )  	return TRUE;  } -gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *format, ... ) +gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *text )  { +	irc_channel_t *ic = c->ui_data; +	 +	irc_channel_printf( ic, "%s", text );  } -gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at ) +gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at )  { +	irc_t *irc = bee->ui_data; +	irc_user_t *iu = bu->ui_data; +	irc_channel_t *ic = c->ui_data; +	char *ts = NULL; +	 +	if( sent_at > 0 && set_getbool( &bee->set, "display_timestamps" ) ) +		ts = irc_format_timestamp( irc, sent_at ); +	 +	irc_send_msg( iu, "PRIVMSG", ic->name, msg, ts ); +	g_free( ts ); +	 +	return TRUE;  }  gboolean bee_irc_chat_add_user( bee_t *bee, struct groupchat *c, bee_user_t *bu ) @@ -300,8 +315,8 @@ const struct bee_ui_funcs irc_ui_funcs = {  	bee_irc_chat_new,  	bee_irc_chat_free, -	NULL, -	NULL, +	bee_irc_chat_log, +	bee_irc_chat_msg,  	bee_irc_chat_add_user,  	NULL, diff --git a/protocols/bee.h b/protocols/bee.h index f69d29d4..27e31d05 100644 --- a/protocols/bee.h +++ b/protocols/bee.h @@ -80,8 +80,8 @@ typedef struct bee_ui_funcs  	gboolean (*chat_new)( bee_t *bee, struct groupchat *c );  	gboolean (*chat_free)( bee_t *bee, struct groupchat *c ); -	gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *format, ... ); -	gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at ); +	gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *text ); +	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 ); diff --git a/protocols/bee_chat.c b/protocols/bee_chat.c index 501bb6aa..0c7bebd9 100644 --- a/protocols/bee_chat.c +++ b/protocols/bee_chat.c @@ -104,56 +104,44 @@ void imcb_chat_free( struct groupchat *c )  void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )  { -#if 0  	struct im_connection *ic = c->ic; -	char *wrapped; -	user_t *u; +	bee_t *bee = ic->bee; +	bee_user_t *bu; +	char *s;  	/* Gaim sends own messages through this too. IRC doesn't want this, so kill them */  	if( g_strcasecmp( who, ic->acc->user ) == 0 )  		return; -	u = user_findhandle( ic, who ); +	bu = bee_user_by_handle( bee, ic, who ); -	if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) || -	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) ) +	s = set_getstr( &ic->bee->set, "strip_html" ); +	if( ( g_strcasecmp( s, "always" ) == 0 ) || +	    ( ( ic->flags & OPT_DOES_HTML ) && s ) )  		strip_html( msg ); -	wrapped = word_wrap( msg, 425 ); -	if( c && u ) -	{ -		char *ts = NULL; -		if( set_getbool( &ic->irc->set, "display_timestamps" ) ) -			ts = format_timestamp( ic->irc, sent_at ); -		irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); -		g_free( ts ); -	} +	if( bu && bee->ui->chat_msg ) +		bee->ui->chat_msg( bee, c, bu, msg, sent_at );  	else -	{ -		imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped ); -	} -	g_free( wrapped ); -#endif +		imcb_chat_log( c, "Message from unknown participant %s: %s", who, msg );  }  void imcb_chat_log( struct groupchat *c, char *format, ... )  { -#if 0 -	irc_t *irc = c->ic->irc; +	struct im_connection *ic = c->ic; +	bee_t *bee = ic->bee;  	va_list params;  	char *text; -	user_t *u; +	 +	if( !bee->ui->chat_log ) +		return;  	va_start( params, format );  	text = g_strdup_vprintf( format, params );  	va_end( params ); -	u = user_find( irc, irc->mynick ); -	 -	irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text ); -	 +	bee->ui->chat_log( bee, c, text );  	g_free( text ); -#endif  }  void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) | 
