gloox  1.0.1
socks5bytestream.h
1 /*
2  Copyright (c) 2006-2012 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 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__