gloox  0.9.9.12
inbandbytestreammanager.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 INBANDBYTESTREAMMANAGER_H__
15 #define INBANDBYTESTREAMMANAGER_H__
16 
17 #include "iqhandler.h"
18 #include "jid.h"
19 
20 namespace gloox
21 {
22 
23  class InBandBytestreamHandler;
24  class InBandBytestream;
25  class ClientBase;
26 
179  class GLOOX_API InBandBytestreamManager : public IqHandler
180  {
181  public:
188  GLOOX_DEPRECATED_CTOR InBandBytestreamManager( ClientBase *parent );
189 
193  virtual ~InBandBytestreamManager();
194 
208  bool requestInBandBytestream( const JID& to, InBandBytestreamHandler *ibbh,
209  const std::string& sid = "" );
210 
215  void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
216 
221  int blockSize() const { return m_blockSize; }
222 
229  bool dispose( InBandBytestream *ibb );
230 
240  void acceptInBandBytestream( InBandBytestream *ibb );
241 
251  void rejectInBandBytestream( InBandBytestream *ibb );
252 
261  void registerInBandBytestreamHandler( InBandBytestreamHandler *ibbh, bool sync = true );
262 
266  void removeInBandBytestreamHandler();
267 
268  // reimplemented from IqHandler
269  virtual bool handleIq( Stanza *stanza );
270 
271  // reimplemented from IqHandler
272  virtual bool handleIqID( Stanza *stanza, int context );
273 
274  private:
275  void acceptInBandBytestream( InBandBytestream *ibb, const JID& from, const std::string& id );
276  void rejectInBandBytestream( InBandBytestream *ibb, const JID& from, const std::string& id );
277 
278  enum IBBActionType
279  {
280  IBBOpenStream,
281  IBBCloseStream
282  };
283 
284  typedef std::map<std::string, InBandBytestream*> IBBMap;
285  IBBMap m_ibbMap;
286 
287  struct TrackItem
288  {
289  std::string sid;
290  InBandBytestreamHandler *ibbh;
291  };
292  typedef std::map<std::string, TrackItem> TrackMap;
293  TrackMap m_trackMap;
294 
295  struct AsyncIBBItem
296  {
297  InBandBytestream *ibb;
298  JID from;
299  std::string id;
300  };
301  typedef std::map<std::string, AsyncIBBItem> AsyncTrackMap;
302  AsyncTrackMap m_asyncTrackMap;
303 
304  ClientBase *m_parent;
305  InBandBytestreamHandler *m_inbandBytestreamHandler;
306  bool m_syncInbandBytestreams;
307  int m_blockSize;
308 
309  };
310 
311 }
312 
313 #endif // INBANDBYTESTREAMMANAGER_H__