gloox  1.1-svn
connectioncompression.h
1 /*
2  * Copyright (c) 2009 by Jakob Schroeter <js@camaya.net>
3  * This file is part of the gloox library. http://camaya.net/gloox
4  *
5  * This software is distributed under a license. The full license
6  * agreement can be found in the file LICENSE in this distribution.
7  * This software may not be copied, modified, sold or distributed
8  * other than expressed in the named license agreement.
9  *
10  * This software is distributed without any warranty.
11  */
12 
13 #ifndef CONNECTIONCOMPRESSION_H__
14 #define CONNECTIONCOMPRESSION_H__
15 
16 #include "gloox.h"
17 #include "logsink.h"
18 #include "connectionbase.h"
19 #include "connectiondatahandler.h"
20 #include "compressiondatahandler.h"
21 
22 #include <string>
23 
24 namespace gloox
25 {
26 
27  class CompressionDefault;
28 
40  {
41  public:
51 
59  ConnectionCompression( ConnectionBase* conn, const LogSink& log );
60 
64  virtual ~ConnectionCompression();
65 
70  void setConnectionImpl( ConnectionBase* connection );
71 
72  // reimplemented from ConnectionBase
73  virtual ConnectionError connect();
74 
75  // reimplemented from ConnectionBase
76  virtual ConnectionError recv( int timeout = -1 );
77 
78  // reimplemented from ConnectionBase
79  virtual bool send( const std::string& data );
80 
81  // reimplemented from ConnectionBase
82  virtual ConnectionError receive();
83 
84  // reimplemented from ConnectionBase
85  virtual void disconnect();
86 
87  // reimplemented from ConnectionBase
88  virtual void cleanup();
89 
90  // reimplemented from ConnectionBase
91  virtual void getStatistics( long int& totalIn, long int& totalOut );
92 
93  // reimplemented from ConnectionDataHandler
94  virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data );
95 
96  // reimplemented from ConnectionDataHandler
97  virtual void handleConnect( const ConnectionBase* connection );
98 
99  // reimplemented from ConnectionDataHandler
100  virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason );
101 
102  // reimplemented from ConnectionDataHandler
103  virtual ConnectionBase* newInstance() const;
104 
105  // reimplemented from CompressionDataHandler
106  virtual void handleCompressedData( const std::string& data );
107 
108  // reimplemented from CompressionDataHandler
109  virtual void handleDecompressedData( const std::string& data );
110 
111 
112  private:
113  ConnectionCompression& operator=( const ConnectionCompression& );
114  ConnectionBase* m_connection;
115  CompressionDefault* m_compression;
116  const LogSink & m_log;
117 
118  };
119 
120 }
121 
122 #endif // CONNECTIONCOMPRESSION_H__