socks5bytestream.h

00001 /*
00002   Copyright (c) 2006-2008 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 "messagefilter.h"
00018 #include "iqhandler.h"
00019 #include "gloox.h"
00020 #include "socks5bytestreammanager.h"
00021 #include "connectiondatahandler.h"
00022 
00023 #include <string>
00024 
00025 namespace gloox
00026 {
00027 
00028   class ClientBase;
00029   class SOCKS5BytestreamDataHandler;
00030   class ConnectionBase;
00031   class LogSink;
00032 
00044   class GLOOX_API SOCKS5Bytestream : public ConnectionDataHandler
00045   {
00046     friend class SOCKS5BytestreamManager;
00047 
00048     public:
00052       virtual ~SOCKS5Bytestream();
00053 
00058       bool isOpen() const { return m_open; }
00059 
00071       bool connect();
00072 
00076       void close();
00077 
00087       bool send( const std::string& data );
00088 
00095       ConnectionError recv( int timeout = -1 );
00096 
00101       const std::string& sid() const { return m_sid; }
00102 
00108       const JID& target() const { return m_target; }
00109 
00115       const JID& initiator() const { return m_initiator; }
00116 
00122       void setConnectionImpl( ConnectionBase* connection );
00123 
00129       ConnectionBase* connectionImpl( ) { return m_connection; }
00130 
00135       void setStreamHosts( const StreamHostList& hosts ) { m_hosts = hosts; }
00136 
00143       void registerSOCKS5BytestreamDataHandler( SOCKS5BytestreamDataHandler *s5bdh )
00144         { m_socks5BytestreamDataHandler = s5bdh; }
00145 
00149       void removeSOCKS5BytestreamDataHandler()
00150         { m_socks5BytestreamDataHandler = 0; }
00151 
00152       // re-implemented from ConnectionDataHandler
00153       virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
00154 
00155       // re-implemented from ConnectionDataHandler
00156       virtual void handleConnect( const ConnectionBase* connection );
00157 
00158       // re-implemented from ConnectionDataHandler
00159       virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
00160 
00161     private:
00162       SOCKS5Bytestream( SOCKS5BytestreamManager* manager, ConnectionBase* connection,
00163                         LogSink& logInstance, const JID& initiator, const JID& target,
00164                         const std::string& sid );
00165       void activate();
00166 
00167       SOCKS5BytestreamManager *m_manager;
00168       ConnectionBase* m_connection;
00169       ConnectionBase* m_socks5;
00170       const LogSink& m_logInstance;
00171       SOCKS5BytestreamDataHandler *m_socks5BytestreamDataHandler;
00172       const JID m_initiator;
00173       const JID m_target;
00174       std::string m_sid;
00175       bool m_open;
00176       JID m_proxy;
00177 
00178       StreamHostList m_hosts;
00179 
00180   };
00181 
00182 }
00183 
00184 #endif // SOCKS5BYTESTREAM_H__

Generated on Mon Dec 7 13:28:19 2009 for gloox by  doxygen 1.6.1