1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Update qxt to latest upstream git revision

Now we are using plain qxt again as all needed local modifications are
merged upstream.
This commit is contained in:
Uwe L. Korn 2014-08-10 12:00:25 +01:00
parent 4a20e6f5f9
commit c86b629c4a
3 changed files with 39 additions and 16 deletions

View File

@ -65,6 +65,7 @@ public:
QSslCertificate localCertificate;
QSslKey privateKey;
bool autoEncrypt;
QSsl::SslProtocol proto;
QQueue<QSslSocket*> pendingConnections;
};
@ -75,6 +76,7 @@ QxtSslServer::QxtSslServer(QObject* parent) : QTcpServer(parent)
{
QXT_INIT_PRIVATE(QxtSslServer);
qxt_d().autoEncrypt = true;
qxt_d().proto = QSsl::TlsV1SslV3;
}
/*!
@ -194,16 +196,34 @@ bool QxtSslServer::autoEncrypt() const
return qxt_d().autoEncrypt;
}
/*!
* Sets the protocol used when \a autoEncrypt is enabled.
*
* \sa protocol
*/
void QxtSslServer::setProtocol(QSsl::SslProtocol proto)
{
qxt_d().proto = proto;
}
/*!
* Returns the protocol used when \a autoEncrypt is enabled.
* \sa setProtocol
*/
QSsl::SslProtocol QxtSslServer::protocol() const
{
return qxt_d().proto;
}
/*!
* \reimp
*/
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
#if QT_VERSION >= 0x050000
void QxtSslServer::incomingConnection(qintptr socketDescriptor)
#else
void QxtSslServer::incomingConnection(int socketDescriptor)
#endif
{
qWarning() << Q_FUNC_INFO << socketDescriptor;
QSslSocket* socket = new QSslSocket(this);
if(socket->setSocketDescriptor(socketDescriptor)) {
socket->setLocalCertificate(qxt_d().localCertificate);

View File

@ -60,9 +60,12 @@ public:
void setAutoEncrypt(bool on);
bool autoEncrypt() const;
void setProtocol(QSsl::SslProtocol proto);
QSsl::SslProtocol protocol() const;
protected:
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
virtual void incomingConnection(qintptr socketDescriptor);
#if QT_VERSION >= 0x050000
virtual void incomingConnection(qintptr socketDescriptor);
#else
virtual void incomingConnection(int socketDescriptor);
#endif

View File

@ -131,7 +131,9 @@ bool QxtScgiServerConnector::canParseRequest(const QByteArray& buffer)
return false;
}
return (buffer.size() > expectedsize.toInt());
// The SCGI header is [len]":"[key/value pairs]","
int headersize = expectedsize.count() + expectedsize.toInt() + 2;
return (buffer.size() >= headersize);
}
/*!
@ -159,25 +161,26 @@ QHttpRequestHeader QxtScgiServerConnector::parseRequest(QByteArray& buffer)
}
buffer = buffer.right(buffer.size() - (expectedsize_s.count() + 1));
int expectedsize = expectedsize_s.toInt();
QByteArray requestheaders = buffer.mid(expectedsize_s.count() + 1, expectedsize);
buffer = buffer.mid(expectedsize_s.count() + expectedsize + 2);
QHttpRequestHeader request_m;
QByteArray name;
int i = 0;
while ((i = buffer.indexOf('\0')) > -1)
while ((i = requestheaders.indexOf('\0')) > -1)
{
if (name.isEmpty())
{
name = buffer.left(i);
name = requestheaders.left(i);
}
else
{
request_m.setValue(QString::fromLatin1(name).toLower(), QString::fromLatin1(buffer.left(i)));
request_m.setValue(QString::fromLatin1(name).toLower(), QString::fromLatin1(requestheaders.left(i)));
name = "";
}
buffer = buffer.mid(i + 1);
requestheaders = requestheaders.mid(i + 1);
}
@ -188,16 +191,13 @@ QHttpRequestHeader QxtScgiServerConnector::parseRequest(QByteArray& buffer)
{
if (key.startsWith(QString("http_")))
{
request_m.setValue(key.right(key.size() - 5), request_m.value(key));
QString realKey = key.right(key.size() - 5).replace(QLatin1Char('_'), QLatin1Char('-'));
request_m.setValue(realKey, request_m.value(key));
}
}
request_m.setValue("Connection", "close");
buffer.chop(1);
return request_m;
}