gloox  0.9.9.12
inbandbytestream.h
1 /*
2  Copyright (c) 2006-2008 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 
14 #ifndef INBANDBYTESTREAM_H__
15 #define INBANDBYTESTREAM_H__
16 
17 #include "messagefilter.h"
18 #include "iqhandler.h"
19 #include "gloox.h"
20 #include "inbandbytestreammanager.h"
21 
22 namespace gloox
23 {
24 
25  class ClientBase;
26  class InBandBytestreamDataHandler;
27 
39  class GLOOX_API InBandBytestream : public MessageFilter
40  {
41  friend class InBandBytestreamManager;
42 
43  public:
47  virtual ~InBandBytestream();
48 
53  bool isOpen() const { return m_open; }
54 
65  bool sendBlock( const std::string& data );
66 
71  const std::string& sid() const { return m_sid; }
72 
77  int blockSize() const { return (int)m_blockSize; }
78 
85  void registerInBandBytestreamDataHandler( InBandBytestreamDataHandler *ibbdh );
86 
90  void removeInBandBytestreamDataHandler();
91 
92  // reimplemented from MessageFilter
93  virtual void decorate( Tag *tag );
94 
95  // reimplemented from MessageFilter
96  virtual void filter( Stanza *stanza );
97 
98  private:
99  InBandBytestream( MessageSession *session, ClientBase *clientbase );
100  void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
101  void close(); // locally
102  void closed(); // by remote entity
103  void setSid( const std::string& sid ) { m_sid = sid; }
104 
105  ClientBase *m_clientbase;
106  InBandBytestreamManager *m_manager;
107  InBandBytestreamDataHandler *m_inbandBytestreamDataHandler;
108  std::string m_sid;
109  std::string::size_type m_blockSize;
110  int m_sequence;
111  int m_lastChunkReceived;
112  bool m_open;
113 
114  };
115 
116 }
117 
118 #endif // INBANDBYTESTREAM_H__