summaryrefslogtreecommitdiff
path: root/webproxyconn.cc
blob: ae75e1ab6b7ce205f18bed3d2bb2b7c550bdb18b (plain)
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
#include <QtCore/QDebug>

#include "sappeer.h"
#include "endianhelpers.h"
#include "webproxyconn.h"

WebProxyConn::WebProxyConn(SAPConnection *conn, QObject *parent)
	: QObject(parent), _conn(conn),
	  _in(conn->getSocket(501)), _out(conn->getSocket(502))
{
	connect(_conn, SIGNAL(disconnected()), SLOT(deleteLater()));
	Q_ASSERT(_in && _out);
	connect(_in, SIGNAL(messageReceived()), SLOT(handleMessageReceived()));
}

WebProxyConn::RequestMessage WebProxyConn::unpackRequestMessage(const QByteArray &data)
{
	RequestMessage msg;
	int offset = 0;
	msg.command = read<quint8>(data, offset);
	msg.subCommand = read<quint8>(data, offset);
	msg.type = read<quint8>(data, offset);
	msg.transactionId = read<quint8>(data, offset);

	const quint32 len = read<quint32>(data, offset);

	qDebug() << "command=" << msg.command << "sub=" << msg.subCommand
			 << "type=" << msg.type << "transaction=" << msg.transactionId;

	qDebug() << QString::fromUtf8(data.mid(offset, len));

	return msg;
}

void WebProxyConn::handleMessageReceived()
{
	QByteArray data = _in->receive();
	qDebug() << data.toHex();
	RequestMessage req = unpackRequestMessage(data);
	qDebug() << "End of data";
}
s="p">(); } else if (parts.count() == 4) { section = 0; segment = parts[0].toUInt(); shelf = parts[1].toUInt(); book = parts[2].toUInt(); page = parts[3].toUInt(); } else { qWarning() << "Unknown page address syntax:" << addr; } v = addressToUint64(section, segment, shelf, book, page); } QString AfdPageAddress::toString() const { QStringList l; l.reserve(5); if (section()) { l.append(QString::number(section())); } l.append(QString::number(segment())); l.append(QString::number(shelf())); l.append(QString::number(book())); l.append(QString::number(page())); return l.join("."); }