From 1c40aa73b52e4507404c82056170069a859fb0cb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 28 Jun 2010 01:07:46 +0100 Subject: Mark nameless groupchat channels as temporary so they don't stick around forever. --- irc_im.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'irc_im.c') diff --git a/irc_im.c b/irc_im.c index f4c5f390..6572be44 100644 --- a/irc_im.c +++ b/irc_im.c @@ -454,10 +454,8 @@ static gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c ) if( ic->flags & IRC_CHANNEL_JOINED ) irc_channel_printf( ic, "Cleaning up channel, bye!" ); - /* irc_channel_free( ic ); */ - - irc_channel_del_user( ic, ic->irc->user, FALSE, "Chatroom closed by server" ); ic->data = NULL; + irc_channel_del_user( ic, ic->irc->user, FALSE, "Chatroom closed by server" ); return TRUE; } @@ -500,6 +498,9 @@ static gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_u { irc_t *irc = bee->ui_data; + /* TODO: Possible bug here: If a module removes $user here instead of just + using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into + a broken state around here. */ irc_channel_del_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data, FALSE, NULL ); return TRUE; @@ -695,14 +696,18 @@ static gboolean bee_irc_channel_chat_invite( irc_channel_t *ic, irc_user_t *iu ) } static char *set_eval_room_account( set_t *set, char *value ); +static char *set_eval_chat_type( set_t *set, char *value ); static gboolean bee_irc_channel_init( irc_channel_t *ic ) { set_add( &ic->set, "account", NULL, set_eval_room_account, ic ); - set_add( &ic->set, "chat_type", "groupchat", NULL, ic ); + set_add( &ic->set, "chat_type", "groupchat", set_eval_chat_type, ic ); set_add( &ic->set, "nick", NULL, NULL, ic ); set_add( &ic->set, "room", NULL, NULL, ic ); + /* chat_type == groupchat */ + ic->flags |= IRC_CHANNEL_TEMP; + return TRUE; } @@ -722,6 +727,20 @@ static char *set_eval_room_account( set_t *set, char *value ) return g_strdup_printf( "%s(%s)", acc->prpl->name, acc->user ); } +static char *set_eval_chat_type( set_t *set, char *value ) +{ + struct irc_channel *ic = set->data; + + if( strcmp( value, "groupchat" ) == 0 ) + ic->flags |= IRC_CHANNEL_TEMP; + else if( strcmp( value, "room" ) == 0 ) + ic->flags &= ~IRC_CHANNEL_TEMP; + else + return NULL; + + return value; +} + static gboolean bee_irc_channel_free( irc_channel_t *ic ) { set_del( &ic->set, "account" ); @@ -729,6 +748,8 @@ static gboolean bee_irc_channel_free( irc_channel_t *ic ) set_del( &ic->set, "nick" ); set_del( &ic->set, "room" ); + ic->flags &= ~IRC_CHANNEL_TEMP; + return TRUE; } -- cgit v1.2.3