From d7645a33be670cb8ff6375c9632a20edde7479ae Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 5 Jan 2013 19:59:24 +0100 Subject: [PATCH] Update QxtWeb --- src/web/Api_v1.cpp | 2 +- .../qxt/qxtweb-standalone/CMakeLists.txt | 55 +- .../qxtweb-standalone/qxtweb/qhttpheader.cpp | 960 ++++++++++++++++++ .../qxtweb-standalone/qxtweb/qhttpheader.h | 179 ++++ .../qxtweb/qxtabstracthttpconnector.cpp | 212 ++-- .../qxtweb/qxtabstracthttpconnector.h | 89 +- .../qxtweb/qxtabstractwebservice.cpp | 60 +- .../qxtweb/qxtabstractwebservice.h | 52 +- .../qxtweb/qxtabstractwebsessionmanager.cpp | 86 +- .../qxtweb/qxtabstractwebsessionmanager.h | 56 +- .../qxtweb/qxtabstractwebsessionmanager_p.h | 52 +- .../qxtweb/qxtboundcfunction.h | 52 +- .../qxtweb/qxtboundfunction.h | 56 +- .../qxtweb/qxtboundfunctionbase.h | 52 +- .../qxt/qxtweb-standalone/qxtweb/qxtfifo.cpp | 272 +++++ .../qxt/qxtweb-standalone/qxtweb/qxtfifo.h | 57 ++ .../qxtweb-standalone/qxtweb/qxtglobal.cpp | 76 +- .../qxt/qxtweb-standalone/qxtweb/qxtglobal.h | 92 +- .../qxtweb/qxthtmltemplate.cpp | 52 +- .../qxtweb/qxthtmltemplate.h | 52 +- .../qxtweb/qxthttpserverconnector.cpp | 170 +++- .../qxtweb/qxthttpsessionmanager.cpp | 290 +++--- .../qxtweb/qxthttpsessionmanager.h | 74 +- .../qxtweb/qxtmetaobject.cpp | 58 +- .../qxtweb-standalone/qxtweb/qxtmetaobject.h | 54 +- .../qxt/qxtweb-standalone/qxtweb/qxtnull.cpp | 54 +- .../qxt/qxtweb-standalone/qxtweb/qxtnull.h | 52 +- .../qxtweb-standalone/qxtweb/qxtnullable.h | 52 +- .../qxtweb/qxtscgiserverconnector.cpp | 72 +- .../qxtweb-standalone/qxtweb/qxtsslserver.cpp | 220 ++++ .../qxt/qxtweb-standalone/qxtweb/qxtweb.h | 57 +- .../qxtweb/qxtwebcgiservice.cpp | 64 +- .../qxtweb/qxtwebcgiservice.h | 52 +- .../qxtweb/qxtwebcgiservice_p.h | 52 +- .../qxtweb/qxtwebcontent.cpp | 313 +++--- .../qxtweb-standalone/qxtweb/qxtwebcontent.h | 63 +- .../qxtweb-standalone/qxtweb/qxtwebevent.cpp | 122 ++- .../qxtweb-standalone/qxtweb/qxtwebevent.h | 70 +- .../qxtweb/qxtwebjsonrpcservice.cpp | 512 ++++++++++ .../qxtweb/qxtwebjsonrpcservice.h | 56 + .../qxtweb/qxtwebjsonrpcservice_p.h | 66 ++ .../qxtweb/qxtwebservicedirectory.cpp | 52 +- .../qxtweb/qxtwebservicedirectory.h | 52 +- .../qxtweb/qxtwebservicedirectory_p.h | 52 +- .../qxtweb/qxtwebslotservice.cpp | 54 +- .../qxtweb/qxtwebslotservice.h | 52 +- 46 files changed, 4141 insertions(+), 1208 deletions(-) create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.cpp create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.h create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.cpp create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.h create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtsslserver.cpp create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.cpp create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.h create mode 100644 thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice_p.h diff --git a/src/web/Api_v1.cpp b/src/web/Api_v1.cpp index 632f3e2f3..76327e2f8 100644 --- a/src/web/Api_v1.cpp +++ b/src/web/Api_v1.cpp @@ -192,7 +192,7 @@ Api_v1::sid( QxtWebRequestEvent* event, QString unused ) return send404( event ); // 503? } - QxtWebPageEvent* e = new QxtWebPageEvent( event->sessionID, event->requestID, iodev ); + QxtWebPageEvent* e = new QxtWebPageEvent( event->sessionID, event->requestID, iodev.data() ); e->streaming = iodev->isSequential(); e->contentType = rp->mimetype().toAscii(); if ( rp->size() > 0 ) diff --git a/thirdparty/qxt/qxtweb-standalone/CMakeLists.txt b/thirdparty/qxt/qxtweb-standalone/CMakeLists.txt index 1aeb800e9..81b42432b 100644 --- a/thirdparty/qxt/qxtweb-standalone/CMakeLists.txt +++ b/thirdparty/qxt/qxtweb-standalone/CMakeLists.txt @@ -22,6 +22,16 @@ ADD_DEFINITIONS( -DBUILD_QXT_CORE -DBUILD_QXT_WEB ) INCLUDE_DIRECTORIES( ${qxtweb} ) +macro(create_qxtweb_fancy_header simpleHeader fancyHeader) + file(WRITE ${CMAKE_BINARY_DIR}/QxtWeb/${fancyHeader} "#include \"${simpleHeader}\"" ) +endmacro() + +create_qxtweb_fancy_header("qxtabstracthttpconnector.h" "QxtHttpServerConnector") +create_qxtweb_fancy_header("qxthttpsessionmanager.h" "HttpSessionManager") +create_qxtweb_fancy_header("qxthttpsessionmanager.h" "QxtHttpSessionManager") +create_qxtweb_fancy_header("qxtwebcontent.h" "QxtWebContent") +create_qxtweb_fancy_header("qxtwebslotservice.h" "QxtWebSlotService") +create_qxtweb_fancy_header("qxtwebevent.h" "QxtWebPageEvent") SET( sources # QxtWeb: @@ -37,40 +47,20 @@ SET( sources ${qxtweb}/qxtwebservicedirectory.cpp ${qxtweb}/qxtwebslotservice.cpp ${qxtweb}/qxtwebcgiservice.cpp + ${qxtweb}/qhttpheader.cpp # Ripped bits of QxtCore: ${qxtweb}/qxtmetaobject.cpp ${qxtweb}/qxtnull.cpp -) + ${qxtweb}/qxtfifo.cpp -SET( headers - # QxtWeb: - ${qxtweb}/qxtabstracthttpconnector.h - ${qxtweb}/qxtabstractwebservice.h - ${qxtweb}/qxtabstractwebsessionmanager.h - ${qxtweb}/qxtabstractwebsessionmanager_p.h -# ${qxtweb}/qxthtmltemplate.h - ${qxtweb}/qxthttpsessionmanager.h -# ${qxtweb}/qxtweb.h - ${qxtweb}/qxtwebcontent.h -# ${qxtweb}/qxtwebevent.h - ${qxtweb}/qxtwebservicedirectory.h - ${qxtweb}/qxtwebservicedirectory_p.h - ${qxtweb}/qxtwebslotservice.h - ${qxtweb}/qxtwebcgiservice.h - ${qxtweb}/qxtwebcgiservice_p.h + # QxtNetwork + ${qxtweb}/qxtsslserver.cpp - # Ripped bits of QxtCore: -# ${qxtweb}/qxtmetaobject.h -# ${qxtweb}/qxtnullable.h -# ${qxtweb}/qxtnull.h + # automoc hack ${qxtweb}/qxtboundfunction.h -# ${qxtweb}/qxtboundfunctionbase.h -# ${qxtweb}/qxtboundcfunction.h -# ${qxtweb}/qxtmetatype.h ) -qt4_wrap_cpp( mocstuff ${headers} ) # DLL on windows due to linker issues, otherwise static IF(WIN32) @@ -97,17 +87,4 @@ target_link_libraries( qxtweb-standalone ${QT_LIBRARIES} ) -# Also build small example app from qxt demos: - -#qt4_wrap_cpp( mocex "example/myservice.h" ) - -#ADD_EXECUTABLE( example-webserver -# ${mocex} -# example/main.cpp -# example/myservice.h -# ) - -#TARGET_LINK_LIBRARIES( example-webserver -# ${QT_LIBRARIES} -# "${CMAKE_CURRENT_SOURCE_DIR}/libqxtweb-standalone.a" -# ) +set_target_properties(qxtweb-standalone PROPERTIES AUTOMOC TRUE) diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.cpp new file mode 100644 index 000000000..131100807 --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.cpp @@ -0,0 +1,960 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//#define QHTTP_DEBUG + +#include "qhttpheader.h" +#include + + +class QHttpHeaderPrivate +{ + Q_DECLARE_PUBLIC(QHttpHeader) +public: + inline virtual ~QHttpHeaderPrivate() {} + + QList > values; + bool valid; + QHttpHeader *q_ptr; +}; + +/**************************************************** + * + * QHttpHeader + * + ****************************************************/ + +/*! + \class QHttpHeader + \obsolete + \brief The QHttpHeader class contains header information for HTTP. + + \ingroup network + \inmodule QtNetwork + + In most cases you should use the more specialized derivatives of + this class, QHttpResponseHeader and QHttpRequestHeader, rather + than directly using QHttpHeader. + + QHttpHeader provides the HTTP header fields. A HTTP header field + consists of a name followed by a colon, a single space, and the + field value. (See RFC 1945.) Field names are case-insensitive. A + typical header field looks like this: + \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 0 + + In the API the header field name is called the "key" and the + content is called the "value". You can get and set a header + field's value by using its key with value() and setValue(), e.g. + \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 1 + + Some fields are so common that getters and setters are provided + for them as a convenient alternative to using \l value() and + \l setValue(), e.g. contentLength() and contentType(), + setContentLength() and setContentType(). + + Each header key has a \e single value associated with it. If you + set the value for a key which already exists the previous value + will be discarded. + + \sa QHttpRequestHeader QHttpResponseHeader +*/ + +/*! + \fn int QHttpHeader::majorVersion() const + + Returns the major protocol-version of the HTTP header. +*/ + +/*! + \fn int QHttpHeader::minorVersion() const + + Returns the minor protocol-version of the HTTP header. +*/ + +/*! + Constructs an empty HTTP header. +*/ +QHttpHeader::QHttpHeader() + : d_ptr(new QHttpHeaderPrivate) +{ + Q_D(QHttpHeader); + d->q_ptr = this; + d->valid = true; +} + +/*! + Constructs a copy of \a header. +*/ +QHttpHeader::QHttpHeader(const QHttpHeader &header) + : d_ptr(new QHttpHeaderPrivate) +{ + Q_D(QHttpHeader); + d->q_ptr = this; + d->valid = header.d_func()->valid; + d->values = header.d_func()->values; +} + +/*! + Constructs a HTTP header for \a str. + + This constructor parses the string \a str for header fields and + adds this information. The \a str should consist of one or more + "\r\n" delimited lines; each of these lines should have the format + key, colon, space, value. +*/ +QHttpHeader::QHttpHeader(const QString &str) + : d_ptr(new QHttpHeaderPrivate) +{ + Q_D(QHttpHeader); + d->q_ptr = this; + d->valid = true; + parse(str); +} + +/*! \internal + */ +QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QString &str) + : d_ptr(&dd) +{ + Q_D(QHttpHeader); + d->q_ptr = this; + d->valid = true; + if (!str.isEmpty()) + parse(str); +} + +/*! \internal + */ +QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header) + : d_ptr(&dd) +{ + Q_D(QHttpHeader); + d->q_ptr = this; + d->valid = header.d_func()->valid; + d->values = header.d_func()->values; +} +/*! + Destructor. +*/ +QHttpHeader::~QHttpHeader() +{ +} + +/*! + Assigns \a h and returns a reference to this http header. +*/ +QHttpHeader &QHttpHeader::operator=(const QHttpHeader &h) +{ + Q_D(QHttpHeader); + d->values = h.d_func()->values; + d->valid = h.d_func()->valid; + return *this; +} + +/*! + Returns true if the HTTP header is valid; otherwise returns false. + + A QHttpHeader is invalid if it was created by parsing a malformed string. +*/ +bool QHttpHeader::isValid() const +{ + Q_D(const QHttpHeader); + return d->valid; +} + +/*! \internal + Parses the HTTP header string \a str for header fields and adds + the keys/values it finds. If the string is not parsed successfully + the QHttpHeader becomes \link isValid() invalid\endlink. + + Returns true if \a str was successfully parsed; otherwise returns false. + + \sa toString() +*/ +bool QHttpHeader::parse(const QString &str) +{ + Q_D(QHttpHeader); + QStringList lst; + int pos = str.indexOf(QLatin1Char('\n')); + if (pos > 0 && str.at(pos - 1) == QLatin1Char('\r')) + lst = str.trimmed().split(QLatin1String("\r\n")); + else + lst = str.trimmed().split(QLatin1String("\n")); + lst.removeAll(QString()); // No empties + + if (lst.isEmpty()) + return true; + + QStringList lines; + QStringList::Iterator it = lst.begin(); + for (; it != lst.end(); ++it) { + if (!(*it).isEmpty()) { + if ((*it)[0].isSpace()) { + if (!lines.isEmpty()) { + lines.last() += QLatin1Char(' '); + lines.last() += (*it).trimmed(); + } + } else { + lines.append((*it)); + } + } + } + + int number = 0; + it = lines.begin(); + for (; it != lines.end(); ++it) { + if (!parseLine(*it, number++)) { + d->valid = false; + return false; + } + } + return true; +} + +/*! \internal +*/ +void QHttpHeader::setValid(bool v) +{ + Q_D(QHttpHeader); + d->valid = v; +} + +/*! + Returns the first value for the entry with the given \a key. If no entry + has this \a key, an empty string is returned. + + \sa setValue() removeValue() hasKey() keys() +*/ +QString QHttpHeader::value(const QString &key) const +{ + Q_D(const QHttpHeader); + QString lowercaseKey = key.toLower(); + QList >::ConstIterator it = d->values.constBegin(); + while (it != d->values.constEnd()) { + if ((*it).first.toLower() == lowercaseKey) + return (*it).second; + ++it; + } + return QString(); +} + +/*! + Returns all the entries with the given \a key. If no entry + has this \a key, an empty string list is returned. +*/ +QStringList QHttpHeader::allValues(const QString &key) const +{ + Q_D(const QHttpHeader); + QString lowercaseKey = key.toLower(); + QStringList valueList; + QList >::ConstIterator it = d->values.constBegin(); + while (it != d->values.constEnd()) { + if ((*it).first.toLower() == lowercaseKey) + valueList.append((*it).second); + ++it; + } + return valueList; +} + +/*! + Returns a list of the keys in the HTTP header. + + \sa hasKey() +*/ +QStringList QHttpHeader::keys() const +{ + Q_D(const QHttpHeader); + QStringList keyList; + QSet seenKeys; + QList >::ConstIterator it = d->values.constBegin(); + while (it != d->values.constEnd()) { + const QString &key = (*it).first; + QString lowercaseKey = key.toLower(); + if (!seenKeys.contains(lowercaseKey)) { + keyList.append(key); + seenKeys.insert(lowercaseKey); + } + ++it; + } + return keyList; +} + +/*! + Returns true if the HTTP header has an entry with the given \a + key; otherwise returns false. + + \sa value() setValue() keys() +*/ +bool QHttpHeader::hasKey(const QString &key) const +{ + Q_D(const QHttpHeader); + QString lowercaseKey = key.toLower(); + QList >::ConstIterator it = d->values.constBegin(); + while (it != d->values.constEnd()) { + if ((*it).first.toLower() == lowercaseKey) + return true; + ++it; + } + return false; +} + +/*! + Sets the value of the entry with the \a key to \a value. + + If no entry with \a key exists, a new entry with the given \a key + and \a value is created. If an entry with the \a key already + exists, the first value is discarded and replaced with the given + \a value. + + \sa value() hasKey() removeValue() +*/ +void QHttpHeader::setValue(const QString &key, const QString &value) +{ + Q_D(QHttpHeader); + QString lowercaseKey = key.toLower(); + QList >::Iterator it = d->values.begin(); + while (it != d->values.end()) { + if ((*it).first.toLower() == lowercaseKey) { + (*it).second = value; + return; + } + ++it; + } + // not found so add + addValue(key, value); +} + +/*! + Sets the header entries to be the list of key value pairs in \a values. +*/ +void QHttpHeader::setValues(const QList > &values) +{ + Q_D(QHttpHeader); + d->values = values; +} + +/*! + Adds a new entry with the \a key and \a value. +*/ +void QHttpHeader::addValue(const QString &key, const QString &value) +{ + Q_D(QHttpHeader); + d->values.append(qMakePair(key, value)); +} + +/*! + Returns all the entries in the header. +*/ +QList > QHttpHeader::values() const +{ + Q_D(const QHttpHeader); + return d->values; +} + +/*! + Removes the entry with the key \a key from the HTTP header. + + \sa value() setValue() +*/ +void QHttpHeader::removeValue(const QString &key) +{ + Q_D(QHttpHeader); + QString lowercaseKey = key.toLower(); + QList >::Iterator it = d->values.begin(); + while (it != d->values.end()) { + if ((*it).first.toLower() == lowercaseKey) { + d->values.erase(it); + return; + } + ++it; + } +} + +/*! + Removes all the entries with the key \a key from the HTTP header. +*/ +void QHttpHeader::removeAllValues(const QString &key) +{ + Q_D(QHttpHeader); + QString lowercaseKey = key.toLower(); + QList >::Iterator it = d->values.begin(); + while (it != d->values.end()) { + if ((*it).first.toLower() == lowercaseKey) { + it = d->values.erase(it); + continue; + } + ++it; + } +} + +/*! \internal + Parses the single HTTP header line \a line which has the format + key, colon, space, value, and adds key/value to the headers. The + linenumber is \a number. Returns true if the line was successfully + parsed and the key/value added; otherwise returns false. + + \sa parse() +*/ +bool QHttpHeader::parseLine(const QString &line, int) +{ + int i = line.indexOf(QLatin1Char(':')); + if (i == -1) + return false; + + addValue(line.left(i).trimmed(), line.mid(i + 1).trimmed()); + + return true; +} + +/*! + Returns a string representation of the HTTP header. + + The string is suitable for use by the constructor that takes a + QString. It consists of lines with the format: key, colon, space, + value, "\r\n". +*/ +QString QHttpHeader::toString() const +{ + Q_D(const QHttpHeader); + if (!isValid()) + return QLatin1String(""); + + QString ret = QLatin1String(""); + + QList >::ConstIterator it = d->values.constBegin(); + while (it != d->values.constEnd()) { + ret += (*it).first + QLatin1String(": ") + (*it).second + QLatin1String("\r\n"); + ++it; + } + return ret; +} + +/*! + Returns true if the header has an entry for the special HTTP + header field \c content-length; otherwise returns false. + + \sa contentLength() setContentLength() +*/ +bool QHttpHeader::hasContentLength() const +{ + return hasKey(QLatin1String("content-length")); +} + +/*! + Returns the value of the special HTTP header field \c + content-length. + + \sa setContentLength() hasContentLength() +*/ +uint QHttpHeader::contentLength() const +{ + return value(QLatin1String("content-length")).toUInt(); +} + +/*! + Sets the value of the special HTTP header field \c content-length + to \a len. + + \sa contentLength() hasContentLength() +*/ +void QHttpHeader::setContentLength(int len) +{ + setValue(QLatin1String("content-length"), QString::number(len)); +} + +/*! + Returns true if the header has an entry for the special HTTP + header field \c content-type; otherwise returns false. + + \sa contentType() setContentType() +*/ +bool QHttpHeader::hasContentType() const +{ + return hasKey(QLatin1String("content-type")); +} + +/*! + Returns the value of the special HTTP header field \c content-type. + + \sa setContentType() hasContentType() +*/ +QString QHttpHeader::contentType() const +{ + QString type = value(QLatin1String("content-type")); + if (type.isEmpty()) + return QString(); + + int pos = type.indexOf(QLatin1Char(';')); + if (pos == -1) + return type; + + return type.left(pos).trimmed(); +} + +/*! + Sets the value of the special HTTP header field \c content-type to + \a type. + + \sa contentType() hasContentType() +*/ +void QHttpHeader::setContentType(const QString &type) +{ + setValue(QLatin1String("content-type"), type); +} + +class QHttpResponseHeaderPrivate : public QHttpHeaderPrivate +{ + Q_DECLARE_PUBLIC(QHttpResponseHeader) +public: + int statCode; + QString reasonPhr; + int majVer; + int minVer; +}; + +/**************************************************** + * + * QHttpResponseHeader + * + ****************************************************/ + +/*! + \class QHttpResponseHeader + \obsolete + \brief The QHttpResponseHeader class contains response header information for HTTP. + + \ingroup network + \inmodule QtNetwork + + This class is used by the QHttp class to report the header + information that the client received from the server. + + HTTP responses have a status code that indicates the status of the + response. This code is a 3-digit integer result code (for details + see to RFC 1945). In addition to the status code, you can also + specify a human-readable text that describes the reason for the + code ("reason phrase"). This class allows you to get the status + code and the reason phrase. + + \sa QHttpRequestHeader, QHttp, {HTTP Example} +*/ + +/*! + Constructs an empty HTTP response header. +*/ +QHttpResponseHeader::QHttpResponseHeader() + : QHttpHeader(*new QHttpResponseHeaderPrivate) +{ + setValid(false); +} + +/*! + Constructs a copy of \a header. +*/ +QHttpResponseHeader::QHttpResponseHeader(const QHttpResponseHeader &header) + : QHttpHeader(*new QHttpResponseHeaderPrivate, header) +{ + Q_D(QHttpResponseHeader); + d->statCode = header.d_func()->statCode; + d->reasonPhr = header.d_func()->reasonPhr; + d->majVer = header.d_func()->majVer; + d->minVer = header.d_func()->minVer; +} + +/*! + Copies the contents of \a header into this QHttpResponseHeader. +*/ +QHttpResponseHeader &QHttpResponseHeader::operator=(const QHttpResponseHeader &header) +{ + Q_D(QHttpResponseHeader); + QHttpHeader::operator=(header); + d->statCode = header.d_func()->statCode; + d->reasonPhr = header.d_func()->reasonPhr; + d->majVer = header.d_func()->majVer; + d->minVer = header.d_func()->minVer; + return *this; +} + +/*! + Constructs a HTTP response header from the string \a str. The + string is parsed and the information is set. The \a str should + consist of one or more "\r\n" delimited lines; the first line should be the + status-line (format: HTTP-version, space, status-code, space, + reason-phrase); each of remaining lines should have the format key, colon, + space, value. +*/ +QHttpResponseHeader::QHttpResponseHeader(const QString &str) + : QHttpHeader(*new QHttpResponseHeaderPrivate) +{ + parse(str); +} + +/*! + \since 4.1 + + Constructs a QHttpResponseHeader, setting the status code to \a code, the + reason phrase to \a text and the protocol-version to \a majorVer and \a + minorVer. + + \sa statusCode() reasonPhrase() majorVersion() minorVersion() +*/ +QHttpResponseHeader::QHttpResponseHeader(int code, const QString &text, int majorVer, int minorVer) + : QHttpHeader(*new QHttpResponseHeaderPrivate) +{ + setStatusLine(code, text, majorVer, minorVer); +} + +/*! + \since 4.1 + + Sets the status code to \a code, the reason phrase to \a text and + the protocol-version to \a majorVer and \a minorVer. + + \sa statusCode() reasonPhrase() majorVersion() minorVersion() +*/ +void QHttpResponseHeader::setStatusLine(int code, const QString &text, int majorVer, int minorVer) +{ + Q_D(QHttpResponseHeader); + setValid(true); + d->statCode = code; + d->reasonPhr = text; + d->majVer = majorVer; + d->minVer = minorVer; +} + +/*! + Returns the status code of the HTTP response header. + + \sa reasonPhrase() majorVersion() minorVersion() +*/ +int QHttpResponseHeader::statusCode() const +{ + Q_D(const QHttpResponseHeader); + return d->statCode; +} + +/*! + Returns the reason phrase of the HTTP response header. + + \sa statusCode() majorVersion() minorVersion() +*/ +QString QHttpResponseHeader::reasonPhrase() const +{ + Q_D(const QHttpResponseHeader); + return d->reasonPhr; +} + +/*! + Returns the major protocol-version of the HTTP response header. + + \sa minorVersion() statusCode() reasonPhrase() +*/ +int QHttpResponseHeader::majorVersion() const +{ + Q_D(const QHttpResponseHeader); + return d->majVer; +} + +/*! + Returns the minor protocol-version of the HTTP response header. + + \sa majorVersion() statusCode() reasonPhrase() +*/ +int QHttpResponseHeader::minorVersion() const +{ + Q_D(const QHttpResponseHeader); + return d->minVer; +} + +/*! \internal +*/ +bool QHttpResponseHeader::parseLine(const QString &line, int number) +{ + Q_D(QHttpResponseHeader); + if (number != 0) + return QHttpHeader::parseLine(line, number); + + QString l = line.simplified(); + if (l.length() < 10) + return false; + + if (l.left(5) == QLatin1String("HTTP/") && l[5].isDigit() && l[6] == QLatin1Char('.') && + l[7].isDigit() && l[8] == QLatin1Char(' ') && l[9].isDigit()) { + d->majVer = l[5].toLatin1() - '0'; + d->minVer = l[7].toLatin1() - '0'; + + int pos = l.indexOf(QLatin1Char(' '), 9); + if (pos != -1) { + d->reasonPhr = l.mid(pos + 1); + d->statCode = l.mid(9, pos - 9).toInt(); + } else { + d->statCode = l.mid(9).toInt(); + d->reasonPhr.clear(); + } + } else { + return false; + } + + return true; +} + +/*! \reimp +*/ +QString QHttpResponseHeader::toString() const +{ + Q_D(const QHttpResponseHeader); + QString ret(QLatin1String("HTTP/%1.%2 %3 %4\r\n%5\r\n")); + return ret.arg(d->majVer).arg(d->minVer).arg(d->statCode).arg(d->reasonPhr).arg(QHttpHeader::toString()); +} + +class QHttpRequestHeaderPrivate : public QHttpHeaderPrivate +{ + Q_DECLARE_PUBLIC(QHttpRequestHeader) +public: + QString m; + QString p; + int majVer; + int minVer; +}; + +/**************************************************** + * + * QHttpRequestHeader + * + ****************************************************/ + +/*! + \class QHttpRequestHeader + \obsolete + \brief The QHttpRequestHeader class contains request header information for HTTP. + + \ingroup network + \inmodule QtNetwork + + This class is used in the QHttp class to report the header + information if the client requests something from the server. + + HTTP requests have a method which describes the request's action. + The most common requests are "GET" and "POST". In addition to the + request method the header also includes a request-URI to specify + the location for the method to use. + + The method, request-URI and protocol-version can be set using a + constructor or later using setRequest(). The values can be + obtained using method(), path(), majorVersion() and + minorVersion(). + + Note that the request-URI must be in the format expected by the + HTTP server. That is, all reserved characters must be encoded in + %HH (where HH are two hexadecimal digits). See + QUrl::toPercentEncoding() for more information. + + Important inherited functions: setValue() and value(). + + \sa QHttpResponseHeader QHttp +*/ + +/*! + Constructs an empty HTTP request header. +*/ +QHttpRequestHeader::QHttpRequestHeader() + : QHttpHeader(*new QHttpRequestHeaderPrivate) +{ + setValid(false); +} + +/*! + Constructs a HTTP request header for the method \a method, the + request-URI \a path and the protocol-version \a majorVer and \a + minorVer. The \a path argument must be properly encoded for an + HTTP request. +*/ +QHttpRequestHeader::QHttpRequestHeader(const QString &method, const QString &path, int majorVer, int minorVer) + : QHttpHeader(*new QHttpRequestHeaderPrivate) +{ + Q_D(QHttpRequestHeader); + d->m = method; + d->p = path; + d->majVer = majorVer; + d->minVer = minorVer; +} + +/*! + Constructs a copy of \a header. +*/ +QHttpRequestHeader::QHttpRequestHeader(const QHttpRequestHeader &header) + : QHttpHeader(*new QHttpRequestHeaderPrivate, header) +{ + Q_D(QHttpRequestHeader); + d->m = header.d_func()->m; + d->p = header.d_func()->p; + d->majVer = header.d_func()->majVer; + d->minVer = header.d_func()->minVer; +} + +/*! + Copies the content of \a header into this QHttpRequestHeader +*/ +QHttpRequestHeader &QHttpRequestHeader::operator=(const QHttpRequestHeader &header) +{ + Q_D(QHttpRequestHeader); + QHttpHeader::operator=(header); + d->m = header.d_func()->m; + d->p = header.d_func()->p; + d->majVer = header.d_func()->majVer; + d->minVer = header.d_func()->minVer; + return *this; +} + +/*! + Constructs a HTTP request header from the string \a str. The \a + str should consist of one or more "\r\n" delimited lines; the first line + should be the request-line (format: method, space, request-URI, space + HTTP-version); each of the remaining lines should have the format key, + colon, space, value. +*/ +QHttpRequestHeader::QHttpRequestHeader(const QString &str) + : QHttpHeader(*new QHttpRequestHeaderPrivate) +{ + parse(str); +} + +/*! + This function sets the request method to \a method, the + request-URI to \a path and the protocol-version to \a majorVer and + \a minorVer. The \a path argument must be properly encoded for an + HTTP request. + + \sa method() path() majorVersion() minorVersion() +*/ +void QHttpRequestHeader::setRequest(const QString &method, const QString &path, int majorVer, int minorVer) +{ + Q_D(QHttpRequestHeader); + setValid(true); + d->m = method; + d->p = path; + d->majVer = majorVer; + d->minVer = minorVer; +} + +/*! + Returns the method of the HTTP request header. + + \sa path() majorVersion() minorVersion() setRequest() +*/ +QString QHttpRequestHeader::method() const +{ + Q_D(const QHttpRequestHeader); + return d->m; +} + +/*! + Returns the request-URI of the HTTP request header. + + \sa method() majorVersion() minorVersion() setRequest() +*/ +QString QHttpRequestHeader::path() const +{ + Q_D(const QHttpRequestHeader); + return d->p; +} + +/*! + Returns the major protocol-version of the HTTP request header. + + \sa minorVersion() method() path() setRequest() +*/ +int QHttpRequestHeader::majorVersion() const +{ + Q_D(const QHttpRequestHeader); + return d->majVer; +} + +/*! + Returns the minor protocol-version of the HTTP request header. + + \sa majorVersion() method() path() setRequest() +*/ +int QHttpRequestHeader::minorVersion() const +{ + Q_D(const QHttpRequestHeader); + return d->minVer; +} + +/*! \internal +*/ +bool QHttpRequestHeader::parseLine(const QString &line, int number) +{ + Q_D(QHttpRequestHeader); + if (number != 0) + return QHttpHeader::parseLine(line, number); + + QStringList lst = line.simplified().split(QLatin1String(" ")); + if (lst.count() > 0) { + d->m = lst[0]; + if (lst.count() > 1) { + d->p = lst[1]; + if (lst.count() > 2) { + QString v = lst[2]; + if (v.length() >= 8 && v.left(5) == QLatin1String("HTTP/") && + v[5].isDigit() && v[6] == QLatin1Char('.') && v[7].isDigit()) { + d->majVer = v[5].toLatin1() - '0'; + d->minVer = v[7].toLatin1() - '0'; + return true; + } + } + } + } + + return false; +} + +/*! \reimp +*/ +QString QHttpRequestHeader::toString() const +{ + Q_D(const QHttpRequestHeader); + QString first(QLatin1String("%1 %2")); + QString last(QLatin1String(" HTTP/%3.%4\r\n%5\r\n")); + return first.arg(d->m).arg(d->p) + + last.arg(d->majVer).arg(d->minVer).arg(QHttpHeader::toString()); +} + diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.h new file mode 100644 index 000000000..e32d08f2d --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qhttpheader.h @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QHTTP_H +#define QHTTP_H + +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Network) + +#ifndef QT_NO_HTTP + +class QTcpSocket; +class QTimerEvent; +class QIODevice; +class QAuthenticator; +class QNetworkProxy; +class QSslError; + +class QHttpPrivate; + +class QHttpHeaderPrivate; +class Q_NETWORK_EXPORT QHttpHeader +{ +public: + QHttpHeader(); + QHttpHeader(const QHttpHeader &header); + QHttpHeader(const QString &str); + virtual ~QHttpHeader(); + + QHttpHeader &operator=(const QHttpHeader &h); + + void setValue(const QString &key, const QString &value); + void setValues(const QList > &values); + void addValue(const QString &key, const QString &value); + QList > values() const; + bool hasKey(const QString &key) const; + QStringList keys() const; + QString value(const QString &key) const; + QStringList allValues(const QString &key) const; + void removeValue(const QString &key); + void removeAllValues(const QString &key); + + // ### Qt 5: change to qint64 + bool hasContentLength() const; + uint contentLength() const; + void setContentLength(int len); + + bool hasContentType() const; + QString contentType() const; + void setContentType(const QString &type); + + virtual QString toString() const; + bool isValid() const; + + virtual int majorVersion() const = 0; + virtual int minorVersion() const = 0; + +protected: + virtual bool parseLine(const QString &line, int number); + bool parse(const QString &str); + void setValid(bool); + + QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString()); + QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header); + QScopedPointer d_ptr; + +private: + Q_DECLARE_PRIVATE(QHttpHeader) +}; + +class QHttpResponseHeaderPrivate; +class Q_NETWORK_EXPORT QHttpResponseHeader : public QHttpHeader +{ +public: + QHttpResponseHeader(); + QHttpResponseHeader(const QHttpResponseHeader &header); + QHttpResponseHeader(const QString &str); + QHttpResponseHeader(int code, const QString &text = QString(), int majorVer = 1, int minorVer = 1); + QHttpResponseHeader &operator=(const QHttpResponseHeader &header); + + void setStatusLine(int code, const QString &text = QString(), int majorVer = 1, int minorVer = 1); + + int statusCode() const; + QString reasonPhrase() const; + + int majorVersion() const; + int minorVersion() const; + + QString toString() const; + +protected: + bool parseLine(const QString &line, int number); + +private: + Q_DECLARE_PRIVATE(QHttpResponseHeader) + friend class QHttpPrivate; +}; + +class QHttpRequestHeaderPrivate; +class Q_NETWORK_EXPORT QHttpRequestHeader : public QHttpHeader +{ +public: + QHttpRequestHeader(); + QHttpRequestHeader(const QString &method, const QString &path, int majorVer = 1, int minorVer = 1); + QHttpRequestHeader(const QHttpRequestHeader &header); + QHttpRequestHeader(const QString &str); + QHttpRequestHeader &operator=(const QHttpRequestHeader &header); + + void setRequest(const QString &method, const QString &path, int majorVer = 1, int minorVer = 1); + + QString method() const; + QString path() const; + + int majorVersion() const; + int minorVersion() const; + + QString toString() const; + +protected: + bool parseLine(const QString &line, int number); + +private: + Q_DECLARE_PRIVATE(QHttpRequestHeader) +}; + +#endif // QT_NO_HTTP + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QHTTP_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.cpp index 374ae8b8e..a3f362507 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtAbstractHttpConnector @@ -51,6 +57,7 @@ headers (by implementing writeHeaders(QIODevice*, const QHttpResponseHeader&)). #include #include #include +#include #ifndef QXT_DOXYGEN_RUN class QxtAbstractHttpConnectorPrivate : public QxtPrivate @@ -59,8 +66,8 @@ public: QxtHttpSessionManager* manager; QReadWriteLock bufferLock, requestLock; QHash buffers; // connection->buffer + QHash > contents; // connection->content QHash requests; // requestID->connection - QHash > dataSources; // iodevices providing result data quint32 nextRequestID; inline quint32 getNextRequestID(QIODevice* connection) @@ -76,11 +83,17 @@ public: return nextRequestID; } + inline void doneWithBuffer(QIODevice* device) + { + QWriteLocker locker(&bufferLock); + buffers.remove(device); + contents.remove(device); + } + inline void doneWithRequest(quint32 requestID) { QWriteLocker locker(&requestLock); requests.remove(requestID); - dataSources.remove(requestID); } inline QIODevice* getRequestConnection(quint32 requestID) @@ -88,18 +101,6 @@ public: QReadLocker locker(&requestLock); return requests[requestID]; } - - inline void setRequestDataSource( quint32 requestID, QSharedPointer& dataSource ) - { - QWriteLocker locker(&requestLock); - dataSources.insert( requestID, dataSource ); - } - - inline QSharedPointer& getRequestDataSource(quint32 requestID) - { - QReadLocker locker(&requestLock); - return dataSources[requestID]; - } }; #endif @@ -125,7 +126,7 @@ void QxtAbstractHttpConnector::setSessionManager(QxtHttpSessionManager* manager) /*! * Returns the session manager into which the connector is installed. * - * \sa QxtHttpSessionManager::setConnector + * \sa QxtHttpSessionManager::setConnector() */ QxtHttpSessionManager* QxtAbstractHttpConnector::sessionManager() const { @@ -143,21 +144,6 @@ QIODevice* QxtAbstractHttpConnector::getRequestConnection(quint32 requestID) return qxt_d().getRequestConnection(requestID); } -void QxtAbstractHttpConnector::setRequestDataSource( quint32 requestID, QSharedPointer& dataSource ) -{ - qxt_d().setRequestDataSource( requestID, dataSource ); -} - -QSharedPointer& QxtAbstractHttpConnector::getRequestDataSource(quint32 requestID) -{ - return qxt_d().getRequestDataSource( requestID ); -} - -void QxtAbstractHttpConnector::doneWithRequest(quint32 requestID) -{ - qxt_d().doneWithRequest( requestID ); -} - /*! * Starts managing a new connection from \a device. * @@ -166,6 +152,7 @@ void QxtAbstractHttpConnector::doneWithRequest(quint32 requestID) */ void QxtAbstractHttpConnector::addConnection(QIODevice* device) { + if(!device) return; QWriteLocker locker(&qxt_d().bufferLock); qxt_d().buffers[device] = QByteArray(); QObject::connect(device, SIGNAL(readyRead()), this, SLOT(incomingData())); @@ -184,25 +171,71 @@ void QxtAbstractHttpConnector::incomingData(QIODevice* device) device = qobject_cast(sender()); if (!device) return; } - QReadLocker locker(&qxt_d().bufferLock); - QByteArray& buffer = qxt_d().buffers[device]; - buffer.append(device->readAll()); - if (!canParseRequest(buffer)) return; - QHttpRequestHeader header = parseRequest(buffer); - QxtWebContent* content = 0; - QByteArray start; - if (header.contentLength() > 0) + // Scope things so we don't block access during incomingRequest() + QHttpRequestHeader header; + QxtWebContent *content = 0; { - start = buffer.left(header.value("content-length").toInt()); - buffer = buffer.mid(header.value("content-length").toInt()); - content = new QxtWebContent(header.contentLength(), start, device); + // Fetch the incoming data block + QByteArray block = device->readAll(); + // Check for a current content "device" + QReadLocker locker(&qxt_d().bufferLock); + content = qxt_d().contents[device]; + if(content && (content->wantAll() || content->bytesNeeded() > 0)){ + // This block (or part of it) belongs to content device + qint64 needed = block.size(); + if(!content->wantAll() && needed > content->bytesNeeded()) + needed = content->bytesNeeded(); + content->write(block.constData(), needed); + if(block.size() <= needed) + return; // Used it all ... + block.remove(0, needed); + } + // The data received represents a new request (or start thereof) + qxt_d().contents[device] = content = NULL; + QByteArray& buffer = qxt_d().buffers[device]; + buffer.append(block); + if (!canParseRequest(buffer)) return; + // Have received all of the headers so we can start processing + header = parseRequest(buffer); + QByteArray start; + int len = header.hasContentLength() ? int(header.contentLength()) : -1; + if(len > 0) + { + if(len <= buffer.size()){ + // This request is fully-received & excess is another request + // Leave in buffer & we'll fake a following "readyRead()" + start = buffer.left(len); + buffer = buffer.mid(len); + content = new QxtWebContent(start, this); + if(buffer.size() > 0) + QMetaObject::invokeMethod(this, "incomingData", + Qt::QueuedConnection, Q_ARG(QIODevice*, device)); + } + else{ + // This request isn't finished yet but may still have one to + // follow it. Remember the content device so we can append to + // it until we've got it all. + start = buffer; + buffer.clear(); + qxt_d().contents[device] = content = + new QxtWebContent(len, start, this, device); + } + } + else if (header.hasKey("connection") && header.value("connection").toLower() == "close") + { + // Not pipelining so we want to pass all remaining data to the + // content device. Although 'len' will be -1, we're using an + // explict value for clarity. This causes the content device + // to indicate it wants all remaining data. + start = buffer; + buffer.clear(); + qxt_d().contents[device] = content = + new QxtWebContent(-1, start, this, device); + } // else no content + // + // NOTE: Buffer lock goes out of scope after this point } - else if (header.hasKey("connection") && header.value("connection").toLower() == "close") - { - start = buffer; - buffer.clear(); - content = new QxtWebContent(header.contentLength(), start, device); - } // else no content + // Allocate request ID and process it quint32 requestID = qxt_d().getNextRequestID(device); sessionManager()->incomingRequest(requestID, header, content); } @@ -212,23 +245,54 @@ void QxtAbstractHttpConnector::incomingData(QIODevice* device) */ void QxtAbstractHttpConnector::disconnected() { + quint32 requestID=0; QIODevice* device = qobject_cast(sender()); if (!device) return; - QWriteLocker locker(&qxt_d().bufferLock); - qxt_d().buffers.remove(device); + + requestID = qxt_d().requests.key(device); + qxt_d().doneWithRequest(requestID); + qxt_d().doneWithBuffer(device); sessionManager()->disconnected(device); } +/*! + * Returns the current local server port assigned during binding. This will + * be 0 if the connector isn't currently bound or when a port number isn't + * applicable to the connector in use. + * + * \sa listen() + */ +quint16 QxtAbstractHttpConnector::serverPort() const +{ + return 0; +} + /*! * \fn virtual bool QxtAbstractHttpConnector::listen(const QHostAddress& interface, quint16 port) * Invoked by the session manager to indicate that the connector should listen * for incoming connections on the specified \a interface and \a port. * - * If the interface is QHostAddress::Any, the server will listen on all network interfaces. + * If the interface is QHostAddress::Any, the server will listen on all + * network interfaces. + * If the port is explicitly set to 0, the underlying network subsystem will + * assign a port in the dynamic range. In this case, the resulting port number + * may be obtained using the serverPort() method. * * Returns true on success, or false if the server could not begin listening. * - * \sa addConnection(QIODevice*) + * \sa addConnection(), shutdown() + */ + +/*! + * \fn virtual bool QxtAbstractHttpConnector::shutdown() + * Invoked by the session manager to indicate that the connector should close + * it's listener port and stop accepting new connections. A shutdown may be + * followed by a new listen (to switch ports or handle a change in the + * machine's IP address). + * + * Returns true on success, or false if the server wasn't listening. + * + * \sa listen() */ /*! diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.h index 78aa1fb9b..33ee3c3c2 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstracthttpconnector.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTABSTRACTHTTPCONNECTOR_H #define QXTABSTRACTHTTPCONNECTOR_H @@ -29,11 +35,12 @@ #include "qxtglobal.h" #include #include -#include -#include +#include "qhttpheader.h" QT_FORWARD_DECLARE_CLASS(QIODevice) +QT_FORWARD_DECLARE_CLASS(QTcpServer) class QxtHttpSessionManager; +class QxtSslServer; class QxtAbstractHttpConnectorPrivate; class QXT_WEB_EXPORT QxtAbstractHttpConnector : public QObject @@ -43,15 +50,14 @@ class QXT_WEB_EXPORT QxtAbstractHttpConnector : public QObject public: QxtAbstractHttpConnector(QObject* parent = 0); virtual bool listen(const QHostAddress& iface, quint16 port) = 0; + virtual bool shutdown() = 0; + virtual quint16 serverPort() const; protected: QxtHttpSessionManager* sessionManager() const; void addConnection(QIODevice* device); QIODevice* getRequestConnection(quint32 requestID); - void setRequestDataSource( quint32 requestID, QSharedPointer& dataSource ); - QSharedPointer& getRequestDataSource(quint32 requestID); - void doneWithRequest(quint32 requestID); virtual bool canParseRequest(const QByteArray& buffer) = 0; virtual QHttpRequestHeader parseRequest(QByteArray& buffer) = 0; virtual void writeHeaders(QIODevice* device, const QHttpResponseHeader& header) = 0; @@ -70,8 +76,12 @@ class QXT_WEB_EXPORT QxtHttpServerConnector : public QxtAbstractHttpConnector { Q_OBJECT public: - QxtHttpServerConnector(QObject* parent = 0); - virtual bool listen(const QHostAddress& iface, quint16 port); + QxtHttpServerConnector(QObject* parent = 0, QTcpServer* server = 0); + virtual bool listen(const QHostAddress& iface, quint16 port = 80); + virtual bool shutdown(); + virtual quint16 serverPort() const; + + QTcpServer* tcpServer() const; protected: virtual bool canParseRequest(const QByteArray& buffer); @@ -85,6 +95,22 @@ private: QXT_DECLARE_PRIVATE(QxtHttpServerConnector) }; +#ifndef QT_NO_OPENSSL +class QXT_WEB_EXPORT QxtHttpsServerConnector : public QxtHttpServerConnector +{ + Q_OBJECT +public: + QxtHttpsServerConnector(QObject* parent = 0); + virtual bool listen(const QHostAddress& iface, quint16 port = 443); + + QxtSslServer* tcpServer() const; + +protected Q_SLOTS: + virtual void peerVerifyError(const QSslError &error); + virtual void sslErrors(const QList &errors); +}; +#endif + class QxtScgiServerConnectorPrivate; class QXT_WEB_EXPORT QxtScgiServerConnector : public QxtAbstractHttpConnector { @@ -92,6 +118,8 @@ class QXT_WEB_EXPORT QxtScgiServerConnector : public QxtAbstractHttpConnector public: QxtScgiServerConnector(QObject* parent = 0); virtual bool listen(const QHostAddress& iface, quint16 port); + virtual bool shutdown(); + virtual quint16 serverPort() const; protected: virtual bool canParseRequest(const QByteArray& buffer); @@ -112,6 +140,7 @@ Q_OBJECT public: QxtFcgiConnector(QObject* parent = 0); virtual bool listen(const QHostAddress& iface, quint16 port); + virtual bool shutdown(); private: QXT_DECLARE_PRIVATE(QxtFcgiConnector) diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.cpp index ae64e3067..c17a74cc3 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtAbstractWebService @@ -108,14 +114,16 @@ QxtAbstractWebSessionManager* QxtAbstractWebService::sessionManager() const /*! * \fn virtual void QxtAbstractWebService::pageRequestedEvent(QxtWebRequestEvent* event) - * This \a event handler must be reimplemented in subclasses to receive page - * request events. + * This event handler must be reimplemented in subclasses to receive page + * request events. The supplied \a event object is owned by the session + * manager and remains valid until a corresponding response has been + * processed. It must never be deleted by a service handler. * * Every page request event received MUST be responded to with a QxtWebPageEvent * or a QxtWebPageEvent subclass. This response does not have to be posted * during the execution of this function, to support asynchronous design, but * failure to post an event will cause the web browser making the request to - * wait until it times out. + * wait until it times out and leak memory from pending event objects. * * \sa QxtWebRequestEvent */ diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.h index 98497819c..bc1b7c7cb 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebservice.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTABSTRACTWEBSERVICE_H #define QXTABSTRACTWEBSERVICE_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.cpp index 260b63ab1..31ab04aaa 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtAbstractWebSessionManager @@ -77,6 +83,7 @@ void QxtAbstractWebSessionManagerPrivate::sessionDestroyed(int sessionID) { freeList.enqueue(sessionID); sessions.remove(sessionID); + qxt_p().sessionDestroyed(sessionID); } } @@ -121,7 +128,7 @@ void QxtAbstractWebSessionManager::setServiceFactory(ServiceFactory* factory) /*! * Returns the service factory in use by the session manager. * - * \sa setServiceFactory(ServiceFactory*) + * \sa setServiceFactory() */ QxtAbstractWebSessionManager::ServiceFactory* QxtAbstractWebSessionManager::serviceFactory() const { @@ -156,6 +163,19 @@ int QxtAbstractWebSessionManager::createService() return sessionID; // you can always get the service with this } +/*! + * Notification that a service has been destroyed. The \a sessionID contains + * the session ID# which has already been deallocated. + * + * Derived classes should reimplement this method to perform any housekeeping + * chores needed when a service is removed (such as expiring session cookies). + * + * This default implementation does nothing at all. + */ +void QxtAbstractWebSessionManager::sessionDestroyed(int) +{ +} + /*! * \fn virtual bool QxtAbstractWebSessionManager::start() * Starts the session manager. @@ -163,11 +183,27 @@ int QxtAbstractWebSessionManager::createService() * Session managers should not create sessions before start() is invoked. * Subclasses are encouraged to refrain from accepting connections until the * session manager is started. + * + * Returns true if the session was successfully started and false otherwise. + */ + +/*! + * \fn virtual bool QxtAbstractWebSessionManager::shutdown() + * Stops the session manager. + * + * This method stops listening for new connections. Any active connections + * remain viable. It is permissible to start() the session again after a + * successful shutdown (to change ports for example). + * + * Returns true if the session was active (successfully shut down) and false + * otherwise. This may be connected to an application's aboutToQuit() signal + * but doing so is not likely to allow any currently processing requests to + * complete. */ /*! * \fn virtual void QxtAbstractWebSessionManager::postEvent(QxtWebEvent* event) - * Adds the event to the event queue for its associated session. + * Adds the \a event to the event queue for its associated session. * * Since different protocols may require different event processing behavior, * there is no default implementation in QxtAbstractWebSessionManager. Subclasses diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.h index 8f040376a..15ba9cb80 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTABSTRACTWEBSESSIONMANAGER_H #define QXTABSTRACTWEBSESSIONMANAGER_H @@ -47,8 +53,12 @@ public: QxtAbstractWebService* session(int sessionID) const; +public Q_SLOTS: + virtual bool shutdown() = 0; + protected: int createService(); + virtual void sessionDestroyed(int sessionID); protected Q_SLOTS: virtual void processEvents() = 0; diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager_p.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager_p.h index b285e26da..7db08429c 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager_p.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtabstractwebsessionmanager_p.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTABSTRACTWEBSESSIONMANAGER_P_H #define QXTABSTRACTWEBSESSIONMANAGER_P_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundcfunction.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundcfunction.h index 3e49142dc..ac6fd7049 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundcfunction.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundcfunction.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTBOUNDCFUNCTION_H #define QXTBOUNDCFUNCTION_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunction.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunction.h index f2255c419..bcd07c502 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunction.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunction.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTBOUNDFUNCTION_H #define QXTBOUNDFUNCTION_H @@ -81,6 +87,10 @@ class QXT_CORE_EXPORT QxtBoundFunction : public QObject { Q_OBJECT public: +#ifndef QXT_DOXYGEN_RUN + virtual ~QxtBoundFunction() {}; +#endif + /*! * Invokes the bound function and returns a value. * diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunctionbase.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunctionbase.h index 47da5f1d9..a78b5ed10 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunctionbase.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtboundfunctionbase.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ // This file exists for the convenience of QxtBoundCFunction. // It is not part of the public API and is subject to change. diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.cpp new file mode 100644 index 000000000..2aeb866a2 --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.cpp @@ -0,0 +1,272 @@ + +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +/*! +\class QxtFifo + +\inmodule QxtCore + +\brief The QxtFifo class provides a simple loopback QIODevice. + +read and write to the same object +emits a readyRead Signal. +useful for loopback tests where QBuffer does not work. + +\code +QxtFifo fifo; + QTextStream (&fifo)<>a; + qDebug()< +#include +#include +#include + +#include + +#if QT_VERSION >= 0x50000 +# define QXT_EXCHANGE(x) fetchAndStoreOrdered(x) +# define QXT_EXCHANGE_(x) fetchAndStoreOrdered(x.load()) +# define QXT_ADD fetchAndAddOrdered +#elif QT_VERSION >= 0x040400 +# include +# define QXT_EXCHANGE fetchAndStoreOrdered +# define QXT_EXCHANGE_ QXT_EXCHANGE +# define QXT_ADD fetchAndAddOrdered +#else + typedef QBasicAtomic QBasicAtomicInt; +# define QXT_EXCHANGE exchange +# define QXT_EXCHANGE_ QXT_EXCHANGE +# define QXT_ADD fetchAndAdd +#endif + +struct QxtFifoNode { + QxtFifoNode(const char* data, int size) : content(data, size) { +#if QT_VERSION >= 0x50000 + next.store(0); +#else + next = NULL; +#endif + } + QxtFifoNode(const QByteArray &data) : content(data) { +#if QT_VERSION >= 0x50000 + next.store(0); +#else + next = NULL; +#endif + } + + QByteArray content; + QBasicAtomicPointer next; +}; + +class QxtFifoPrivate : public QxtPrivate { +public: + QXT_DECLARE_PUBLIC(QxtFifo) + QxtFifoPrivate() { + QxtFifoNode *n = new QxtFifoNode(NULL, 0); +#if QT_VERSION >= 0x50000 + head.store(n); + tail.store(n); +#else + head = n; + tail = n; +#endif + +#if QT_VERSION >= 0x50000 + available.store(0); +#else + available = 0; +#endif + } + + QBasicAtomicPointer head, tail; + QBasicAtomicInt available; +}; + +/*! +Constructs a new QxtFifo with \a parent. +*/ +QxtFifo::QxtFifo(QObject *parent) : QIODevice(parent) +{ + QXT_INIT_PRIVATE(QxtFifo); + setOpenMode(QIODevice::ReadWrite); +} + +/*! +Constructs a new QxtFifo with \a parent and initial content from \a prime. +*/ +QxtFifo::QxtFifo(const QByteArray &prime, QObject *parent) : QIODevice(parent) +{ + QXT_INIT_PRIVATE(QxtFifo); + setOpenMode(QIODevice::ReadWrite); + // Since we're being constructed, access to the internals is safe + + QxtFifoNode *head; + int available; +#if QT_VERSION >= 0x50000 + head = qxt_d().head.load(); + available = qxt_d().available.load(); +#else + head = qxt_d().head; + available = qxt_d().available; +#endif + +} + +/*! +\reimp +*/ +qint64 QxtFifo::readData ( char * data, qint64 maxSize ) +{ + int bytes, step; +#if QT_VERSION >= 0x50000 + bytes = qxt_d().available.load(); +#else + bytes = qxt_d().available; +#endif + + + if(!bytes) return 0; + if(bytes > maxSize) bytes = maxSize; + int written = bytes; + char* writePos = data; + QxtFifoNode* node; + while(bytes > 0) { + +#if QT_VERSION >= 0x50000 + node = qxt_d().head.load(); +#else + node = qxt_d().head; +#endif + + step = node->content.size(); + if(step >= bytes) { + int rem = step - bytes; + memcpy(writePos, node->content.constData(), bytes); + step = bytes; + node->content = node->content.right(rem); + } else { + memcpy(writePos, node->content.constData(), step); + qxt_d().head.QXT_EXCHANGE_(node->next); + delete node; +#if QT_VERSION >= 0x50000 + node = qxt_d().head.load(); +#else + node = qxt_d().head; +#endif + } + writePos += step; + bytes -= step; + } + qxt_d().available.QXT_ADD(-written); + return written; +} + +/*! +\reimp +*/ +qint64 QxtFifo::writeData ( const char * data, qint64 maxSize ) +{ + if(maxSize > 0) { + if(maxSize > INT_MAX) maxSize = INT_MAX; // qint64 could easily exceed QAtomicInt, so let's play it safe + QxtFifoNode* newData = new QxtFifoNode(data, maxSize); +#if QT_VERSION >= 0x50000 + qxt_d().tail.load()->next.QXT_EXCHANGE(newData); +#else + qxt_d().tail->next.QXT_EXCHANGE(newData); +#endif + qxt_d().tail.QXT_EXCHANGE(newData); + qxt_d().available.QXT_ADD(maxSize); + QMetaObject::invokeMethod(this, "bytesWritten", Qt::QueuedConnection, Q_ARG(qint64, maxSize)); + QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); + } + return maxSize; +} + +/*! +\reimp +*/ +bool QxtFifo::isSequential () const +{ + return true; +} + +/*! +\reimp +*/ +qint64 QxtFifo::bytesAvailable () const +{ +#if QT_VERSION >= 0x50000 + return qxt_d().available.load() + QIODevice::bytesAvailable(); +#else + return qxt_d().available + QIODevice::bytesAvailable(); + +#endif +} + +/*! +*/ +void QxtFifo::clear() +{ + qxt_d().available.QXT_EXCHANGE(0); + qxt_d().tail.QXT_EXCHANGE_(qxt_d().head); + +#if QT_VERSION >= 0x50000 + QxtFifoNode* node = qxt_d().head.load()->next.QXT_EXCHANGE(NULL); +#else + QxtFifoNode* node = qxt_d().head->next.QXT_EXCHANGE(NULL); +#endif + +#if QT_VERSION >= 0x50000 + while (node && node->next.load()) +#else + while (node && node->next) +#endif + { + QxtFifoNode* next = node->next.QXT_EXCHANGE(NULL); + delete node; + node = next; + } +#if QT_VERSION >= 0x50000 + qxt_d().head.load()->content = QByteArray(); +#else + qxt_d().head->content = QByteArray(); +#endif +} diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.h new file mode 100644 index 000000000..01ae76bd0 --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtfifo.h @@ -0,0 +1,57 @@ + +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#ifndef QXTFIFO_H +#define QXTFIFO_H +#include "qxtglobal.h" +#include + +class QxtFifoPrivate; +class QXT_CORE_EXPORT QxtFifo : public QIODevice +{ + Q_OBJECT +public: + QxtFifo(QObject * parent = 0); + virtual bool isSequential() const; + virtual qint64 bytesAvailable() const; + + void clear(); + +protected: + explicit QxtFifo(const QByteArray &prime, QObject * parent = 0); + virtual qint64 readData(char * data, qint64 maxSize); + virtual qint64 writeData(const char * data, qint64 maxSize); + +private: + QXT_DECLARE_PRIVATE(QxtFifo) +}; + +#endif // QXTFIFO_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.cpp index fe7b9e782..3da47c146 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #include "qxtglobal.h" @@ -74,7 +80,7 @@ \sa QXT_VERSION_STR */ -const char* qxtVersion() +const char * qxtVersion() { return QXT_VERSION_STR; } @@ -170,13 +176,14 @@ void MyTestPrivate::doQuux() { * \relates * Declares that a public class has a related private class. * - * This shuold be put in the private section of the public class. The parameter is the name of the public class. + * This shuold be put in the private section of the public class. The + * parameter \a PUB must be the name of the public class. */ /*! * \macro QXT_DECLARE_PUBLIC(PUB) * \relates - * Declares that a private class has a related public class. + * Declares that a private class has a related public class named \a PUB. * * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. */ @@ -187,23 +194,26 @@ void MyTestPrivate::doQuux() { * Initializes resources owned by the private class. * * This should be called from the public class's constructor, - * before qxt_d() is used for the first time. The parameter is the name of the public class. + * before qxt_d() is used for the first time. The parameter \a PUB must be + * the name of the public class. */ /*! * \macro QXT_D(PUB) * \relates - * Returns a reference in the current scope named "d" to the private class. + * Returns a reference in the current scope named "d" to the private class + * associated with the public class \a PUB. * - * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + * This function is only available in a class using QXT_DECLARE_PRIVATE(). */ /*! * \macro QXT_P(PUB) * \relates - * Creates a reference in the current scope named "q" to the public class. + * Creates a reference in the current scope named "q" to the public class + * named \a PUB. * - * This macro only works in a class using \a QXT_DECLARE_PUBLIC. + * This macro only works in a class using QXT_DECLARE_PUBLIC(). */ /*! @@ -228,7 +238,7 @@ void MyTestPrivate::doQuux() { * \relates * Returns a reference to the public class. * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This function is only available in a class using QXT_DECLARE_PUBLIC(). */ /*! @@ -236,6 +246,6 @@ void MyTestPrivate::doQuux() { * \relates * Returns a const reference to the public class. * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This function is only available in a class using QXT_DECLARE_PUBLIC(). * This overload will be automatically used in const functions. */ diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.h index 575372dcd..7d5abfbe0 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.h @@ -1,47 +1,57 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTGLOBAL_H #define QXTGLOBAL_H #include -#define QXT_VERSION 0x000600 -#define QXT_VERSION_STR "0.6.0" +#define QXT_VERSION 0x000700 +#define QXT_VERSION_STR "0.7.0" //--------------------------global macros------------------------------ #ifndef QXT_NO_MACROS +#ifndef _countof +#define _countof(x) (sizeof(x)/sizeof(*x)) +#endif + #endif // QXT_NO_MACROS //--------------------------export macros------------------------------ #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_CORE) # define QXT_CORE_EXPORT Q_DECL_EXPORT # else @@ -51,7 +61,7 @@ # define QXT_CORE_EXPORT #endif // BUILD_QXT_CORE -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_GUI) # define QXT_GUI_EXPORT Q_DECL_EXPORT # else @@ -61,7 +71,7 @@ # define QXT_GUI_EXPORT #endif // BUILD_QXT_GUI -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_NETWORK) # define QXT_NETWORK_EXPORT Q_DECL_EXPORT # else @@ -71,7 +81,7 @@ # define QXT_NETWORK_EXPORT #endif // BUILD_QXT_NETWORK -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_SQL) # define QXT_SQL_EXPORT Q_DECL_EXPORT # else @@ -81,7 +91,7 @@ # define QXT_SQL_EXPORT #endif // BUILD_QXT_SQL -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_WEB) # define QXT_WEB_EXPORT Q_DECL_EXPORT # else @@ -91,7 +101,7 @@ # define QXT_WEB_EXPORT #endif // BUILD_QXT_WEB -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_BERKELEY) # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT # else @@ -101,7 +111,7 @@ # define QXT_BERKELEY_EXPORT #endif // BUILD_QXT_BERKELEY -#if !defined(QXT_STATIC) +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) # if defined(BUILD_QXT_ZEROCONF) # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT # else @@ -111,7 +121,7 @@ # define QXT_ZEROCONF_EXPORT #endif // QXT_ZEROCONF_EXPORT -#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF +#if defined(BUILD_QXT_CORE) || defined(BUILD_QXT_GUI) || defined(BUILD_QXT_SQL) || defined(BUILD_QXT_NETWORK) || defined(BUILD_QXT_WEB) || defined(BUILD_QXT_BERKELEY) || defined(BUILD_QXT_ZEROCONF) # define BUILD_QXT #endif @@ -167,6 +177,14 @@ protected: { return *qxt_p_ptr; } + inline PUB* qxt_ptr() + { + return qxt_p_ptr; + } + inline const PUB* qxt_ptr() const + { + return qxt_p_ptr; + } private: PUB* qxt_p_ptr; @@ -198,6 +216,14 @@ public: { return *static_cast(pvt); } + inline PVT * operator->() + { + return static_cast(pvt); + } + inline const PVT * operator->() const + { + return static_cast(pvt); + } private: QxtPrivateInterface(const QxtPrivateInterface&) { } QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.cpp index c8ded5081..fba49feaa 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtHtmlTemplate diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.h index 02a33eca2..daafa49c1 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthtmltemplate.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTHTMLTEMPLATE_H #define QXTHTMLTEMPLATE_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpserverconnector.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpserverconnector.cpp index 910ee3789..270e840e9 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpserverconnector.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpserverconnector.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtHttpServerConnector @@ -41,8 +47,32 @@ high traffic scenarios or virtual hosting configurations. \sa QxtHttpSessionManager */ + +/*! +\class QxtHttpsServerConnector + +\inmodule QxtWeb + +\brief The QxtHttpsServerConnector class provides a built-in HTTPS server for QxtHttpSessionManager + +QxtHttpSessionManager does the work of managing sessions and state for the +otherwise stateless HTTP protocol, but it relies on QxtAbstractHttpConnector +subclasses to implement the protocol used to communicate with the web server. + +QxtHttpsServerConnector is a convenience subclass of QxtHttpServerConnector +that adds HTTPS handling to the internal web server by delegating the +incoming connection handling to QxtSslServer. + +QxtHttpsServerConnector is only available if Qt was compiled with OpenSSL support. + +\sa QxtHttpSessionManager +\sa QxtHttpServerConnector +\sa QxtSslServer +*/ + #include "qxthttpsessionmanager.h" #include "qxtwebevent.h" +#include "qxtsslserver.h" #include #include #include @@ -57,12 +87,19 @@ public: #endif /*! - * Creates a QxtHttpServerConnector with the given \a parent. + * Creates a QxtHttpServerConnector with the given \a parent and \a server. + * + * You may pass a QTcpServer subclass to the \a server parameter to enable customized behaviors, for + * instance to use QSslSocket like QxtHttpsServerConnector does. Pass 0 (the default) to \a server + * to allow QxtHttpServerConnector to create its own QTcpServer. */ -QxtHttpServerConnector::QxtHttpServerConnector(QObject* parent) : QxtAbstractHttpConnector(parent) +QxtHttpServerConnector::QxtHttpServerConnector(QObject* parent, QTcpServer* server) : QxtAbstractHttpConnector(parent) { QXT_INIT_PRIVATE(QxtHttpServerConnector); - qxt_d().server = new QTcpServer(this); + if(server) + qxt_d().server = server; + else + qxt_d().server = new QTcpServer(this); QObject::connect(qxt_d().server, SIGNAL(newConnection()), this, SLOT(acceptConnection())); } @@ -74,6 +111,36 @@ bool QxtHttpServerConnector::listen(const QHostAddress& iface, quint16 port) return qxt_d().server->listen(iface, port); } +/*! + * \reimp + */ +bool QxtHttpServerConnector::shutdown() +{ + if(qxt_d().server->isListening()){ + qxt_d().server->close(); + return true; + } + return false; +} + +/*! + * \reimp + */ +quint16 QxtHttpServerConnector::serverPort() const +{ + return qxt_d().server->serverPort(); +} + +/*! + * Returns the QTcpServer used by this QxtHttpServerConnector. Use this pointer + * to adjust the maxPendingConnections or QNetworkProxy properties of the + * server. + */ +QTcpServer* QxtHttpServerConnector::tcpServer() const +{ + return qxt_d().server; +} + /*! * \internal */ @@ -123,3 +190,54 @@ void QxtHttpServerConnector::writeHeaders(QIODevice* device, const QHttpResponse if (header.majorVersion() == 0) return; // 0.9 doesn't have headers device->write(header.toString().toUtf8()); } + +#ifndef QT_NO_OPENSSL +/*! + * Creates a QxtHttpsServerConnector with the given \a parent. + */ +QxtHttpsServerConnector::QxtHttpsServerConnector(QObject* parent) +: QxtHttpServerConnector(parent, new QxtSslServer) +{ + // initializers only + // Reparent the SSL server + tcpServer()->setParent(this); +} + +/*! + * \reimp + */ +bool QxtHttpsServerConnector::listen(const QHostAddress& iface, quint16 port) +{ + return QxtHttpServerConnector::listen(iface, port); +} + +/*! + * Returns the QxtSslServer used by this QxtHttpsServerConnector. Use this + * pointer to adjust the maxPendingConnections or QNetworkProxy properties of the + * server or the SSL properties assigned to incoming connections. + */ +QxtSslServer* QxtHttpsServerConnector::tcpServer() const +{ + return static_cast(QxtHttpServerConnector::tcpServer()); +} + +/*! + * Handles peer verification errors during SSL negotiation. This method may + * be overridden to tear-down the connection. + */ +void QxtHttpsServerConnector::peerVerifyError(const QSslError &error) +{ + qWarning() << "QxtHttpsServerConnector::peerVerifyError(): " << error.errorString(); +} + +/*! + * Handles errors with SSL negotiation. This method may be overridden to + * examine the errors and take appropriate action. The default behavior + * is to terminate the connection (ie: ignoreSslErrors() is NOT called). + */ +void QxtHttpsServerConnector::sslErrors(const QList &errors) +{ + for(int i = 0; i < errors.size(); ++i) + qWarning() << "QxtHttpsServerConnector::sslErrors(): " << errors.at(i).errorString(); +} +#endif /* QT_NO_OPENSSL */ diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.cpp index e02ba562a..f74d31a89 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtHttpSessionManager @@ -44,7 +50,7 @@ service, even one that only returns a more useful error message. QxtHttpSessionManager attempts to be thread-safe in accepting connections and posting events. It is reentrant for all other functionality. -\sa QxtAbstractWebService +\sa class QxtAbstractWebService */ #include "qxthttpsessionmanager.h" @@ -62,6 +68,9 @@ posting events. It is reentrant for all other functionality. #include #include #include +#ifndef QT_NO_OPENSSL +#include +#endif #ifndef QXT_DOXYGEN_RUN class QxtHttpSessionManagerPrivate : public QxtPrivate @@ -69,7 +78,7 @@ class QxtHttpSessionManagerPrivate : public QxtPrivate public: struct ConnectionState { - QxtBoundFunction* onBytesWritten; + QxtBoundFunction *onBytesWritten, *onReadyRead, *onAboutToClose; bool readyRead; bool finishedTransfer; bool keepAlive; @@ -77,6 +86,13 @@ public: int httpMajorVersion; int httpMinorVersion; int sessionID; + + void clearHandlers() { + delete onBytesWritten; + delete onReadyRead; + delete onAboutToClose; + onBytesWritten = onReadyRead = onAboutToClose = 0; + } }; QxtHttpSessionManagerPrivate() : iface(QHostAddress::Any), port(80), sessionCookieName("sessionID"), connector(0), staticService(0), autoCreateSession(true), @@ -92,6 +108,7 @@ public: QMutex eventLock; QList eventQueue; + QHash, QxtWebRequestEvent*> pendingRequests; QMutex sessionLock; QHash sessionKeys; // sessionKey->sessionID @@ -112,12 +129,12 @@ QxtHttpSessionManager::QxtHttpSessionManager(QObject* parent) : QxtAbstractWebSe /*! * Returns the interface on which the session manager will listen for incoming connections. - * \sa setInterface + * \sa setListenInterface() */ QHostAddress QxtHttpSessionManager::listenInterface() const - { - return qxt_d().iface; - } +{ + return qxt_d().iface; +} /*! * Sets the interface \a iface on which the session manager will listen for incoming @@ -126,7 +143,7 @@ QHostAddress QxtHttpSessionManager::listenInterface() const * The default value is QHostAddress::Any, which will cause the session manager * to listen on all network interfaces. * - * \sa QxtAbstractHttpConnector::listen + * \sa QxtAbstractHttpConnector::listen() */ void QxtHttpSessionManager::setListenInterface(const QHostAddress& iface) { @@ -134,8 +151,11 @@ void QxtHttpSessionManager::setListenInterface(const QHostAddress& iface) } /*! - * Returns the port on which the session manager will listen for incoming connections. - * \sa setInterface + * Returns the port on which the session manager is expected to listen for + * incoming connections. This is always whatever value was supplied in the + * last setPort() and not neccessarily the port number actually being + * used. + * \sa setPort(), serverPort() */ quint16 QxtHttpSessionManager::port() const { @@ -143,19 +163,39 @@ quint16 QxtHttpSessionManager::port() const } /*! - * Sets the \a port on which the session manager will listen for incoming connections. + * Sets the \a port on which the session manager should listen for incoming + * connections. * * The default value is to listen on port 80. This is an acceptable value when * using QxtHttpServerConnector, but it is not likely to be desirable for other - * connectors. + * connectors. You may also use 0 to allow the network layer to dynamically + * assign a port number. In this case, the serverPort() method will + * return the actual port assigned once the session has been successfully + * started. * - * \sa port + * \note Setting the port number after the session has been started will + * have no effect unless it is shutdown and started again. + * + * \sa port(), serverPort() */ void QxtHttpSessionManager::setPort(quint16 port) { qxt_d().port = port; } +/*! + * Returns the port on which the session manager is listening for incoming + * connections. This will be 0 if the session manager has not been started + * or was shutdown. + * \sa setInterface(), setPort() + */ +quint16 QxtHttpSessionManager::serverPort() const +{ + if(qxt_d().connector) + return connector()->serverPort(); + return 0; +} + /*! * \reimp */ @@ -165,9 +205,18 @@ bool QxtHttpSessionManager::start() return connector()->listen(listenInterface(), port()); } +/*! + * \reimp + */ +bool QxtHttpSessionManager::shutdown() +{ + Q_ASSERT(qxt_d().connector); + return connector()->shutdown(); +} + /*! * Returns the name of the HTTP cookie used to track sessions in the web browser. - * \sa setSessionCookieName + * \sa setSessionCookieName() */ QByteArray QxtHttpSessionManager::sessionCookieName() const { @@ -175,11 +224,12 @@ QByteArray QxtHttpSessionManager::sessionCookieName() const } /*! - * Sets the \a name of the HTTP cookie used to track sessions in the web browser. + * Sets the \a name of the HTTP cookie used to track sessions in the web + * browser. * * The default value is "sessionID". * - * \sa sessionCookieName + * \sa sessionCookieName() */ void QxtHttpSessionManager::setSessionCookieName(const QByteArray& name) { @@ -189,7 +239,7 @@ void QxtHttpSessionManager::setSessionCookieName(const QByteArray& name) /*! * Sets the \a connector used to manage connections to web browsers. * - * \sa connector + * \sa connector() */ void QxtHttpSessionManager::setConnector(QxtAbstractHttpConnector* connector) { @@ -203,7 +253,7 @@ void QxtHttpSessionManager::setConnector(QxtAbstractHttpConnector* connector) * This overload is provided for convenience and can construct the predefined * connectors provided with Qxt. * - * \sa connector + * \sa connector() */ void QxtHttpSessionManager::setConnector(Connector connector) { @@ -220,7 +270,7 @@ void QxtHttpSessionManager::setConnector(Connector connector) /*! * Returns the connector used to manage connections to web browsers. - * \sa setConnector + * \sa setConnector() */ QxtAbstractHttpConnector* QxtHttpSessionManager::connector() const { @@ -231,7 +281,7 @@ QxtAbstractHttpConnector* QxtHttpSessionManager::connector() const * Returns \c true if sessions are automatically created for every connection * that does not already have a session cookie associated with it; otherwise * returns \c false. - * \sa setAutoCreateSession + * \sa setAutoCreateSession() */ bool QxtHttpSessionManager::autoCreateSession() const { @@ -245,7 +295,7 @@ bool QxtHttpSessionManager::autoCreateSession() const * Sessions are only created for clients that support HTTP cookies. HTTP/0.9 * clients will never generate a session. * - * \sa autoCreateSession + * \sa autoCreateSession() */ void QxtHttpSessionManager::setAutoCreateSession(bool enable) { @@ -256,7 +306,7 @@ void QxtHttpSessionManager::setAutoCreateSession(bool enable) * Returns the QxtAbstractWebService that is used to respond to requests from * connections that are not associated with a session. * - * \sa setStaticContentService + * \sa setStaticContentService() */ QxtAbstractWebService* QxtHttpSessionManager::staticContentService() const { @@ -270,7 +320,7 @@ QxtAbstractWebService* QxtHttpSessionManager::staticContentService() const * If no static content service is set, connections that are not associated * with a session will receive an "Internal Configuration Error". * - * \sa staticContentService + * \sa staticContentService() */ void QxtHttpSessionManager::setStaticContentService(QxtAbstractWebService* service) { @@ -289,6 +339,19 @@ void QxtHttpSessionManager::postEvent(QxtWebEvent* h) QMetaObject::invokeMethod(this, "processEvents", Qt::QueuedConnection); } +/*! + * This method removes the session cookie value corresponding to a deleted + * service. + */ +void QxtHttpSessionManager::sessionDestroyed(int sessionID) +{ + QMutexLocker locker(&qxt_d().sessionLock); + QUuid key = qxt_d().sessionKeys.key(sessionID); +// qDebug() << Q_FUNC_INFO << "sessionID" << sessionID << "key" << key; + if(!key.isNull()) + qxt_d().sessionKeys.remove(key); +} + /*! * Creates a new session and sends the session key to the web browser. * @@ -307,7 +370,7 @@ int QxtHttpSessionManager::newSession() } while (qxt_d().sessionKeys.contains(key)); qxt_d().sessionKeys[key] = sessionID; - postEvent(new QxtWebStoreCookieEvent(sessionID, qxt_d().sessionCookieName, key)); + postEvent(new QxtWebStoreCookieEvent(sessionID, qxt_d().sessionCookieName, key.toString())); return sessionID; } @@ -319,6 +382,9 @@ int QxtHttpSessionManager::newSession() * Subclasses may override this function to perform preprocessing on each * request, but they must call the base class implementation in order to * generate and dispatch the appropriate events. + * + * To facilitate use with multi-threaded applications, the event will remain + * valid until a response is posted. */ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpRequestHeader& header, QxtWebContent* content) { @@ -340,6 +406,8 @@ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpReques if (qxt_d().sessionKeys.contains(sessionCookie)) { sessionID = qxt_d().sessionKeys[sessionCookie]; + if(!sessionID && header.majorVersion() > 0 && qxt_d().autoCreateSession) + sessionID = newSession(); } else if (header.majorVersion() > 0 && qxt_d().autoCreateSession) { @@ -361,11 +429,21 @@ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpReques state.keepAlive = true; qxt_d().sessionLock.unlock(); - QxtWebRequestEvent* event = new QxtWebRequestEvent(sessionID, requestID, QUrl(header.path())); + QxtWebRequestEvent* event = new QxtWebRequestEvent(sessionID, requestID, QUrl::fromEncoded(header.path().toUtf8())); + qxt_d().eventLock.lock(); + qxt_d().pendingRequests.insert(QPair(sessionID, requestID), event); + qxt_d().eventLock.unlock(); QTcpSocket* socket = qobject_cast(device); if (socket) { - event->remoteAddress = socket->peerAddress().toString(); + event->remoteAddress = socket->peerAddress(); +#ifndef QT_NO_OPENSSL + QSslSocket* sslSocket = qobject_cast(socket); + if(sslSocket) { + event->isSecure = true; + event->clientCertificate = sslSocket->peerCertificate(); + } +#endif } event->method = header.method(); event->cookies = cookies; @@ -385,7 +463,10 @@ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpReques event->headers.insert("X-Request-Protocol", "HTTP/" + QString::number(state.httpMajorVersion) + '.' + QString::number(state.httpMinorVersion)); if (sessionID && session(sessionID)) { - session(sessionID)->pageRequestedEvent(event); + QxtAbstractWebService *service = session(sessionID); + if(content) + content->setParent(service); // Set content ownership to the service + service->pageRequestedEvent(event); } else if (qxt_d().staticService) { @@ -403,9 +484,11 @@ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpReques void QxtHttpSessionManager::disconnected(QIODevice* device) { QMutexLocker locker(&qxt_d().sessionLock); - if (qxt_d().connectionState.contains(device)) - delete qxt_d().connectionState[device].onBytesWritten; + if (qxt_d().connectionState.contains(device)) { + qxt_d().connectionState[device].clearHandlers(); + } qxt_d().connectionState.remove(device); + device->deleteLater(); } /*! @@ -451,6 +534,8 @@ void QxtHttpSessionManager::processEvents() { QxtWebStoreCookieEvent* ce = static_cast(e); QString cookie = ce->name + '=' + ce->data; + if (!ce->path.isEmpty()) + cookie += "; path=" + ce->path; if (ce->expiration.isValid()) { cookie += "; max-age=" + QString::number(QDateTime::currentDateTime().secsTo(ce->expiration)) @@ -462,7 +547,9 @@ void QxtHttpSessionManager::processEvents() else if (e->type() == QxtWebEvent::RemoveCookie) { QxtWebRemoveCookieEvent* ce = static_cast(e); - header.addValue("set-cookie", ce->name + "=; max-age=0; expires=" + QDateTime(QDate(1970, 1, 1)).toString("ddd, dd-MMM-YYYY hh:mm:ss GMT")); + QString path; + if(!ce->path.isEmpty()) path = "path=" + ce->path + "; "; + header.addValue("set-cookie", ce->name + "=; "+path+"max-age=0; expires=" + QDateTime(QDate(1970, 1, 1)).toString("ddd, dd-MMM-YYYY hh:mm:ss GMT")); removeIDs.push_front(i); } } @@ -473,9 +560,15 @@ void QxtHttpSessionManager::processEvents() // TODO: This should only be invoked when pipelining occurs // In theory it shouldn't cause any problems as POST is specced to not be pipelined if (content) content->ignoreRemainingContent(); + QHash,QxtWebRequestEvent*>::iterator iPending = + qxt_d().pendingRequests.find(QPair(sessionID, requestID)); + if(iPending != qxt_d().pendingRequests.end()){ + delete *iPending; + qxt_d().pendingRequests.erase(iPending); + } QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[connector()->getRequestConnection(requestID)]; - + QIODevice* source; header.setStatusLine(pe->status, pe->statusMessage, state.httpMajorVersion, state.httpMinorVersion); if (re) @@ -493,8 +586,7 @@ void QxtHttpSessionManager::processEvents() if (state.httpMajorVersion == 0 || (state.httpMajorVersion == 1 && state.httpMinorVersion == 0)) pe->chunked = false; - connector()->setRequestDataSource( pe->requestID, pe->dataSource ); - QSharedPointer source( pe->dataSource ); + source = pe->dataSource; state.finishedTransfer = false; bool emptyContent = !source->bytesAvailable() && !pe->streaming; state.readyRead = source->bytesAvailable(); @@ -508,40 +600,27 @@ void QxtHttpSessionManager::processEvents() } else { - if (state.onBytesWritten) delete state.onBytesWritten; // disconnect old handler + pe->dataSource = 0; // so that it isn't destroyed when the event is deleted + state.clearHandlers(); // disconnect old handlers + if (!pe->chunked) { state.keepAlive = false; - state.onBytesWritten = QxtMetaObject::bind(this, SLOT(sendNextBlock(int)), - Q_ARG(int, requestID)); - - QxtMetaObject::connect(source.data(), SIGNAL(readyRead()), - QxtMetaObject::bind(this, SLOT(blockReadyRead(int)), - Q_ARG(int, requestID)), - Qt::QueuedConnection); - - QxtMetaObject::connect(source.data(), SIGNAL(aboutToClose()), - QxtMetaObject::bind(this, SLOT(closeConnection(int)), - Q_ARG(int, requestID)), - Qt::QueuedConnection); + state.onBytesWritten = QxtMetaObject::bind(this, SLOT(sendNextBlock(int, QObject*)), Q_ARG(int, requestID), Q_ARG(QObject*, source)); + state.onReadyRead = QxtMetaObject::bind(this, SLOT(blockReadyRead(int, QObject*)), Q_ARG(int, requestID), Q_ARG(QObject*, source)); + state.onAboutToClose = QxtMetaObject::bind(this, SLOT(closeConnection(int)), Q_ARG(int, requestID)); } else { header.setValue("transfer-encoding", "chunked"); - state.onBytesWritten = QxtMetaObject::bind(this, SLOT(sendNextChunk(int)), - Q_ARG(int, requestID)); - - QxtMetaObject::connect(source.data(), SIGNAL(readyRead()), - QxtMetaObject::bind(this, SLOT(chunkReadyRead(int)), - Q_ARG(int, requestID)), - Qt::QueuedConnection); - - QxtMetaObject::connect(source.data(), SIGNAL(aboutToClose()), - QxtMetaObject::bind(this, SLOT(sendEmptyChunk(int)), - Q_ARG(int, requestID)), - Qt::QueuedConnection); + state.onBytesWritten = QxtMetaObject::bind(this, SLOT(sendNextChunk(int, QObject*)), Q_ARG(int, requestID), Q_ARG(QObject*, source)); + state.onReadyRead = QxtMetaObject::bind(this, SLOT(chunkReadyRead(int, QObject*)), Q_ARG(int, requestID), Q_ARG(QObject*, source)); + state.onAboutToClose = QxtMetaObject::bind(this, SLOT(sendEmptyChunk(int, QObject*)), Q_ARG(int, requestID), Q_ARG(QObject*, source)); } QxtMetaObject::connect(device, SIGNAL(bytesWritten(qint64)), state.onBytesWritten, Qt::QueuedConnection); + QxtMetaObject::connect(source, SIGNAL(readyRead()), state.onReadyRead, Qt::QueuedConnection); + QxtMetaObject::connect(source, SIGNAL(aboutToClose()), state.onAboutToClose, Qt::QueuedConnection); + QObject::connect(device, SIGNAL(destroyed()), source, SLOT(deleteLater())); if (state.keepAlive) { @@ -555,9 +634,9 @@ void QxtHttpSessionManager::processEvents() if (state.readyRead) { if (pe->chunked) - sendNextChunk(requestID); + sendNextChunk(requestID, source); else - sendNextBlock(requestID); + sendNextBlock(requestID, source); } } @@ -573,32 +652,24 @@ void QxtHttpSessionManager::processEvents() /*! * \internal */ -void QxtHttpSessionManager::chunkReadyRead(int requestID) +void QxtHttpSessionManager::chunkReadyRead(int requestID, QObject* dataSourceObject) { - if (!connector()) return; - - const QSharedPointer& dataSource = connector()->getRequestDataSource( requestID ); + QIODevice* dataSource = static_cast(dataSourceObject); if (!dataSource->bytesAvailable()) return; - QIODevice* device = connector()->getRequestConnection(requestID); - if (!device) return; - if (!device->bytesToWrite() || qxt_d().connectionState[device].readyRead == false) { qxt_d().connectionState[device].readyRead = true; - sendNextChunk(requestID); + sendNextChunk(requestID, dataSourceObject); } } /*! * \internal */ -void QxtHttpSessionManager::sendNextChunk(int requestID) +void QxtHttpSessionManager::sendNextChunk(int requestID, QObject* dataSourceObject) { - if ( !connector() ) - return; - - const QSharedPointer& dataSource = connector()->getRequestDataSource( requestID ); + QIODevice* dataSource = static_cast(dataSourceObject); QIODevice* device = connector()->getRequestConnection(requestID); QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device]; if (state.finishedTransfer) @@ -619,13 +690,13 @@ void QxtHttpSessionManager::sendNextChunk(int requestID) } state.readyRead = false; if (!state.streaming && !dataSource->bytesAvailable()) - QMetaObject::invokeMethod(this, "sendEmptyChunk", Q_ARG(int, requestID)); + QMetaObject::invokeMethod(this, "sendEmptyChunk", Q_ARG(int, requestID), Q_ARG(QObject*, dataSource)); } /*! * \internal */ -void QxtHttpSessionManager::sendEmptyChunk(int requestID) +void QxtHttpSessionManager::sendEmptyChunk(int requestID, QObject* dataSource) { QIODevice* device = connector()->getRequestConnection(requestID); if (!qxt_d().connectionState.contains(device)) return; // in case a disconnect signal and a bytesWritten signal get fired in the wrong order @@ -633,13 +704,11 @@ void QxtHttpSessionManager::sendEmptyChunk(int requestID) if (state.finishedTransfer) return; state.finishedTransfer = true; device->write("0\r\n\r\n"); - + dataSource->deleteLater(); if (state.keepAlive) { delete state.onBytesWritten; state.onBytesWritten = 0; - QSharedPointer& dataSource = connector()->getRequestDataSource( requestID ); - dataSource.clear(); connector()->incomingData(device); } else @@ -654,45 +723,38 @@ void QxtHttpSessionManager::sendEmptyChunk(int requestID) void QxtHttpSessionManager::closeConnection(int requestID) { QIODevice* device = connector()->getRequestConnection(requestID); - if( !device ) return; // already closing/closed QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device]; state.finishedTransfer = true; - state.onBytesWritten = NULL; QTcpSocket* socket = qobject_cast(device); if (socket) socket->disconnectFromHost(); else device->close(); - - connector()->doneWithRequest( requestID ); } /*! * \internal */ -void QxtHttpSessionManager::blockReadyRead(int requestID) +void QxtHttpSessionManager::blockReadyRead(int requestID, QObject* dataSourceObject) { - const QSharedPointer& dataSource = connector()->getRequestDataSource( requestID ); + QIODevice* dataSource = static_cast(dataSourceObject); if (!dataSource->bytesAvailable()) return; QIODevice* device = connector()->getRequestConnection(requestID); if (!device->bytesToWrite() || qxt_d().connectionState[device].readyRead == false) { qxt_d().connectionState[device].readyRead = true; - sendNextBlock(requestID); + sendNextBlock(requestID, dataSourceObject); } } /*! * \internal */ -void QxtHttpSessionManager::sendNextBlock(int requestID) +void QxtHttpSessionManager::sendNextBlock(int requestID, QObject* dataSourceObject) { - QSharedPointer& dataSource = connector()->getRequestDataSource( requestID ); + QIODevice* dataSource = static_cast(dataSourceObject); QIODevice* device = connector()->getRequestConnection(requestID); - if (!device) - return; - if (!qxt_d().connectionState.contains(device)) return; // in case a disconnect signal and a bytesWritten signal get fired in the wrong order QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device]; if (state.finishedTransfer) return; @@ -701,11 +763,13 @@ void QxtHttpSessionManager::sendNextBlock(int requestID) state.readyRead = false; return; } - QByteArray chunk = dataSource->read(32768); // this is a good chunk size + QByteArray chunk = dataSource->read(32768); // empirically determined to be a good chunk size device->write(chunk); state.readyRead = false; if (!state.streaming && !dataSource->bytesAvailable()) { closeConnection(requestID); + dataSource->deleteLater(); + state.clearHandlers(); } } diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.h index 6ded5a032..c00e1a15d 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxthttpsessionmanager.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTHTTPSESSIONMANAGER_H #define QXTHTTPSESSIONMANAGER_H @@ -29,8 +35,7 @@ #include "qxtabstractwebsessionmanager.h" #include "qxtabstracthttpconnector.h" #include -#include -#include +#include "qhttpheader.h" class QxtWebEvent; class QxtWebContent; @@ -40,6 +45,11 @@ class QXT_WEB_EXPORT QxtHttpSessionManager : public QxtAbstractWebSessionManager { friend class QxtAbstractHttpConnector; Q_OBJECT + Q_PROPERTY(QHostAddress listenInterface READ listenInterface WRITE setListenInterface) + Q_PROPERTY(QByteArray sessionCookieName READ sessionCookieName WRITE setSessionCookieName) + Q_PROPERTY(quint16 port READ port WRITE setPort) + Q_PROPERTY(quint16 serverPort READ serverPort) + Q_PROPERTY(bool autoCreateSession READ autoCreateSession WRITE setAutoCreateSession) public: enum Connector { HttpServer, Scgi, Fcgi }; @@ -53,6 +63,8 @@ public: quint16 port() const; void setPort(quint16 port); + quint16 serverPort() const; + QByteArray sessionCookieName() const; void setSessionCookieName(const QByteArray& name); @@ -67,8 +79,10 @@ public: QxtAbstractHttpConnector* connector() const; virtual bool start(); + virtual bool shutdown(); protected: + virtual void sessionDestroyed(int sessionID); virtual int newSession(); virtual void incomingRequest(quint32 requestID, const QHttpRequestHeader& header, QxtWebContent* device); @@ -77,11 +91,11 @@ protected Q_SLOTS: private Q_SLOTS: void closeConnection(int requestID); - void chunkReadyRead(int requestID); - void sendNextChunk(int requestID); - void sendEmptyChunk(int requestID); - void blockReadyRead(int requestID); - void sendNextBlock(int requestID); + void chunkReadyRead(int requestID, QObject* dataSource); + void sendNextChunk(int requestID, QObject* dataSource); + void sendEmptyChunk(int requestID, QObject* dataSource); + void blockReadyRead(int requestID, QObject* dataSource); + void sendNextBlock(int requestID, QObject* dataSource); private: void disconnected(QIODevice* device); diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.cpp index e55fd3615..be4bc7309 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \namespace QxtMetaObject @@ -323,11 +329,7 @@ namespace QxtMetaObject */ bool connect(QObject* sender, const char* signal, QxtBoundFunction* slot, Qt::ConnectionType type) { - if (!sender) - { - qWarning() << "Got connect() with a null sender!"; - return false; - } + Q_ASSERT(sender); const QMetaObject* meta = sender->metaObject(); int methodID = meta->indexOfMethod(meta->normalizedSignature(signal).mid(1).constData()); if (methodID < 0) diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.h index a2acdfe99..be2d72c47 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtmetaobject.h @@ -1,28 +1,34 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ #ifndef QXTMETAOBJECT_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + #define QXTMETAOBJECT_H #include diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.cpp index 68f342be3..c1bc782b4 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.cpp @@ -1,27 +1,33 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ #include "qxtnull.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + // nothing here diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.h index 9e8f7e9b8..6978a97bc 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnull.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTNULL_H #define QXTNULL_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnullable.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnullable.h index eb2a9e291..596a79292 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnullable.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtnullable.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtNullable QxtNullable diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtscgiserverconnector.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtscgiserverconnector.cpp index 3297b94ff..bad6ee747 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtscgiserverconnector.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtscgiserverconnector.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtScgiServerConnector @@ -70,6 +76,26 @@ bool QxtScgiServerConnector::listen(const QHostAddress& iface, quint16 port) return qxt_d().server->listen(iface, port); } +/*! + * \reimp + */ +bool QxtScgiServerConnector::shutdown() +{ + if(qxt_d().server->isListening()){ + qxt_d().server->close(); + return true; + } + return false; +} + +/*! + * \reimp + */ +quint16 QxtScgiServerConnector::serverPort() const +{ + return qxt_d().server->serverPort(); +} + /*! * \internal */ diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtsslserver.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtsslserver.cpp new file mode 100644 index 000000000..f24214740 --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtsslserver.cpp @@ -0,0 +1,220 @@ + +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtsslserver.h" +#include +#include + +/*! + * \class QxtSslServer + * \inmodule QxtNetwork + * \brief The QxtSslServer class provides a simple SSL server. + * + * QxtSslServer is a simple SSL server. As a QTcpServer subclass it shares all of the same behaviors + * as its parent class, except that new connections are created as QSslSocket objects instead of + * QTcpSocket objects. + * + * Before QxtSslServer can accept any encrypted connections, the local certificate (see setLocalCertificate) + * and private key (see setPrivateKey) must be set. Failure to set these properties before accepting + * connections will cause all incoming connections to generate sslError signals when negotiating + * encryption. If autoEncrypt is disabled, the local certificate and private key can be set on the + * individual socket objects before starting encryption; this behavior is generally not necessary unless + * you wish to serve up a different certificate based on some property of the connection or some data + * negotiated before beginning encryption. + * + * Unlike QTcpServer, overriding QxtSslServer::incomingConnection() is not recommended. + * + * QxtSslServer is only available if Qt was compiled with OpenSSL support. + */ + +#ifndef QT_NO_OPENSSL +#include + +class QxtSslServerPrivate : public QxtPrivate +{ +public: + QXT_DECLARE_PUBLIC(QxtSslServer) + QSslCertificate localCertificate; + QSslKey privateKey; + bool autoEncrypt; + QQueue pendingConnections; +}; + +/*! + * Constructs a new QxtSslServer object with the specified \a parent. + */ +QxtSslServer::QxtSslServer(QObject* parent) : QTcpServer(parent) +{ + QXT_INIT_PRIVATE(QxtSslServer); + qxt_d().autoEncrypt = true; +} + +/*! + * \reimp + */ +bool QxtSslServer::hasPendingConnections() const +{ + return !qxt_d().pendingConnections.isEmpty(); +} + +/*! + * \reimp + */ +QTcpSocket* QxtSslServer::nextPendingConnection() +{ + if(!hasPendingConnections()) return 0; + return qxt_d().pendingConnections.dequeue(); +} + +/*! + * Sets the certificate to be presented to clients during the SSL handshake. + * + * Setting the certificate only affects new connections established after the certificate + * has been set. + * + * A certificate is the means of identification used in the SSL process. The local + * certificate is used by the remote end to verify the local user's identity against its + * list of Certification Authorities. + * + * \sa localCertificate + * \sa setPrivateKey + */ +void QxtSslServer::setLocalCertificate(const QSslCertificate& cert) +{ + qxt_d().localCertificate = cert; +} + +/*! + * This is an overloaded function, provided for convenience. + * + * Sets the certificate to be presented to clients during the SSL handshake to + * the first certificate contained in the file specified by \a path. + * + * \sa localCertificate + */ +void QxtSslServer::setLocalCertificate(const QString& path, QSsl::EncodingFormat format) +{ + QFile file(path); + if(!file.open(QIODevice::ReadOnly)) return; + setLocalCertificate(QSslCertificate(&file, format)); +} + +/*! + * Returns the local certificate used to identify the server, or an empty certificate if none has been set. + * \sa setLocalCertificate + */ +QSslCertificate QxtSslServer::localCertificate() const +{ + return qxt_d().localCertificate; +} + +/*! + * Sets the private key used for encryption. + * + * Setting the private key only affects new connections established after the key has been set. + * + * \sa privateKey + */ +void QxtSslServer::setPrivateKey(const QSslKey& key) +{ + qxt_d().privateKey = key; +} + +/*! + * This is an overloaded function, provided for convenience. + * + * Sets the private key used for encryption to the key contained in the file specified by + * \a path. The specified algorithm, format, and pass phrase are used to decrypt the key. + * + * \sa privateKey + */ +void QxtSslServer::setPrivateKey(const QString& path, QSsl::KeyAlgorithm algo, QSsl::EncodingFormat format, const QByteArray& passPhrase) +{ + QFile file(path); + if(!file.open(QIODevice::ReadOnly)) return; + setPrivateKey(QSslKey(&file, algo, format, QSsl::PrivateKey, passPhrase)); +} + +/*! + * Returns the private key used to encrypt communication, or an empty key if none has been set. + * \sa setPrivateKey + */ +QSslKey QxtSslServer::privateKey() const +{ + return qxt_d().privateKey; +} + +/*! + * Enables or disables automatically starting encryption on new connections. + * + * Set this property to false if you wish to enable encryption on incoming connections + * at a later time. The default value is true. + * + * \sa autoEncrypt + */ +void QxtSslServer::setAutoEncrypt(bool on) +{ + qxt_d().autoEncrypt = on; +} + +/*! + * Returns true if incoming connections will automatically be encrypted, or false otherwise. + * \sa setAutoEncrypt + */ +bool QxtSslServer::autoEncrypt() const +{ + return qxt_d().autoEncrypt; +} + +/*! + * \reimp + */ +void QxtSslServer::incomingConnection(int socketDescriptor) +{ + QSslSocket* socket = new QSslSocket(this); + if(socket->setSocketDescriptor(socketDescriptor)) { + socket->setLocalCertificate(qxt_d().localCertificate); + socket->setPrivateKey(qxt_d().privateKey); + if(parent()){ + connect(socket, SIGNAL(sslErrors(const QList&)), + parent(), SLOT(sslErrors(const QList&))); + connect(socket, SIGNAL(peerVerifyError(const QSslError&)), + parent(), SLOT(peerVerifyError(const QSslError&))); + } + qxt_d().pendingConnections.enqueue(socket); + // emit newConnection(); // removed: QTcpServerPrivate emits this for us + if(qxt_d().autoEncrypt) socket->startServerEncryption(); + } else { + delete socket; + } +} + +#endif /* QT_NO_OPENSSL */ diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtweb.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtweb.h index 0940ba88e..6c3e1cd6c 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtweb.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtweb.h @@ -1,38 +1,45 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ #ifndef QXTWEB_H_INCLUDED +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + #define QXTWEB_H_INCLUDED #include "qxtabstracthttpconnector.h" #include "qxtabstractwebservice.h" #include "qxtabstractwebsessionmanager.h" -#include "qxtwebcgiservice.h" #include "qxthtmltemplate.h" #include "qxthttpsessionmanager.h" +#include "qxtwebcgiservice.h" #include "qxtwebcontent.h" #include "qxtwebevent.h" +#include "qxtwebjsonrpcservice.h" #include "qxtwebservicedirectory.h" #include "qxtwebslotservice.h" diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.cpp index 4ddc00c7e..ead51ce09 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtWebCgiService @@ -194,7 +200,7 @@ void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event) env["SCRIPT_NAME"] = event->originalUrl.path().remove(QRegExp(QRegExp::escape(event->url.path()) + '$')); env["SCRIPT_FILENAME"] = qxt_d().binary; // CGI/1.1 doesn't define this but PHP demands it env.remove("REMOTE_HOST"); - env["REMOTE_ADDR"] = event->remoteAddress; + env["REMOTE_ADDR"] = event->remoteAddress.toString(); // TODO: If we ever support HTTP authentication, we should use these env.remove("AUTH_TYPE"); env.remove("REMOTE_USER"); @@ -212,8 +218,8 @@ void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event) env["QUERY_STRING"] = event->url.encodedQuery(); // Populate HTTP header environment variables - QMultiHash::const_iterator iter = event->headers.constBegin(); - while (iter != event->headers.constEnd()) + QMultiHash::const_iterator iter = event->headers.begin(); + while (iter != event->headers.end()) { QString key = "HTTP_" + iter.key().toUpper().replace('-', '_'); if (key != "HTTP_CONTENT_TYPE" && key != "HTTP_CONTENT_LENGTH") @@ -222,9 +228,9 @@ void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event) } // Populate HTTP_COOKIE parameter - iter = event->cookies.constBegin(); + iter = event->cookies.begin(); QString cookies; - while (iter != event->cookies.constEnd()) + while (iter != event->cookies.end()) { if (!cookies.isEmpty()) cookies += "; "; @@ -321,7 +327,7 @@ void QxtWebCgiServicePrivate::processReadyRead() // If a previous header (currently just status) hasn't created an event, create a normal page event here if (!event) { - event = new QxtWebPageEvent(request.sessionID, request.requestID, QSharedPointer(process) ); + event = new QxtWebPageEvent(request.sessionID, request.requestID, process); event->status = code; } // Add other response headers passed from CGI (currently only Content-Type is supported) diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.h index 3f68e7946..b944519b6 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBCGISERVICE_H #define QXTWEBCGISERVICE_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice_p.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice_p.h index b7355a3d0..1b1a25339 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice_p.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcgiservice_p.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBCGISERVICE_P_H #define QXTWEBCGISERVICE_P_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.cpp index ff5866356..6fa17026b 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.cpp @@ -1,37 +1,43 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtWebContent \inmodule QxtWeb -\brief The QxtWebContent class provides and I/O device for data sent by the web browser +\brief The QxtWebContent class provides an I/O device for data sent by the web browser -QxtWebContent is a read-only QIODevice subclass that encapsulates data sent -from the web browser, for instance in a POST or PUT request. +QxtWebContent is a QxtFifo subclass that encapsulates data sent from the web +browser, for instance in a POST or PUT request. In order to avoid delays while reading content sent from the client, and to insulate multiple pipelined requests on the same connection from each other, @@ -43,93 +49,71 @@ QxtWeb uses QxtWebContent as an abstraction for streaming data. #include "qxtwebcontent.h" #include #include +#include +#include #ifndef QXT_DOXYGEN_RUN class QxtWebContentPrivate : public QxtPrivate { public: - QxtWebContentPrivate() : ignoreRemaining(false) {} + QxtWebContentPrivate() : bytesNeeded(0), ignoreRemaining(false) {} QXT_DECLARE_PUBLIC(QxtWebContent) - void init(int contentLength, const QByteArray& start, QIODevice* device) + void init(int contentLength, QIODevice* device) { - this->start = start; - this->device = device; - if (contentLength <= 0) - bytesRemaining = -1; - else - bytesRemaining = contentLength - start.length(); - if (device) - { - QObject::connect(device, SIGNAL(readyRead()), &qxt_p(), SIGNAL(readyRead())); - // QObject::connect(device, SIGNAL(aboutToClose()), this, SIGNAL(aboutToClose())); - // QObject::connect(device, SIGNAL(destroyed()), this, SIGNAL(aboutToClose())); - // ask the object if it has an error signal - if (device->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(SIGNAL(error(QAbstractSocket::SocketError)))) >= 0) - { - QObject::connect(device, SIGNAL(error(QAbstractSocket::SocketError)), &qxt_p(), SLOT(errorReceived(QAbstractSocket::SocketError))); - } - } - qxt_p().setOpenMode(QIODevice::ReadOnly); + if (contentLength < 0) + bytesNeeded = -1; + else{ + bytesNeeded = contentLength - qxt_p().bytesAvailable(); + Q_ASSERT(bytesNeeded >= 0); + } + if(device){ + // Connect a disconnected signal if it has one + if(device->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(SIGNAL(disconnected()))) >= 0){ + QObject::connect(device, SIGNAL(disconnected()), &qxt_p(), SLOT(sourceDisconnect()), Qt::QueuedConnection); + } + // Likewise, connect an error signal if it has one + if(device->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(SIGNAL(error(QAbstractSocket::SocketError)))) >= 0){ + QObject::connect(device, SIGNAL(error(QAbstractSocket::SocketError)), &qxt_p(), SLOT(errorReceived(QAbstractSocket::SocketError))); + } + } } - qint64 bytesRemaining; - QByteArray start; - QIODevice* device; + qint64 bytesNeeded; bool ignoreRemaining; }; #endif /*! - * Constructs a QxtWebContent object. + * Constructs a QxtWebContent object with the specified \a parent. * - * The content provided by this constructor is the first \a contentLength bytes - * read from the provided \a device. + * The content provided by this constructor is the data contained in \a prime, + * followed by whatever data is subsequently written to this object from the + * source device up to the specified \a contentLength. Note that the provided + * \a sourceDevice is used solely to detect socket errors and does not specify + * parentage. This variation is ReadWrite to permit incoming data but should + * never be written to by the service handler. * - * The QxtWebContent object is parented to the \a device. */ -QxtWebContent::QxtWebContent(int contentLength, QIODevice* device) : QIODevice(device) +QxtWebContent::QxtWebContent(int contentLength, const QByteArray& prime, + QObject *parent, QIODevice* sourceDevice) : QxtFifo(prime, parent) { QXT_INIT_PRIVATE(QxtWebContent); - qxt_d().init(contentLength, QByteArray(), device); -} - -/*! - * Constructs a QxtWebContent object. - * - * The content provided by this constructor is the data contained in \a start, - * followed by enough data read from the provided \a device to fill the desired - * \a contentLength. - * - * The QxtWebContent object is parented to the \a device. - */ -QxtWebContent::QxtWebContent(int contentLength, const QByteArray& start, QIODevice* device) : QIODevice(device) -{ - QXT_INIT_PRIVATE(QxtWebContent); - qxt_d().init(contentLength, start, device); + qxt_d().init(contentLength, sourceDevice); } /*! * Constructs a QxtWebContent object with the specified \a parent. * * The content provided by this constructor is exactly the data contained in - * \a content. + * \a content. This variation is ReadOnly. */ -QxtWebContent::QxtWebContent(const QByteArray& content, QObject* parent) : QIODevice(parent) +QxtWebContent::QxtWebContent(const QByteArray& content, QObject* parent) +: QxtFifo(content, parent) { QXT_INIT_PRIVATE(QxtWebContent); - qxt_d().init(content.size(), content, 0); -} - -/*! - * \reimp - */ -qint64 QxtWebContent::bytesAvailable() const -{ - qint64 available = QIODevice::bytesAvailable() + (qxt_d().device ? qxt_d().device->bytesAvailable() : 0) + qxt_d().start.count(); - if (available > qxt_d().bytesRemaining) - return qxt_d().bytesRemaining; - return available; + qxt_d().init(content.size(), 0); + setOpenMode(ReadOnly); } /*! @@ -137,61 +121,72 @@ qint64 QxtWebContent::bytesAvailable() const */ qint64 QxtWebContent::readData(char* data, qint64 maxSize) { - char* writePtr = data; - // read more than 32k; TCP ideally handles 48k blocks but we need wiggle room - if (maxSize > 32768) maxSize = 32768; - - // don't read more than the content-length - int sz = qxt_d().start.count(); - if (sz > 0 && maxSize > sz) - { - memcpy(writePtr, qxt_d().start.constData(), sz); - writePtr += sz; - maxSize -= sz; - qxt_d().start.clear(); - } - else if (sz > 0 && sz > maxSize) - { - memcpy(writePtr, qxt_d().start.constData(), maxSize); - qxt_d().start = qxt_d().start.mid(maxSize); - return maxSize; - } - - if (qxt_d().device == 0) - { - return sz; - } - else if (qxt_d().bytesRemaining >= 0) - { - qint64 readBytes = qxt_d().device->read(writePtr, (maxSize > qxt_d().bytesRemaining) ? qxt_d().bytesRemaining : maxSize); - qxt_d().bytesRemaining -= readBytes; - if (qxt_d().bytesRemaining == 0) QMetaObject::invokeMethod(this, "aboutToClose", Qt::QueuedConnection); - return sz + readBytes; - } - else - { - return sz + qxt_d().device->read(writePtr, maxSize); - } + int result = QxtFifo::readData(data, maxSize); + if(bytesAvailable() == 0 && bytesNeeded() == 0) + QMetaObject::invokeMethod(this, "aboutToClose", Qt::QueuedConnection); + return result; } /*! - * Returns the number of bytes of content that have not yet been read. - * - * Note that not all of the remaining content may be immediately available for - * reading. This function returns the content length, minus the number of - * bytes that have already been read. + * Returns \bold true if the total content size is unknown and + * \bold false otherwise. + */ +bool QxtWebContent::wantAll() const +{ + return (qxt_d().bytesNeeded == -1); +} + +/*! + * Returns the total number of bytes of content expected. This will be \bold -1 + * if the total content size is unknown. This total includes both unread + * data and that which has not been received yet. To obtain the number of + * bytes available for reading, use bytesAvailable(). + * \sa bytesNeeded(), wantAll() */ qint64 QxtWebContent::unreadBytes() const { - return qxt_d().start.size() + qxt_d().bytesRemaining; + if(wantAll()) + return -1; + return bytesAvailable() + bytesNeeded(); +} + +/*! + * Returns the number of bytes of content that have not yet been written + * from the source device. This will be \bold -1 if the total content size is + * unknown and \bold zero once all data has been received from the source (the + * readChannelFinished() signal will be emitted when that occurs). + */ +qint64 QxtWebContent::bytesNeeded() const +{ + return qxt_d().bytesNeeded; } /*! * \reimp */ -qint64 QxtWebContent::writeData(const char*, qint64) +qint64 QxtWebContent::writeData(const char *data, qint64 maxSize) { - // always an error to write + if(!(openMode() & WriteOnly)){ + qWarning("QxtWebContent(): size=%lld but read-only", maxSize); + return -1; // Not accepting writes + } + if(maxSize > 0) { + // This must match the QxtFifo implementation for consistency + if(maxSize > INT_MAX) maxSize = INT_MAX; // qint64 could easily exceed QAtomicInt, so let's play it safe + if(qxt_d().bytesNeeded >= 0){ + if(maxSize > qxt_d().bytesNeeded){ + qWarning("QxtWebContent(): size=%lld needed %lld", maxSize, + qxt_d().bytesNeeded); + maxSize = qxt_d().bytesNeeded; + } + qxt_d().bytesNeeded -= maxSize; + Q_ASSERT(qxt_d().bytesNeeded >= 0); + } + if(qxt_d().ignoreRemaining) + return maxSize; + return QxtFifo::writeData(data, maxSize); + } + // Error return -1; } @@ -200,26 +195,28 @@ qint64 QxtWebContent::writeData(const char*, qint64) */ void QxtWebContent::errorReceived(QAbstractSocket::SocketError) { - setErrorString(qxt_d().device->errorString()); + QIODevice *device = qobject_cast(sender()); + if(device) + setErrorString(device->errorString()); } /*! - * Blocks until all of the streaming data has been read from the browser. + * Blocks until all of the streaming data has been read from the browser. * - * Note that this function will block events for the thread on which it is called. - * If the main thread is blocked, QxtWeb will be unable to process additional - * requests until the content has been received. + * Note that this method effectively runs a tight event loop. Although it + * will not block a thread's other activities, it may result in high CPU + * consumption and cause performance problems. It is suggested that you + * avoid use of this method and try to implement services using the + * readChannelFinished() signal instead. */ void QxtWebContent::waitForAllContent() { - if (!qxt_d().device) return; - QByteArray buffer; - while (qxt_d().device && qxt_d().bytesRemaining > 0) - { - buffer = qxt_d().device->readAll(); - qxt_d().start += buffer; - qxt_d().bytesRemaining -= buffer.size(); - if (qxt_d().bytesRemaining > 0) qxt_d().device->waitForReadyRead(-1); + while(qxt_d().bytesNeeded != 0 && !qxt_d().ignoreRemaining){ + // Still need data ... yield processing + if(QCoreApplication::hasPendingEvents()) + QCoreApplication::processEvents(); + if(this->thread() != QThread::currentThread()) + QThread::yieldCurrentThread(); } } @@ -231,11 +228,30 @@ void QxtWebContent::waitForAllContent() */ void QxtWebContent::ignoreRemainingContent() { - if (qxt_d().bytesRemaining <= 0 || !qxt_d().device) return; - if (!qxt_d().ignoreRemaining) - { - qxt_d().ignoreRemaining = true; - QObject::connect(qxt_d().device, SIGNAL(readyRead()), this, SLOT(ignoreRemainingContent())); + if (qxt_d().bytesNeeded == 0) return; + if(!qxt_d().ignoreRemaining){ + qxt_d().ignoreRemaining = true; + qxt_d().bytesNeeded = 0; + } +} + +/*! + * \internal + * This slot handles a disconnect notice from a source I/O device to handle + * cases where the source size is unknown. The internal state is adjusted + * ensuring a reader will unblock in waitForAllContent(). If unread + * data is present, a readyRead() signal will be emitted. + * The readChannelFinished() signal is emitted regardless. + */ +void QxtWebContent::sourceDisconnect() +{ + if (qxt_d().bytesNeeded == 0) return; + if(!qxt_d().ignoreRemaining){ + qxt_d().ignoreRemaining = true; + qxt_d().bytesNeeded = 0; + if(bytesAvailable() != 0) + QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "readChannelFinished", Qt::QueuedConnection); } } @@ -244,8 +260,11 @@ typedef QPair QxtQueryItem; #endif /*! - * Extracts the key/value pairs from application/x-www-form-urlencoded \a data, - * such as the query string from the URL or the form data from a POST request. + * Parses URL-encoded form data + * + * Extracts the key/value pairs from \bold application/x-www-form-urlencoded + * \a data, such as the query string from the URL or the form data from a + * POST request. */ QHash QxtWebContent::parseUrlEncodedQuery(const QString& data) { diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.h index 06e88a808..e5cb48f79 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebcontent.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBCONTENT_H #define QXTWEBCONTENT_H @@ -30,18 +36,20 @@ #include #include #include +#include class QxtWebContentPrivate; -class QXT_WEB_EXPORT QxtWebContent : public QIODevice +class QXT_WEB_EXPORT QxtWebContent : public QxtFifo { Q_OBJECT public: - QxtWebContent(int contentLength, const QByteArray& start, QIODevice* device); - QxtWebContent(int contentLength, QIODevice* device); + QxtWebContent(int contentLength, const QByteArray& start, QObject *parent, + QIODevice* sourceDevice); explicit QxtWebContent(const QByteArray& content, QObject* parent = 0); static QHash parseUrlEncodedQuery(const QString& data); - virtual qint64 bytesAvailable() const; + bool wantAll() const; + qint64 bytesNeeded() const; qint64 unreadBytes() const; void waitForAllContent(); @@ -54,6 +62,7 @@ protected: virtual qint64 writeData(const char* data, qint64 maxSize); private Q_SLOTS: + void sourceDisconnect(); void errorReceived(QAbstractSocket::SocketError); private: diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.cpp index cd0d75755..9c59b4606 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #include "qxtwebevent.h" #include "qxtwebcontent.h" @@ -89,8 +95,8 @@ browser. /*! * Constructs a QxtWebRequestEvent for the specified \a sessionID, \a requestID and \a url. */ -QxtWebRequestEvent::QxtWebRequestEvent(int sessionID, int requestID, const QUrl& url) - : QxtWebEvent(QxtWebEvent::Request, sessionID), requestID(requestID), url(url), originalUrl(url) {} +QxtWebRequestEvent::QxtWebRequestEvent(int _sessionID, int _requestID, const QUrl& _url) + : QxtWebEvent(QxtWebEvent::Request, _sessionID), requestID(_requestID), url(_url), originalUrl(_url), isSecure(false) {} /*! * Destroys the event and any content that may still be associated with it. @@ -128,6 +134,37 @@ QxtWebRequestEvent::~QxtWebRequestEvent() * Contains the content of the request body, if present. */ +/*! + * \variable QxtWebRequestEvent::isSecure + * If the request was sent over an encrypted channel, such as HTTPS, isSecure will be + * set to \a true and clientCertificate will be set. Otherwise, isSecure will be set + * to \a false. + * + * \sa clientCertificate, remoteAddress + */ + +/*! + * \variable QxtWebRequestEvent::remoteAddress + * This variable will contain the address of the client as a QHostAddress. + * In IPv6 dual-stack systems (generally only Linux), this may be a IPv4 + * mapped address. + * + * \warning This variable was originally declared as a QString value in + * prior releases, albeit undocumented until now. + * + * \sa isSecure, clientCertificate + */ + +/*! + * \variable QxtWebRequestEvent::clientCertificate + * If the request was sent over an encrypted channel, such as HTTPS, clientCertificate + * will contain the certificate presented by the requesting client, if any. + * + * This member variable is not available if Qt was not compiled with SSL support. + * + * \sa isSecure, remoteAddress + */ + /*! * \variable QxtWebRequestEvent::cookies * Contains all of the cookies sent by the web browser. @@ -137,7 +174,7 @@ QxtWebRequestEvent::~QxtWebRequestEvent() * \variable QxtWebRequestEvent::headers * Contains all of the headers sent by the web browser. * - * Note that use of these values may not be portable across session maangers. + * Note that use of these values may not be portable across session managers. */ /* @@ -197,7 +234,7 @@ content that will be sent to a web browser. * QxtWeb takes ownership of the source and will delete it when the response * is completed. */ -QxtWebPageEvent::QxtWebPageEvent(int sessionID, int requestID, QSharedPointer source) +QxtWebPageEvent::QxtWebPageEvent(int sessionID, int requestID, QIODevice* source) : QxtWebEvent(QxtWebEvent::Page, sessionID), dataSource(source), chunked(true), streaming(true), requestID(requestID), status(200), statusMessage("OK"), contentType("text/html") {} @@ -216,7 +253,7 @@ QxtWebPageEvent::QxtWebPageEvent(int sessionID, int requestID, QByteArray source QBuffer* buffer = new QBuffer; buffer->setData(source); buffer->open(QIODevice::ReadOnly); - dataSource = QSharedPointer( buffer ); + dataSource = buffer; } /*! @@ -229,15 +266,15 @@ QxtWebPageEvent::QxtWebPageEvent(QxtWebEvent::EventType typeOverride, int sessio QBuffer* buffer = new QBuffer; buffer->setData(source); buffer->open(QIODevice::ReadOnly); - dataSource = QSharedPointer( buffer ); + dataSource = buffer; } /*! - * Destroys the event + * Destroys the event and any data source attached to it. */ QxtWebPageEvent::~QxtWebPageEvent() { - + if (!dataSource.isNull()) dataSource->deleteLater(); } /*! @@ -323,9 +360,12 @@ a cookie on the web browser. * with the cookie. The browser will delete the cookie automatically after * the specified date. If an expiration date is not supplied, the cookie will * expire when the browser is closed. + * + * The cookie will be assigned a path of / by default. You may change this + * using the \a path member. */ QxtWebStoreCookieEvent::QxtWebStoreCookieEvent(int sessionID, QString name, QString data, QDateTime expiration) - : QxtWebEvent(QxtWebEvent::StoreCookie, sessionID), name(name), data(data), expiration(expiration) {} + : QxtWebEvent(QxtWebEvent::StoreCookie, sessionID), name(name), data(data), expiration(expiration), path("/") {} /*! * \variable QxtWebStoreCookieEvent::name @@ -343,6 +383,14 @@ QxtWebStoreCookieEvent::QxtWebStoreCookieEvent(int sessionID, QString name, QStr * cookie will expire when the web browser is closed. */ +/*! + * \variable QxtWebStoreCookieEvent::path + * Contains the path of the cookie to be stored. + * + * The default value is "/". Set the path to an empty QString to send + * the cookie with no path specifier. + */ + /*! \class QxtWebRemoveCookieEvent @@ -357,6 +405,8 @@ a cookie stored on the web browser. /*! * Constructs a QxtWebRemoveCookieEvent for the specified \a sessionID that * removed the cookie with \a name from the web browser. + * + * The cookie's path is / by default. You may change this using the \a path member. */ QxtWebRemoveCookieEvent::QxtWebRemoveCookieEvent(int sessionID, QString name) : QxtWebEvent(QxtWebEvent::RemoveCookie, sessionID), name(name) {} @@ -366,6 +416,14 @@ QxtWebRemoveCookieEvent::QxtWebRemoveCookieEvent(int sessionID, QString name) * Contains the name of the cookie to be removed. */ +/*! + * \variable QxtWebStoreCookieEvent::path + * Contains the path of the cookie to be removed. + * + * The default value is "/". Set the path to an empty QString to send + * the cookie with no path specifier. + */ + /*! \class QxtWebRedirectEvent diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.h index 1b57c535c..fa491e918 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebevent.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBEVENT_H #define QXTWEBEVENT_H @@ -34,6 +40,10 @@ #include #include #include +#include +#ifndef QT_NO_OPENSSL +#include +#endif QT_FORWARD_DECLARE_CLASS(QIODevice) class QxtWebContent; @@ -68,7 +78,7 @@ class QXT_WEB_EXPORT QxtWebRequestEvent : public QxtWebEvent { public: QxtWebRequestEvent(int sessionID, int requestID, const QUrl& url); - ~QxtWebRequestEvent(); + virtual ~QxtWebRequestEvent(); const int requestID; @@ -77,7 +87,11 @@ public: QString contentType; QPointer content; QString method; - QString remoteAddress; + QHostAddress remoteAddress; + bool isSecure; +#ifndef QT_NO_OPENSSL + QSslCertificate clientCertificate; +#endif QMultiHash cookies; QMultiHash headers; @@ -98,11 +112,11 @@ class QxtWebRedirectEvent; class QXT_WEB_EXPORT QxtWebPageEvent : public QxtWebEvent { public: - QxtWebPageEvent(int sessionID, int requestID, QSharedPointer source); + QxtWebPageEvent(int sessionID, int requestID, QIODevice* source = 0); QxtWebPageEvent(int sessionID, int requestID, QByteArray source); // creates a QBuffer virtual ~QxtWebPageEvent(); - QSharedPointer dataSource; // data is read from this device and written to the client + QPointer dataSource; // data is read from this device and written to the client bool chunked; bool streaming; @@ -132,6 +146,7 @@ public: QString name; QString data; QDateTime expiration; + QString path; }; class QXT_WEB_EXPORT QxtWebRemoveCookieEvent : public QxtWebEvent @@ -140,6 +155,7 @@ public: QxtWebRemoveCookieEvent(int sessionID, QString name); QString name; + QString path; }; class QXT_WEB_EXPORT QxtWebRedirectEvent : public QxtWebPageEvent diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.cpp new file mode 100644 index 000000000..8033beecf --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.cpp @@ -0,0 +1,512 @@ +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +/*! +\class QxtWebJsonRPCService + +\inmodule QxtWeb + +\brief The QxtWebJsonRPCService class provides a Slot based webservice that responds to JSONRPC + +See http://json-rpc.org for details on the protocol + +To create a Webservice, simply subclass QxtWebJsonRPCService. All slots are exposed as jsonrpc method + +\code +class MyService : public QxtWebJsonRPCService +{ +Q_OBJECT +public slots: + int add(int a, int b + { + return a +b; + } +} +\endcode + +\code +curl -d '{"method":"add", "id":1, "params": [9,2] }' localhost:1339 +{"error":null,"id":1,"result":11} +\endcode + +\sa QxtAbstractWebService +*/ + +#include "qxtwebjsonrpcservice_p.h" +#include "qxtwebevent.h" +#include "qxtwebcontent.h" +#include "qxtjson.h" + +#include +#include +#include +#include + + +QxtWebJsonRPCService::Private::Private(QxtWebJsonRPCService *that) + : QObject() + , p(that) + , invokable(0) +{ +} + +void QxtWebJsonRPCService::Private::initTables(QObject *in) +{ + invokable = in; + const QMetaObject *po = invokable->metaObject(); + for (int i = po->methodOffset(); i < po->methodCount(); i++) { + + QxtWebJsonRPCService::Private::Method method; + QMetaMethod mo = po->method (i); +#if QT_VERSION >= 0x50000 + method.name = QByteArray(mo.methodSignature()).split('(').at(0); +#else + method.name = QByteArray(mo.signature()).split('(').at(0); +#endif + method.meta = mo; + method.argCount = mo.parameterTypes ().count(); + method.returns = QByteArray(mo.typeName()).count(); + methods.insert(method.name + QByteArray::number(method.argCount), method); + } +} + +void QxtWebJsonRPCService::Private::readFinished() +{ + QxtWebContent *c = qobject_cast(sender()); + handle(c); +} + +void QxtWebJsonRPCService::Private::handle(QxtWebContent *c) +{ + QxtWebRequestEvent *event = content.take(c); + currentRequest = 0; + c->ignoreRemainingContent(); + + QString data = QString::fromUtf8(c->readAll()); + + QVariantMap var = QxtJSON::parse(data).toMap(); + + if (var.isEmpty()) { + QByteArray resp = "{\"result\": null, \"error\": \"invalid json data\", \"id\": 0}\r\n"; + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, resp); + err->status = 500; + p->postEvent(err); + return; + } + QVariant rid = var.value("id"); + QString action = var.value("method").toString(); + QVariant argsE = var.value("params"); + handle(event, rid, action, argsE); +} + +void QxtWebJsonRPCService::Private::handle(QxtWebRequestEvent *event, QVariant rid, QString action, QVariant argsE) +{ + QVariantMap argsM; + QVariantList args; + + if (argsE.type() == QVariant::Map) { + argsM = argsE.toMap(); + args = argsM.values(); + } else { + args = argsE.toList(); + } + + if (!invokable) + initTables(p); + + + if (!methods.contains(action.toUtf8() + QByteArray::number(args.count()))) { + QVariantMap res; + res.insert("result", QVariant()); + res.insert("error", "no such method or incorrect number of arguments"); + res.insert("id", rid); + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, + QxtJSON::stringify(res).toUtf8() + "\r\n"); + p->postEvent(err); + return; + } + Method method = methods.value(action.toUtf8() + QByteArray::number(args.count())); + if (argsE.type() == QVariant::Map) { + args.clear(); + foreach (const QString &pname, method.meta.parameterNames ()) { + args.append(argsM.value(pname)); + } + } + + + QList vargs; + foreach (const QVariant &ar, args) { + vargs.append(QGenericArgument(ar.typeName(), ar.data())); + } + + QVariant returnValue; + currentRequest = event; + currentRequestId = rid; + requestCanceled = false; + + bool ok = false; + if (method.returns) { + QVariant retA(QVariant::nameToType(method.meta.typeName())); + QGenericReturnArgument ret(retA.typeName(), retA.data()); + if (args.count() > 8) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)), + (vargs.at(7)), + (vargs.at(7)) + ); + } + if (args.count() > 7) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)), + (vargs.at(7)) + ); + } + else if (args.count() > 6) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)) + ); + } + else if (args.count() > 5) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)) + ); + } + else if (args.count() > 4) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)) + ); + } + else if (args.count() > 3) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)) + ); + } + else if (args.count() > 2) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)) + ); + } + else if (args.count() > 1) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)), + (vargs.at(1)) + ); + } + else if (args.count() > 0) + { + ok = method.meta.invoke(invokable, + ret, + (vargs.at(0)) + ); + } + else + { + ok = method.meta.invoke(invokable, + ret + ); + } + returnValue = retA; + // the pass through QGenericReturnArgument didn't make it non null. + returnValue.data_ptr().is_null = 0; + } else { + if (args.count() > 8) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)), + (vargs.at(7)), + (vargs.at(7)) + ); + } + if (args.count() > 7) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)), + (vargs.at(7)) + ); + } + else if (args.count() > 6) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)), + (vargs.at(6)) + ); + } + else if (args.count() > 5) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)), + (vargs.at(5)) + ); + } + else if (args.count() > 4) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)), + (vargs.at(4)) + ); + } + else if (args.count() > 3) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)), + (vargs.at(3)) + ); + } + else if (args.count() > 2) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)), + (vargs.at(2)) + ); + } + else if (args.count() > 1) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)), + (vargs.at(1)) + ); + } + else if (args.count() > 0) + { + ok = method.meta.invoke(invokable, + (vargs.at(0)) + ); + } + else + { + ok = method.meta.invoke(invokable + ); + } + } + if (!ok) { + QVariantMap res; + res.insert("result", QVariant()); + res.insert("error", "execution failure"); + res.insert("id", rid); + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, + QxtJSON::stringify(res).toUtf8() + "\r\n"); + p->postEvent(err); + return; + } + if (requestCanceled) { + return; + } + + QVariantMap res; + res.insert("result", returnValue); + res.insert("error", QVariant()); + res.insert("id", rid); + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, + QxtJSON::stringify(res).toUtf8() + "\r\n"); + p->postEvent(err); + return; + +} +/*! + Constructs a new QxtWebJsonRPCService with \a sm and \a parent. + */ +QxtWebJsonRPCService::QxtWebJsonRPCService(QxtAbstractWebSessionManager* sm, QObject* parent) + : QxtAbstractWebService(sm, parent) + , d(new Private(this)) +{ + +} + +QxtWebJsonRPCService::~QxtWebJsonRPCService() +{ + delete d; +} + +/*! + * respond to the current request with an error. + * + * The return value of the current slot is NOT used. + * Instead null is returned, adhering to the jsonrpc specificaiton. + * + * Calling this function from somewhere else then a handler slot is undefined behaviour. + */ + +void QxtWebJsonRPCService::throwRPCError(QVariant error) +{ + d->requestCanceled= true; + QxtWebRequestEvent *event = d->currentRequest; + + QVariantMap res; + res.insert("result", QVariant()); + res.insert("error", error); + res.insert("id", d->currentRequestId); + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, + QxtJSON::stringify(res).toUtf8() + "\r\n"); + postEvent(err); +} + +/*! + Returns the current absolute url of this service depending on the request \a event. + */ +QUrl QxtWebJsonRPCService::self(QxtWebRequestEvent* event) + +{ + QStringList u = event->url.path().split('/'); + QStringList o = event->originalUrl.path().split('/'); + u.removeFirst(); + o.removeFirst(); + for (int i = 0;i < u.count();i++) + o.removeLast(); + + + QString r = "/"; + foreach(const QString& d, o) + { + r += d + '/'; + } + return r; +} + +/*! + \reimp + */ +void QxtWebJsonRPCService::pageRequestedEvent(QxtWebRequestEvent* event) +{ + if (event->method == "GET") { + QVariantMap params; + QList > enc = event->url.encodedQueryItems (); + for (int i = 0; i < enc.count(); i++) { + params.insert( + QUrl::fromPercentEncoding (enc.at(i).first), + QUrl::fromPercentEncoding (enc.at(i).second)); + } + QString method = event->url.path().split('/').last(); + d->handle(event, QVariant(), method, params); + return; + } + + + if (!event->content) { + QVariantMap res; + res.insert("result", QVariant()); + res.insert("error", "missing POST data"); + res.insert("id", QVariant()); + QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID, + QxtJSON::stringify(res).toUtf8() + "\r\n"); + err->status = 500; + postEvent(err); + return; + } + + d->content.insert(event->content, event); + if (event->content->bytesNeeded() == 0) { + d->handle(event->content); + } else { + connect(event->content, SIGNAL(readChannelFinished()), d, SLOT(readFinished())); + } +} + +/*! + \reimp + */ +void QxtWebJsonRPCService::functionInvokedEvent(QxtWebRequestEvent* event) +{ + postEvent(new QxtWebErrorEvent(event->sessionID, event->requestID, 500, "

Not supported

")); +} diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.h new file mode 100644 index 000000000..0873fe33a --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice.h @@ -0,0 +1,56 @@ + +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#ifndef QXTWEBJSONRPCSERVICE_H +#define QXTWEBJSONRPCSERVICE_H + +#include "qxtabstractwebservice.h" +#include + +class QXT_WEB_EXPORT QxtWebJsonRPCService : public QxtAbstractWebService +{ + Q_OBJECT +public: + explicit QxtWebJsonRPCService(QxtAbstractWebSessionManager* sm, QObject* parent = 0); + virtual ~QxtWebJsonRPCService(); + +protected: + void throwRPCError(QVariant error); + + QUrl self(QxtWebRequestEvent* event); + virtual void pageRequestedEvent(QxtWebRequestEvent* event); + virtual void functionInvokedEvent(QxtWebRequestEvent* event); +private: + class Private; + Private *d; +}; + +#endif // QXTWEBJSONRPCSERVICE_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice_p.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice_p.h new file mode 100644 index 000000000..04c974fff --- /dev/null +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebjsonrpcservice_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtwebjsonrpcservice.h" +#include "qxtwebcontent.h" +#include "qxtwebevent.h" +#include + +class QxtWebJsonRPCService::Private : public QObject +{ +Q_OBJECT +public: + Private(QxtWebJsonRPCService *that); + QMap content; + + QxtWebJsonRPCService *p; + void initTables(QObject *invokable); + bool tablesInitilized; + QObject *invokable; + + struct Method + { + QMetaMethod meta; + QByteArray name; + bool returns; + int argCount; + }; + QMap methods; + + QxtWebRequestEvent *currentRequest; + QVariant currentRequestId; + bool requestCanceled; + +public slots: + void readFinished(); + void handle(QxtWebContent *); + void handle( QxtWebRequestEvent *event, QVariant id, QString method, QVariant args); +}; + diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.cpp index 06209b36e..06a6f07f2 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! \class QxtWebServiceDirectory diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.h index a0ebe71d2..854871f59 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBSERVICEDIRECTORY_H #define QXTWEBSERVICEDIRECTORY_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory_p.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory_p.h index cbaa7528e..c5e8258fe 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory_p.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebservicedirectory_p.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBSERVICEDIRECTORY_P_H #define QXTWEBSERVICEDIRECTORY_P_H diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.cpp b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.cpp index 0ae2bd9a0..6e4104ef0 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.cpp +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.cpp @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ /*! @@ -36,7 +42,7 @@ A WebService that resolves the first part of the path to a slot name and passes \code class MyService : public QxtWebSlotService { -Q_OBJECT +//Q_OBJECT public slots: void hello(QxtWebRequestEvent* event, QString a) { diff --git a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.h b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.h index 4f917825e..8d0ca2d18 100644 --- a/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.h +++ b/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtwebslotservice.h @@ -1,27 +1,33 @@ + /**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtWeb module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ #ifndef QXTWEBSLOTSERVICE_H #define QXTWEBSLOTSERVICE_H