Changeset c8eeadd for irc_channel.c


Ignore:
Timestamp:
2010-07-04T10:16:07Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5c7b45c
Parents:
0bd948e
Message:

Added automatic joining of channels. Auto-rejoin functionality for
groupchats not reimplemented yet but that's the next step.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_channel.c

    r0bd948e rc8eeadd  
    4848        irc->channels = g_slist_append( irc->channels, ic );
    4949       
     50        set_add( &ic->set, "auto_join", "false", set_eval_bool, ic );
    5051        set_add( &ic->set, "type", "control", set_eval_channel_type, ic );
    5152       
     
    309310}
    310311
     312void irc_channel_auto_joins( irc_t *irc, account_t *acc )
     313{
     314        GSList *l;
     315       
     316        for( l = irc->channels; l; l = l->next )
     317        {
     318                irc_channel_t *ic = l->data;
     319                gboolean aj = set_getbool( &ic->set, "auto_join" );
     320                char *type;
     321               
     322                if( acc &&
     323                    ( type = set_getstr( &ic->set, "chat_type" ) ) &&
     324                    strcmp( type, "room" ) == 0 )
     325                {
     326                        /* Bit of an ugly special case: Handle chatrooms here, we
     327                           can only auto-join them if their account is online. */
     328                        char *acc_s;
     329                       
     330                        if( !aj && !( ic->flags & IRC_CHANNEL_JOINED ) )
     331                                /* Only continue if this one's marked as auto_join
     332                                   or if we're in it already. (Possible if the
     333                                   client auto-rejoined it before identyfing.) */
     334                                continue;
     335                        else if( !( acc_s = set_getstr( &ic->set, "account" ) ) )
     336                                continue;
     337                        else if( account_get( irc->b, acc_s ) != acc )
     338                                continue;
     339                        else if( acc->ic == NULL || !( acc->ic->flags & OPT_LOGGED_IN ) )
     340                                continue;
     341                        else
     342                                ic->f->join( ic );
     343                }
     344                else if( aj )
     345                {
     346                        irc_channel_add_user( ic, irc->user );
     347                }
     348        }
     349}
     350
    311351void irc_channel_printf( irc_channel_t *ic, char *format, ... )
    312352{
     
    521561                bee_irc_channel_update( ic->irc, ic, NULL );
    522562        }
     563       
     564        return TRUE;
     565}
     566
     567static gboolean control_channel_join( irc_channel_t *ic )
     568{
     569        bee_irc_channel_update( ic->irc, ic, NULL );
    523570       
    524571        return TRUE;
     
    608655static const struct irc_channel_funcs control_channel_funcs = {
    609656        control_channel_privmsg,
    610         NULL,
     657        control_channel_join,
    611658        NULL,
    612659        NULL,
Note: See TracChangeset for help on using the changeset viewer.