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 "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 //        FTTypeIBB   = 2,          /**< In-Band Bytestreams. */
00135 //        FTTypeOOB   = 4           /**< Out-of-Band Data. */
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       // re-implemented from SIProfileHandler
00254       virtual void handleSIRequest( const JID& from, const std::string& id, const std::string& profile,
00255                                     Tag* si, Tag* ptag, Tag* fneg );
00256 
00257       // re-implemented from SIHandler
00258       virtual void handleSIRequestResult( const JID& from, const std::string& sid,
00259                                           Tag* si, Tag* ptag, Tag* fneg );
00260 
00261       // re-implemented from SIHandler
00262       virtual void handleSIRequestError( Stanza* stanza, const std::string& sid );
00263 
00264       // re-implemented from SOCKS5BytestreamHandler
00265       virtual void handleIncomingSOCKS5BytestreamRequest( const std::string& sid, const JID& from );
00266 
00267       // re-implemented from SOCKS5BytestreamHandler
00268       virtual void handleIncomingSOCKS5Bytestream( SOCKS5Bytestream* s5b );
00269 
00270       // re-implemented from SOCKS5BytestreamHandler
00271       virtual void handleOutgoingSOCKS5Bytestream( SOCKS5Bytestream *s5b );
00272 
00273       // re-implemented from SOCKS5BytestreamHandler
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__

Generated on Sun Apr 27 11:08:13 2008 for gloox by  doxygen 1.5.5