Changes in root_commands.c [1f92a58:ba7d16f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r1f92a58 rba7d16f 32 32 #include <string.h> 33 33 34 void root_command_string( irc_t *irc, char *command)34 void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) 35 35 { 36 36 char *cmd[IRC_MAX_ARGS]; … … 161 161 irc->status |= USTATUS_IDENTIFIED; 162 162 irc_umode_set( irc, "+R", 1 ); 163 if( set_getbool( &irc-> b->set, "auto_connect" ) )163 if( set_getbool( &irc->set, "auto_connect" ) ) 164 164 cmd_account( irc, account_on ); 165 165 break; … … 201 201 storage_status_t status; 202 202 203 status = storage_remove (irc-> user->nick, cmd[1]);203 status = storage_remove (irc->nick, cmd[1]); 204 204 switch (status) { 205 205 case STORAGE_NO_SUCH_USER: … … 213 213 irc->status &= ~USTATUS_IDENTIFIED; 214 214 irc_umode_set( irc, "-R", 1 ); 215 irc_usermsg( irc, "Account `%s' removed", irc-> user->nick );215 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 216 216 break; 217 217 default: … … 221 221 } 222 222 223 static void cmd_save( irc_t *irc, char **cmd )224 {225 if( ( irc->status & USTATUS_IDENTIFIED ) == 0 )226 irc_usermsg( irc, "Please create an account first" );227 else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK )228 irc_usermsg( irc, "Configuration saved" );229 else230 irc_usermsg( irc, "Configuration could not be saved!" );231 }232 233 223 struct cmd_account_del_data 234 224 { … … 242 232 account_t *a; 243 233 244 for( a = cad->irc-> b->accounts; a && a != cad->a; a = a->next );234 for( a = cad->irc->accounts; a && a != cad->a; a = a->next ); 245 235 246 236 if( a == NULL ) … … 254 244 else 255 245 { 256 account_del( cad->irc ->b, a );246 account_del( cad->irc, a ); 257 247 irc_usermsg( cad->irc, "Account deleted" ); 258 248 } … … 295 285 set_name = set_full; 296 286 297 head = &irc-> b->set;287 head = &irc->set; 298 288 } 299 289 else … … 366 356 account_t *a; 367 357 368 if( ( a = account_get( irc ->b, id ) ) )358 if( ( a = account_get( irc, id ) ) ) 369 359 return &a->set; 370 360 else … … 414 404 } 415 405 416 a = account_add( irc ->b, prpl, cmd[3], cmd[4] );406 a = account_add( irc, prpl, cmd[3], cmd[4] ); 417 407 if( cmd[5] ) 418 408 { … … 428 418 MIN_ARGS( 2 ); 429 419 430 if( !( a = account_get( irc ->b, cmd[2] ) ) )420 if( !( a = account_get( irc, cmd[2] ) ) ) 431 421 { 432 422 irc_usermsg( irc, "Invalid account" ); … … 450 440 "set' command. Are you sure you want to delete this " 451 441 "account?", a->prpl->name, a->user ); 452 //query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );442 query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad ); 453 443 g_free( msg ); 454 444 } … … 461 451 irc_usermsg( irc, "Account list:" ); 462 452 463 for( a = irc-> b->accounts; a; a = a->next )453 for( a = irc->accounts; a; a = a->next ) 464 454 { 465 455 char *con; … … 484 474 if( cmd[2] ) 485 475 { 486 if( ( a = account_get( irc ->b, cmd[2] ) ) )476 if( ( a = account_get( irc, cmd[2] ) ) ) 487 477 { 488 478 if( a->ic ) … … 493 483 else 494 484 { 495 account_on( irc ->b, a );485 account_on( irc, a ); 496 486 } 497 487 } … … 504 494 else 505 495 { 506 if ( irc->b->accounts ) 507 { 496 if ( irc->accounts ) { 508 497 irc_usermsg( irc, "Trying to get all accounts connected..." ); 509 498 510 for( a = irc-> b->accounts; a; a = a->next )499 for( a = irc->accounts; a; a = a->next ) 511 500 if( !a->ic && a->auto_connect ) 512 account_on( irc ->b, a );501 account_on( irc, a ); 513 502 } 514 503 else … … 524 513 irc_usermsg( irc, "Deactivating all active (re)connections..." ); 525 514 526 for( a = irc-> b->accounts; a; a = a->next )515 for( a = irc->accounts; a; a = a->next ) 527 516 { 528 517 if( a->ic ) 529 account_off( irc ->b, a );518 account_off( irc, a ); 530 519 else if( a->reconnect ) 531 520 cancel_auto_reconnect( a ); 532 521 } 533 522 } 534 else if( ( a = account_get( irc ->b, cmd[2] ) ) )523 else if( ( a = account_get( irc, cmd[2] ) ) ) 535 524 { 536 525 if( a->ic ) 537 526 { 538 account_off( irc ->b, a );527 account_off( irc, a ); 539 528 } 540 529 else if( a->reconnect ) … … 567 556 } 568 557 569 #if 0570 558 static void cmd_add( irc_t *irc, char **cmd ) 571 559 { … … 656 644 } 657 645 } 658 #endif659 646 660 647 static void cmd_rename( irc_t *irc, char **cmd ) 661 648 { 662 irc_user_t *iu; 663 664 iu = irc_user_by_name( irc, cmd[1] ); 665 666 if( iu == NULL ) 649 user_t *u; 650 651 if( g_strcasecmp( cmd[1], irc->nick ) == 0 ) 652 { 653 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 654 } 655 else if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) 656 { 657 if( strchr( CTYPES, cmd[2][0] ) && nick_ok( cmd[2] + 1 ) ) 658 { 659 u = user_find( irc, irc->nick ); 660 661 irc_part( irc, u, irc->channel ); 662 g_free( irc->channel ); 663 irc->channel = g_strdup( cmd[2] ); 664 irc_join( irc, u, irc->channel ); 665 666 if( strcmp( cmd[0], "set_rename" ) != 0 ) 667 set_setstr( &irc->set, "control_channel", cmd[2] ); 668 } 669 } 670 else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) 671 { 672 irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); 673 } 674 else if( !nick_ok( cmd[2] ) ) 675 { 676 irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); 677 } 678 else if( !( u = user_find( irc, cmd[1] ) ) ) 667 679 { 668 680 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 669 681 } 670 else if( iu == irc->user ) 671 { 672 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 673 } 674 else if( !nick_ok( cmd[2] ) ) 675 { 676 irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); 677 } 678 else if( irc_user_by_name( irc, cmd[2] ) ) 679 { 680 irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); 681 } 682 else 683 { 684 if( !irc_user_set_nick( iu, cmd[2] ) ) 685 { 686 irc_usermsg( irc, "Error while changing nick" ); 687 return; 688 } 689 690 if( iu == irc->root ) 691 { 682 else 683 { 684 user_rename( irc, cmd[1], cmd[2] ); 685 irc_write( irc, ":%s!%s@%s NICK %s", cmd[1], u->user, u->host, cmd[2] ); 686 if( g_strcasecmp( cmd[1], irc->mynick ) == 0 ) 687 { 688 g_free( irc->mynick ); 689 irc->mynick = g_strdup( cmd[2] ); 690 692 691 /* If we're called internally (user did "set root_nick"), 693 692 let's not go O(INF). :-) */ 694 693 if( strcmp( cmd[0], "set_rename" ) != 0 ) 695 set_setstr( &irc-> b->set, "root_nick", cmd[2] );696 } 697 else if( iu->bu)698 { 699 nick_set( iu->bu->ic->acc, iu->bu->handle, cmd[2] );694 set_setstr( &irc->set, "root_nick", cmd[2] ); 695 } 696 else if( u->send_handler == buddy_send_handler ) 697 { 698 nick_set( u->ic->acc, u->handle, cmd[2] ); 700 699 } 701 700 … … 704 703 } 705 704 706 #if 0707 705 char *set_eval_root_nick( set_t *set, char *new_nick ) 708 706 { … … 915 913 { 916 914 cmd_set_real( irc, cmd, NULL, NULL ); 915 } 916 917 static void cmd_save( irc_t *irc, char **cmd ) 918 { 919 if( ( irc->status & USTATUS_IDENTIFIED ) == 0 ) 920 irc_usermsg( irc, "Please create an account first" ); 921 else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK ) 922 irc_usermsg( irc, "Configuration saved" ); 923 else 924 irc_usermsg( irc, "Configuration could not be saved!" ); 917 925 } 918 926 … … 982 990 } 983 991 992 static void cmd_nick( irc_t *irc, char **cmd ) 993 { 994 account_t *a; 995 996 if( !cmd[1] || !( a = account_get( irc, cmd[1] ) ) ) 997 { 998 irc_usermsg( irc, "Invalid account"); 999 } 1000 else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) 1001 { 1002 irc_usermsg( irc, "That account is not on-line" ); 1003 } 1004 else if ( !cmd[2] ) 1005 { 1006 irc_usermsg( irc, "Your name is `%s'" , a->ic->displayname ? a->ic->displayname : "NULL" ); 1007 } 1008 else if ( !a->prpl->set_my_name ) 1009 { 1010 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); 1011 } 1012 else 1013 { 1014 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 1015 1016 a->prpl->set_my_name( a->ic, cmd[2] ); 1017 } 1018 } 1019 984 1020 static void cmd_qlist( irc_t *irc, char **cmd ) 985 1021 { … … 1000 1036 else 1001 1037 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); 1038 } 1039 1040 static void cmd_join_chat( irc_t *irc, char **cmd ) 1041 { 1042 irc_usermsg( irc, "This command is now obsolete. " 1043 "Please try the `chat' command instead." ); 1002 1044 } 1003 1045 … … 1175 1217 } 1176 1218 } 1177 #endif1178 1219 1179 1220 const command_t commands[] = { 1180 1221 { "help", 0, cmd_help, 0 }, 1181 { "account", 1, cmd_account, 0 },1182 1222 { "identify", 1, cmd_identify, 0 }, 1183 1223 { "register", 1, cmd_register, 0 }, 1184 1224 { "drop", 1, cmd_drop, 0 }, 1185 { "save", 0, cmd_save, 0 }, 1186 #if 0 1225 { "account", 1, cmd_account, 0 }, 1187 1226 { "add", 2, cmd_add, 0 }, 1188 1227 { "info", 1, cmd_info, 0 }, 1189 #endif1190 1228 { "rename", 2, cmd_rename, 0 }, 1191 #if 01192 1229 { "remove", 1, cmd_remove, 0 }, 1193 1230 { "block", 1, cmd_block, 0 }, 1194 1231 { "allow", 1, cmd_allow, 0 }, 1232 { "save", 0, cmd_save, 0 }, 1195 1233 { "set", 0, cmd_set, 0 }, 1196 1234 { "yes", 0, cmd_yesno, 0 }, … … 1202 1240 { "chat", 1, cmd_chat, 0 }, 1203 1241 { "transfer", 0, cmd_transfer, 0 }, 1204 #endif1205 1242 { NULL } 1206 1243 };
Note: See TracChangeset
for help on using the changeset viewer.