Changeset f3579fd
- Timestamp:
- 2008-08-24T20:52:31Z (16 years ago)
- Branches:
- master
- Children:
- f536a99
- Parents:
- 7125cb3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
account.c
r7125cb3 rf3579fd 55 55 56 56 s = set_add( &a->set, "password", NULL, set_eval_account, a ); 57 s->flags |= ACC_SET_NOSAVE ;57 s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; 58 58 59 59 s = set_add( &a->set, "username", NULL, set_eval_account, a ); -
irc.c
r7125cb3 rf3579fd 34 34 GSList *irc_connection_list = NULL; 35 35 36 static char * passchange( set_t *set, char *value )36 static char *set_eval_password( set_t *set, char *value ) 37 37 { 38 38 irc_t *irc = set->data; 39 39 40 irc_setpass( irc, value ); 41 irc_usermsg( irc, "Password successfully changed" ); 42 return NULL; 40 if( irc->status & USTATUS_IDENTIFIED ) 41 { 42 irc_setpass( irc, value ); 43 return NULL; 44 } 45 else 46 { 47 return SET_INVALID; 48 } 43 49 } 44 50 … … 150 156 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 151 157 s = set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 152 s = set_add( &irc->set, "password", NULL, passchange, irc );158 s = set_add( &irc->set, "password", NULL, set_eval_password, irc ); 153 159 s->flags |= SET_NULL_OK; 154 160 s = set_add( &irc->set, "private", "true", set_eval_bool, irc ); -
root_commands.c
r7125cb3 rf3579fd 238 238 } 239 239 240 static void cmd_showset( irc_t *irc, set_t *set ) 241 { 242 char *s; 243 244 if( set && ( s = set_getstr( &set, set->key ) ) ) /* HACK! */ 245 irc_usermsg( irc, "%s = `%s'", set->key, s ); 246 else 247 irc_usermsg( irc, "%s is empty", set->key ); 248 } 249 240 250 static void cmd_account( irc_t *irc, char **cmd ) 241 251 { … … 445 455 { 446 456 set_t *s = set_find( &a->set, set_name ); 457 int st; 447 458 448 459 if( a->ic && s && s->flags & ACC_SET_OFFLINE_ONLY ) … … 460 471 461 472 if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 462 s et_reset( &a->set, set_name );473 st = set_reset( &a->set, set_name ); 463 474 else 464 set_setstr( &a->set, set_name, cmd[3] ); 465 } 466 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 467 { 468 char *s = set_getstr( &a->set, set_name ); 469 if( s ) 470 irc_usermsg( irc, "%s = `%s'", set_name, s ); 475 st = set_setstr( &a->set, set_name, cmd[3] ); 476 477 if( set_getstr( &a->set, set_name ) == NULL ) 478 { 479 if( st ) 480 irc_usermsg( irc, "Setting changed successfully" ); 481 else 482 irc_usermsg( irc, "Failed to change setting" ); 483 } 471 484 else 472 irc_usermsg( irc, "%s is empty", set_name ); 485 { 486 cmd_showset( irc, set_find( &a->set, set_name ) ); 487 } 488 } 489 else if( set_name ) 490 { 491 cmd_showset( irc, set_find( &a->set, set_name ) ); 473 492 } 474 493 else … … 477 496 while( s ) 478 497 { 479 if( s->value || s->def ) 480 irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); 481 else 482 irc_usermsg( irc, "%s is empty", s->key ); 498 cmd_showset( irc, s ); 483 499 s = s->next; 484 500 } … … 823 839 if( cmd[1] && cmd[2] ) 824 840 { 841 int st; 842 825 843 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 826 844 { 827 s et_reset( &irc->set, cmd[2] );845 st = set_reset( &irc->set, cmd[2] ); 828 846 set_name = cmd[2]; 829 847 } 830 848 else 831 849 { 832 set_setstr( &irc->set, cmd[1], cmd[2] ); 833 } 834 } 835 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 836 { 837 char *s = set_getstr( &irc->set, set_name ); 838 if( s ) 839 irc_usermsg( irc, "%s = `%s'", set_name, s ); 840 else 841 irc_usermsg( irc, "%s is empty", set_name ); 850 st = set_setstr( &irc->set, cmd[1], cmd[2] ); 851 } 852 853 /* Normally we just show the variable's new/unchanged 854 value as feedback to the user, but this has always 855 caused confusion when changing the password. Give 856 other feedback instead: */ 857 if( set_getstr( &irc->set, set_name ) == NULL ) 858 { 859 if( st ) 860 irc_usermsg( irc, "Setting changed successfully" ); 861 else 862 irc_usermsg( irc, "Failed to change setting" ); 863 } 864 else 865 { 866 cmd_showset( irc, set_find( &irc->set, set_name ) ); 867 } 868 } 869 else if( set_name ) 870 { 871 cmd_showset( irc, set_find( &irc->set, set_name ) ); 842 872 843 873 if( strchr( set_name, '/' ) ) … … 849 879 while( s ) 850 880 { 851 if( s->value || s->def ) 852 irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); 853 else 854 irc_usermsg( irc, "%s is empty", s->key ); 881 cmd_showset( irc, s ); 855 882 s = s->next; 856 883 } -
set.c
r7125cb3 rf3579fd 182 182 } 183 183 184 voidset_reset( set_t **head, char *key )184 int set_reset( set_t **head, char *key ) 185 185 { 186 186 set_t *s; … … 188 188 s = set_find( head, key ); 189 189 if( s ) 190 set_setstr( head, key, s->def ); 190 return set_setstr( head, key, s->def ); 191 192 return 0; 191 193 } 192 194 -
set.h
r7125cb3 rf3579fd 92 92 int set_setint( set_t **head, char *key, int value ); 93 93 void set_del( set_t **head, char *key ); 94 voidset_reset( set_t **head, char *key );94 int set_reset( set_t **head, char *key ); 95 95 96 96 /* Two very useful generic evaluators. */
Note: See TracChangeset
for help on using the changeset viewer.