Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

inbandbytestream.h

00001 /*
00002   Copyright (c) 2006-2008 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 INBANDBYTESTREAM_H__
00015 #define INBANDBYTESTREAM_H__
00016 
00017 #include "bytestream.h"
00018 #include "iqhandler.h"
00019 #include "gloox.h"
00020 
00021 namespace gloox
00022 {
00023 
00024   class ClientBase;
00025   class BytestreamDataHandler;
00026 
00037   class GLOOX_API InBandBytestream : public Bytestream, public IqHandler
00038   {
00039 
00040     friend class SIProfileFT;
00041 
00042     public:
00046       virtual ~InBandBytestream();
00047 
00052       int blockSize() const { return m_blockSize; }
00053 
00059       void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
00060 
00061       // reimplemented from Bytestream
00062       virtual ConnectionError recv( int timeout = -1 ) { (void)timeout; return ConnNoError; }
00063 
00064       // reimplemented from Bytestream
00065       bool send( const std::string& data );
00066 
00067       // reimplemented from Bytestream
00068       virtual bool connect();
00069 
00070       // reimplemented from Bytestream
00071       virtual void close();
00072 
00073       // reimplemented from IqHandler
00074       virtual bool handleIq( const IQ& iq );
00075 
00076       // reimplemented from IqHandler
00077       virtual void handleIqID( const IQ& iq, int context );
00078 
00079     private:
00080 #ifdef INBANDBYTESTREAM_TEST
00081     public:
00082 #endif
00083       enum IBBType
00084       {
00085         IBBOpen,
00086         IBBData,
00087         IBBClose,
00088         IBBInvalid
00089       };
00090 
00097       class IBB : public StanzaExtension
00098       {
00099         public:
00105           IBB( const std::string& sid, int blocksize );
00106 
00114           IBB( const std::string& sid, int seq, const std::string& data );
00115 
00120           IBB( const std::string& sid );
00121 
00126           IBB( const Tag* tag = 0 );
00127 
00131           virtual ~IBB();
00132 
00137           IBBType type() const { return m_type; }
00138 
00143           int blocksize() const { return m_blockSize; }
00144 
00149           int seq() const { return m_seq; }
00150 
00155           const std::string sid() const { return m_sid; }
00156 
00161           const std::string& data() const { return m_data; }
00162 
00163           // reimplemented from StanzaExtension
00164           virtual const std::string& filterString() const;
00165 
00166           // reimplemented from StanzaExtension
00167           virtual StanzaExtension* newInstance( const Tag* tag ) const
00168           {
00169             return new IBB( tag );
00170           }
00171 
00172           // reimplemented from StanzaExtension
00173           virtual Tag* tag() const;
00174 
00175         private:
00176           std::string m_sid;
00177           int m_seq;
00178           int m_blockSize;
00179           std::string m_data;
00180           IBBType m_type;
00181       };
00182 
00183       InBandBytestream( ClientBase* clientbase, LogSink& logInstance, const JID& initiator,
00184                         const JID& target, const std::string& sid );
00185       void closed(); // by remote entity
00186       void returnResult( const JID& to, const std::string& id );
00187 
00188       ClientBase* m_clientbase;
00189       int m_blockSize;
00190       int m_sequence;
00191       int m_lastChunkReceived;
00192 
00193   };
00194 
00195 }
00196 
00197 #endif // INBANDBYTESTREAM_H__

Generated on Mon Jun 23 10:50:18 2008 for gloox by  doxygen 1.4.1