Changeset 2c2df7d for root_commands.c


Ignore:
Timestamp:
2007-11-28T21:07:30Z (16 years ago)
Author:
ulim <a.sporto+bee@…>
Branches:
master
Children:
2ff2076, fa30fa5
Parents:
221a273
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r221a273 r2c2df7d  
    972972                irc_usermsg( irc, "Tried to join chat, not sure if this was successful" );
    973973                g_free( channel );
     974        }
     975}
     976
     977static void cmd_transfers( irc_t *irc, char **cmd )
     978{
     979        GSList *files = irc->file_transfers;
     980        enum { LIST, REJECT, CANCEL };
     981        int subcmd = LIST;
     982        int fid;
     983
     984        if( !files )
     985        {
     986                irc_usermsg( irc, "No pending transfers" );
     987                return;
     988        }
     989
     990        if( cmd[1] &&
     991            ( strcmp( cmd[1], "reject" ) == 0 ) )
     992        {
     993                subcmd = REJECT;
     994        }
     995        else if( cmd[1] &&
     996                 ( strcmp( cmd[1], "cancel" ) == 0 ) &&
     997                 cmd[2] &&
     998                 ( fid = atoi( cmd[2] ) ) )
     999        {
     1000                subcmd = CANCEL;
     1001        }
     1002
     1003        for( ; files; files = g_slist_next( files ) )
     1004        {
     1005                file_transfer_t *file = files->data;
     1006               
     1007                switch( subcmd ) {
     1008                case LIST:
     1009                        if ( file->status == FT_STATUS_LISTENING )
     1010                                irc_usermsg( irc,
     1011                                        "Pending file(id %d): %s (Listening...)", file->local_id, file->file_name);
     1012                        else
     1013                        {
     1014                                int kb_per_s = 0;
     1015                                time_t diff = time( NULL ) - file->started;
     1016                                if ( ( file->started > 0 ) && ( file->bytes_transferred > 0 ) )
     1017                                        kb_per_s = file->bytes_transferred / 1024 / diff;
     1018                                       
     1019                                irc_usermsg( irc,
     1020                                        "Pending file(id %d): %s (%10zd/%zd kb, %d kb/s)", file->local_id, file->file_name,
     1021                                        file->bytes_transferred/1024, file->file_size/1024, kb_per_s);
     1022                        }
     1023                        break;
     1024                case REJECT:
     1025                        if( file->status == FT_STATUS_LISTENING )
     1026                        {
     1027                                irc_usermsg( irc, "Rejecting file transfer for %s", file->file_name );
     1028                                imcb_file_canceled( file, "Denied by user" );
     1029                        }
     1030                        break;
     1031                case CANCEL:
     1032                        if( file->local_id == fid )
     1033                        {
     1034                                irc_usermsg( irc, "Canceling file transfer for %s", file->file_name );
     1035                                imcb_file_canceled( file, "Canceled by user" );
     1036                        }
     1037                        break;
     1038                }
    9741039        }
    9751040}
     
    9951060        { "qlist",          0, cmd_qlist,          0 },
    9961061        { "join_chat",      2, cmd_join_chat,      0 },
     1062        { "transfers",      0, cmd_transfers,      0 },
    9971063        { NULL }
    9981064};
Note: See TracChangeset for help on using the changeset viewer.