Changes in root_commands.c [3af70b0:5100caa]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r3af70b0 r5100caa 127 127 } 128 128 129 static void cmd_account( irc_t *irc, char **cmd ); 130 129 131 static void cmd_identify( irc_t *irc, char **cmd ) 130 132 { 131 133 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); 134 char *account_on[] = { "account", "on", NULL }; 132 135 133 136 switch (status) { … … 139 142 break; 140 143 case STORAGE_OK: 141 irc_usermsg( irc, "Password accepted " );144 irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); 142 145 irc_umode_set( irc, "+R", 1 ); 146 if( set_getint( &irc->set, "auto_connect" ) ) 147 cmd_account( irc, account_on ); 143 148 break; 149 case STORAGE_OTHER_ERROR: 144 150 default: 145 irc_usermsg( irc, " Something very weird happened" );151 irc_usermsg( irc, "Unknown error while loading configuration" ); 146 152 break; 147 153 } … … 226 232 227 233 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 229 234 if( cmd[5] ) 230 a->server = g_strdup(cmd[5] );235 set_setstr( &a->set, "server", cmd[5] ); 231 236 232 237 irc_usermsg( irc, "Account successfully added" ); … … 306 311 307 312 for( a = irc->accounts; a; a = a->next ) 308 if( !a->gc )313 if( !a->gc && a->auto_connect ) 309 314 account_on( irc, a ); 310 315 } … … 352 357 } 353 358 } 359 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 360 { 361 char *acc_handle, *set_name = NULL, *tmp; 362 363 if( !cmd[2] ) 364 { 365 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); 366 return; 367 } 368 369 acc_handle = g_strdup( cmd[2] ); 370 if( ( tmp = strchr( acc_handle, '/' ) ) ) 371 { 372 *tmp = 0; 373 set_name = tmp + 1; 374 } 375 a = account_get( irc, acc_handle ); 376 377 if( a == NULL ) 378 { 379 irc_usermsg( irc, "Invalid account" ); 380 return; 381 } 382 383 if( cmd[3] ) 384 { 385 set_t *s = set_find( &a->set, set_name ); 386 387 if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) 388 { 389 irc_usermsg( irc, "This setting can only be changed when the account is off-line" ); 390 return; 391 } 392 393 set_setstr( &a->set, set_name, cmd[3] ); 394 395 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) 396 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" ); 397 } 398 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 399 { 400 char *s = set_getstr( &a->set, set_name ); 401 if( s ) 402 irc_usermsg( irc, "%s = `%s'", set_name, s ); 403 else 404 irc_usermsg( irc, "%s is empty", set_name ); 405 } 406 else 407 { 408 set_t *s = a->set; 409 while( s ) 410 { 411 if( s->value || s->def ) 412 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 413 else 414 irc_usermsg( irc, "%s is empty", s->key ); 415 s = s->next; 416 } 417 } 418 419 g_free( acc_handle ); 420 } 354 421 else 355 422 { … … 394 461 else 395 462 { 396 nick_set( irc, cmd[2], a->gc-> prpl, cmd[3] );463 nick_set( irc, cmd[2], a->gc->acc->prpl, cmd[3] ); 397 464 } 398 465 } … … 401 468 add them to your *real* (server-side) contact list. */ 402 469 if( add_for_real ) 403 a->gc-> prpl->add_buddy( a->gc, cmd[2] );470 a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); 404 471 405 472 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 435 502 } 436 503 437 if( !gc-> prpl->get_info )504 if( !gc->acc->prpl->get_info ) 438 505 { 439 506 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 441 508 else 442 509 { 443 gc-> prpl->get_info( gc, cmd[2] );510 gc->acc->prpl->get_info( gc, cmd[2] ); 444 511 } 445 512 } … … 476 543 else if( u->send_handler == buddy_send_handler ) 477 544 { 478 nick_set( irc, u->handle, u->gc-> prpl, cmd[2] );545 nick_set( irc, u->handle, u->gc->acc->prpl, cmd[2] ); 479 546 } 480 547 … … 495 562 s = g_strdup( u->handle ); 496 563 497 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );564 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 498 565 user_del( irc, cmd[1] ); 499 566 nick_del( irc, cmd[1] ); … … 552 619 } 553 620 554 if( !gc-> prpl->add_deny || !gc->prpl->rem_permit )621 if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) 555 622 { 556 623 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 611 678 } 612 679 613 if( !gc-> prpl->rem_deny || !gc->prpl->add_permit )680 if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) 614 681 { 615 682 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 666 733 if( cmd[1] && cmd[2] ) 667 734 { 668 set_setstr( irc, cmd[1], cmd[2] );735 set_setstr( &irc->set, cmd[1], cmd[2] ); 669 736 670 737 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 673 740 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 674 741 { 675 char *s = set_getstr( irc, cmd[1] );742 char *s = set_getstr( &irc->set, cmd[1] ); 676 743 if( s ) 677 744 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 745 else 746 irc_usermsg( irc, "%s is empty", cmd[1] ); 678 747 } 679 748 else … … 684 753 if( s->value || s->def ) 685 754 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 755 else 756 irc_usermsg( irc, "%s is empty", s->key ); 686 757 s = s->next; 687 758 } … … 727 798 if( online == 1 ) 728 799 { 729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );800 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 730 801 irc_usermsg( irc, format, u->nick, s, "Online" ); 731 802 } … … 738 809 if( away == 1 ) 739 810 { 740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );811 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 741 812 irc_usermsg( irc, format, u->nick, s, u->away ); 742 813 } … … 748 819 if( offline == 1 ) 749 820 { 750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );821 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 751 822 irc_usermsg( irc, format, u->nick, s, "Offline" ); 752 823 } … … 773 844 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 774 845 } 775 else if ( !a-> gc->prpl->set_info )846 else if ( !a->prpl->set_info ) 776 847 { 777 848 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 781 852 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 782 853 783 a-> gc->prpl->set_info( a->gc, cmd[2] );854 a->prpl->set_info( a->gc, cmd[2] ); 784 855 } 785 856 } … … 800 871 for( num = 0; q; q = q->next, num ++ ) 801 872 if( q->gc ) /* Not necessary yet, but it might come later */ 802 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc-> prpl->name, q->gc->username, q->question );873 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); 803 874 else 804 875 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); … … 828 899 user_t *u; 829 900 901 /* FIXME: Hmmm, this is actually pretty dangerous code... REMOVEME? :-) */ 830 902 for( u = irc->users; u; u = u->next ) 831 903 if( u->gc == gc ) 832 904 { 833 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );905 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 834 906 user_del( irc, u->nick ); 835 907 } … … 846 918 for( n = gc->irc->nicks; n; n = n->next ) 847 919 { 848 if( n->proto == gc-> prpl && !user_findhandle( gc, n->handle ) )849 { 850 gc-> prpl->add_buddy( gc, n->handle );920 if( n->proto == gc->acc->prpl && !user_findhandle( gc, n->handle ) ) 921 { 922 gc->acc->prpl->add_buddy( gc, n->handle ); 851 923 add_buddy( gc, NULL, n->handle, NULL ); 852 924 }
Note: See TracChangeset
for help on using the changeset viewer.