gloox  1.0.28
socks5bytestream.h
1 /*
2  Copyright (c) 2006-2023 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 SOCKS5BYTESTREAM_H__
15 #define SOCKS5BYTESTREAM_H__
16 
17 #include "bytestream.h"
18 #include "gloox.h"
19 #include "socks5bytestreammanager.h"
20 #include "connectiondatahandler.h"
21 
22 #include <string>
23 
24 namespace gloox
25 {
26 
27  class SOCKS5BytestreamDataHandler;
28  class ConnectionBase;
29  class LogSink;
30 
42  class GLOOX_API SOCKS5Bytestream : public ConnectionDataHandler, public Bytestream
43  {
44  friend class SOCKS5BytestreamManager;
45 
46  public:
50  virtual ~SOCKS5Bytestream();
51 
63  virtual bool connect();
64 
68  virtual void close();
69 
79  virtual bool send( const std::string& data );
80 
87  virtual ConnectionError recv( int timeout = -1 );
88 
94  void setConnectionImpl( ConnectionBase* connection );
95 
101  ConnectionBase* connectionImpl( ) { return m_connection; }
102 
107  void setStreamHosts( const StreamHostList& hosts ) { m_hosts = hosts; }
108 
109  // reimplemented from ConnectionDataHandler
110  virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
111 
112  // reimplemented from ConnectionDataHandler
113  virtual void handleConnect( const ConnectionBase* connection );
114 
115  // reimplemented from ConnectionDataHandler
116  virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
117 
118  private:
120  LogSink& logInstance, const JID& initiator, const JID& target,
121  const std::string& sid );
122  void activate();
123 
124  SOCKS5BytestreamManager* m_manager;
125  ConnectionBase* m_connection;
126  ConnectionBase* m_socks5;
127  JID m_proxy;
128  bool m_connected;
129 
130  StreamHostList m_hosts;
131 
132  };
133 
134 }
135 
136 #endif // SOCKS5BYTESTREAM_H__
An abstraction of a single bytestream.
Definition: bytestream.h:37
An abstract base class for a connection.
This is an abstract base class to receive events from a ConnectionBase-derived object.
An abstraction of a JID.
Definition: jid.h:31
An implementation of log sink and source.
Definition: logsink.h:39
An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams.
An implementation of a single SOCKS5 Bytestream (XEP-0065).
ConnectionBase * connectionImpl()
void setStreamHosts(const StreamHostList &hosts)
The namespace for the gloox library.
Definition: adhoc.cpp:28
ConnectionError
Definition: gloox.h:684
std::list< StreamHost > StreamHostList