Changes in root_commands.c [0baed0d:b8a491d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r0baed0d rb8a491d 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 10Wilmer van der Gaast and others *4 * Copyright 2002-2004 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 654 654 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 655 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 656 else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) 672 657 { … … 716 701 717 702 return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; 718 }719 720 char *set_eval_control_channel( set_t *set, char *new_name )721 {722 irc_t *irc = set->data;723 724 if( strcmp( irc->channel, new_name ) != 0 )725 {726 char *cmd[] = { "set_rename", irc->channel, new_name, NULL };727 728 cmd_rename( irc, cmd );729 }730 731 return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID;732 703 } 733 704 … … 1154 1125 { 1155 1126 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); 1127 } 1128 } 1129 1130 static void cmd_transfer( irc_t *irc, char **cmd ) 1131 { 1132 GSList *files = irc->file_transfers; 1133 enum { LIST, REJECT, CANCEL }; 1134 int subcmd = LIST; 1135 int fid; 1136 1137 if( !files ) 1138 { 1139 irc_usermsg( irc, "No pending transfers" ); 1140 return; 1141 } 1142 1143 if( cmd[1] && ( strcmp( cmd[1], "reject" ) == 0 ) ) 1144 { 1145 subcmd = REJECT; 1146 } 1147 else if( cmd[1] && ( strcmp( cmd[1], "cancel" ) == 0 ) && 1148 cmd[2] && ( sscanf( cmd[2], "%d", &fid ) == 1 ) ) 1149 { 1150 subcmd = CANCEL; 1151 } 1152 1153 for( ; files; files = g_slist_next( files ) ) 1154 { 1155 file_transfer_t *file = files->data; 1156 1157 switch( subcmd ) { 1158 case LIST: 1159 if ( file->status == FT_STATUS_LISTENING ) 1160 irc_usermsg( irc, 1161 "Pending file(id %d): %s (Listening...)", file->local_id, file->file_name); 1162 else 1163 { 1164 int kb_per_s = 0; 1165 time_t diff = time( NULL ) - file->started ? : 1; 1166 if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) ) 1167 kb_per_s = file->bytes_transferred / 1024 / diff; 1168 1169 irc_usermsg( irc, 1170 "Pending file(id %d): %s (%10zd/%zd kb, %d kb/s)", file->local_id, file->file_name, 1171 file->bytes_transferred/1024, file->file_size/1024, kb_per_s); 1172 } 1173 break; 1174 case REJECT: 1175 if( file->status == FT_STATUS_LISTENING ) 1176 { 1177 irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name ); 1178 imcb_file_canceled( file, "Denied by user" ); 1179 } 1180 break; 1181 case CANCEL: 1182 if( file->local_id == fid ) 1183 { 1184 irc_usermsg( irc, "Canceling file transfer for %s", file->file_name ); 1185 imcb_file_canceled( file, "Canceled by user" ); 1186 } 1187 break; 1188 } 1156 1189 } 1157 1190 } … … 1178 1211 { "join_chat", 2, cmd_join_chat, 0 }, 1179 1212 { "chat", 1, cmd_chat, 0 }, 1213 { "transfer", 0, cmd_transfer, 0 }, 1180 1214 { NULL } 1181 1215 };
Note: See TracChangeset
for help on using the changeset viewer.