socks5bytestream.h

00001 /*
00002   Copyright (c) 2006-2009 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 SOCKS5BYTESTREAM_H__
00015 #define SOCKS5BYTESTREAM_H__
00016 
00017 #include "bytestream.h"
00018 #include "gloox.h"
00019 #include "socks5bytestreammanager.h"
00020 #include "connectiondatahandler.h"
00021 
00022 #include <string>
00023 
00024 namespace gloox
00025 {
00026 
00027   class SOCKS5BytestreamDataHandler;
00028   class ConnectionBase;
00029   class LogSink;
00030 
00042   class GLOOX_API SOCKS5Bytestream : public ConnectionDataHandler, public Bytestream
00043   {
00044     friend class SOCKS5BytestreamManager;
00045 
00046     public:
00050       virtual ~SOCKS5Bytestream();
00051 
00063       virtual bool connect();
00064 
00068       virtual void close();
00069 
00079       virtual bool send( const std::string& data );
00080 
00087       virtual ConnectionError recv( int timeout = -1 );
00088 
00094       void setConnectionImpl( ConnectionBase* connection );
00095 
00101       ConnectionBase* connectionImpl( ) { return m_connection; }
00102 
00107       void setStreamHosts( const StreamHostList& hosts ) { m_hosts = hosts; }
00108 
00109       // reimplemented from ConnectionDataHandler
00110       virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
00111 
00112       // reimplemented from ConnectionDataHandler
00113       virtual void handleConnect( const ConnectionBase* connection );
00114 
00115       // reimplemented from ConnectionDataHandler
00116       virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
00117 
00118     private:
00119       SOCKS5Bytestream( SOCKS5BytestreamManager* manager, ConnectionBase* connection,
00120                         LogSink& logInstance, const JID& initiator, const JID& target,
00121                         const std::string& sid );
00122       void activate();
00123 
00124       SOCKS5BytestreamManager* m_manager;
00125       ConnectionBase* m_connection;
00126       ConnectionBase* m_socks5;
00127       JID m_proxy;
00128       bool m_connected;
00129 
00130       StreamHostList m_hosts;
00131 
00132   };
00133 
00134 }
00135 
00136 #endif // SOCKS5BYTESTREAM_H__
Generated on Tue Jun 8 23:37:54 2010 for gloox by  doxygen 1.6.3