Changeset 94d5da9c
- Timestamp:
- 2010-07-18T22:12:19Z (14 years ago)
- Branches:
- master
- Children:
- 6d8cc05
- Parents:
- 4f22a68c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r4f22a68c r94d5da9c 180 180 IRC_CHANNEL_USER_HALFOP = 2, 181 181 IRC_CHANNEL_USER_VOICE = 4, 182 IRC_CHANNEL_USER_NONE = 8, 182 183 } irc_channel_user_flags_t; 183 184 … … 203 204 struct account *account; 204 205 struct prpl *protocol; 206 char modes[4]; 205 207 }; 206 208 -
irc_channel.c
r4f22a68c r94d5da9c 536 536 static char *set_eval_by_group( set_t *set, char *value ); 537 537 static char *set_eval_by_protocol( set_t *set, char *value ); 538 static char *set_eval_show_users( set_t *set, char *value ); 538 539 539 540 static gboolean control_channel_init( irc_channel_t *ic ) … … 545 546 set_add( &ic->set, "group", NULL, set_eval_by_group, ic ); 546 547 set_add( &ic->set, "protocol", NULL, set_eval_by_protocol, ic ); 548 set_add( &ic->set, "show_users", "online+,away", set_eval_show_users, ic ); 547 549 548 550 ic->data = icc = g_new0( struct irc_control_channel, 1 ); 549 551 icc->type = IRC_CC_TYPE_DEFAULT; 552 553 /* Have to run the evaluator to initialize icc->modes. */ 554 set_setstr( &ic->set, "show_users", set_getstr( &ic->set, "show_users" ) ); 550 555 551 556 return TRUE; … … 625 630 } 626 631 632 static char *set_eval_show_users( set_t *set, char *value ) 633 { 634 struct irc_channel *ic = set->data; 635 struct irc_control_channel *icc = ic->data; 636 char **parts = g_strsplit( value, ",", 0 ), **part; 637 char modes[4]; 638 639 memset( modes, 0, 4 ); 640 for( part = parts; *part; part ++ ) 641 { 642 char last, modechar = IRC_CHANNEL_USER_NONE; 643 644 if( **part == '\0' ) 645 goto fail; 646 647 last = (*part)[strlen(*part+1)]; 648 if( last == '+' ) 649 modechar = IRC_CHANNEL_USER_VOICE; 650 else if( last == '%' ) 651 modechar = IRC_CHANNEL_USER_HALFOP; 652 else if( last == '@' ) 653 modechar = IRC_CHANNEL_USER_OP; 654 655 if( strncmp( *part, "offline", 7 ) == 0 ) 656 modes[0] = modechar; 657 else if( strncmp( *part, "away", 4 ) == 0 ) 658 modes[1] = modechar; 659 else if( strncmp( *part, "online", 6 ) == 0 ) 660 modes[2] = modechar; 661 else 662 goto fail; 663 } 664 memcpy( icc->modes, modes, 4 ); 665 bee_irc_channel_update( ic->irc, ic, NULL ); 666 667 g_strfreev( parts ); 668 return value; 669 670 fail: 671 g_strfreev( parts ); 672 return SET_INVALID; 673 } 674 627 675 static gboolean control_channel_free( irc_channel_t *ic ) 628 676 { -
irc_im.c
r4f22a68c r94d5da9c 143 143 struct irc_control_channel *icc; 144 144 GSList *l; 145 gboolean show= FALSE;145 gboolean match = FALSE; 146 146 147 147 if( ic == NULL ) … … 170 170 icc = ic->data; 171 171 172 if( !( iu->bu->flags & BEE_USER_ONLINE ) ) 173 show = FALSE; 174 else if( icc->type == IRC_CC_TYPE_DEFAULT ) 175 show = TRUE; 172 if( icc->type == IRC_CC_TYPE_DEFAULT ) 173 match = TRUE; 176 174 else if( icc->type == IRC_CC_TYPE_GROUP ) 177 show= iu->bu->group == icc->group;175 match = iu->bu->group == icc->group; 178 176 else if( icc->type == IRC_CC_TYPE_ACCOUNT ) 179 show= iu->bu->ic->acc == icc->account;177 match = iu->bu->ic->acc == icc->account; 180 178 else if( icc->type == IRC_CC_TYPE_PROTOCOL ) 181 show= iu->bu->ic->acc->prpl == icc->protocol;182 183 if( ! show)179 match = iu->bu->ic->acc->prpl == icc->protocol; 180 181 if( !match ) 184 182 { 185 183 irc_channel_del_user( ic, iu, IRC_CDU_PART, NULL ); … … 187 185 else 188 186 { 189 irc_channel_add_user( ic, iu ); 190 191 if( set_getbool( &irc->b->set, "away_devoice" ) ) 192 irc_channel_user_set_mode( ic, iu, ( iu->bu->flags & BEE_USER_AWAY ) ? 193 0 : IRC_CHANNEL_USER_VOICE ); 187 int mode = 0; 188 189 if( !( iu->bu->flags & BEE_USER_ONLINE ) ) 190 mode = icc->modes[0]; 191 else if( iu->bu->flags & BEE_USER_AWAY ) 192 mode = icc->modes[1]; 194 193 else 195 irc_channel_user_set_mode( ic, iu, 0 ); 194 mode = icc->modes[2]; 195 196 if( !mode ) 197 irc_channel_del_user( ic, iu, IRC_CDU_PART, NULL ); 198 else 199 { 200 irc_channel_add_user( ic, iu ); 201 irc_channel_user_set_mode( ic, iu, mode ); 202 } 196 203 } 197 204 }
Note: See TracChangeset
for help on using the changeset viewer.