From a45977185a485624095bff1a15024e9199eee676 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 1 Jan 2016 22:05:42 +0100 Subject: reorganize source files into SAP and agents --- webproxytrans.cc | 74 -------------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 webproxytrans.cc (limited to 'webproxytrans.cc') diff --git a/webproxytrans.cc b/webproxytrans.cc deleted file mode 100644 index 23b41b7..0000000 --- a/webproxytrans.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include - -#include "webproxyconn.h" -#include "webproxytrans.h" - -static const QByteArray connectResponse("HTTP/1.1 200 Connection established\r\n\r\n"); - -WebProxyTrans::WebProxyTrans(int transactionId, bool tunnel, const QString &host, int port, WebProxyConn *conn) - : QObject(conn), _transactionId(transactionId), _tunnel(tunnel), _socket(new QTcpSocket(this)) -{ - connect(_socket, SIGNAL(connected()), this, SLOT(handleSocketConnected())); - connect(_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(handleSocketDataWritten(qint64))); - connect(_socket, SIGNAL(readyRead()), this, SLOT(handleSocketDataReady())); - connect(_socket, SIGNAL(disconnected()), this, SLOT(handleSocketDisconnected())); - - _socket->connectToHost(host, port); -} - -int WebProxyTrans::transactionId() const -{ - return _transactionId; -} - -void WebProxyTrans::write(const QByteArray &data) -{ - if (!_outBuf.isEmpty() || !_socket->isValid()) { - _outBuf.append(data); - } else if (_socket->isValid()) { - // Write directly to socket - _socket->write(data); - } -} - -void WebProxyTrans::handleSocketConnected() -{ - qDebug() << "Transaction" << _transactionId << "Connected"; - if (_tunnel) { - emit dataReceived(connectResponse); - } - writeFromBuffer(); -} - -void WebProxyTrans::handleSocketDataWritten(qint64 written) -{ - Q_UNUSED(written); - writeFromBuffer(); -} - -void WebProxyTrans::handleSocketDataReady() -{ - emit dataReceived(_socket->readAll()); -} - -void WebProxyTrans::handleSocketDisconnected() -{ - qDebug() << "Transaction" << _transactionId << "Disconnected"; - emit disconnected(); -} - -WebProxyConn* WebProxyTrans::conn() -{ - return static_cast(parent()); -} - -void WebProxyTrans::writeFromBuffer() -{ - if (!_outBuf.isEmpty()) { - qint64 written = _socket->write(_outBuf); - if (written > 0) { - _outBuf.remove(0, written); - } - } -} -- cgit v1.2.3