diff options
author | ulim <a.sporto+bee@gmail.com> | 2007-11-28 22:07:30 +0100 |
---|---|---|
committer | ulim <a.sporto+bee@gmail.com> | 2007-11-28 22:07:30 +0100 |
commit | 2c2df7dd91930345a9b22a8bb61327d1dcc7e3d5 (patch) | |
tree | ce4aa38f4022e5a14cc8b8a8534f287f274daaeb /root_commands.c | |
parent | 221a27346f768b9626f2a0281ff774790858a0c2 (diff) |
Initial import of jabber file receive and DCC send support. This introduces
only a few changes to bitlbees code, mainly the addition of the "transfers"
command.
This is known to work with Kopete, Psi, and Pidgin (formerly known as gaim).
At least with Pidgin also over a proxy. DCC has only been tested with irssi.
IPV6 is untested but should work.
Currently, only receiving via SOCKS5BYTESREAMS is implemented. I'm not sure if
the alternative(in-band bytestreams IBB) is worth implementing since I didn't
see a client yet that can do it. Additionally, it is probably very slow and
needs support by the server as well.
Diffstat (limited to 'root_commands.c')
-rw-r--r-- | root_commands.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/root_commands.c b/root_commands.c index 642f5374..2da77519 100644 --- a/root_commands.c +++ b/root_commands.c @@ -974,6 +974,71 @@ static void cmd_join_chat( irc_t *irc, char **cmd ) } } +static void cmd_transfers( irc_t *irc, char **cmd ) +{ + GSList *files = irc->file_transfers; + enum { LIST, REJECT, CANCEL }; + int subcmd = LIST; + int fid; + + if( !files ) + { + irc_usermsg( irc, "No pending transfers" ); + return; + } + + if( cmd[1] && + ( strcmp( cmd[1], "reject" ) == 0 ) ) + { + subcmd = REJECT; + } + else if( cmd[1] && + ( strcmp( cmd[1], "cancel" ) == 0 ) && + cmd[2] && + ( fid = atoi( cmd[2] ) ) ) + { + subcmd = CANCEL; + } + + for( ; files; files = g_slist_next( files ) ) + { + file_transfer_t *file = files->data; + + switch( subcmd ) { + case LIST: + if ( file->status == FT_STATUS_LISTENING ) + irc_usermsg( irc, + "Pending file(id %d): %s (Listening...)", file->local_id, file->file_name); + else + { + int kb_per_s = 0; + time_t diff = time( NULL ) - file->started; + if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) ) + kb_per_s = file->bytes_transferred / 1024 / diff; + + irc_usermsg( irc, + "Pending file(id %d): %s (%10zd/%zd kb, %d kb/s)", file->local_id, file->file_name, + file->bytes_transferred/1024, file->file_size/1024, kb_per_s); + } + break; + case REJECT: + if( file->status == FT_STATUS_LISTENING ) + { + irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name ); + imcb_file_canceled( file, "Denied by user" ); + } + break; + case CANCEL: + if( file->local_id == fid ) + { + irc_usermsg( irc, "Canceling file transfer for %s", file->file_name ); + imcb_file_canceled( file, "Canceled by user" ); + } + break; + } + } +} + const command_t commands[] = { { "help", 0, cmd_help, 0 }, { "identify", 1, cmd_identify, 0 }, @@ -994,5 +1059,6 @@ const command_t commands[] = { { "nick", 1, cmd_nick, 0 }, { "qlist", 0, cmd_qlist, 0 }, { "join_chat", 2, cmd_join_chat, 0 }, + { "transfers", 0, cmd_transfers, 0 }, { NULL } }; |