inbandbytestream.h
/*
Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef INBANDBYTESTREAM_H__
#define INBANDBYTESTREAM_H__
#include "bytestream.h"
#include "iqhandler.h"
#include "messagehandler.h"
#include "gloox.h"
namespace gloox
{
class BytestreamDataHandler;
class ClientBase;
class Message;
class GLOOX_API InBandBytestream : public Bytestream, public IqHandler, public MessageHandler
{
friend class SIProfileFT;
public:
virtual ~InBandBytestream();
int blockSize() const { return m_blockSize; }
void setBlockSize( int blockSize ) { m_blockSize = blockSize; }
// reimplemented from Bytestream
virtual ConnectionError recv( int timeout = -1 ) { (void)timeout; return ConnNoError; }
// reimplemented from Bytestream
bool send( const std::string& data );
// reimplemented from Bytestream
virtual bool connect();
// reimplemented from Bytestream
virtual void close();
// reimplemented from IqHandler
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler
virtual void handleIqID( const IQ& iq, int context );
// reimplemented from MessageHandler
virtual void handleMessage( const Message& msg, MessageSession* session = 0 );
private:
#ifdef INBANDBYTESTREAM_TEST
public:
#endif
enum IBBType
{
IBBOpen,
IBBData,
IBBClose,
IBBInvalid
};
class IBB : public StanzaExtension
{
public:
IBB( const std::string& sid, int blocksize );
IBB( const std::string& sid, int seq, const std::string& data );
IBB( const std::string& sid );
IBB( const Tag* tag = 0 );
virtual ~IBB();
IBBType type() const { return m_type; }
int blocksize() const { return m_blockSize; }
int seq() const { return m_seq; }
const std::string sid() const { return m_sid; }
const std::string& data() const { return m_data; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new IBB( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new IBB( *this );
}
private:
std::string m_sid;
int m_seq;
int m_blockSize;
std::string m_data;
IBBType m_type;
};
InBandBytestream( ClientBase* clientbase, LogSink& logInstance, const JID& initiator,
const JID& target, const std::string& sid );
InBandBytestream& operator=( const InBandBytestream& );
void closed(); // by remote entity
void returnResult( const JID& to, const std::string& id );
void returnError( const JID& to, const std::string& id, StanzaErrorType type, StanzaError error );
ClientBase* m_clientbase;
int m_blockSize;
int m_sequence;
int m_lastChunkReceived;
};
}
#endif // INBANDBYTESTREAM_H__
gloox::BytestreamDataHandler
A virtual interface that allows implementors to receive data sent over a SOCKS5 Bytestream as defined...
Definition bytestreamdatahandler.h:40
gloox::Bytestream::Bytestream
Bytestream(StreamType type, LogSink &logInstance, const JID &initiator, const JID &target, const std::string &sid)
Definition bytestream.h:56
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::InBandBytestream::setBlockSize
void setBlockSize(int blockSize)
Definition inbandbytestream.h:66
gloox::InBandBytestream::recv
virtual ConnectionError recv(int timeout=-1)
Definition inbandbytestream.h:69
gloox::InBandBytestream::blockSize
int blockSize() const
Definition inbandbytestream.h:58
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::MessageHandler
A virtual interface which can be reimplemented to receive incoming message stanzas.
Definition messagehandler.h:37
gloox::MessageSession
An abstraction of a message session between any two entities.
Definition messagesession.h:146
gloox::Message
An abstraction of a message stanza.
Definition message.h:34
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::ConnectionError
ConnectionError
Definition gloox.h:684
gloox::ConnNoError
@ ConnNoError
Definition gloox.h:685