Changes in root_commands.c [75a4b85:3af70b0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r75a4b85 r3af70b0 127 127 } 128 128 129 static void cmd_account( irc_t *irc, char **cmd );130 131 129 static void cmd_identify( irc_t *irc, char **cmd ) 132 130 { 133 131 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); 134 char *account_on[] = { "account", "on", NULL };135 132 136 133 switch (status) { … … 142 139 break; 143 140 case STORAGE_OK: 144 irc_usermsg( irc, "Password accepted , settings and accounts loaded" );141 irc_usermsg( irc, "Password accepted" ); 145 142 irc_umode_set( irc, "+R", 1 ); 146 if( set_getint( &irc->set, "auto_connect" ) )147 cmd_account( irc, account_on );148 143 break; 149 case STORAGE_OTHER_ERROR:150 144 default: 151 irc_usermsg( irc, " Unknown error while loading configuration" );145 irc_usermsg( irc, "Something very weird happened" ); 152 146 break; 153 147 } … … 232 226 233 227 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 234 229 if( cmd[5] ) 235 set_setstr( &a->set, "server",cmd[5] );230 a->server = g_strdup( cmd[5] ); 236 231 237 232 irc_usermsg( irc, "Account successfully added" ); … … 311 306 312 307 for( a = irc->accounts; a; a = a->next ) 313 if( !a->gc && a->auto_connect)308 if( !a->gc ) 314 309 account_on( irc, a ); 315 310 } … … 357 352 } 358 353 } 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 else412 irc_usermsg( irc, "%s is empty", set_name );413 }414 else415 {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 else422 irc_usermsg( irc, "%s is empty", s->key );423 s = s->next;424 }425 }426 427 g_free( acc_handle );428 }429 354 else 430 355 { … … 469 394 else 470 395 { 471 nick_set( a, cmd[2], cmd[3] );396 nick_set( irc, cmd[2], a->gc->prpl, cmd[3] ); 472 397 } 473 398 } … … 476 401 add them to your *real* (server-side) contact list. */ 477 402 if( add_for_real ) 478 a->gc-> acc->prpl->add_buddy( a->gc, cmd[2] );403 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 479 404 480 405 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 510 435 } 511 436 512 if( !gc-> acc->prpl->get_info )437 if( !gc->prpl->get_info ) 513 438 { 514 439 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 516 441 else 517 442 { 518 gc-> acc->prpl->get_info( gc, cmd[2] );443 gc->prpl->get_info( gc, cmd[2] ); 519 444 } 520 445 } … … 551 476 else if( u->send_handler == buddy_send_handler ) 552 477 { 553 nick_set( u->gc->acc, u->handle, cmd[2] );478 nick_set( irc, u->handle, u->gc->prpl, cmd[2] ); 554 479 } 555 480 … … 570 495 s = g_strdup( u->handle ); 571 496 572 u->gc-> acc->prpl->remove_buddy( u->gc, u->handle, NULL );497 u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); 573 498 user_del( irc, cmd[1] ); 574 nick_del( u->gc->acc, u->handle);499 nick_del( irc, cmd[1] ); 575 500 576 501 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); … … 627 552 } 628 553 629 if( !gc-> acc->prpl->add_deny || !gc->acc->prpl->rem_permit )554 if( !gc->prpl->add_deny || !gc->prpl->rem_permit ) 630 555 { 631 556 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 686 611 } 687 612 688 if( !gc-> acc->prpl->rem_deny || !gc->acc->prpl->add_permit )613 if( !gc->prpl->rem_deny || !gc->prpl->add_permit ) 689 614 { 690 615 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 741 666 if( cmd[1] && cmd[2] ) 742 667 { 743 set_setstr( &irc->set, cmd[1], cmd[2] );668 set_setstr( irc, cmd[1], cmd[2] ); 744 669 745 670 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 748 673 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 749 674 { 750 char *s = set_getstr( &irc->set, cmd[1] );675 char *s = set_getstr( irc, cmd[1] ); 751 676 if( s ) 752 677 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 753 else754 irc_usermsg( irc, "%s is empty", cmd[1] );755 678 } 756 679 else … … 761 684 if( s->value || s->def ) 762 685 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 763 else764 irc_usermsg( irc, "%s is empty", s->key );765 686 s = s->next; 766 687 } … … 806 727 if( online == 1 ) 807 728 { 808 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 809 730 irc_usermsg( irc, format, u->nick, s, "Online" ); 810 731 } … … 817 738 if( away == 1 ) 818 739 { 819 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 820 741 irc_usermsg( irc, format, u->nick, s, u->away ); 821 742 } … … 827 748 if( offline == 1 ) 828 749 { 829 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> acc->prpl->name );750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->user->prpl->name ); 830 751 irc_usermsg( irc, format, u->nick, s, "Offline" ); 831 752 } … … 852 773 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 853 774 } 854 else if ( !a-> prpl->set_info )775 else if ( !a->gc->prpl->set_info ) 855 776 { 856 777 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 860 781 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 861 782 862 a-> prpl->set_info( a->gc, cmd[2] );783 a->gc->prpl->set_info( a->gc, cmd[2] ); 863 784 } 864 785 } … … 879 800 for( num = 0; q; q = q->next, num ++ ) 880 801 if( q->gc ) /* Not necessary yet, but it might come later */ 881 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc-> acc->prpl->name, q->gc->username, q->question );802 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->prpl->name, q->gc->username, q->question ); 882 803 else 883 804 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 else 840 { 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." ); 884 856 } 885 857 … … 902 874 { "blist", 0, cmd_blist, 0 }, 903 875 { "nick", 1, cmd_nick, 0 }, 876 { "import_buddies", 1, cmd_import_buddies, 0 }, 904 877 { "qlist", 0, cmd_qlist, 0 }, 905 878 { NULL }
Note: See TracChangeset
for help on using the changeset viewer.