socks5bytestream.h

00001 /*
00002   Copyright (c) 2006-2007 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 
00128       void setStreamHosts( const StreamHostList& hosts ) { m_hosts = hosts; }
00129 
00136       void registerSOCKS5BytestreamDataHandler( SOCKS5BytestreamDataHandler *s5bdh )
00137         { m_socks5BytestreamDataHandler = s5bdh; }
00138 
00142       void removeSOCKS5BytestreamDataHandler()
00143         { m_socks5BytestreamDataHandler = 0; }
00144 
00145       // re-implemented from ConnectionDataHandler
00146       virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
00147 
00148       // re-implemented from ConnectionDataHandler
00149       virtual void handleConnect( const ConnectionBase* connection );
00150 
00151       // re-implemented from ConnectionDataHandler
00152       virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
00153 
00154     private:
00155       SOCKS5Bytestream( SOCKS5BytestreamManager* manager, ConnectionBase* connection,
00156                         LogSink& logInstance, const JID& initiator, const JID& target,
00157                         const std::string& sid );
00158       void activate();
00159 
00160       SOCKS5BytestreamManager *m_manager;
00161       ConnectionBase* m_connection;
00162       ConnectionBase* m_socks5;
00163       const LogSink& m_logInstance;
00164       SOCKS5BytestreamDataHandler *m_socks5BytestreamDataHandler;
00165       const JID m_initiator;
00166       const JID m_target;
00167       std::string m_sid;
00168       bool m_open;
00169       JID m_proxy;
00170 
00171       StreamHostList m_hosts;
00172 
00173   };
00174 
00175 }
00176 
00177 #endif // SOCKS5BYTESTREAM_H__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008