4 #include "compressionhandler.h"
7 CompressionHandler::CompressionHandler() : errorCode_(0)
9 outgoing_buffer_
.open(QIODevice::ReadWrite
);
10 compressor_
= new Compressor(&outgoing_buffer_
);
12 incoming_buffer_
.open(QIODevice::ReadWrite
);
13 decompressor_
= new Decompressor(&incoming_buffer_
);
16 void CompressionHandler::writeIncoming(const QByteArray
& a
)
18 //qDebug("CompressionHandler::writeIncoming");
19 //qDebug() << (QString("Incoming %1 bytes").arg(a.size()).toAscii());
20 errorCode_
= decompressor_
->write(a
);
22 QTimer::singleShot(0, this, SIGNAL(readyRead()));
24 QTimer::singleShot(0, this, SIGNAL(error()));
27 void CompressionHandler::write(const QByteArray
& a
)
29 //qDebug() << (QString("CompressionHandler::write(%1)").arg(a.size()).toAscii());
30 errorCode_
= compressor_
->write(a
);
32 QTimer::singleShot(0, this, SIGNAL(readyReadOutgoing()));
34 QTimer::singleShot(0, this, SIGNAL(error()));
37 QByteArray
CompressionHandler::read()
39 //qDebug("CompressionHandler::read");
40 QByteArray b
= incoming_buffer_
.buffer();
41 incoming_buffer_
.buffer().clear();
42 incoming_buffer_
.reset();
46 QByteArray
CompressionHandler::readOutgoing(int* i
)
48 //qDebug("CompressionHandler::readOutgoing");
49 //qDebug() << (QString("Outgoing %1 bytes").arg(outgoing_buffer_.size()).toAscii());
50 QByteArray b
= outgoing_buffer_
.buffer();
51 outgoing_buffer_
.buffer().clear();
52 outgoing_buffer_
.reset();
57 int CompressionHandler::errorCode()