Browse Source

Fix compilation with Qt5.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
ef3f7d18c9
  1. 4
      src/main.cpp
  2. 1
      src/qtlibtorrent/qbtsession.h
  3. 10
      src/tracker/qtracker.cpp
  4. 16
      src/webui/httprequestparser.cpp

4
src/main.cpp

@ -36,8 +36,12 @@ @@ -36,8 +36,12 @@
#ifndef DISABLE_GUI
#if defined(QBT_STATIC_QT)
#include <QtPlugin>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_IMPORT_PLUGIN(QICOPlugin)
#else
Q_IMPORT_PLUGIN(qico)
#endif
#endif
#include <QMessageBox>
#include <QStyleFactory>
#include <QStyle>

1
src/qtlibtorrent/qbtsession.h

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#ifndef __BITTORRENT_H__
#define __BITTORRENT_H__
#include <QMap>
#include <QHash>
#include <QUrl>
#include <QStringList>

10
src/tracker/qtracker.cpp

@ -31,6 +31,9 @@ @@ -31,6 +31,9 @@
#include <QHttpRequestHeader>
#include <QTcpSocket>
#include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QUrlQuery>
#endif
#include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp>
@ -109,8 +112,13 @@ void QTracker::readRequest() @@ -109,8 +112,13 @@ void QTracker::readRequest()
// OK, this is a GET request
// Parse GET parameters
QHash<QString, QString> get_parameters;
QUrl url = QUrl::fromEncoded(http_request.path().toAscii());
QUrl url = QUrl::fromEncoded(http_request.path().toLatin1());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QUrlQuery query(url);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
get_parameters[pair.first] = pair.second;

16
src/webui/httprequestparser.cpp

@ -31,6 +31,9 @@ @@ -31,6 +31,9 @@
#include "httprequestparser.h"
#include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QUrlQuery>
#endif
#include <QDebug>
HttpRequestParser::HttpRequestParser(): m_error(false)
@ -69,11 +72,16 @@ void HttpRequestParser::writeHeader(const QByteArray& ba) { @@ -69,11 +72,16 @@ void HttpRequestParser::writeHeader(const QByteArray& ba) {
m_error = false;
// Parse header
m_header = QHttpRequestHeader(ba);
QUrl url = QUrl::fromEncoded(m_header.path().toAscii());
QUrl url = QUrl::fromEncoded(m_header.path().toLatin1());
m_path = url.path();
// Parse GET parameters
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QUrlQuery query(url);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
m_getMap[pair.first] = pair.second;
@ -102,8 +110,14 @@ void HttpRequestParser::writeMessage(const QByteArray& ba) { @@ -102,8 +110,14 @@ void HttpRequestParser::writeMessage(const QByteArray& ba) {
// Parse POST data
if (m_header.contentType() == "application/x-www-form-urlencoded") {
QUrl url;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString tmp(m_data);
QUrlQuery query(tmp);
QListIterator<QPair<QString, QString> > i(query.queryItems());
#else
url.setEncodedQuery(m_data);
QListIterator<QPair<QString, QString> > i(url.queryItems());
#endif
while (i.hasNext()) {
QPair<QString, QString> pair = i.next();
m_postMap[pair.first] = pair.second;

Loading…
Cancel
Save