mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 02:54:33 +02:00
qt5: port QxtWeb and the web api
This commit is contained in:
@@ -111,7 +111,11 @@ public:
|
||||
|
||||
inline void* qxtConstructByName(const char* typeName, const void* copy = 0)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
return QMetaType::create(QMetaType::type(typeName), copy);
|
||||
#else
|
||||
return QMetaType::construct(QMetaType::type(typeName), copy);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void qxtDestroyByName(const char* typeName, void* data)
|
||||
|
@@ -215,7 +215,11 @@ void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event)
|
||||
env["CONTENT_TYPE"] = event->contentType;
|
||||
env["CONTENT_LENGTH"] = QString::number(event->content->unreadBytes());
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
env["QUERY_STRING"] = event->url.query();
|
||||
#else
|
||||
env["QUERY_STRING"] = event->url.encodedQuery();
|
||||
#endif
|
||||
|
||||
// Populate HTTP header environment variables
|
||||
QMultiHash<QString, QString>::const_iterator iter = event->headers.constBegin();
|
||||
@@ -251,10 +255,18 @@ void QxtWebCgiService::pageRequestedEvent(QxtWebRequestEvent* event)
|
||||
process->setEnvironment(p_env);
|
||||
|
||||
// Launch process
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
if (event->url.hasQuery() && event->url.query().contains('='))
|
||||
#else
|
||||
if (event->url.hasQuery() && event->url.encodedQuery().contains('='))
|
||||
#endif
|
||||
{
|
||||
// CGI/1.1 spec says to pass the query on the command line if there's no embedded = sign
|
||||
process->start(qxt_d().binary + ' ' + QUrl::fromPercentEncoding(event->url.encodedQuery()), QIODevice::ReadWrite);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
process->start(qxt_d().binary + ' ' + event->url.query(), QIODevice::ReadWrite);
|
||||
#else
|
||||
process->start(qxt_d().binary + ' ' + event->url.encodedQuery(), QIODevice::ReadWrite);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -52,6 +52,10 @@ QxtWeb uses QxtWebContent as an abstraction for streaming data.
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
#include <QUrlQuery>
|
||||
#endif
|
||||
|
||||
#ifndef QXT_DOXYGEN_RUN
|
||||
class QxtWebContentPrivate : public QxtPrivate<QxtWebContent>
|
||||
{
|
||||
@@ -270,7 +274,11 @@ QHash<QString, QString> QxtWebContent::parseUrlEncodedQuery(const QString& data)
|
||||
{
|
||||
QUrl post("/?" + data);
|
||||
QHash<QString, QString> rv;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
foreach(const QxtQueryItem& item, QUrlQuery( post ).queryItems())
|
||||
#else
|
||||
foreach(const QxtQueryItem& item, post.queryItems())
|
||||
#endif
|
||||
{
|
||||
rv.insertMulti(item.first, item.second);
|
||||
}
|
||||
|
Reference in New Issue
Block a user