inbandbytestreammanager.h

00001 /*
00002   Copyright (c) 2006-2007 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 INBANDBYTESTREAMMANAGER_H__
00015 #define INBANDBYTESTREAMMANAGER_H__
00016 
00017 #include "iqhandler.h"
00018 #include "jid.h"
00019 
00020 namespace gloox
00021 {
00022 
00023   class InBandBytestreamHandler;
00024   class InBandBytestream;
00025   class ClientBase;
00026 
00177   class GLOOX_API InBandBytestreamManager : public IqHandler
00178   {
00179     public:
00184       InBandBytestreamManager( ClientBase *parent );
00185 
00189       virtual ~InBandBytestreamManager();
00190 
00204       bool requestInBandBytestream( const JID& to, InBandBytestreamHandler *ibbh,
00205                                     const std::string& sid = "" );
00206 
00211       void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
00212 
00217       int blockSize() const { return m_blockSize; }
00218 
00225       bool dispose( InBandBytestream *ibb );
00226 
00236       void acceptInBandBytestream( InBandBytestream *ibb );
00237 
00247       void rejectInBandBytestream( InBandBytestream *ibb );
00248 
00257       void registerInBandBytestreamHandler( InBandBytestreamHandler *ibbh, bool sync = true );
00258 
00262       void removeInBandBytestreamHandler();
00263 
00264       // reimplemented from IqHandler
00265       virtual bool handleIq( Stanza *stanza );
00266 
00267       // reimplemented from IqHandler
00268       virtual bool handleIqID( Stanza *stanza, int context );
00269 
00270     private:
00271       void acceptInBandBytestream( InBandBytestream *ibb, const JID& from, const std::string& id );
00272       void rejectInBandBytestream( InBandBytestream *ibb, const JID& from, const std::string& id );
00273 
00274       enum IBBActionType
00275       {
00276         IBBOpenStream,
00277         IBBCloseStream
00278       };
00279 
00280       typedef std::map<std::string, InBandBytestream*> IBBMap;
00281       IBBMap m_ibbMap;
00282 
00283       struct TrackItem
00284       {
00285         std::string sid;
00286         InBandBytestreamHandler *ibbh;
00287       };
00288       typedef std::map<std::string, TrackItem> TrackMap;
00289       TrackMap m_trackMap;
00290 
00291       struct AsyncIBBItem
00292       {
00293         InBandBytestream *ibb;
00294         JID from;
00295         std::string id;
00296       };
00297       typedef std::map<std::string, AsyncIBBItem> AsyncTrackMap;
00298       AsyncTrackMap m_asyncTrackMap;
00299 
00300       ClientBase *m_parent;
00301       InBandBytestreamHandler *m_inbandBytestreamHandler;
00302       bool m_syncInbandBytestreams;
00303       int m_blockSize;
00304 
00305   };
00306 
00307 }
00308 
00309 #endif // INBANDBYTESTREAMMANAGER_H__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008