glooxd  0.3-svn
connectioncompression.h
1 /*
2  * Copyright (c) 2009 by Jakob Schroeter <js@camaya.net>
3  * This file is part of the glooxd library. http://camaya.net/glooxd
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 "glooxd.h"
17 
18 #include <gloox/gloox.h>
19 #include <gloox/compressiondatahandler.h>
20 #include <gloox/connectionbase.h>
21 #include <gloox/connectiondatahandler.h>
22 
23 #include <string>
24 
25 namespace gloox {
26  class CompressionDefault;
27  class LogSink;
28 }
29 
30 namespace glooxd
31 {
32 
43  class GLOOXD_API ConnectionCompression : public gloox::CompressionDataHandler,
44  public gloox::ConnectionBase,
45  gloox::ConnectionDataHandler
46  {
47  public:
56  ConnectionCompression( gloox::ConnectionDataHandler* cdh, gloox::ConnectionBase* conn,
57  const gloox::LogSink& log );
58 
66  ConnectionCompression( gloox::ConnectionBase* conn, const gloox::LogSink& log );
67 
71  virtual ~ConnectionCompression();
72 
77  void setConnectionImpl( gloox::ConnectionBase* connection );
78 
79  // reimplemented from ConnectionBase
80  virtual gloox::ConnectionError connect();
81 
82  // reimplemented from ConnectionBase
83  virtual gloox::ConnectionError recv( int timeout = -1 );
84 
85  // reimplemented from ConnectionBase
86  virtual bool send( const std::string& data );
87 
88  // reimplemented from ConnectionBase
89  virtual gloox::ConnectionError receive();
90 
91  // reimplemented from ConnectionBase
92  virtual void disconnect();
93 
94  // reimplemented from ConnectionBase
95  virtual void cleanup();
96 
97  // reimplemented from ConnectionBase
98  virtual void getStatistics( long int& totalIn, long int& totalOut );
99 
100  // reimplemented from ConnectionDataHandler
101  virtual void handleReceivedData( const gloox::ConnectionBase* connection, const std::string& data );
102 
103  // reimplemented from ConnectionDataHandler
104  virtual void handleConnect( const gloox::ConnectionBase* connection );
105 
106  // reimplemented from ConnectionDataHandler
107  virtual void handleDisconnect( const gloox::ConnectionBase* connection, gloox::ConnectionError reason );
108 
109  // reimplemented from ConnectionDataHandler
110  virtual gloox::ConnectionBase* newInstance() const;
111 
112  // reimplemented from CompressionDataHandler
113  virtual void handleCompressedData( const std::string& data );
114 
115  // reimplemented from CompressionDataHandler
116  virtual void handleDecompressedData( const std::string& data );
117 
118 
119  private:
120  gloox::ConnectionBase* m_connection;
121  gloox::CompressionDefault* m_compression;
122  const gloox::LogSink& m_log;
123 
124  };
125 
126 }
127 
128 #endif // CONNECTIONCOMPRESSION_H__