#include <siprofileft.h>
Inherits SIProfileHandler, SIHandler, BytestreamHandler, and IqHandler.
Inheritance diagram for SIProfileFT:

Public Types | |
| enum | StreamType { FTTypeS5B = 1, FTTypeIBB = 2, FTTypeOOB = 4, FTTypeAll = 0xFF } |
Public Member Functions | |
| SIProfileFT (ClientBase *parent, SIProfileFTHandler *sipfth, SIManager *manager=0, SOCKS5BytestreamManager *s5Manager=0) | |
| virtual | ~SIProfileFT () |
| const std::string | requestFT (const JID &to, const std::string &name, long size, const std::string &hash=EmptyString, const std::string &desc=EmptyString, const std::string &date=EmptyString, const std::string &mimetype=EmptyString, int streamTypes=FTTypeAll, const JID &from=JID(), const std::string &sid=EmptyString) |
| void | acceptFT (const JID &to, const std::string &sid, StreamType type=FTTypeS5B, const JID &from=JID()) |
| void | declineFT (const JID &to, const std::string &sid, SIManager::SIError reason, const std::string &text=EmptyString) |
| void | cancel (Bytestream *bs) |
| void | dispose (Bytestream *bs) |
| void | registerSIProfileFTHandler (SIProfileFTHandler *sipfth) |
| void | removeSIProfileFTHandler () |
| void | setStreamHosts (StreamHostList hosts) |
| void | addStreamHost (const JID &jid, const std::string &host, int port) |
| void | registerSOCKS5BytestreamServer (SOCKS5BytestreamServer *server) |
| void | removeSOCKS5BytestreamServer () |
| virtual void | handleSIRequest (const JID &from, const JID &to, const std::string &id, const SIManager::SI &si) |
| virtual void | handleSIRequestResult (const JID &from, const JID &to, const std::string &sid, const SIManager::SI &si) |
| virtual void | handleSIRequestError (const IQ &iq, const std::string &sid) |
| virtual void | handleIncomingBytestreamRequest (const std::string &sid, const JID &from) |
| virtual void | handleIncomingBytestream (Bytestream *bs) |
| virtual void | handleOutgoingBytestream (Bytestream *bs) |
| virtual void | handleBytestreamError (const IQ &iq, const std::string &sid) |
| virtual bool | handleIq (const IQ &iq) |
| virtual void | handleIqID (const IQ &iq, int context) |
An SIProfileFT object acts as a 'plugin' to the SIManager. SIProfileFT manages most of the file transfer functionality. The naming comes from the fact that File Transfer (FT) is a profile of Stream Initiation (SI).
Usage:
Create a new SIProfileFT object. It needs a ClientBase -derived object (e.g. Client) as well as a SIProfileFTHandler -derived object that will receive file transfer-related events. If you already use SI and the SIManager somewhere else, you should pass a pointer to that SIManager object as third parameter to SIProfileFT's constructor.
class MyFileTransferHandler : public SIProfileFTHandler { // ... }; Client* client = new Client( ... ); // ... MyFileTransferHandler* mh = new MyFileTransferHandler( ... ); SIProfileFT* ft = new SIProfileFT( client, mh );
You are now, basically, ready to send and receive files.
A couple of notes:
ft->addStreamHost( JID( "proxy.server.dom" ), "101.102.103.104", 6677 );
SOCKS5BytestreamServer* server = new SOCKS5BytestreamServer( client->logInstance(), 1234 ); if( server->listen() != ConnNoError ) printf( "port in use\n" ); ft->addStreamHost( client->jid(), my_ip, 1234 ); ft->registerSOCKS5BytestreamServer( server );
delete server delete ft; delete client;
For usage examples see src/examples/ft_send.cpp and src/examples/ft_recv.cpp.
Definition at line 150 of file siprofileft.h.
|
|
Supported stream types.
Definition at line 157 of file siprofileft.h. |
|
||||||||||||||||||||
|
Constructor.
Definition at line 31 of file siprofileft.cpp. |
|
|
Virtual destructor. Definition at line 52 of file siprofileft.cpp. |
|
||||||||||||||||||||
|
Call this function to accept a file transfer request previously announced by means of SIProfileFTHandler::handleFTRequest() .
Definition at line 98 of file siprofileft.cpp. |
|
||||||||||||||||
|
Adds one StreamHost to the list of SOCKS5 StreamHosts.
Definition at line 176 of file siprofileft.cpp. |
|
|
Cancels the given bytestream. Most useful for SOCKS5 bytestreams where no proxies could be found. The given Bytestream will be deleted.
Definition at line 156 of file siprofileft.cpp. |
|
||||||||||||||||||||
|
Call this function to decline a FT request previously announced by means of SIProfileFTHandler::handleFTRequest() .
Definition at line 136 of file siprofileft.cpp. |
|
|
To get rid of a bytestream (i.e., close and delete it), call this function. The remote entity will be notified about the closing of the stream.
Definition at line 145 of file siprofileft.cpp. |
|
||||||||||||
|
Notifies the handler of errors occuring when a bytestream was requested. For example, if the remote entity does not implement SOCKS5 bytestreams.
Implements BytestreamHandler. Definition at line 306 of file siprofileft.cpp. |
|
|
Notifies the implementor of a new incoming bytestream. The bytestream is not yet ready to send data. To initialize the bytestream and to prepare it for data transfer, register a BytestreamDataHandler with it and call its connect() method. To not block your application while the data transfer lasts, you most likely want to put the bytestream into its own thread or process (before calling connect() on it). It is safe to do so without additional synchronization. When you are finished using the bytestream, use SIProfileFT::dispose() to get rid of it.
Implements BytestreamHandler. Definition at line 294 of file siprofileft.cpp. |
|
||||||||||||
|
Notifies the implementor of a new incoming bytestream request. You have to call either BytestreamManager::acceptBytestream() or BytestreamManager::rejectBytestream(), to accept or reject the bytestream request, respectively.
Implements BytestreamHandler. Definition at line 288 of file siprofileft.cpp. |
|
|
Reimplement this function if you want to be notified about incoming IQs.
Implements IqHandler. Definition at line 316 of file siprofileft.h. |
|
||||||||||||
|
Reimplement this function if you want to be notified about incoming IQs with a specific value of the
Implements IqHandler. Definition at line 271 of file siprofileft.cpp. |
|
|
Notifies the implementor of successful establishing of an outgoing bytestream request. The stream has been accepted by the remote entity and is ready to send data. The BytestreamHandler does not become the owner of the Bytestream object. Use SIProfileFT::dispose() to get rid of the bytestream object after it has been closed.
Implements BytestreamHandler. Definition at line 300 of file siprofileft.cpp. |
|
||||||||||||||||||||
|
This function is called to handle incoming SI requests, i.e. a remote entity requested a stream to send a file to you. You should use either SIManager::acceptSI() or SIManager::declineSI() to accept or reject the request, respectively.
Implements SIProfileHandler. Definition at line 182 of file siprofileft.cpp. |
|
||||||||||||
|
This function is called to handle a request error or decline.
Implements SIHandler. Definition at line 282 of file siprofileft.cpp. |
|
||||||||||||||||||||
|
This function is called to handle results of outgoing SI requests, i.e. you requested a stream (using SIManager::requestSI()) to send a file to a remote entity.
Implements SIHandler. Definition at line 228 of file siprofileft.cpp. |
|
|
Registers a handler that will be informed about incoming file transfer requests, i.e. when a remote entity wishes to send a file.
Definition at line 256 of file siprofileft.h. |
|
|
Tells the interal SOCKS5BytestreamManager which SOCKS5BytestreamServer handles peer-2-peer SOCKS5 bytestreams.
Definition at line 283 of file siprofileft.h. |
|
|
Removes the previously registered file transfer request handler. Definition at line 261 of file siprofileft.h. |
|
|
Un-registers any local SOCKS5BytestreamServer. Definition at line 289 of file siprofileft.h. |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Starts negotiating a file transfer with a remote entity.
Definition at line 63 of file siprofileft.cpp. |
|
|
Sets a list of StreamHosts that will be used for subsequent SOCKS5 bytestream requests.
Definition at line 170 of file siprofileft.cpp. |
1.4.1