Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

siprofileft.h

00001 /*
00002   Copyright (c) 2007-2008 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 
00199       const std::string requestFT( const JID& to, const std::string& name, long size,
00200                                    const std::string& hash = EmptyString,
00201                                    const std::string& desc = EmptyString,
00202                                    const std::string& date = EmptyString,
00203                                    const std::string& mimetype = EmptyString,
00204                                    int streamTypes = FTTypeAll );
00205 
00214       void acceptFT( const JID& to, const std::string& sid,
00215                      StreamType type = FTTypeS5B );
00216 
00225       void declineFT( const JID& to, const std::string& sid, SIManager::SIError reason,
00226                       const std::string& text = EmptyString );
00227 
00233       void setRangedTransfers( bool ranged ) { m_ranged = ranged; }
00234 
00240       void dispose( Bytestream* bs );
00241 
00248       void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; }
00249 
00253       void removeSIProfileFTHandler() { m_handler = 0; }
00254 
00260       void setStreamHosts( StreamHostList hosts );
00261 
00268       void addStreamHost( const JID& jid, const std::string& host, int port );
00269 
00275       void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server )
00276         { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); }
00277 
00281       void removeSOCKS5BytestreamServer()
00282         { if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); }
00283 
00284       // reimplemented from SIProfileHandler
00285       virtual void handleSIRequest( const JID& from, const std::string& id,
00286                                     const std::string& profile,
00287                                     const Tag* si, const Tag* ptag, const Tag* fneg );
00288 
00289       // reimplemented from SIHandler
00290       virtual void handleSIRequestResult( const JID& from, const std::string& sid,
00291                                           const Tag* si, const Tag* ptag,
00292                                           const Tag* fneg );
00293 
00294       // reimplemented from SIHandler
00295       virtual void handleSIRequestError( const IQ& iq, const std::string& sid );
00296 
00297       // reimplemented from BytestreamHandler
00298       virtual void handleIncomingBytestreamRequest( const std::string& sid, const JID& from );
00299 
00300       // reimplemented from BytestreamHandler
00301       virtual void handleIncomingBytestream( Bytestream* bs );
00302 
00303       // reimplemented from BytestreamHandler
00304       virtual void handleOutgoingBytestream( Bytestream* bs );
00305 
00306       // reimplemented from BytestreamHandler
00307       virtual void handleBytestreamError( const IQ& iq, const std::string& sid );
00308 
00309       // reimplemented from IqHandler.
00310       virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
00311 
00312       // reimplemented from IqHandler.
00313       virtual void handleIqID( const IQ& iq, int context );
00314 
00315     private:
00316 
00317       enum TrackEnum
00318       {
00319         OOBSent
00320       };
00321 
00322       ClientBase* m_parent;
00323       SIManager* m_manager;
00324       SIProfileFTHandler* m_handler;
00325       SOCKS5BytestreamManager* m_socks5Manager;
00326       StreamHostList m_hosts;
00327       StringMap m_id2sid;
00328       bool m_delManager;
00329       bool m_delS5Manager;
00330       bool m_ranged;
00331 
00332   };
00333 
00334 }
00335 
00336 #endif // SIPROFILEFT_H__

Generated on Tue Apr 22 15:10:12 2008 for gloox by  doxygen 1.4.1