#include "private/qpacketprotocol_p.h"
-#include <QBuffer>
-#include <QElapsedTimer>
+#include <QtCore/QBuffer>
+#include <QtCore/QElapsedTimer>
QT_BEGIN_NAMESPACE
-#define MAX_PACKET_SIZE 0x7FFFFFFF
+static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF;
/*!
\class QPacketProtocol
{
Q_OBJECT
public:
- QPacketProtocolPrivate(QPacketProtocol * parent, QIODevice * _dev)
+ QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
waitingForPacket(false), dev(_dev)
{
{
Q_ASSERT(!sendingPackets.isEmpty());
- while(bytes) {
- if(sendingPackets.at(0) > bytes) {
+ while (bytes) {
+ if (sendingPackets.at(0) > bytes) {
sendingPackets[0] -= bytes;
bytes = 0;
} else {
qint32 inProgressSize;
qint32 maxPacketSize;
bool waitingForPacket;
- QIODevice * dev;
+ QIODevice *dev;
};
/*!
Construct a QPacketProtocol instance that works on \a dev with the
specified \a parent.
*/
-QPacketProtocol::QPacketProtocol(QIODevice * dev, QObject * parent)
+QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
: QObject(parent), d(new QPacketProtocolPrivate(this, dev))
{
Q_ASSERT(dev);
*/
qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
{
- if(max > (signed)sizeof(qint32))
+ if (max > (signed)sizeof(qint32))
d->maxPacketSize = max;
return d->maxPacketSize;
}
*/
void QPacketProtocol::send(const QPacket & p)
{
- if(p.b.isEmpty())
+ if (p.b.isEmpty())
return; // We don't send empty packets
qint64 sendSize = p.b.size() + sizeof(qint32);
*/
QPacket QPacketProtocol::read()
{
- if(0 == d->packets.count())
+ if (0 == d->packets.count())
return QPacket();
QPacket rv(d->packets.at(0));
/*!
Return the QIODevice passed to the QPacketProtocol constructor.
*/
-QIODevice * QPacketProtocol::device()
+QIODevice *QPacketProtocol::device()
{
return d->dev;
}
*/
QPacket::~QPacket()
{
- if(buf) {
+ if (buf) {
delete buf;
buf = 0;
}
\internal
*/
-QPacketAutoSend::QPacketAutoSend(QPacketProtocol * _p)
+QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p)
: QPacket(), p(_p)
{
}
QPacketAutoSend::~QPacketAutoSend()
{
- if(!b.isEmpty())
+ if (!b.isEmpty())
p->send(*this);
}
{
Q_OBJECT
public:
- explicit QPacketProtocol(QIODevice * dev, QObject * parent = 0);
+ explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0);
virtual ~QPacketProtocol();
qint32 maximumPacketSize() const;
void clear();
- QIODevice * device();
+ QIODevice *device();
Q_SIGNALS:
void readyRead();
void packetWritten();
private:
- QPacketProtocolPrivate * d;
+ QPacketProtocolPrivate *d;
};
protected:
friend class QPacketProtocol;
- QPacket(const QByteArray & ba);
+ QPacket(const QByteArray &ba);
QByteArray b;
- QBuffer * buf;
+ QBuffer *buf;
};
class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket
private:
friend class QPacketProtocol;
QPacketAutoSend(QPacketProtocol *);
- QPacketProtocol * p;
+ QPacketProtocol *p;
};
QT_END_NAMESPACE