diff options
-rw-r--r-- | irc.h | 2 | ||||
-rw-r--r-- | irc_channel.c | 22 | ||||
-rw-r--r-- | irc_im.c | 2 | ||||
-rw-r--r-- | storage_xml.c | 4 |
4 files changed, 30 insertions, 0 deletions
@@ -192,6 +192,7 @@ typedef enum IRC_CC_TYPE_REST, IRC_CC_TYPE_GROUP, IRC_CC_TYPE_ACCOUNT, + IRC_CC_TYPE_PROTOCOL, } irc_control_channel_type_t; struct irc_control_channel @@ -199,6 +200,7 @@ struct irc_control_channel irc_control_channel_type_t type; struct bee_group *group; struct account *account; + struct prpl *protocol; }; extern const struct bee_ui_funcs irc_ui_funcs; diff --git a/irc_channel.c b/irc_channel.c index a241847d..f5e140e0 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -473,6 +473,7 @@ static gboolean control_channel_invite( irc_channel_t *ic, irc_user_t *iu ) static char *set_eval_by_account( set_t *set, char *value ); static char *set_eval_fill_by( set_t *set, char *value ); static char *set_eval_by_group( set_t *set, char *value ); +static char *set_eval_by_protocol( set_t *set, char *value ); static gboolean control_channel_init( irc_channel_t *ic ) { @@ -481,6 +482,7 @@ static gboolean control_channel_init( irc_channel_t *ic ) set_add( &ic->set, "account", NULL, set_eval_by_account, ic ); set_add( &ic->set, "fill_by", "all", set_eval_fill_by, ic ); set_add( &ic->set, "group", NULL, set_eval_by_group, ic ); + set_add( &ic->set, "protocol", NULL, set_eval_by_protocol, ic ); ic->data = icc = g_new0( struct irc_control_channel, 1 ); icc->type = IRC_CC_TYPE_DEFAULT; @@ -514,6 +516,7 @@ static char *set_eval_by_account( set_t *set, char *value ) icc->account = acc; if( icc->type == IRC_CC_TYPE_ACCOUNT ) bee_irc_channel_update( ic->irc, ic, NULL ); + return g_strdup_printf( "%s(%s)", acc->prpl->name, acc->user ); } @@ -530,6 +533,8 @@ static char *set_eval_fill_by( set_t *set, char *value ) icc->type = IRC_CC_TYPE_GROUP; else if( strcmp( value, "account" ) == 0 ) icc->type = IRC_CC_TYPE_ACCOUNT; + else if( strcmp( value, "protocol" ) == 0 ) + icc->type = IRC_CC_TYPE_PROTOCOL; else return SET_INVALID; @@ -545,9 +550,26 @@ static char *set_eval_by_group( set_t *set, char *value ) icc->group = bee_group_by_name( ic->irc->b, value, TRUE ); if( icc->type == IRC_CC_TYPE_GROUP ) bee_irc_channel_update( ic->irc, ic, NULL ); + return g_strdup( icc->group->name ); } +static char *set_eval_by_protocol( set_t *set, char *value ) +{ + struct irc_channel *ic = set->data; + struct irc_control_channel *icc = ic->data; + struct prpl *prpl; + + if( !( prpl = find_protocol( value ) ) ) + return SET_INVALID; + + icc->protocol = prpl; + if( icc->type == IRC_CC_TYPE_PROTOCOL ) + bee_irc_channel_update( ic->irc, ic, NULL ); + + return value; +} + static gboolean control_channel_free( irc_channel_t *ic ) { struct irc_control_channel *icc = ic->data; @@ -156,6 +156,8 @@ void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu ) show = iu->bu->group == icc->group; else if( icc->type == IRC_CC_TYPE_ACCOUNT ) show = iu->bu->ic->acc == icc->account; + else if( icc->type == IRC_CC_TYPE_PROTOCOL ) + show = iu->bu->ic->acc->prpl == icc->protocol; if( !show ) { diff --git a/storage_xml.c b/storage_xml.c index f97b2cd5..a60769bb 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -218,6 +218,10 @@ static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_na return; } + /* The channel may exist already, for example if it's &bitlbee. + Also, it's possible that the user just reconnected and the + IRC client already rejoined all channels it was in. They + should still get the right settings. */ if( ( xd->current_channel = irc_channel_by_name( irc, name ) ) || ( xd->current_channel = irc_channel_new( irc, name ) ) ) set_setstr( &xd->current_channel->set, "type", type ); |