gloox  1.0.20
siprofileft.h
1 /*
2  Copyright (c) 2007-2017 by Jakob Schröter <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 "iqhandler.h"
18 #include "socks5bytestreammanager.h"
19 #include "siprofilehandler.h"
20 #include "sihandler.h"
21 #include "simanager.h"
22 #include "bytestreamhandler.h"
23 
24 #include <string>
25 #include <map>
26 
27 namespace gloox
28 {
29 
30  class ClientBase;
31  class InBandBytestream;
32  class IQ;
33  class JID;
34  class SIProfileFTHandler;
35  class SOCKS5Bytestream;
36 
150  class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler,
151  public BytestreamHandler, public IqHandler
152  {
153  public:
158  {
159  FTTypeS5B = 1,
160  FTTypeIBB = 2,
161  FTTypeOOB = 4,
162  FTTypeAll = 0xFF
163  };
164 
178  SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0,
179  SOCKS5BytestreamManager* s5Manager = 0 );
180 
184  virtual ~SIProfileFT();
185 
202  const std::string requestFT( const JID& to, const std::string& name, long size,
203  const std::string& hash = EmptyString,
204  const std::string& desc = EmptyString,
205  const std::string& date = EmptyString,
206  const std::string& mimetype = EmptyString,
207  int streamTypes = FTTypeAll,
208  const JID& from = JID(),
209  const std::string& sid = EmptyString );
210 
221  void acceptFT( const JID& to, const std::string& sid,
222  StreamType type = FTTypeS5B, const JID& from = JID() );
223 
232  void declineFT( const JID& to, const std::string& sid, SIManager::SIError reason,
233  const std::string& text = EmptyString );
234 
241  void cancel( Bytestream* bs );
242 
248  void dispose( Bytestream* bs );
249 
256  void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; }
257 
261  void removeSIProfileFTHandler() { m_handler = 0; }
262 
268  void setStreamHosts( StreamHostList hosts );
269 
276  void addStreamHost( const JID& jid, const std::string& host, int port );
277 
284  { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); }
285 
290  { if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); }
291 
292  // reimplemented from SIProfileHandler
293  virtual void handleSIRequest( const JID& from, const JID& to, const std::string& id,
294  const SIManager::SI& si );
295 
296  // reimplemented from SIHandler
297  virtual void handleSIRequestResult( const JID& from, const JID& to, const std::string& sid,
298  const SIManager::SI& si );
299 
300  // reimplemented from SIHandler
301  virtual void handleSIRequestError( const IQ& iq, const std::string& sid );
302 
303  // reimplemented from BytestreamHandler
304  virtual void handleIncomingBytestreamRequest( const std::string& sid, const JID& from );
305 
306  // reimplemented from BytestreamHandler
307  virtual void handleIncomingBytestream( Bytestream* bs );
308 
309  // reimplemented from BytestreamHandler
310  virtual void handleOutgoingBytestream( Bytestream* bs );
311 
312  // reimplemented from BytestreamHandler
313  virtual void handleBytestreamError( const IQ& iq, const std::string& sid );
314 
315  // reimplemented from IqHandler.
316  virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
317 
318  // reimplemented from IqHandler.
319  virtual void handleIqID( const IQ& iq, int context );
320 
321  private:
322 
323  enum TrackEnum
324  {
325  OOBSent
326  };
327 
328  ClientBase* m_parent;
329  SIManager* m_manager;
330  SIProfileFTHandler* m_handler;
331  SOCKS5BytestreamManager* m_socks5Manager;
332  StreamHostList m_hosts;
333  StringMap m_id2sid;
334  bool m_delManager;
335  bool m_delS5Manager;
336 
337  };
338 
339 }
340 
341 #endif // SIPROFILEFT_H__
An implementation of the file transfer SI profile (XEP-0096).
Definition: siprofileft.h:150
A server listening for SOCKS5 bytestreams.
An abstract base class to handle results of outgoing SI requests, i.e. you requested a stream (using ...
Definition: sihandler.h:39
An abstract base class to handle file transfer (FT) requests.
An abstraction of an IQ stanza.
Definition: iq.h:33
An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams.
std::list< StreamHost > StreamHostList
void registerSOCKS5BytestreamServer(SOCKS5BytestreamServer *server)
Definition: siprofileft.h:283
void removeSOCKS5BytestreamServer()
Definition: siprofileft.h:289
void removeSIProfileFTHandler()
Definition: siprofileft.h:261
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class manages streams initiated using XEP-0095.
Definition: simanager.h:34
std::map< std::string, std::string > StringMap
Definition: gloox.h:1261
An abstraction of a JID.
Definition: jid.h:30
An abstraction of a single bytestream.
Definition: bytestream.h:36
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition: iqhandler.h:31
void registerSIProfileFTHandler(SIProfileFTHandler *sipfth)
Definition: siprofileft.h:256
A virtual interface that allows to receive new incoming Bytestream requests from remote entities...
const std::string EmptyString
Definition: gloox.cpp:124
virtual bool handleIq(const IQ &iq)
Definition: siprofileft.h:316
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:76
An abstract base class to handle SI requests for a specific profile, e.g. file transfer.