Changeset 0bd948e for irc_user.c


Ignore:
Timestamp:
2010-07-03T21:16:41Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
c8eeadd
Parents:
917a83e
Message:

Show a user going offline as a QUIT, not as one or more PARTs, like in the
old-style BitlBee. This so that the IRC client will show the notification
in query windows as well. Make it a setting though, for bug #539.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_user.c

    r917a83e r0bd948e  
    5252int irc_user_free( irc_t *irc, irc_user_t *iu )
    5353{
    54         GSList *l;
    55         gboolean send_quit = FALSE;
     54        static struct im_connection *last_ic;
     55        static char *msg;
    5656       
    5757        if( !iu )
    5858                return 0;
    5959       
     60        if( iu->bu &&
     61            ( iu->bu->ic->flags & OPT_LOGGING_OUT ) &&
     62            iu->bu->ic != last_ic )
     63        {
     64                char host_prefix[] = "bitlbee.";
     65                char *s;
     66               
     67                /* Irssi recognises netsplits by quitmsgs with two
     68                   hostnames, where a hostname is a "word" with one
     69                   of more dots. Mangle no-dot hostnames a bit. */
     70                if( strchr( irc->root->host, '.' ) )
     71                        *host_prefix = '\0';
     72               
     73                last_ic = iu->bu->ic;
     74                g_free( msg );
     75                if( !set_getbool( &irc->b->set, "simulate_netsplit" ) )
     76                        msg = g_strdup( "Account off-line" );
     77                else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) )
     78                        msg = g_strdup_printf( "%s%s %s", host_prefix,
     79                                irc->root->host, s + 1 );
     80                else
     81                        msg = g_strdup_printf( "%s%s %s.%s",
     82                                host_prefix, irc->root->host,
     83                                iu->bu->ic->acc->prpl->name, irc->root->host );
     84        }
     85        else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) )
     86        {
     87                g_free( msg );
     88                msg = g_strdup( "Removed" );
     89                last_ic = NULL;
     90        }
     91        irc_user_quit( iu, msg );
     92       
    6093        irc->users = g_slist_remove( irc->users, iu );
    6194        g_hash_table_remove( irc->nick_user_hash, iu->key );
    62        
    63         for( l = irc->channels; l; l = l->next )
    64                 send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL );
    65        
    66         if( send_quit )
    67         {
    68                 static struct im_connection *last_ic;
    69                 static char *msg;
    70                
    71                 if( iu->bu &&
    72                     ( iu->bu->ic->flags & OPT_LOGGING_OUT ) &&
    73                     iu->bu->ic != last_ic )
    74                 {
    75                         char host_prefix[] = "bitlbee.";
    76                         char *s;
    77                        
    78                         /* Irssi recognises netsplits by quitmsgs with two
    79                            hostnames, where a hostname is a "word" with one
    80                            of more dots. Mangle no-dot hostnames a bit. */
    81                         if( strchr( irc->root->host, '.' ) )
    82                                 *host_prefix = '\0';
    83                        
    84                         last_ic = iu->bu->ic;
    85                         g_free( msg );
    86                         if( !set_getbool( &irc->b->set, "simulate_netsplit" ) )
    87                                 msg = g_strdup( "Account off-line" );
    88                         else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) )
    89                                 msg = g_strdup_printf( "%s%s %s", host_prefix,
    90                                         irc->root->host, s + 1 );
    91                         else
    92                                 msg = g_strdup_printf( "%s%s %s.%s",
    93                                         host_prefix, irc->root->host,
    94                                         iu->bu->ic->acc->prpl->name, irc->root->host );
    95                 }
    96                 else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) )
    97                 {
    98                         g_free( msg );
    99                         msg = g_strdup( "Removed" );
    100                         last_ic = NULL;
    101                 }
    102                 irc_send_quit( iu, msg );
    103         }
    10495       
    10596        g_free( iu->nick );
     
    205196}
    206197
     198void irc_user_quit( irc_user_t *iu, const char *msg )
     199{
     200        GSList *l;
     201        gboolean send_quit = FALSE;
     202       
     203        if( !iu )
     204                return;
     205       
     206        for( l = iu->irc->channels; l; l = l->next )
     207                send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL );
     208       
     209        if( send_quit )
     210                irc_send_quit( iu, msg );
     211}
     212
    207213/* User-type dependent functions, for root/NickServ: */
    208214static gboolean root_privmsg( irc_user_t *iu, const char *msg )
Note: See TracChangeset for help on using the changeset viewer.