Changes in root_commands.c [3af70b0:3ef6410]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r3af70b0 r3ef6410 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_getbool( &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 } … … 163 169 164 170 case STORAGE_OK: 171 irc_usermsg( irc, "Account successfully created" ); 165 172 irc->status |= USTATUS_IDENTIFIED; 166 173 irc_umode_set( irc, "+R", 1 ); … … 226 233 227 234 a = account_add( irc, prpl, cmd[3], cmd[4] ); 228 229 235 if( cmd[5] ) 230 a->server = g_strdup(cmd[5] );236 set_setstr( &a->set, "server", cmd[5] ); 231 237 232 238 irc_usermsg( irc, "Account successfully added" ); … … 306 312 307 313 for( a = irc->accounts; a; a = a->next ) 308 if( !a->gc )314 if( !a->gc && a->auto_connect ) 309 315 account_on( irc, a ); 310 316 } … … 352 358 } 353 359 } 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 else 413 irc_usermsg( irc, "%s is empty", set_name ); 414 } 415 else 416 { 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 else 423 irc_usermsg( irc, "%s is empty", s->key ); 424 s = s->next; 425 } 426 } 427 428 g_free( acc_handle ); 429 } 354 430 else 355 431 { … … 394 470 else 395 471 { 396 nick_set( irc, cmd[2], a->gc->prpl, cmd[3] );472 nick_set( a, cmd[2], cmd[3] ); 397 473 } 398 474 } … … 401 477 add them to your *real* (server-side) contact list. */ 402 478 if( add_for_real ) 403 a->gc-> prpl->add_buddy( a->gc, cmd[2] );479 a->gc->acc->prpl->add_buddy( a->gc, cmd[2] ); 404 480 405 481 add_buddy( a->gc, NULL, cmd[2], cmd[2] ); … … 435 511 } 436 512 437 if( !gc-> prpl->get_info )513 if( !gc->acc->prpl->get_info ) 438 514 { 439 515 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 441 517 else 442 518 { 443 gc-> prpl->get_info( gc, cmd[2] );519 gc->acc->prpl->get_info( gc, cmd[2] ); 444 520 } 445 521 } … … 476 552 else if( u->send_handler == buddy_send_handler ) 477 553 { 478 nick_set( irc, u->handle, u->gc->prpl, cmd[2] );554 nick_set( u->gc->acc, u->handle, cmd[2] ); 479 555 } 480 556 … … 495 571 s = g_strdup( u->handle ); 496 572 497 u->gc-> prpl->remove_buddy( u->gc, u->handle, NULL );573 u->gc->acc->prpl->remove_buddy( u->gc, u->handle, NULL ); 498 574 user_del( irc, cmd[1] ); 499 nick_del( irc, cmd[1]);575 nick_del( u->gc->acc, s ); 500 576 501 577 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); … … 552 628 } 553 629 554 if( !gc-> prpl->add_deny || !gc->prpl->rem_permit )630 if( !gc->acc->prpl->add_deny || !gc->acc->prpl->rem_permit ) 555 631 { 556 632 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 611 687 } 612 688 613 if( !gc-> prpl->rem_deny || !gc->prpl->add_permit )689 if( !gc->acc->prpl->rem_deny || !gc->acc->prpl->add_permit ) 614 690 { 615 691 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 666 742 if( cmd[1] && cmd[2] ) 667 743 { 668 set_setstr( irc, cmd[1], cmd[2] );744 set_setstr( &irc->set, cmd[1], cmd[2] ); 669 745 670 746 if( ( strcmp( cmd[2], "=" ) ) == 0 && cmd[3] ) … … 673 749 if( cmd[1] ) /* else 'forgotten' on purpose.. Must show new value after changing */ 674 750 { 675 char *s = set_getstr( irc, cmd[1] );751 char *s = set_getstr( &irc->set, cmd[1] ); 676 752 if( s ) 677 753 irc_usermsg( irc, "%s = `%s'", cmd[1], s ); 754 else 755 irc_usermsg( irc, "%s is empty", cmd[1] ); 678 756 } 679 757 else … … 684 762 if( s->value || s->def ) 685 763 irc_usermsg( irc, "%s = `%s'", s->key, s->value?s->value:s->def ); 764 else 765 irc_usermsg( irc, "%s is empty", s->key ); 686 766 s = s->next; 687 767 } … … 727 807 if( online == 1 ) 728 808 { 729 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );809 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 730 810 irc_usermsg( irc, format, u->nick, s, "Online" ); 731 811 } … … 738 818 if( away == 1 ) 739 819 { 740 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );820 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 741 821 irc_usermsg( irc, format, u->nick, s, u->away ); 742 822 } … … 748 828 if( offline == 1 ) 749 829 { 750 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc-> user->prpl->name );830 g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->gc->acc->prpl->name ); 751 831 irc_usermsg( irc, format, u->nick, s, "Offline" ); 752 832 } … … 773 853 irc_usermsg( irc, "Your name is `%s'" , a->gc->displayname ? a->gc->displayname : "NULL" ); 774 854 } 775 else if ( !a-> gc->prpl->set_info )855 else if ( !a->prpl->set_info ) 776 856 { 777 857 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); … … 781 861 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 782 862 783 a-> gc->prpl->set_info( a->gc, cmd[2] );863 a->prpl->set_info( a->gc, cmd[2] ); 784 864 } 785 865 } … … 800 880 for( num = 0; q; q = q->next, num ++ ) 801 881 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 );882 irc_usermsg( irc, "%d, %s(%s): %s", num, q->gc->acc->prpl->name, q->gc->username, q->question ); 803 883 else 804 884 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 885 } 857 886 … … 874 903 { "blist", 0, cmd_blist, 0 }, 875 904 { "nick", 1, cmd_nick, 0 }, 876 { "import_buddies", 1, cmd_import_buddies, 0 },877 905 { "qlist", 0, cmd_qlist, 0 }, 878 906 { NULL }
Note: See TracChangeset
for help on using the changeset viewer.