connectionhttpproxy.h

00001 /*
00002   Copyright (c) 2004-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 CONNECTIONHTTPPROXY_H__
00015 #define CONNECTIONHTTPPROXY_H__
00016 
00017 #include "gloox.h"
00018 #include "connectionbase.h"
00019 #include "logsink.h"
00020 
00021 #include <string>
00022 
00023 namespace gloox
00024 {
00025 
00053   class GLOOX_API ConnectionHTTPProxy : public ConnectionBase, public ConnectionDataHandler
00054   {
00055     public:
00069       ConnectionHTTPProxy( ConnectionBase* connection, const LogSink& logInstance,
00070                            const std::string& server, int port = -1 );
00071 
00083       ConnectionHTTPProxy( ConnectionDataHandler* cdh, ConnectionBase* connection,
00084                            const LogSink& logInstance,
00085                            const std::string& server, int port = -1 );
00086 
00090       virtual ~ConnectionHTTPProxy();
00091 
00092       // reimplemented from ConnectionBase
00093       virtual ConnectionError connect();
00094 
00095       // reimplemented from ConnectionBase
00096       virtual ConnectionError recv( int timeout = -1 );
00097 
00098       // reimplemented from ConnectionBase
00099       virtual bool send( const std::string& data );
00100 
00101       // reimplemented from ConnectionBase
00102       virtual ConnectionError receive();
00103 
00104       // reimplemented from ConnectionBase
00105       virtual void disconnect();
00106 
00107       // reimplemented from ConnectionBase
00108       virtual void cleanup();
00109 
00110       // reimplemented from ConnectionBase
00111       virtual void getStatistics( long int &totalIn, long int &totalOut );
00112 
00113       // reimplemented from ConnectionDataHandler
00114       virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
00115 
00116       // reimplemented from ConnectionDataHandler
00117       virtual void handleConnect( const ConnectionBase* connection );
00118 
00119       // reimplemented from ConnectionDataHandler
00120       virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
00121 
00122       // reimplemented from ConnectionDataHandler
00123       virtual ConnectionBase* newInstance() const;
00124 
00131       void setServer( const std::string& host, int port = -1 )
00132         { m_server = host; m_port = port; }
00133 
00139       void setProxyAuth( const std::string& user, const std::string& password )
00140         { m_proxyUser = user; m_proxyPwd = password; }
00141 
00146       void setConnectionImpl( ConnectionBase* connection );
00147 
00153       void setHTTP11( bool http11 ) { m_http11 = http11; }
00154 
00155    private:
00156       ConnectionHTTPProxy &operator=( const ConnectionHTTPProxy& );
00157 
00158       ConnectionBase* m_connection;
00159       const LogSink& m_logInstance;
00160 
00161       std::string m_proxyUser;
00162       std::string m_proxyPwd;
00163       std::string m_proxyHandshakeBuffer;
00164 
00165       bool m_http11;
00166 
00167   };
00168 
00169 }
00170 
00171 #endif // CONNECTIONHTTPPROXY_H__
Generated on Tue Jun 8 23:37:53 2010 for gloox by  doxygen 1.6.3