Changes in root_commands.c [2272cb3:0baed0d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r2272cb3 r0baed0d 26 26 #define BITLBEE_CORE 27 27 #include "commands.h" 28 #include "crypting.h" 28 29 #include "bitlbee.h" 29 30 #include "help.h" … … 32 33 #include <string.h> 33 34 34 void root_command_string( irc_t *irc, char *command ) 35 { 36 root_command( irc, split_command_parts( command ) ); 35 void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) 36 { 37 char *cmd[IRC_MAX_ARGS]; 38 char *s; 39 int k; 40 char q = 0; 41 42 memset( cmd, 0, sizeof( cmd ) ); 43 cmd[0] = command; 44 k = 1; 45 for( s = command; *s && k < ( IRC_MAX_ARGS - 1 ); s ++ ) 46 if( *s == ' ' && !q ) 47 { 48 *s = 0; 49 while( *++s == ' ' ); 50 if( *s == '"' || *s == '\'' ) 51 { 52 q = *s; 53 s ++; 54 } 55 if( *s ) 56 { 57 cmd[k++] = s; 58 s --; 59 } 60 else 61 { 62 break; 63 } 64 } 65 else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) 66 { 67 char *cpy; 68 69 for( cpy = s; *cpy; cpy ++ ) 70 cpy[0] = cpy[1]; 71 } 72 else if( *s == q ) 73 { 74 q = *s = 0; 75 } 76 cmd[k] = NULL; 77 78 root_command( irc, cmd ); 37 79 } 38 80 … … 51 93 void root_command( irc_t *irc, char *cmd[] ) 52 94 { 53 int i , len;95 int i; 54 96 55 97 if( !cmd[0] ) 56 98 return; 57 99 58 len = strlen( cmd[0] );59 100 for( i = 0; commands[i].command; i++ ) 60 if( g_strncasecmp( commands[i].command, cmd[0], len ) == 0 ) 61 { 62 if( commands[i+1].command && 63 g_strncasecmp( commands[i+1].command, cmd[0], len ) == 0 ) 64 /* Only match on the first letters if the match is unique. */ 65 break; 66 101 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 102 { 67 103 MIN_ARGS( commands[i].required_parameters ); 68 104 … … 126 162 irc->status |= USTATUS_IDENTIFIED; 127 163 irc_umode_set( irc, "+R", 1 ); 128 if( set_getbool( &irc-> b->set, "auto_connect" ) )164 if( set_getbool( &irc->set, "auto_connect" ) ) 129 165 cmd_account( irc, account_on ); 130 166 break; … … 166 202 storage_status_t status; 167 203 168 status = storage_remove (irc-> user->nick, cmd[1]);204 status = storage_remove (irc->nick, cmd[1]); 169 205 switch (status) { 170 206 case STORAGE_NO_SUCH_USER: … … 178 214 irc->status &= ~USTATUS_IDENTIFIED; 179 215 irc_umode_set( irc, "-R", 1 ); 180 irc_usermsg( irc, "Account `%s' removed", irc-> user->nick );216 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 181 217 break; 182 218 default: … … 186 222 } 187 223 188 static void cmd_save( irc_t *irc, char **cmd )189 {190 if( ( irc->status & USTATUS_IDENTIFIED ) == 0 )191 irc_usermsg( irc, "Please create an account first" );192 else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK )193 irc_usermsg( irc, "Configuration saved" );194 else195 irc_usermsg( irc, "Configuration could not be saved!" );196 }197 198 224 struct cmd_account_del_data 199 225 { … … 207 233 account_t *a; 208 234 209 for( a = cad->irc-> b->accounts; a && a != cad->a; a = a->next );235 for( a = cad->irc->accounts; a && a != cad->a; a = a->next ); 210 236 211 237 if( a == NULL ) … … 219 245 else 220 246 { 221 account_del( cad->irc ->b, a );247 account_del( cad->irc, a ); 222 248 irc_usermsg( cad->irc, "Account deleted" ); 223 249 } … … 260 286 set_name = set_full; 261 287 262 head = &irc-> b->set;288 head = &irc->set; 263 289 } 264 290 else … … 331 357 account_t *a; 332 358 333 if( ( a = account_get( irc ->b, id ) ) )359 if( ( a = account_get( irc, id ) ) ) 334 360 return &a->set; 335 361 else … … 379 405 } 380 406 381 a = account_add( irc ->b, prpl, cmd[3], cmd[4] );407 a = account_add( irc, prpl, cmd[3], cmd[4] ); 382 408 if( cmd[5] ) 383 409 { … … 393 419 MIN_ARGS( 2 ); 394 420 395 if( !( a = account_get( irc ->b, cmd[2] ) ) )421 if( !( a = account_get( irc, cmd[2] ) ) ) 396 422 { 397 423 irc_usermsg( irc, "Invalid account" ); … … 415 441 "set' command. Are you sure you want to delete this " 416 442 "account?", a->prpl->name, a->user ); 417 //query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad );443 query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad ); 418 444 g_free( msg ); 419 445 } … … 426 452 irc_usermsg( irc, "Account list:" ); 427 453 428 for( a = irc-> b->accounts; a; a = a->next )454 for( a = irc->accounts; a; a = a->next ) 429 455 { 430 456 char *con; … … 449 475 if( cmd[2] ) 450 476 { 451 if( ( a = account_get( irc ->b, cmd[2] ) ) )477 if( ( a = account_get( irc, cmd[2] ) ) ) 452 478 { 453 479 if( a->ic ) … … 458 484 else 459 485 { 460 account_on( irc ->b, a );486 account_on( irc, a ); 461 487 } 462 488 } … … 469 495 else 470 496 { 471 if ( irc->b->accounts ) 472 { 497 if ( irc->accounts ) { 473 498 irc_usermsg( irc, "Trying to get all accounts connected..." ); 474 499 475 for( a = irc-> b->accounts; a; a = a->next )500 for( a = irc->accounts; a; a = a->next ) 476 501 if( !a->ic && a->auto_connect ) 477 account_on( irc ->b, a );502 account_on( irc, a ); 478 503 } 479 504 else … … 489 514 irc_usermsg( irc, "Deactivating all active (re)connections..." ); 490 515 491 for( a = irc-> b->accounts; a; a = a->next )516 for( a = irc->accounts; a; a = a->next ) 492 517 { 493 518 if( a->ic ) 494 account_off( irc ->b, a );519 account_off( irc, a ); 495 520 else if( a->reconnect ) 496 521 cancel_auto_reconnect( a ); 497 522 } 498 523 } 499 else if( ( a = account_get( irc ->b, cmd[2] ) ) )524 else if( ( a = account_get( irc, cmd[2] ) ) ) 500 525 { 501 526 if( a->ic ) 502 527 { 503 account_off( irc ->b, a );528 account_off( irc, a ); 504 529 } 505 530 else if( a->reconnect ) … … 544 569 } 545 570 546 if( !( a = account_get( irc ->b, cmd[1] ) ) )571 if( !( a = account_get( irc, cmd[1] ) ) ) 547 572 { 548 573 irc_usermsg( irc, "Invalid account" ); … … 562 587 return; 563 588 } 564 else if( irc_user_by_name( irc, cmd[3] ) )589 else if( user_find( irc, cmd[3] ) ) 565 590 { 566 591 irc_usermsg( irc, "The requested nick `%s' already exists", cmd[3] ); … … 576 601 a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL ); 577 602 else 578 /* Only for add -tmp. For regular adds, this callback will 579 be called once the IM server confirms. */ 580 bee_user_new( irc->b, a->ic, cmd[2] ); 603 /* Yeah, officially this is a call-*back*... So if we just 604 called add_buddy, we'll wait for the IM server to respond 605 before we do this. */ 606 imcb_add_buddy( a->ic, cmd[2], NULL ); 581 607 582 608 irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2] ); 583 }584 585 static void cmd_remove( irc_t *irc, char **cmd )586 {587 irc_user_t *iu;588 bee_user_t *bu;589 char *s;590 591 if( !( iu = irc_user_by_name( irc, cmd[1] ) ) || !( bu = iu->bu ) )592 {593 irc_usermsg( irc, "Buddy `%s' not found", cmd[1] );594 return;595 }596 s = g_strdup( bu->handle );597 598 bu->ic->acc->prpl->remove_buddy( bu->ic, bu->handle, NULL );599 nick_del( bu->ic->acc, bu->handle );600 //TODO(wilmer): bee_user_free() and/or let the IM mod do it? irc_user_free( irc, cmd[1] );601 602 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] );603 g_free( s );604 605 return;606 609 } 607 610 … … 613 616 if( !cmd[2] ) 614 617 { 615 irc_user_t *iu = irc_user_by_name( irc, cmd[1] );616 if( ! iu || !iu->bu)618 user_t *u = user_find( irc, cmd[1] ); 619 if( !u || !u->ic ) 617 620 { 618 621 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 619 622 return; 620 623 } 621 ic = iu->bu->ic;622 cmd[2] = iu->bu->handle;623 } 624 else if( !( a = account_get( irc ->b, cmd[1] ) ) )624 ic = u->ic; 625 cmd[2] = u->handle; 626 } 627 else if( !( a = account_get( irc, cmd[1] ) ) ) 625 628 { 626 629 irc_usermsg( irc, "Invalid account" ); … … 645 648 static void cmd_rename( irc_t *irc, char **cmd ) 646 649 { 647 irc_user_t *iu; 648 649 iu = irc_user_by_name( irc, cmd[1] ); 650 651 if( iu == NULL ) 650 user_t *u; 651 652 if( g_strcasecmp( cmd[1], irc->nick ) == 0 ) 653 { 654 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 655 } 656 else if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) 657 { 658 if( strchr( CTYPES, cmd[2][0] ) && nick_ok( cmd[2] + 1 ) ) 659 { 660 u = user_find( irc, irc->nick ); 661 662 irc_part( irc, u, irc->channel ); 663 g_free( irc->channel ); 664 irc->channel = g_strdup( cmd[2] ); 665 irc_join( irc, u, irc->channel ); 666 667 if( strcmp( cmd[0], "set_rename" ) != 0 ) 668 set_setstr( &irc->set, "control_channel", cmd[2] ); 669 } 670 } 671 else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) 672 { 673 irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); 674 } 675 else if( !nick_ok( cmd[2] ) ) 676 { 677 irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); 678 } 679 else if( !( u = user_find( irc, cmd[1] ) ) ) 652 680 { 653 681 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 654 682 } 655 else if( iu == irc->user ) 656 { 657 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 658 } 659 else if( !nick_ok( cmd[2] ) ) 660 { 661 irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); 662 } 663 else if( irc_user_by_name( irc, cmd[2] ) ) 664 { 665 irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); 666 } 667 else 668 { 669 if( !irc_user_set_nick( iu, cmd[2] ) ) 670 { 671 irc_usermsg( irc, "Error while changing nick" ); 672 return; 673 } 674 675 if( iu == irc->root ) 676 { 683 else 684 { 685 user_rename( irc, cmd[1], cmd[2] ); 686 irc_write( irc, ":%s!%s@%s NICK %s", cmd[1], u->user, u->host, cmd[2] ); 687 if( g_strcasecmp( cmd[1], irc->mynick ) == 0 ) 688 { 689 g_free( irc->mynick ); 690 irc->mynick = g_strdup( cmd[2] ); 691 677 692 /* If we're called internally (user did "set root_nick"), 678 693 let's not go O(INF). :-) */ 679 694 if( strcmp( cmd[0], "set_rename" ) != 0 ) 680 set_setstr( &irc-> b->set, "root_nick", cmd[2] );681 } 682 else if( iu->bu)683 { 684 nick_set( iu->bu->ic->acc, iu->bu->handle, cmd[2] );695 set_setstr( &irc->set, "root_nick", cmd[2] ); 696 } 697 else if( u->send_handler == buddy_send_handler ) 698 { 699 nick_set( u->ic->acc, u->handle, cmd[2] ); 685 700 } 686 701 … … 689 704 } 690 705 691 #if 0692 706 char *set_eval_root_nick( set_t *set, char *new_nick ) 693 707 { … … 717 731 return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID; 718 732 } 719 #endif 733 734 static void cmd_remove( irc_t *irc, char **cmd ) 735 { 736 user_t *u; 737 char *s; 738 739 if( !( u = user_find( irc, cmd[1] ) ) || !u->ic ) 740 { 741 irc_usermsg( irc, "Buddy `%s' not found", cmd[1] ); 742 return; 743 } 744 s = g_strdup( u->handle ); 745 746 u->ic->acc->prpl->remove_buddy( u->ic, u->handle, NULL ); 747 nick_del( u->ic->acc, u->handle ); 748 user_del( irc, cmd[1] ); 749 750 irc_usermsg( irc, "Buddy `%s' (nick %s) removed from contact list", s, cmd[1] ); 751 g_free( s ); 752 753 return; 754 } 720 755 721 756 static void cmd_block( irc_t *irc, char **cmd ) … … 724 759 account_t *a; 725 760 726 if( !cmd[2] && ( a = account_get( irc ->b, cmd[1] ) ) && a->ic )761 if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) 727 762 { 728 763 char *format; … … 737 772 for( l = a->ic->deny; l; l = l->next ) 738 773 { 739 bee_user_t *bu = bee_user_by_handle( irc->b, a->ic, l->data ); 740 irc_user_t *iu = bu ? bu->ui_data : NULL; 741 irc_usermsg( irc, format, l->data, iu ? iu->nick : "(none)" ); 774 user_t *u = user_findhandle( a->ic, l->data ); 775 irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); 742 776 } 743 777 irc_usermsg( irc, "End of list." ); … … 747 781 else if( !cmd[2] ) 748 782 { 749 irc_user_t *iu = irc_user_by_name( irc, cmd[1] );750 if( ! iu || !iu->bu)783 user_t *u = user_find( irc, cmd[1] ); 784 if( !u || !u->ic ) 751 785 { 752 786 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 753 787 return; 754 788 } 755 ic = iu->bu->ic;756 cmd[2] = iu->bu->handle;757 } 758 else if( !( a = account_get( irc ->b, cmd[1] ) ) )789 ic = u->ic; 790 cmd[2] = u->handle; 791 } 792 else if( !( a = account_get( irc, cmd[1] ) ) ) 759 793 { 760 794 irc_usermsg( irc, "Invalid account" ); … … 784 818 account_t *a; 785 819 786 if( !cmd[2] && ( a = account_get( irc ->b, cmd[1] ) ) && a->ic )820 if( !cmd[2] && ( a = account_get( irc, cmd[1] ) ) && a->ic ) 787 821 { 788 822 char *format; … … 797 831 for( l = a->ic->permit; l; l = l->next ) 798 832 { 799 bee_user_t *bu = bee_user_by_handle( irc->b, a->ic, l->data ); 800 irc_user_t *iu = bu ? bu->ui_data : NULL; 801 irc_usermsg( irc, format, l->data, iu ? iu->nick : "(none)" ); 833 user_t *u = user_findhandle( a->ic, l->data ); 834 irc_usermsg( irc, format, l->data, u ? u->nick : "(none)" ); 802 835 } 803 836 irc_usermsg( irc, "End of list." ); … … 807 840 else if( !cmd[2] ) 808 841 { 809 irc_user_t *iu = irc_user_by_name( irc, cmd[1] );810 if( ! iu || !iu->bu)842 user_t *u = user_find( irc, cmd[1] ); 843 if( !u || !u->ic ) 811 844 { 812 845 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 813 846 return; 814 847 } 815 ic = iu->bu->ic;816 cmd[2] = iu->bu->handle;817 } 818 else if( !( a = account_get( irc ->b, cmd[1] ) ) )848 ic = u->ic; 849 cmd[2] = u->handle; 850 } 851 else if( !( a = account_get( irc, cmd[1] ) ) ) 819 852 { 820 853 irc_usermsg( irc, "Invalid account" ); … … 883 916 } 884 917 918 static void cmd_save( irc_t *irc, char **cmd ) 919 { 920 if( ( irc->status & USTATUS_IDENTIFIED ) == 0 ) 921 irc_usermsg( irc, "Please create an account first" ); 922 else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK ) 923 irc_usermsg( irc, "Configuration saved" ); 924 else 925 irc_usermsg( irc, "Configuration could not be saved!" ); 926 } 927 885 928 static void cmd_blist( irc_t *irc, char **cmd ) 886 929 { 887 930 int online = 0, away = 0, offline = 0; 888 GSList *l;931 user_t *u; 889 932 char s[256]; 890 933 char *format; … … 907 950 format = "%-16.16s %-40.40s %s"; 908 951 909 irc_usermsg( irc, format, "Nick", "Handle/Account", "Status" ); 910 911 for( l = irc->users; l; l = l->next ) 912 { 913 irc_user_t *iu = l->data; 914 bee_user_t *bu = iu->bu; 915 916 if( !bu || ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE ) 917 continue; 918 952 irc_usermsg( irc, format, "Nick", "User/Host/Network", "Status" ); 953 954 for( u = irc->users; u; u = u->next ) if( u->ic && u->online && !u->away ) 955 { 919 956 if( online == 1 ) 920 957 { 921 958 char st[256] = "Online"; 922 959 923 if( bu->status_msg )924 g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg );925 926 g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user );927 irc_usermsg( irc, format, iu->nick, s, st );960 if( u->status_msg ) 961 g_snprintf( st, sizeof( st ) - 1, "Online (%s)", u->status_msg ); 962 963 g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); 964 irc_usermsg( irc, format, u->nick, s, st ); 928 965 } 929 966 … … 931 968 } 932 969 933 for( l = irc->users; l; l = l->next ) 934 { 935 irc_user_t *iu = l->data; 936 bee_user_t *bu = iu->bu; 937 938 if( !bu || !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) ) 939 continue; 940 970 for( u = irc->users; u; u = u->next ) if( u->ic && u->online && u->away ) 971 { 941 972 if( away == 1 ) 942 973 { 943 g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user );944 irc_usermsg( irc, format, iu->nick, s, irc_user_get_away( iu ));974 g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); 975 irc_usermsg( irc, format, u->nick, s, u->away ); 945 976 } 946 977 n_away ++; 947 978 } 948 979 949 for( l = irc->users; l; l = l->next ) 950 { 951 irc_user_t *iu = l->data; 952 bee_user_t *bu = iu->bu; 953 954 if( !bu || bu->flags & BEE_USER_ONLINE ) 955 continue; 956 980 for( u = irc->users; u; u = u->next ) if( u->ic && !u->online ) 981 { 957 982 if( offline == 1 ) 958 983 { 959 g_snprintf( s, sizeof( s ) - 1, "%s %s(%s)", bu->handle, bu->ic->acc->prpl->name, bu->ic->acc->user );960 irc_usermsg( irc, format, iu->nick, s, "Offline" );984 g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); 985 irc_usermsg( irc, format, u->nick, s, "Offline" ); 961 986 } 962 987 n_offline ++; … … 964 989 965 990 irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); 991 } 992 993 static void cmd_nick( irc_t *irc, char **cmd ) 994 { 995 account_t *a; 996 997 if( !cmd[1] || !( a = account_get( irc, cmd[1] ) ) ) 998 { 999 irc_usermsg( irc, "Invalid account"); 1000 } 1001 else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) 1002 { 1003 irc_usermsg( irc, "That account is not on-line" ); 1004 } 1005 else if ( !cmd[2] ) 1006 { 1007 irc_usermsg( irc, "Your name is `%s'" , a->ic->displayname ? a->ic->displayname : "NULL" ); 1008 } 1009 else if ( !a->prpl->set_my_name ) 1010 { 1011 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); 1012 } 1013 else 1014 { 1015 irc_usermsg( irc, "Setting your name to `%s'", cmd[2] ); 1016 1017 a->prpl->set_my_name( a->ic, cmd[2] ); 1018 } 966 1019 } 967 1020 … … 986 1039 } 987 1040 988 #if 0 1041 static void cmd_join_chat( irc_t *irc, char **cmd ) 1042 { 1043 irc_usermsg( irc, "This command is now obsolete. " 1044 "Please try the `chat' command instead." ); 1045 } 1046 989 1047 static set_t **cmd_chat_set_findhead( irc_t *irc, char *id ) 990 1048 { … … 1098 1156 } 1099 1157 } 1100 #endif 1101 1102 static void cmd_transfer( irc_t *irc, char **cmd ) 1103 { 1104 GSList *files = irc->file_transfers; 1105 enum { LIST, REJECT, CANCEL }; 1106 int subcmd = LIST; 1107 int fid; 1108 1109 if( !files ) 1110 { 1111 irc_usermsg( irc, "No pending transfers" ); 1112 return; 1113 } 1114 1115 if( cmd[1] && ( strcmp( cmd[1], "reject" ) == 0 ) ) 1116 { 1117 subcmd = REJECT; 1118 } 1119 else if( cmd[1] && ( strcmp( cmd[1], "cancel" ) == 0 ) && 1120 cmd[2] && ( sscanf( cmd[2], "%d", &fid ) == 1 ) ) 1121 { 1122 subcmd = CANCEL; 1123 } 1124 1125 for( ; files; files = g_slist_next( files ) ) 1126 { 1127 file_transfer_t *file = files->data; 1128 1129 switch( subcmd ) { 1130 case LIST: 1131 if ( file->status == FT_STATUS_LISTENING ) 1132 irc_usermsg( irc, 1133 "Pending file(id %d): %s (Listening...)", file->local_id, file->file_name); 1134 else 1135 { 1136 int kb_per_s = 0; 1137 time_t diff = time( NULL ) - file->started ? : 1; 1138 if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) ) 1139 kb_per_s = file->bytes_transferred / 1024 / diff; 1140 1141 irc_usermsg( irc, 1142 "Pending file(id %d): %s (%10zd/%zd kb, %d kb/s)", file->local_id, file->file_name, 1143 file->bytes_transferred/1024, file->file_size/1024, kb_per_s); 1144 } 1145 break; 1146 case REJECT: 1147 if( file->status == FT_STATUS_LISTENING ) 1148 { 1149 irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name ); 1150 imcb_file_canceled( file->ic, file, "Denied by user" ); 1151 } 1152 break; 1153 case CANCEL: 1154 if( file->local_id == fid ) 1155 { 1156 irc_usermsg( irc, "Canceling file transfer for %s", file->file_name ); 1157 imcb_file_canceled( file->ic, file, "Canceled by user" ); 1158 } 1159 break; 1160 } 1161 } 1162 } 1163 1164 /* IMPORTANT: Keep this list sorted! The short command logic needs that. */ 1158 1165 1159 const command_t commands[] = { 1160 { "help", 0, cmd_help, 0 }, 1161 { "identify", 1, cmd_identify, 0 }, 1162 { "register", 1, cmd_register, 0 }, 1163 { "drop", 1, cmd_drop, 0 }, 1166 1164 { "account", 1, cmd_account, 0 }, 1167 1165 { "add", 2, cmd_add, 0 }, 1166 { "info", 1, cmd_info, 0 }, 1167 { "rename", 2, cmd_rename, 0 }, 1168 { "remove", 1, cmd_remove, 0 }, 1169 { "block", 1, cmd_block, 0 }, 1168 1170 { "allow", 1, cmd_allow, 0 }, 1169 { "blist", 0, cmd_blist, 0 },1170 { "block", 1, cmd_block, 0 },1171 { "drop", 1, cmd_drop, 0 },1172 { "ft", 0, cmd_transfer, 0 },1173 { "help", 0, cmd_help, 0 },1174 { "identify", 1, cmd_identify, 0 },1175 { "info", 1, cmd_info, 0 },1176 { "no", 0, cmd_yesno, 0 },1177 { "qlist", 0, cmd_qlist, 0 },1178 { "register", 1, cmd_register, 0 },1179 { "remove", 1, cmd_remove, 0 },1180 { "rename", 2, cmd_rename, 0 },1181 1171 { "save", 0, cmd_save, 0 }, 1182 1172 { "set", 0, cmd_set, 0 }, 1183 { "transfer", 0, cmd_transfer, 0 },1184 1173 { "yes", 0, cmd_yesno, 0 }, 1185 #if 0 1174 { "no", 0, cmd_yesno, 0 }, 1175 { "blist", 0, cmd_blist, 0 }, 1176 { "nick", 1, cmd_nick, 0 }, 1177 { "qlist", 0, cmd_qlist, 0 }, 1178 { "join_chat", 2, cmd_join_chat, 0 }, 1186 1179 { "chat", 1, cmd_chat, 0 }, 1187 #endif1188 1180 { NULL } 1189 1181 };
Note: See TracChangeset
for help on using the changeset viewer.