fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

xep-0047 (in-band file transfer) plugin patch #46

Closed macdiesel closed 12 years ago

macdiesel commented 14 years ago

I've created a plugin for xep-0047 (in-band file transfer/byte streams).
http://xmpp.org/extensions/xep-0047.html

The plugin can be found here: http://github.com/macdiesel/SleekXMPP/blob/master/sleekxmpp/plugins/xep_0047.py

No other changes are necessary for this plugin to work, everything for xep_0047 is self contained in this package.

From the inline doc: In-band file transfer for xmpp.

Currently only IQ transfer is supported

Plugin will not accept a file transfer if the sender or recipient JID is the
same as the currently logged in JID.

Plugin configuration options:
acceptTransfers        - Boolean     - Sets the plugin to either accept or deny transfers
saveDirectory          - String      - The default directory that incoming file transfers will be saved in
saveNamePrefix         - String      - Prefix that will be prepended to the saved file name of an incoming transfer
overwriteFile          - Boolean     - If an incoming file transfer should overwrite a file if that file already exists
stanzaType             - String      - Either IQ or message,  Currently only iq is supported
maxSessions            - integer     - The max number of send/receive sessions that may run concurrently
transferTimeout        - integer     - How long should a stream session wait between messages
maxBlockSize           - integer     - Largest block size that a stream session should accept (limited by xmpp server)
prefBlockSize          - integer     - The preferred block size for file transfer
acceptTransferCallback - function ptr- This should be a function pointer that will return a boolean value letting the caller know if a 
                                       file transfer should or should not be accepted.  If this option is provided the maxSessions option is ignored.
fileNameCallback       - function ptr- This should be a function pointer that will return a string with the full path and name a file should be saved as.  
                                       If the provided function pointer returns None or is not provided the default saveDirectory + saveNamePrefix_sid will be used.

There are also 2 events that users of this plugin can register to receive notifications:
FILE_FINISHED_SENDING     - This event is fired after a file send has completed
FILE_FINISHED_RECEIVING   - This event is fired after an incoming file transfer has completed.
fritzy commented 14 years ago

This looks nice, but I'm going to hold off till 1.1 for a merge in on this. It also needs some native stanzas.

macdiesel commented 13 years ago

Some native stanza's have been added. Also the code has been updated so it works with 1.0 beta 2. commit tag can be found here: https://github.com/macdiesel/SleekXMPP/commit/739e1925e6b27aaa4a58f014c5d92a2be33c90b7