Changes in root_commands.c [3ef6410:2811940]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r3ef6410 r2811940 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_getbool( &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 } … … 169 163 170 164 case STORAGE_OK: 171 irc_usermsg( irc, "Account successfully created" );172 165 irc->status |= USTATUS_IDENTIFIED; 173 166 irc_umode_set( irc, "+R", 1 ); … … 233 226 234 227 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 235 229 if( cmd[5] ) 236 set_setstr( &a->set, "server",cmd[5] );230 a->server = g_strdup( cmd[5] ); 237 231 238 232 irc_usermsg( irc, "Account successfully added" ); … … 312 306 313 307 for( a = irc->accounts; a; a = a->next ) 314 if( !a->gc && a->auto_connect)308 if( !a->gc ) 315 309 account_on( irc, a ); 316 310 } … … 358 352 } 359 353 } 360 else if( g_strcasecmp( cmd[1], "set" ) == 0 )361 {362 char *acc_handle, *set_name = NULL, *tmp;363 364 if( !cmd[2] )365 {366 irc_usermsg( irc, "Not enough parameters given (need %d)", 2 );367 return;368 }369 370 acc_handle = g_strdup( cmd[2] );371 if( ( tmp = strchr( acc_handle, '/' ) ) )372 {373 *tmp = 0;374 set_name = tmp + 1;375 }376 a = account_get( irc, acc_handle );377 378 if( a == NULL )379 {380 g_free( acc_handle );381 irc_usermsg( irc, "Invalid account" );382 return;383 }384 385 if( cmd[3] )386 {387 set_t *s = set_find( &a->set, set_name );388 389 if( a->gc && s && s->flags & ACC_SET_OFFLINE_ONLY )390 {391 g_free( acc_handle );392 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "off" );393 return;394 }395 else if( !a->gc && s && s->flags & ACC_SET_ONLINE_ONLY )396 {397 g_free( acc_handle );398 irc_usermsg( irc, "This setting can only be changed when the account is %s-line", "on" );399 return;400 }401 402 set_setstr( &a->set, set_name, cmd[3] );403 404 if( ( strcmp( cmd[3], "=" ) ) == 0 && cmd[4] )405 irc_usermsg( irc, "Warning: Correct syntax: \002account set <variable> <value>\002 (without =)" );406 }407 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */408 {409 char *s = set_getstr( &a->set, set_name );410 if( s )411 irc_usermsg( irc, "%s = `%s'", set_name, s );412 else413 irc_usermsg( irc, "%s is empty", set_name );414 }415 else416 {417 set_t *s = a->set;418 while( s )419 {420 if( s->value || s->def )421 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def );422 else423 irc_usermsg( irc, "%s is empty", s->key );424 s = s->next;425 }426 }427 428 g_free( acc_handle );429 }430 354 else 431 355 { … … 470 394 else 471 395 { 472 nick_set( a, cmd[2], cmd[3] );396 nick_set( irc, cmd[2], a->gc->prpl, cmd[3] ); 473 397 } 474 398 } … … 477 401 add them to your *real* (server-side) contact list. */ 478 402 if( add_for_real ) 479 a->gc-> acc->prpl->add_buddy( a->gc, cmd[2] );403 a->gc->prpl->add_buddy( a->gc, cmd[2] ); 480 404 481 405 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 511 435 } 512 436 513 if( !gc-> acc->prpl->get_info )437 if( !gc->prpl->get_info ) 514 438 { 515 439 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 517 441 else 518 442 { 519 gc-> acc->prpl->get_info( gc, cmd[2] );443 gc->prpl->get_info( gc, cmd[2] ); 520 444 } 521 445 } … … 552 476 else if( u->send_handler == buddy_send_handler ) 553 477 { 554 nick_set( u->gc->acc, u->handle, cmd[2] );478 nick_set( irc, u->handle, u->gc->prpl, cmd[2] ); 555 479 } 556 480 … … 571 495 s = g_strdup( u->handle ); 572 496 573 u->gc-> acc->prpl->remove_buddy( u->gc, u->handle, NULL );497 u->gc->prpl->remove_buddy( u->gc, u->handle, NULL ); 574 498 user_del( irc, cmd[1] ); 575 nick_del( u->gc->acc, s);499 nick_del( irc, cmd[1] ); 576 500 577 501 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); … … 628 552 } 629 553 630 if( !gc-> acc->prpl->add_deny || !gc->acc->prpl->rem_permit )554 if( !gc->prpl->add_deny || !gc->prpl->rem_permit ) 631 555 { 632 556 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 656 580 657 581 irc_usermsg( irc, format, "Handle", "Nickname" ); 658 for( l = a->gc-> deny; l; l = l->next )582 for( l = a->gc->permit; l; l = l->next ) 659 583 { 660 584 user_t *u = user_findhandle( a->gc, l->data ); … … 687 611 } 688 612 689 if( !gc-> acc->prpl->rem_deny || !gc->acc->prpl->add_permit )613 if( !gc->prpl->rem_deny || !gc->prpl->add_permit ) 690 614 { 691 615 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 742 666 if( cmd[1] && cmd[2] ) 743 667 { 744 set_setstr( &irc->set, cmd[1], cmd[2] );668 set_setstr( irc, cmd[1], cmd[2] ); 745 669 746 670 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 749 673 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 750 674 { 751 char *s = set_getstr( &irc->set, cmd[1] );675 char *s = set_getstr( irc, cmd[1] ); 752 676 if( s ) 753 677 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 754 else755 irc_usermsg( irc, "%s is empty", cmd[1] );756 678 } 757 679 else … … 762 684 if( s->value || s->def ) 763 685 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 764 else765 irc_usermsg( irc, "%s is empty", s->key );766 686 s = s->next; 767 687 } … … 807 727 if( online == 1 ) 808 728 { 809 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 ); 810 730 irc_usermsg( irc, format, u->nick, s, "Online" ); 811 731 } … … 818 738 if( away == 1 ) 819 739 { 820 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 ); 821 741 irc_usermsg( irc, format, u->nick, s, u->away ); 822 742 } … … 828 748 if( offline == 1 ) 829 749 { 830 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 ); 831 751 irc_usermsg( irc, format, u->nick, s, "Offline" ); 832 752 } … … 853 773 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 854 774 } 855 else if ( !a-> prpl->set_info )775 else if ( !a->gc->prpl->set_info ) 856 776 { 857 777 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 861 781 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 862 782 863 a-> prpl->set_info( a->gc, cmd[2] );783 a->gc->prpl->set_info( a->gc, cmd[2] ); 864 784 } 865 785 } … … 880 800 for( num = 0; q; q = q->next, num ++ ) 881 801 if( q->gc ) /* Not necessary yet, but it might come later */ 882 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 ); 883 803 else 884 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." ); 885 856 } 886 857 … … 903 874 { "blist", 0, cmd_blist, 0 }, 904 875 { "nick", 1, cmd_nick, 0 }, 876 { "import_buddies", 1, cmd_import_buddies, 0 }, 905 877 { "qlist", 0, cmd_qlist, 0 }, 906 878 { NULL }
Note: See TracChangeset
for help on using the changeset viewer.