Changeset bb151f7


Ignore:
Timestamp:
2010-11-20T20:25:44Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
748bcdd
Parents:
d68365c
Message:

Added irc_channel_with_user() function to find a suitable channel to show
a user's message in, instead of just &bitlbee by default.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    rd68365c rbb151f7  
    287287int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, irc_channel_del_user_type_t type, const char *msg );
    288288irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu );
     289struct irc_channel *irc_channel_with_user( irc_t *irc, irc_user_t *iu );
    289290int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *who );
    290291void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t flags );
  • irc_channel.c

    rd68365c rbb151f7  
    287287                if( icu->iu == iu )
    288288                        return icu;
     289        }
     290       
     291        return NULL;
     292}
     293
     294/* Find a channel we're currently in, that currently has iu in it. */
     295struct irc_channel *irc_channel_with_user( irc_t *irc, irc_user_t *iu )
     296{
     297        GSList *l;
     298       
     299        for( l = irc->channels; l; l = l->next )
     300        {
     301                irc_channel_t *ic = l->data;
     302               
     303                if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
     304                        continue;
     305               
     306                if( ( ic->flags & IRC_CHANNEL_JOINED ) &&
     307                    irc_channel_has_user( ic, iu ) )
     308                        return ic;
     309        }
     310       
     311        /* If there was no match, try once more but just see if the user
     312           *would* be in the channel, i.e. if s/he were online. */
     313        if( iu->bu == NULL )
     314                return NULL;
     315       
     316        for( l = irc->channels; l; l = l->next )
     317        {
     318                irc_channel_t *ic = l->data;
     319               
     320                if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
     321                        continue;
     322               
     323                if( ( ic->flags & IRC_CHANNEL_JOINED ) &&
     324                    irc_channel_wants_user( ic, iu ) )
     325                        return ic;
    289326        }
    290327       
  • irc_im.c

    rd68365c rbb151f7  
    5454        bu->ui_data = iu = irc_user_new( irc, nick );
    5555        iu->bu = bu;
     56       
     57        if( set_getbool( &irc->b->set, "private" ) )
     58                iu->last_channel = NULL;
     59        else
     60                iu->last_channel = irc_channel_with_user( irc, iu );
    5661       
    5762        if( ( s = strchr( bu->handle, '@' ) ) )
     
    210215                if( iu->last_channel->flags & IRC_CHANNEL_JOINED )
    211216                        ic = iu->last_channel;
    212                 else if( irc->default_channel->flags & IRC_CHANNEL_JOINED )
    213                         ic = irc->default_channel;
     217                else
     218                        ic = irc_channel_with_user( irc, iu );
    214219        }
    215220       
  • irc_send.c

    rd68365c rbb151f7  
    127127                if( iu->last_channel->flags & IRC_CHANNEL_JOINED )
    128128                        ic = iu->last_channel;
    129                 else if( irc->default_channel->flags & IRC_CHANNEL_JOINED )
    130                         ic = irc->default_channel;
     129                else
     130                        ic = irc_channel_with_user( irc, irc->root );
    131131        }
    132132       
  • irc_user.c

    rd68365c rbb151f7  
    3434        iu->nick = g_strdup( nick );
    3535        iu->user = iu->host = iu->fullname = iu->nick;
    36        
    37         if( set_getbool( &irc->b->set, "private" ) )
    38                 iu->last_channel = NULL;
    39         else
    40                 iu->last_channel = irc->default_channel;
    4136       
    4237        iu->key = g_strdup( nick );
Note: See TracChangeset for help on using the changeset viewer.