Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / groupwise / libgroupwise / compressionhandler.cpp
blobb6934fc06c1a6b0db400f1c7006e8841e8a6d1a8
1 #include <QTimer>
2 #include <QDebug>
4 #include "compressionhandler.h"
5 #include "compress.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);
21 if (!errorCode_)
22 QTimer::singleShot(0, this, SIGNAL(readyRead()));
23 else
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);
31 if (!errorCode_)
32 QTimer::singleShot(0, this, SIGNAL(readyReadOutgoing()));
33 else
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();
43 return b;
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();
53 *i = b.size();
54 return b;
57 int CompressionHandler::errorCode()
59 return errorCode_;