diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 22:23:58 +0000 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-11-19 22:23:58 +0000 | 
| commit | 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43 (patch) | |
| tree | 8e7d9cf4480f507d6fc644605e91794395c211cf /protocols | |
| parent | ebb95b68792dde490a1ea1042209525f176af58d (diff) | |
Merging /TOPIC code from Miklos Vajna. Untested, because I still have to
implement the Jabber hooks.
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/nogaim.c | 24 | ||||
| -rw-r--r-- | protocols/nogaim.h | 10 | 
2 files changed, 34 insertions, 0 deletions
| diff --git a/protocols/nogaim.c b/protocols/nogaim.c index d1aceb1a..2ad8a049 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -759,6 +759,29 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags,  	g_free( wrapped );  } +void imcb_chat_topic( struct groupchat *c, char *who, char *topic ) +{ +	struct im_connection *ic = c->ic; +	user_t *u = NULL; +	 +	if( who == NULL) +		u = user_find( ic, ic->irc->mynick ); +	else if( g_strcasecmp( who, ic->acc->user ) == 0 ) +		u = user_find( ic, ic->irc->nick ); +	else +		u = user_findhandle( ic, who ); +	 +	if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || +	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) +		strip_html( topic ); +	 +	g_free( c->topic ); +	c->topic = g_strdup( topic ); +	 +	if( c->joined && u ) +		irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); +} +  struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )  {  	struct groupchat *c; @@ -776,6 +799,7 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )  	c->ic = ic;  	c->title = g_strdup( handle );  	c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); +	c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );  	if( set_getbool( &ic->irc->set, "debug" ) )  		imcb_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 5bf6d922..7c643cd3 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -109,6 +109,9 @@ struct groupchat {  	/* The title variable contains the ID you gave when you created the  	 * chat using imcb_chat_new(). */  	char *title; +	/* Use imcb_chat_topic() to change this variable otherwise the user +	 * won't notice the topic change. */ +	char *topic;  	char joined;  	/* This is for you, you can add your own structure here to extend this  	 * structure for your protocol's needs. */ @@ -211,6 +214,11 @@ struct prpl {  	 * not implement this. */  	struct groupchat *  	     (* chat_join)	(struct im_connection *, char *room, char *nick, char *password); +	/* Change the topic, if supported. Note that BitlBee expects the IM +	   server to confirm the topic change with a regular topic change +	   event. If it doesn't do that, you have to fake it to make it +	   visible to the user. */ +	void (* chat_topic)	(struct groupchat *, char *message);  	/* You can tell what away states your protocol supports, so that  	 * BitlBee will try to map the IRC away reasons to them, or use @@ -292,6 +300,8 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );  G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );  /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */  G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ); +/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */ +G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic );  G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );  /* Actions, or whatever. */ | 
