gloox  0.9.9.12
siprofileft.h
1 /*
2  Copyright (c) 2007-2008 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef SIPROFILEFT_H__
15 #define SIPROFILEFT_H__
16 
17 #include "siprofilehandler.h"
18 #include "sihandler.h"
19 #include "simanager.h"
20 #include "socks5bytestreamhandler.h"
21 
22 #include <string>
23 
24 namespace gloox
25 {
26 
27  class ClientBase;
28  class JID;
29  class SIProfileFTHandler;
30  class SOCKS5Bytestream;
31  class SOCKS5BytestreamManager;
32 
125  class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler, public SOCKS5BytestreamHandler
126  {
127  public:
132  {
133  FTTypeS5B = 1/*,*/
134 // FTTypeIBB = 2, /**< In-Band Bytestreams. */
135 // FTTypeOOB = 4 /**< Out-of-Band Data. */
136  };
137 
151  SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0,
152  SOCKS5BytestreamManager* s5Manager = 0 );
153 
157  virtual ~SIProfileFT();
158 
171  const std::string requestFT( const JID& to, const std::string& name, long size,
172  const std::string& hash = "", const std::string& desc = "",
173  const std::string& date = "", const std::string& mimetype = "" );
174 
183  void acceptFT( const JID& to, const std::string& id, StreamType type = FTTypeS5B );
184 
193  void declineFT( const JID& to, const std::string& id, SIManager::SIError reason,
194  const std::string& text = "" );
195 
201  void setRangedTransfers( bool ranged ) { m_ranged = ranged; }
202 
209  void dispose( SOCKS5Bytestream *s5b );
210 
217  void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; }
218 
222  void removeSIProfileFTHandler() { m_handler = 0; }
223 
229  void setStreamHosts( StreamHostList hosts );
230 
237  void addStreamHost( const JID& jid, const std::string& host, int port );
238 
244  void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server )
245  { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); }
246 
250  void removeSOCKS5BytestreamServer()
251  { if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); }
252 
253  // re-implemented from SIProfileHandler
254  virtual void handleSIRequest( const JID& from, const std::string& id, const std::string& profile,
255  Tag* si, Tag* ptag, Tag* fneg );
256 
257  // re-implemented from SIHandler
258  virtual void handleSIRequestResult( const JID& from, const std::string& sid,
259  Tag* si, Tag* ptag, Tag* fneg );
260 
261  // re-implemented from SIHandler
262  virtual void handleSIRequestError( Stanza* stanza, const std::string& sid );
263 
264  // re-implemented from SOCKS5BytestreamHandler
265  virtual void handleIncomingSOCKS5BytestreamRequest( const std::string& sid, const JID& from );
266 
267  // re-implemented from SOCKS5BytestreamHandler
268  virtual void handleIncomingSOCKS5Bytestream( SOCKS5Bytestream* s5b );
269 
270  // re-implemented from SOCKS5BytestreamHandler
271  virtual void handleOutgoingSOCKS5Bytestream( SOCKS5Bytestream *s5b );
272 
273  // re-implemented from SOCKS5BytestreamHandler
274  virtual void handleSOCKS5BytestreamError( Stanza* stanza, const std::string& sid );
275 
276  private:
277  ClientBase* m_parent;
278  SIManager* m_manager;
279  SIProfileFTHandler* m_handler;
280  SOCKS5BytestreamManager* m_socks5Manager;
281  StreamHostList m_hosts;
282  bool m_delManager;
283  bool m_delS5Manager;
284  bool m_ranged;
285 
286  };
287 
288 }
289 
290 #endif // SIPROFILEFT_H__