Changes in root_commands.c [3af70b0:75a4b85]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r3af70b0 r75a4b85 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 g_free( acc_handle ); 380 irc_usermsg( irc, "Invalid account" ); 381 return; 382 } 383 384 if( cmd[3] ) 385 { 386 set_t *s = set_find( &a->set, set_name ); 387 388 if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY ) 389 { 390 g_free( acc_handle ); 391 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" ); 392 return; 393 } 394 else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY ) 395 { 396 g_free( acc_handle ); 397 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" ); 398 return; 399 } 400 401 set_setstr( &a->set, set_name, cmd[3] ); 402 403 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] ) 404 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" ); 405 } 406 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 407 { 408 char *s = set_getstr( &a->set, set_name ); 409 if( s ) 410 irc_usermsg( irc, "%s = `%s'", set_name, s ); 411 else 412 irc_usermsg( irc, "%s is empty", set_name ); 413 } 414 else 415 { 416 set_t *s = a->set; 417 while( s ) 418 { 419 if( s->value || s->def ) 420 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 421 else 422 irc_usermsg( irc, "%s is empty", s->key ); 423 s = s->next; 424 } 425 } 426 427 g_free( acc_handle ); 428 } 354 429 else 355 430 { … … 394 469 else 395 470 { 396 nick_set( irc, cmd[2], a->gc->prpl, cmd[3] );471 nick_set( a, cmd[2], cmd[3] ); 397 472 } 398 473 } … … 401 476 add them to your *real* (server-side) contact list. */ 402 477 if( add_for_real ) 403 a->gc-> prpl->add_buddy( a->gc, cmd[2] );478 a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); 404 479 405 480 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 435 510 } 436 511 437 if( !gc-> prpl->get_info )512 if( !gc->acc->prpl->get_info ) 438 513 { 439 514 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 441 516 else 442 517 { 443 gc-> prpl->get_info( gc, cmd[2] );518 gc->acc->prpl->get_info( gc, cmd[2] ); 444 519 } 445 520 } … … 476 551 else if( u->send_handler == buddy_send_handler ) 477 552 { 478 nick_set( irc, u->handle, u->gc->prpl, cmd[2] );553 nick_set( u->gc->acc, u->handle, cmd[2] ); 479 554 } 480 555 … … 495 570 s = g_strdup( u->handle ); 496 571 497 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );572 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 498 573 user_del( irc, cmd[1] ); 499 nick_del( irc, cmd[1]);574 nick_del( u->gc->acc, u->handle ); 500 575 501 576 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); … … 552 627 } 553 628 554 if( !gc-> prpl->add_deny || !gc->prpl->rem_permit )629 if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) 555 630 { 556 631 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 611 686 } 612 687 613 if( !gc-> prpl->rem_deny || !gc->prpl->add_permit )688 if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) 614 689 { 615 690 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 666 741 if( cmd[1] && cmd[2] ) 667 742 { 668 set_setstr( irc, cmd[1], cmd[2] );743 set_setstr( &irc->set, cmd[1], cmd[2] ); 669 744 670 745 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 673 748 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 674 749 { 675 char *s = set_getstr( irc, cmd[1] );750 char *s = set_getstr( &irc->set, cmd[1] ); 676 751 if( s ) 677 752 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 753 else 754 irc_usermsg( irc, "%s is empty", cmd[1] ); 678 755 } 679 756 else … … 684 761 if( s->value || s->def ) 685 762 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 763 else 764 irc_usermsg( irc, "%s is empty", s->key ); 686 765 s = s->next; 687 766 } … … 727 806 if( online == 1 ) 728 807 { 729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );808 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 730 809 irc_usermsg( irc, format, u->nick, s, "Online" ); 731 810 } … … 738 817 if( away == 1 ) 739 818 { 740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );819 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 741 820 irc_usermsg( irc, format, u->nick, s, u->away ); 742 821 } … … 748 827 if( offline == 1 ) 749 828 { 750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );829 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 751 830 irc_usermsg( irc, format, u->nick, s, "Offline" ); 752 831 } … … 773 852 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 774 853 } 775 else if ( !a-> gc->prpl->set_info )854 else if ( !a->prpl->set_info ) 776 855 { 777 856 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 781 860 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 782 861 783 a-> gc->prpl->set_info( a->gc, cmd[2] );862 a->prpl->set_info( a->gc, cmd[2] ); 784 863 } 785 864 } … … 800 879 for( num = 0; q; q = q->next, num ++ ) 801 880 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 );881 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); 803 882 else 804 883 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); 805 }806 807 static void cmd_import_buddies( irc_t *irc, char **cmd )808 {809 struct gaim_connection *gc;810 account_t *a;811 nick_t *n;812 813 if( !( a = account_get( irc, cmd[1] ) ) )814 {815 irc_usermsg( irc, "Invalid account" );816 return;817 }818 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) )819 {820 irc_usermsg( irc, "That account is not on-line" );821 return;822 }823 824 if( cmd[2] )825 {826 if( g_strcasecmp( cmd[2], "clear" ) == 0 )827 {828 user_t *u;829 830 for( u = irc->users; u; u = u->next )831 if( u->gc == gc )832 {833 u->gc->prpl->remove_buddy( u->gc, u->handle, NULL );834 user_del( irc, u->nick );835 }836 837 irc_usermsg( irc, "Old buddy list cleared." );838 }839 else840 {841 irc_usermsg( irc, "Invalid argument: %s", cmd[2] );842 return;843 }844 }845 846 for( n = gc->irc->nicks; n; n = n->next )847 {848 if( n->proto == gc->prpl && !user_findhandle( gc, n->handle ) )849 {850 gc->prpl->add_buddy( gc, n->handle );851 add_buddy( gc, NULL, n->handle, NULL );852 }853 }854 855 irc_usermsg( irc, "Sent all add requests. Please wait for a while, the server needs some time to handle all the adds." );856 884 } 857 885 … … 874 902 { "blist", 0, cmd_blist, 0 }, 875 903 { "nick", 1, cmd_nick, 0 }, 876 { "import_buddies", 1, cmd_import_buddies, 0 },877 904 { "qlist", 0, cmd_qlist, 0 }, 878 905 { NULL }
Note: See TracChangeset
for help on using the changeset viewer.