4
#include "compressionhandler.h"
5
#include "xmpp/zlib/zlibcompressor.h"
6
#include "xmpp/zlib/zlibdecompressor.h"
8
CompressionHandler::CompressionHandler()
11
outgoing_buffer_.open(QIODevice::ReadWrite);
12
compressor_ = new ZLibCompressor(&outgoing_buffer_);
14
incoming_buffer_.open(QIODevice::ReadWrite);
15
decompressor_ = new ZLibDecompressor(&incoming_buffer_);
18
CompressionHandler::~CompressionHandler()
24
void CompressionHandler::writeIncoming(const QByteArray& a)
26
//qDebug("CompressionHandler::writeIncoming");
27
//qDebug() << QString("Incoming %1 bytes").arg(a.size());
28
errorCode_ = decompressor_->write(a);
30
QTimer::singleShot(0, this, SIGNAL(readyRead()));
32
QTimer::singleShot(0, this, SIGNAL(error()));
35
void CompressionHandler::write(const QByteArray& a)
37
//qDebug() << QString("CompressionHandler::write(%1)").arg(a.size());
38
errorCode_ = compressor_->write(a);
40
QTimer::singleShot(0, this, SIGNAL(readyReadOutgoing()));
42
QTimer::singleShot(0, this, SIGNAL(error()));
45
QByteArray CompressionHandler::read()
47
//qDebug("CompressionHandler::read");
48
QByteArray b = incoming_buffer_.buffer();
49
incoming_buffer_.buffer().clear();
50
incoming_buffer_.reset();
54
QByteArray CompressionHandler::readOutgoing(int* i)
56
//qDebug("CompressionHandler::readOutgoing");
57
//qDebug() << QString("Outgoing %1 bytes").arg(outgoing_buffer_.size());
58
QByteArray b = outgoing_buffer_.buffer();
59
outgoing_buffer_.buffer().clear();
60
outgoing_buffer_.reset();
65
int CompressionHandler::errorCode()