gloox
1.0
|
00001 /* 00002 Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 00014 #ifndef SIPROFILEFT_H__ 00015 #define SIPROFILEFT_H__ 00016 00017 #include "iqhandler.h" 00018 #include "socks5bytestreammanager.h" 00019 #include "siprofilehandler.h" 00020 #include "sihandler.h" 00021 #include "simanager.h" 00022 #include "bytestreamhandler.h" 00023 00024 #include <string> 00025 #include <map> 00026 00027 namespace gloox 00028 { 00029 00030 class ClientBase; 00031 class InBandBytestream; 00032 class IQ; 00033 class JID; 00034 class SIProfileFTHandler; 00035 class SOCKS5Bytestream; 00036 00150 class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler, 00151 public BytestreamHandler, public IqHandler 00152 { 00153 public: 00157 enum StreamType 00158 { 00159 FTTypeS5B = 1, 00160 FTTypeIBB = 2, 00161 FTTypeOOB = 4, 00162 FTTypeAll = 0xFF 00163 }; 00164 00178 SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0, 00179 SOCKS5BytestreamManager* s5Manager = 0 ); 00180 00184 virtual ~SIProfileFT(); 00185 00202 const std::string requestFT( const JID& to, const std::string& name, long size, 00203 const std::string& hash = EmptyString, 00204 const std::string& desc = EmptyString, 00205 const std::string& date = EmptyString, 00206 const std::string& mimetype = EmptyString, 00207 int streamTypes = FTTypeAll, 00208 const JID& from = JID(), 00209 const std::string& sid = EmptyString ); 00210 00221 void acceptFT( const JID& to, const std::string& sid, 00222 StreamType type = FTTypeS5B, const JID& from = JID() ); 00223 00232 void declineFT( const JID& to, const std::string& sid, SIManager::SIError reason, 00233 const std::string& text = EmptyString ); 00234 00241 void cancel( Bytestream* bs ); 00242 00248 void dispose( Bytestream* bs ); 00249 00256 void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; } 00257 00261 void removeSIProfileFTHandler() { m_handler = 0; } 00262 00268 void setStreamHosts( StreamHostList hosts ); 00269 00276 void addStreamHost( const JID& jid, const std::string& host, int port ); 00277 00283 void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server ) 00284 { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); } 00285 00289 void removeSOCKS5BytestreamServer() 00290 { if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); } 00291 00292 // reimplemented from SIProfileHandler 00293 virtual void handleSIRequest( const JID& from, const JID& to, const std::string& id, 00294 const SIManager::SI& si ); 00295 00296 // reimplemented from SIHandler 00297 virtual void handleSIRequestResult( const JID& from, const JID& to, const std::string& sid, 00298 const SIManager::SI& si ); 00299 00300 // reimplemented from SIHandler 00301 virtual void handleSIRequestError( const IQ& iq, const std::string& sid ); 00302 00303 // reimplemented from BytestreamHandler 00304 virtual void handleIncomingBytestreamRequest( const std::string& sid, const JID& from ); 00305 00306 // reimplemented from BytestreamHandler 00307 virtual void handleIncomingBytestream( Bytestream* bs ); 00308 00309 // reimplemented from BytestreamHandler 00310 virtual void handleOutgoingBytestream( Bytestream* bs ); 00311 00312 // reimplemented from BytestreamHandler 00313 virtual void handleBytestreamError( const IQ& iq, const std::string& sid ); 00314 00315 // reimplemented from IqHandler. 00316 virtual bool handleIq( const IQ& iq ) { (void)iq; return false; } 00317 00318 // reimplemented from IqHandler. 00319 virtual void handleIqID( const IQ& iq, int context ); 00320 00321 private: 00322 00323 enum TrackEnum 00324 { 00325 OOBSent 00326 }; 00327 00328 ClientBase* m_parent; 00329 SIManager* m_manager; 00330 SIProfileFTHandler* m_handler; 00331 SOCKS5BytestreamManager* m_socks5Manager; 00332 StreamHostList m_hosts; 00333 StringMap m_id2sid; 00334 bool m_delManager; 00335 bool m_delS5Manager; 00336 00337 }; 00338 00339 } 00340 00341 #endif // SIPROFILEFT_H__