Changeset 6a9d068


Ignore:
Timestamp:
2010-05-03T00:39:39Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f924563
Parents:
e54112f
Message:

Restore away_devoice.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    re54112f r6a9d068  
    640640                        irc_channel_add_user( ic, irc->user );
    641641                       
     642                        if( strcmp( set_getstr( &irc->b->set, "ops" ), "both" ) == 0 ||
     643                            strcmp( set_getstr( &irc->b->set, "ops" ), "user" ) == 0 )
     644                                irc_channel_user_set_mode( ic, irc->user, IRC_CHANNEL_USER_OP );
     645                       
    642646                        irc->last_root_cmd = g_strdup( ROOT_CHAN );
    643647                       
  • irc.h

    re54112f r6a9d068  
    196196irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu );
    197197int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *who );
     198void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t flags );
    198199gboolean irc_channel_name_ok( const char *name );
    199200
     
    216217void irc_send_msg_f( irc_user_t *iu, const char *type, const char *dst, const char *format, ... ) G_GNUC_PRINTF( 4, 5 );
    217218void irc_send_nick( irc_user_t *iu, const char *new );
     219void irc_send_channel_user_mode_diff( irc_channel_t *ic, irc_user_t *iu,
     220                                      irc_channel_user_flags_t old, irc_channel_user_flags_t new );
    218221
    219222/* irc_user.c */
  • irc_channel.c

    re54112f r6a9d068  
    4343       
    4444        irc_channel_add_user( ic, irc->root );
     45        if( strcmp( set_getstr( &irc->b->set, "ops" ), "both" ) == 0 ||
     46            strcmp( set_getstr( &irc->b->set, "ops" ), "root" ) == 0 )
     47                irc_channel_user_set_mode( ic, irc->root, IRC_CHANNEL_USER_OP );
    4548       
    4649        irc->channels = g_slist_prepend( irc->channels, ic );
     
    157160       
    158161        return 1;
     162}
     163
     164void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t flags )
     165{
     166        irc_channel_user_t *icu = irc_channel_has_user( ic, iu );
     167       
     168        if( icu->flags == flags )
     169                return;
     170       
     171        if( ic->flags & IRC_CHANNEL_JOINED )
     172                irc_send_channel_user_mode_diff( ic, iu, icu->flags, flags );
     173       
     174        icu->flags = flags;
    159175}
    160176
  • irc_im.c

    re54112f r6a9d068  
    9292                       
    9393                        irc_channel_add_user( ic, iu );
     94                       
     95                        if( set_getbool( &bee->set, "away_devoice" ) )
     96                                irc_channel_user_set_mode( ic, iu, ( bu->flags & BEE_USER_AWAY ) ?
     97                                                           0 : IRC_CHANNEL_USER_VOICE );
    9498                }
    9599                else
  • irc_send.c

    re54112f r6a9d068  
    157157        GSList *l;
    158158        char namelist[385] = "";
    159         //char *ops = set_getstr( &ic->irc->b->set, "ops" );
    160159       
    161160        /* RFCs say there is no error reply allowed on NAMES, so when the
     
    172171                }
    173172               
    174                 /*
    175                 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) )
     173                if( icu->flags & IRC_CHANNEL_USER_OP )
     174                        strcat( namelist, "@" );
     175                else if( icu->flags & IRC_CHANNEL_USER_HALFOP )
     176                        strcat( namelist, "%" );
     177                else if( icu->flags & IRC_CHANNEL_USER_VOICE )
    176178                        strcat( namelist, "+" );
    177                 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||
    178                          ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )
    179                         strcat( namelist, "@" );
    180                 */
    181179               
    182180                strcat( namelist, iu->nick );
     
    327325                   iu->nick, iu->user, iu->host, new );
    328326}
     327
     328/* Send an update of a user's mode inside a channel, compared to what it was. */
     329void irc_send_channel_user_mode_diff( irc_channel_t *ic, irc_user_t *iu,
     330        irc_channel_user_flags_t old, irc_channel_user_flags_t new )
     331{
     332        char changes[3*(5+strlen(iu->nick))];
     333        char from[strlen(ic->irc->root->nick)+strlen(ic->irc->root->user)+strlen(ic->irc->root->host)+3];
     334        int n;
     335       
     336        *changes = '\0'; n = 0;
     337        if( ( old & IRC_CHANNEL_USER_OP ) != ( new & IRC_CHANNEL_USER_OP ) )
     338        {
     339                n ++;
     340                if( new & IRC_CHANNEL_USER_OP )
     341                        strcat( changes, "+o" );
     342                else
     343                        strcat( changes, "-o" );
     344        }
     345        if( ( old & IRC_CHANNEL_USER_HALFOP ) != ( new & IRC_CHANNEL_USER_HALFOP ) )
     346        {
     347                n ++;
     348                if( new & IRC_CHANNEL_USER_HALFOP )
     349                        strcat( changes, "+h" );
     350                else
     351                        strcat( changes, "-h" );
     352        }
     353        if( ( old & IRC_CHANNEL_USER_VOICE ) != ( new & IRC_CHANNEL_USER_VOICE ) )
     354        {
     355                n ++;
     356                if( new & IRC_CHANNEL_USER_VOICE )
     357                        strcat( changes, "+v" );
     358                else
     359                        strcat( changes, "-v" );
     360        }
     361        while( n )
     362        {
     363                strcat( changes, " " );
     364                strcat( changes, iu->nick );
     365                n --;
     366        }
     367       
     368        if( set_getbool( &ic->irc->b->set, "simulate_netsplit" ) )
     369                g_snprintf( from, sizeof( from ), "%s", ic->irc->root->host );
     370        else
     371                g_snprintf( from, sizeof( from ), "%s!%s@%s", ic->irc->root->nick,
     372                            ic->irc->root->user, ic->irc->root->host );
     373       
     374        irc_write( ic->irc, ":%s MODE %s %s", from, ic->name, changes );
     375}
Note: See TracChangeset for help on using the changeset viewer.