inbandbytestream.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef INBANDBYTESTREAM_H__
00015 #define INBANDBYTESTREAM_H__
00016
00017 #include "bytestream.h"
00018 #include "iqhandler.h"
00019 #include "messagehandler.h"
00020 #include "gloox.h"
00021
00022 namespace gloox
00023 {
00024
00025 class BytestreamDataHandler;
00026 class ClientBase;
00027 class Message;
00028
00043 class GLOOX_API InBandBytestream : public Bytestream, public IqHandler, public MessageHandler
00044 {
00045
00046 friend class SIProfileFT;
00047
00048 public:
00052 virtual ~InBandBytestream();
00053
00058 int blockSize() const { return m_blockSize; }
00059
00065 void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
00066
00067
00068 virtual ConnectionError recv( int timeout = -1 ) { (void)timeout; return ConnNoError; }
00069
00070
00071 bool send( const std::string& data );
00072
00073
00074 virtual bool connect();
00075
00076
00077 virtual void close();
00078
00079
00080 virtual bool handleIq( const IQ& iq );
00081
00082
00083 virtual void handleIqID( const IQ& iq, int context );
00084
00085
00086 virtual void handleMessage( const Message& msg, MessageSession* session = 0 );
00087
00088 private:
00089 #ifdef INBANDBYTESTREAM_TEST
00090 public:
00091 #endif
00092 enum IBBType
00093 {
00094 IBBOpen,
00095 IBBData,
00096 IBBClose,
00097 IBBInvalid
00098 };
00099
00106 class IBB : public StanzaExtension
00107 {
00108 public:
00114 IBB( const std::string& sid, int blocksize );
00115
00123 IBB( const std::string& sid, int seq, const std::string& data );
00124
00129 IBB( const std::string& sid );
00130
00135 IBB( const Tag* tag = 0 );
00136
00140 virtual ~IBB();
00141
00146 IBBType type() const { return m_type; }
00147
00152 int blocksize() const { return m_blockSize; }
00153
00158 int seq() const { return m_seq; }
00159
00164 const std::string sid() const { return m_sid; }
00165
00170 const std::string& data() const { return m_data; }
00171
00172
00173 virtual const std::string& filterString() const;
00174
00175
00176 virtual StanzaExtension* newInstance( const Tag* tag ) const
00177 {
00178 return new IBB( tag );
00179 }
00180
00181
00182 virtual Tag* tag() const;
00183
00184
00185 virtual StanzaExtension* clone() const
00186 {
00187 return new IBB( *this );
00188 }
00189
00190 private:
00191 std::string m_sid;
00192 int m_seq;
00193 int m_blockSize;
00194 std::string m_data;
00195 IBBType m_type;
00196 };
00197
00198 InBandBytestream( ClientBase* clientbase, LogSink& logInstance, const JID& initiator,
00199 const JID& target, const std::string& sid );
00200 InBandBytestream& operator=( const InBandBytestream& );
00201 void closed();
00202 void returnResult( const JID& to, const std::string& id );
00203 void returnError( const JID& to, const std::string& id, StanzaErrorType type, StanzaError error );
00204
00205 ClientBase* m_clientbase;
00206 int m_blockSize;
00207 int m_sequence;
00208 int m_lastChunkReceived;
00209
00210 };
00211
00212 }
00213
00214 #endif // INBANDBYTESTREAM_H__