siprofileft.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef SIPROFILEFT_H__
00015 #define SIPROFILEFT_H__
00016
00017 #include "siprofilehandler.h"
00018 #include "sihandler.h"
00019 #include "simanager.h"
00020 #include "socks5bytestreamhandler.h"
00021
00022 #include <string>
00023
00024 namespace gloox
00025 {
00026
00027 class ClientBase;
00028 class JID;
00029 class SIProfileFTHandler;
00030 class SOCKS5Bytestream;
00031 class SOCKS5BytestreamManager;
00032
00125 class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler, public SOCKS5BytestreamHandler
00126 {
00127 public:
00131 enum StreamType
00132 {
00133 FTTypeS5B = 1
00134
00135
00136 };
00137
00151 SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0,
00152 SOCKS5BytestreamManager* s5Manager = 0 );
00153
00157 virtual ~SIProfileFT();
00158
00171 const std::string requestFT( const JID& to, const std::string& name, long size,
00172 const std::string& hash = "", const std::string& desc = "",
00173 const std::string& date = "", const std::string& mimetype = "" );
00174
00183 void acceptFT( const JID& to, const std::string& id, StreamType type = FTTypeS5B );
00184
00193 void declineFT( const JID& to, const std::string& id, SIManager::SIError reason,
00194 const std::string& text = "" );
00195
00201 void setRangedTransfers( bool ranged ) { m_ranged = ranged; }
00202
00209 void dispose( SOCKS5Bytestream *s5b );
00210
00217 void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; }
00218
00222 void removeSIProfileFTHandler() { m_handler = 0; }
00223
00229 void setStreamHosts( StreamHostList hosts );
00230
00237 void addStreamHost( const JID& jid, const std::string& host, int port );
00238
00244 void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server )
00245 { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); }
00246
00250 void removeSOCKS5BytestreamServer()
00251 { if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); }
00252
00253
00254 virtual void handleSIRequest( const JID& from, const std::string& id, const std::string& profile,
00255 Tag* si, Tag* ptag, Tag* fneg );
00256
00257
00258 virtual void handleSIRequestResult( const JID& from, const std::string& sid,
00259 Tag* si, Tag* ptag, Tag* fneg );
00260
00261
00262 virtual void handleSIRequestError( Stanza* stanza, const std::string& sid );
00263
00264
00265 virtual void handleIncomingSOCKS5BytestreamRequest( const std::string& sid, const JID& from );
00266
00267
00268 virtual void handleIncomingSOCKS5Bytestream( SOCKS5Bytestream* s5b );
00269
00270
00271 virtual void handleOutgoingSOCKS5Bytestream( SOCKS5Bytestream *s5b );
00272
00273
00274 virtual void handleSOCKS5BytestreamError( Stanza* stanza, const std::string& sid );
00275
00276 private:
00277 ClientBase* m_parent;
00278 SIManager* m_manager;
00279 SIProfileFTHandler* m_handler;
00280 SOCKS5BytestreamManager* m_socks5Manager;
00281 StreamHostList m_hosts;
00282 bool m_delManager;
00283 bool m_delS5Manager;
00284 bool m_ranged;
00285
00286 };
00287
00288 }
00289
00290 #endif // SIPROFILEFT_H__