/usr/include/gloox/inbandbytestream.h is in libgloox-dev 1.0.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | /*
Copyright (c) 2006-2014 by Jakob Schroeter <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;
/**
* @brief An implementation of a single In-Band Bytestream (@xep{0047}).
*
* One instance of this class handles a single byte stream.
*
* See SIProfileFT for a detailed description on how to implement file transfer.
*
* @note This class can @b receive data wrapped in Message stanzas. This will only work if you
* are not using MessageSessions. However, it will always send
* data using IQ stanzas (which will always work).
*
* @author Jakob Schroeter <js@camaya.net>
* @since 0.8
*/
class GLOOX_API InBandBytestream : public Bytestream, public IqHandler, public MessageHandler
{
friend class SIProfileFT;
public:
/**
* Virtual destructor.
*/
virtual ~InBandBytestream();
/**
* Lets you retrieve this bytestream's block-size.
* @return The bytestream's block-size.
*/
int blockSize() const { return m_blockSize; }
/**
* Sets the stream's block-size. Default: 4096
* @param blockSize The new block size.
* @note You should not change the block size once connect() has been called.
*/
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
};
/**
* @brief An abstraction of IBB elements, implemented as as StanzaExtension.
*
* @author Jakob Schroeter <js@camaya.net>
* @since 1.0
*/
class IBB : public StanzaExtension
{
public:
/**
* Constructs a new IBB object that opens an IBB, using the given SID and block size.
* @param sid The SID of the IBB to open.
* @param blocksize The streams block size.
*/
IBB( const std::string& sid, int blocksize );
/**
* Constructs a new IBB object that can be used to send a single block of data,
* using the given SID and sequence number.
* @param sid The SID of the IBB.
* @param seq The block's sequence number.
* @param data The block data, not base64 encoded.
*/
IBB( const std::string& sid, int seq, const std::string& data );
/**
* Constructs a new IBB object that closes an IBB, using the given SID.
* @param sid The SID of the IBB to close.
*/
IBB( const std::string& sid );
/**
* Constructs a new IBB object from the given Tag.
* @param tag The Tag to parse.
*/
IBB( const Tag* tag = 0 );
/**
* Virtual destructor.
*/
virtual ~IBB();
/**
* Returns the IBB's type.
* @return The IBB's type.
*/
IBBType type() const { return m_type; }
/**
* Returns the IBB's block size. Only meaningful if the IBB is of type() IBBOpen.
* @return The IBB's block size.
*/
int blocksize() const { return m_blockSize; }
/**
* Returns the current block's sequence number.
* @return The current block's sequence number.
*/
int seq() const { return m_seq; }
/**
* Returns the current block's SID.
* @return The current block's SID.
*/
const std::string sid() const { return m_sid; }
/**
* Returns the current block's data (not base64 encoded).
* @return The current block's data.
*/
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__
|