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 @@
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#if defined(QBT_STATIC_QT) #if defined(QBT_STATIC_QT)
#include <QtPlugin> #include <QtPlugin>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_IMPORT_PLUGIN(QICOPlugin)
#else
Q_IMPORT_PLUGIN(qico) Q_IMPORT_PLUGIN(qico)
#endif #endif
#endif
#include <QMessageBox> #include <QMessageBox>
#include <QStyleFactory> #include <QStyleFactory>
#include <QStyle> #include <QStyle>

1
src/qtlibtorrent/qbtsession.h

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

10
src/tracker/qtracker.cpp

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

16
src/webui/httprequestparser.cpp

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

Loading…
Cancel
Save