connectionhttpproxy.h

00001 /*
00002   Copyright (c) 2004-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 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 
00047   class GLOOX_API ConnectionHTTPProxy : public ConnectionBase, public ConnectionDataHandler
00048   {
00049     public:
00063       ConnectionHTTPProxy( ConnectionBase *connection, const LogSink& logInstance,
00064                            const std::string& server, int port = -1 );
00065 
00077       ConnectionHTTPProxy( ConnectionDataHandler *cdh, ConnectionBase *connection,
00078                            const LogSink& logInstance,
00079                            const std::string& server, int port = -1 );
00080 
00084       virtual ~ConnectionHTTPProxy();
00085 
00086       // reimplemented from ConnectionBase
00087       virtual ConnectionError connect();
00088 
00089       // reimplemented from ConnectionBase
00090       virtual ConnectionError recv( int timeout = -1 );
00091 
00092       // reimplemented from ConnectionBase
00093       virtual bool send( const std::string& data );
00094 
00095       // reimplemented from ConnectionBase
00096       virtual ConnectionError receive();
00097 
00098       // reimplemented from ConnectionBase
00099       virtual void disconnect();
00100 
00101       // reimplemented from ConnectionBase
00102       virtual void cleanup();
00103 
00104       // reimplemented from ConnectionBase
00105       virtual void getStatistics( int &totalIn, int &totalOut );
00106 
00107       // reimplemented from ConnectionDataHandler
00108       virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
00109 
00110       // reimplemented from ConnectionDataHandler
00111       virtual void handleConnect( const ConnectionBase* connection );
00112 
00113       // reimplemented from ConnectionDataHandler
00114       virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
00115 
00116       // reimplemented from ConnectionDataHandler
00117       virtual ConnectionBase* newInstance() const;
00118 
00125       void setServer( const std::string& host, int port = -1 )
00126         { m_server = host; m_port = port; }
00127 
00133       void setProxyAuth( const std::string& user, const std::string& password )
00134         { m_proxyUser = user; m_proxyPassword = password; }
00135 
00140       void setConnectionImpl( ConnectionBase* connection );
00141 
00147       void setHTTP11( bool http11 ) { m_http11 = http11; }
00148 
00149    private:
00150       ConnectionHTTPProxy &operator=( const ConnectionHTTPProxy& );
00151 
00152       ConnectionBase *m_connection;
00153       const LogSink& m_logInstance;
00154 
00155       std::string m_proxyUser;
00156       std::string m_proxyPassword;
00157       std::string m_proxyHandshakeBuffer;
00158 
00159       bool m_http11;
00160 
00161   };
00162 
00163 }
00164 
00165 #endif // CONNECTIONHTTPPROXY_H__

Generated on Fri Oct 10 15:26:11 2008 for gloox by  doxygen 1.5.6