Coding style, use nullptr and other minor things

This commit is contained in:
thalieht
2017-09-07 03:00:04 +03:00
committed by sledgehammer999
parent 8482464ad0
commit 07130c4b26
54 changed files with 361 additions and 403 deletions

View File

@@ -29,8 +29,8 @@
#ifndef BITTORRENT_INFOHASH_H
#define BITTORRENT_INFOHASH_H
#include <libtorrent/sha1_hash.hpp>
#include <QString>
#include <libtorrent/sha1_hash.hpp>
namespace BitTorrent
{

View File

@@ -29,8 +29,8 @@
#ifndef BITTORRENT_MAGNETURI_H
#define BITTORRENT_MAGNETURI_H
#include <QString>
#include <QList>
#include <QString>
#include <QUrl>
#include <libtorrent/add_torrent_params.hpp>

View File

@@ -26,12 +26,13 @@
* exception statement from your version.
*/
#include "base/net/geoipmanager.h"
#include "base/utils/string.h"
#include "base/unicodestrings.h"
#include "base/bittorrent/torrenthandle.h"
#include "peerinfo.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/net/geoipmanager.h"
#include "base/unicodestrings.h"
#include "base/utils/string.h"
namespace libt = libtorrent;
using namespace BitTorrent;
@@ -99,7 +100,6 @@ bool PeerInfo::isRemoteChocked() const
return (m_nativeInfo.flags & libt::peer_info::remote_choked);
}
bool PeerInfo::isSupportsExtensions() const
{
return (m_nativeInfo.flags & libt::peer_info::supports_extensions);
@@ -115,7 +115,6 @@ bool PeerInfo::isHandshake() const
return (m_nativeInfo.flags & libt::peer_info::handshake);
}
bool PeerInfo::isConnecting() const
{
return (m_nativeInfo.flags & libt::peer_info::connecting);
@@ -136,7 +135,6 @@ bool PeerInfo::optimisticUnchoke() const
return (m_nativeInfo.flags & libt::peer_info::optimistic_unchoke);
}
bool PeerInfo::isSnubbed() const
{
return (m_nativeInfo.flags & libt::peer_info::snubbed);
@@ -152,7 +150,6 @@ bool PeerInfo::isEndgameMode() const
return (m_nativeInfo.flags & libt::peer_info::endgame_mode);
}
bool PeerInfo::isHolepunched() const
{
return (m_nativeInfo.flags & libt::peer_info::holepunched);
@@ -183,7 +180,6 @@ bool PeerInfo::isPlaintextEncrypted() const
return (m_nativeInfo.flags & libt::peer_info::plaintext_encrypted);
}
PeerAddress PeerInfo::address() const
{
return PeerAddress(QHostAddress(QString::fromStdString(m_nativeInfo.ip.address().to_string())),
@@ -195,7 +191,6 @@ QString PeerInfo::client() const
return QString::fromStdString(m_nativeInfo.client);
}
qreal PeerInfo::progress() const
{
return m_nativeInfo.progress;
@@ -206,7 +201,6 @@ int PeerInfo::payloadUpSpeed() const
return m_nativeInfo.payload_up_speed;
}
int PeerInfo::payloadDownSpeed() const
{
return m_nativeInfo.payload_down_speed;
@@ -217,7 +211,6 @@ qlonglong PeerInfo::totalUpload() const
return m_nativeInfo.total_upload;
}
qlonglong PeerInfo::totalDownload() const
{
return m_nativeInfo.total_download;
@@ -239,7 +232,7 @@ QString PeerInfo::connectionType() const
return QString::fromUtf8(C_UTP);
QString connection;
switch(m_nativeInfo.connection_type) {
switch (m_nativeInfo.connection_type) {
case libt::peer_info::http_seed:
case libt::peer_info::web_seed:
connection = "Web";
@@ -281,14 +274,14 @@ qreal PeerInfo::relevance() const
void PeerInfo::determineFlags()
{
if (isInteresting()) {
//d = Your client wants to download, but peer doesn't want to send (interested and choked)
// d = Your client wants to download, but peer doesn't want to send (interested and choked)
if (isRemoteChocked()) {
m_flags += "d ";
m_flagsDescription += tr("interested(local) and choked(peer)");
m_flagsDescription += ", ";
}
else {
//D = Currently downloading (interested and not choked)
// D = Currently downloading (interested and not choked)
m_flags += "D ";
m_flagsDescription += tr("interested(local) and unchoked(peer)");
m_flagsDescription += ", ";
@@ -296,92 +289,91 @@ void PeerInfo::determineFlags()
}
if (isRemoteInterested()) {
//u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
if (isChocked()) {
m_flags += "u ";
m_flagsDescription += tr("interested(peer) and choked(local)");
m_flagsDescription += ", ";
}
else {
//U = Currently uploading (interested and not choked)
// U = Currently uploading (interested and not choked)
m_flags += "U ";
m_flagsDescription += tr("interested(peer) and unchoked(local)");
m_flagsDescription += ", ";
}
}
//O = Optimistic unchoke
// O = Optimistic unchoke
if (optimisticUnchoke()) {
m_flags += "O ";
m_flagsDescription += tr("optimistic unchoke");
m_flagsDescription += ", ";
}
//S = Peer is snubbed
// S = Peer is snubbed
if (isSnubbed()) {
m_flags += "S ";
m_flagsDescription += tr("peer snubbed");
m_flagsDescription += ", ";
}
//I = Peer is an incoming connection
// I = Peer is an incoming connection
if (!isLocalConnection()) {
m_flags += "I ";
m_flagsDescription += tr("incoming connection");
m_flagsDescription += ", ";
}
//K = Peer is unchoking your client, but your client is not interested
// K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting()) {
m_flags += "K ";
m_flagsDescription += tr("not interested(local) and unchoked(peer)");
m_flagsDescription += ", ";
}
//? = Your client unchoked the peer but the peer is not interested
// ? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested()) {
m_flags += "? ";
m_flagsDescription += tr("not interested(peer) and unchoked(local)");
m_flagsDescription += ", ";
}
//X = Peer was included in peerlists obtained through Peer Exchange (PEX)
// X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX()) {
m_flags += "X ";
m_flagsDescription += tr("peer from PEX");
m_flagsDescription += ", ";
}
//H = Peer was obtained through DHT
// H = Peer was obtained through DHT
if (fromDHT()) {
m_flags += "H ";
m_flagsDescription += tr("peer from DHT");
m_flagsDescription += ", ";
}
//E = Peer is using Protocol Encryption (all traffic)
// E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted()) {
m_flags += "E ";
m_flagsDescription += tr("encrypted traffic");
m_flagsDescription += ", ";
}
//e = Peer is using Protocol Encryption (handshake)
// e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted()) {
m_flags += "e ";
m_flagsDescription += tr("encrypted handshake");
m_flagsDescription += ", ";
}
//P = Peer is using uTorrent uTP
// P = Peer is using uTorrent uTP
if (useUTPSocket()) {
m_flags += "P ";
m_flagsDescription += QString::fromUtf8(C_UTP);
m_flagsDescription += ", ";
}
//L = Peer is local
// L = Peer is local
if (fromLSD()) {
m_flags += "L";
m_flagsDescription += tr("peer from LSD");

View File

@@ -29,11 +29,11 @@
#ifndef BITTORRENT_PEERINFO_H
#define BITTORRENT_PEERINFO_H
#include <libtorrent/peer_info.hpp>
#include <QHostAddress>
#include <QBitArray>
#include <QCoreApplication>
#include <QHostAddress>
#include <libtorrent/peer_info.hpp>
namespace BitTorrent
{

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libt.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,17 +24,15 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "filterparserthread.h"
#include <cctype>
#include <QDataStream>
#include <QFile>
#include <cctype>
#include "base/logger.h"
namespace libt = libtorrent;

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef FILTERPARSERTHREAD_H
@@ -42,7 +40,7 @@ class FilterParserThread : public QThread
Q_OBJECT
public:
FilterParserThread(QObject *parent = 0);
FilterParserThread(QObject *parent = nullptr);
~FilterParserThread();
void processFilterFile(const QString &filePath);
libtorrent::ip_filter IPfilter();

View File

@@ -29,11 +29,11 @@
#ifndef RESUMEDATASAVINGMANAGER_H
#define RESUMEDATASAVINGMANAGER_H
#include <QObject>
#include <QByteArray>
#include <QDir>
#include <QObject>
class ResumeDataSavingManager: public QObject
class ResumeDataSavingManager : public QObject
{
Q_OBJECT

View File

@@ -4,9 +4,9 @@
#include <libtorrent/session.hpp>
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
#include "base/profile.h"
#include "base/bittorrent/session.h"
static const qint64 SAVE_INTERVAL = 15 * 60 * 1000;

View File

@@ -4,7 +4,10 @@
#include <QObject>
#include <QTimer>
namespace BitTorrent { class Session; }
namespace BitTorrent
{
class Session;
}
class Statistics : QObject
{

View File

@@ -29,6 +29,10 @@
#include "session.h"
#include <cstdlib>
#include <queue>
#include <vector>
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>
@@ -43,10 +47,6 @@
#include <QTimer>
#include <QUuid>
#include <cstdlib>
#include <queue>
#include <vector>
#include <libtorrent/alert_types.hpp>
#if LIBTORRENT_VERSION_NUM >= 10100
#include <libtorrent/bdecode.hpp>
@@ -71,24 +71,24 @@
#include <libtorrent/torrent_info.hpp>
#include "base/logger.h"
#include "base/profile.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/net/portforwarder.h"
#include "base/net/proxyconfigurationmanager.h"
#include "base/profile.h"
#include "base/torrentfileguard.h"
#include "base/torrentfilter.h"
#include "base/unicodestrings.h"
#include "base/utils/net.h"
#include "base/utils/misc.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/net.h"
#include "base/utils/random.h"
#include "base/utils/string.h"
#include "magneturi.h"
#include "private/filterparserthread.h"
#include "private/statistics.h"
#include "private/bandwidthscheduler.h"
#include "private/filterparserthread.h"
#include "private/resumedatasavingmanager.h"
#include "private/statistics.h"
#include "torrenthandle.h"
#include "tracker.h"
#include "trackerentry.h"

View File

@@ -27,21 +27,23 @@
* exception statement from your version.
*/
#include "torrenthandle.h"
#include <algorithm>
#include <type_traits>
#include <QDebug>
#include <QStringList>
#include <QFile>
#include <QDir>
#include <QByteArray>
#include <QBitArray>
#include <QByteArray>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QStringList>
#include <libtorrent/entry.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/address.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/create_torrent.hpp>
#include <libtorrent/entry.hpp>
#include <libtorrent/magnet_uri.hpp>
#if LIBTORRENT_VERSION_NUM >= 10100
#include <libtorrent/time.hpp>
@@ -56,13 +58,12 @@
#include "base/logger.h"
#include "base/preferences.h"
#include "base/profile.h"
#include "base/utils/string.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "session.h"
#include "base/utils/string.h"
#include "peerinfo.h"
#include "session.h"
#include "trackerentry.h"
#include "torrenthandle.h"
const QString QB_EXT {".!qB"};

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,16 +25,15 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <vector>
#include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp>
#include "base/preferences.h"
#include "base/http/server.h"
#include "base/preferences.h"
#include "base/utils/string.h"
#include "tracker.h"

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2010 Christophe Dumez
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,17 +25,16 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef BITTORRENT_TRACKER_H
#define BITTORRENT_TRACKER_H
#include <QHash>
#include "base/http/types.h"
#include "base/http/responsebuilder.h"
#include "base/http/irequesthandler.h"
#include "base/http/responsebuilder.h"
#include "base/http/types.h"
namespace libtorrent
{
@@ -82,7 +81,7 @@ namespace BitTorrent
Q_DISABLE_COPY(Tracker)
public:
explicit Tracker(QObject *parent = 0);
explicit Tracker(QObject *parent = nullptr);
~Tracker();
bool start();

View File

@@ -12,9 +12,9 @@
#endif
#endif
#include "base/preferences.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/magneturi.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/preferences.h"
#include "filesystemwatcher.h"
#ifndef CIFS_MAGIC_NUMBER

View File

@@ -1,12 +1,12 @@
#ifndef FILESYSTEMWATCHER_H
#define FILESYSTEMWATCHER_H
#include <QFileSystemWatcher>
#include <QDir>
#include <QTimer>
#include <QFileSystemWatcher>
#include <QHash>
#include <QPointer>
#include <QStringList>
#include <QHash>
#include <QTimer>
/*
* Subclassing QFileSystemWatcher in order to support Network File
@@ -17,7 +17,7 @@ class FileSystemWatcher : public QFileSystemWatcher
Q_OBJECT
public:
explicit FileSystemWatcher(QObject *parent = 0);
explicit FileSystemWatcher(QObject *parent = nullptr);
~FileSystemWatcher();
QStringList directories() const;

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,21 +25,20 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "requestparser.h"
#include <QDebug>
#include <QDir>
#include <QStringList>
#include <QUrl>
#include <QUrlQuery>
#include <QDir>
#include <QDebug>
#include "requestparser.h"
const QByteArray EOL("\r\n");
const QByteArray EOH("\r\n\r\n");
inline QString unquoted(const QString& str)
inline QString unquoted(const QString &str)
{
if ((str[0] == '\"') && (str[str.length() - 1] == '\"'))
return str.mid(1, str.length() - 2);
@@ -49,7 +48,7 @@ inline QString unquoted(const QString& str)
using namespace Http;
RequestParser::ErrorCode RequestParser::parse(const QByteArray& data, Request& request, uint maxContentLength)
RequestParser::ErrorCode RequestParser::parse(const QByteArray &data, Request &request, uint maxContentLength)
{
return RequestParser(maxContentLength).parseHttpRequest(data, request);
}
@@ -59,42 +58,42 @@ RequestParser::RequestParser(uint maxContentLength)
{
}
RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data, Request& request)
RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray &data, Request &request)
{
m_request = Request();
// Parse HTTP request header
const int header_end = data.indexOf(EOH);
if (header_end < 0) {
const int headerEnd = data.indexOf(EOH);
if (headerEnd < 0) {
qDebug() << Q_FUNC_INFO << "incomplete request";
return IncompleteRequest;
}
if (!parseHttpHeader(data.left(header_end))) {
if (!parseHttpHeader(data.left(headerEnd))) {
qWarning() << Q_FUNC_INFO << "header parsing error";
return BadRequest;
}
// Parse HTTP request message
if (m_request.headers.contains("content-length")) {
int content_length = m_request.headers["content-length"].toInt();
if (content_length < 0) {
qWarning() << Q_FUNC_INFO << "bad request: content-length negative";
int contentLength = m_request.headers["content-length"].toInt();
if (contentLength < 0) {
qWarning() << Q_FUNC_INFO << "bad request: content-length is negative";
return BadRequest;
}
if (content_length > static_cast<int>(m_maxContentLength)) {
if (contentLength > static_cast<int>(m_maxContentLength)) {
qWarning() << Q_FUNC_INFO << "bad request: message too long";
return BadRequest;
}
QByteArray content = data.mid(header_end + EOH.length(), content_length);
if (content.length() < content_length) {
QByteArray content = data.mid(headerEnd + EOH.length(), contentLength);
if (content.length() < contentLength) {
qDebug() << Q_FUNC_INFO << "incomplete request";
return IncompleteRequest;
}
if ((content_length > 0) && !parseContent(content)) {
if ((contentLength > 0) && !parseContent(content)) {
qWarning() << Q_FUNC_INFO << "message parsing error";
return BadRequest;
}
@@ -102,7 +101,7 @@ RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data,
// qDebug() << Q_FUNC_INFO;
// qDebug() << "HTTP Request header:";
// qDebug() << data.left(header_end) << "\n";
// qDebug() << data.left(headerEnd) << "\n";
request = m_request;
return NoError;
@@ -132,7 +131,7 @@ bool RequestParser::parseStartingLine(const QString &line)
return false;
}
bool RequestParser::parseHeaderLine(const QString &line, QPair<QString, QString>& out)
bool RequestParser::parseHeaderLine(const QString &line, QPair<QString, QString> &out)
{
int i = line.indexOf(QLatin1Char(':'));
if (i == -1) {
@@ -150,7 +149,7 @@ bool RequestParser::parseHttpHeader(const QByteArray &data)
QStringList lines = str.trimmed().split(EOL);
QStringList headerLines;
foreach (const QString& line, lines) {
foreach (const QString &line, lines) {
if (line[0].isSpace()) { // header line continuation
if (!headerLines.isEmpty()) { // really continuation
headerLines.last() += QLatin1Char(' ');
@@ -181,7 +180,7 @@ bool RequestParser::parseHttpHeader(const QByteArray &data)
return true;
}
QList<QByteArray> RequestParser::splitMultipartData(const QByteArray& data, const QByteArray& boundary)
QList<QByteArray> RequestParser::splitMultipartData(const QByteArray &data, const QByteArray &boundary)
{
QList<QByteArray> ret;
QByteArray sep = boundary + EOL;
@@ -205,7 +204,7 @@ QList<QByteArray> RequestParser::splitMultipartData(const QByteArray& data, cons
return ret;
}
bool RequestParser::parseContent(const QByteArray& data)
bool RequestParser::parseContent(const QByteArray &data)
{
// Parse message content
qDebug() << Q_FUNC_INFO << "Content-Length: " << m_request.headers["content-length"];
@@ -243,14 +242,14 @@ Content-Disposition: form-data; name=\"Upload\"
Submit Query
--cH2ae0GI3KM7GI3Ij5ae0ei4Ij5Ij5--
**/
QString content_type = m_request.headers["content-type"];
if (content_type.startsWith("multipart/form-data")) {
QString contentType = m_request.headers["content-type"];
if (contentType.startsWith("multipart/form-data")) {
const QRegExp boundaryRegexQuoted("boundary=\"([ \\w'()+,-\\./:=\\?]+)\"");
const QRegExp boundaryRegexNotQuoted("boundary=([\\w'()+,-\\./:=\\?]+)");
QByteArray boundary;
if (boundaryRegexQuoted.indexIn(content_type) < 0) {
if (boundaryRegexNotQuoted.indexIn(content_type) < 0) {
if (boundaryRegexQuoted.indexIn(contentType) < 0) {
if (boundaryRegexNotQuoted.indexIn(contentType) < 0) {
qWarning() << "Could not find boundary in multipart/form-data header!";
return false;
}
@@ -274,21 +273,21 @@ Submit Query
return true;
}
qWarning() << Q_FUNC_INFO << "unknown content type:" << qPrintable(content_type);
qWarning() << Q_FUNC_INFO << "unknown content type:" << qPrintable(contentType);
return false;
}
bool RequestParser::parseFormData(const QByteArray& data)
bool RequestParser::parseFormData(const QByteArray &data)
{
// Parse form data header
const int header_end = data.indexOf(EOH);
if (header_end < 0) {
const int headerEnd = data.indexOf(EOH);
if (headerEnd < 0) {
qDebug() << "Invalid form data: \n" << data;
return false;
}
QString header_str = QString::fromUtf8(data.left(header_end));
QStringList lines = header_str.trimmed().split(EOL);
QString headerStr = QString::fromUtf8(data.left(headerEnd));
QStringList lines = headerStr.trimmed().split(EOL);
QStringMap headers;
foreach (const QString& line, lines) {
QPair<QString, QString> header;
@@ -302,7 +301,7 @@ bool RequestParser::parseFormData(const QByteArray& data)
if (!headers.contains("content-disposition")
|| !parseHeaderValue(headers["content-disposition"], disposition)
|| !disposition.contains("name")) {
qDebug() << "Invalid form data header: \n" << header_str;
qDebug() << "Invalid form data header: \n" << headerStr;
return false;
}
@@ -310,18 +309,18 @@ bool RequestParser::parseFormData(const QByteArray& data)
UploadedFile ufile;
ufile.filename = disposition["filename"];
ufile.type = disposition["content-type"];
ufile.data = data.mid(header_end + EOH.length());
ufile.data = data.mid(headerEnd + EOH.length());
m_request.files.append(ufile);
}
else {
m_request.posts[disposition["name"]] = QString::fromUtf8(data.mid(header_end + EOH.length()));
m_request.posts[disposition["name"]] = QString::fromUtf8(data.mid(headerEnd + EOH.length()));
}
return true;
}
bool RequestParser::parseHeaderValue(const QString& value, QStringMap& out)
bool RequestParser::parseHeaderValue(const QString &value, QStringMap &out)
{
int pos = value.indexOf(QLatin1Char(';'));
if (pos == -1) {

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef HTTP_REQUESTPARSER_H

View File

@@ -37,7 +37,7 @@ namespace Http
class ResponseBuilder : public QObject
{
public:
explicit ResponseBuilder(QObject *parent = 0);
explicit ResponseBuilder(QObject *parent = nullptr);
protected:
void status(uint code = 200, const QString &text = QLatin1String("OK"));

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "responsegenerator.h"
@@ -69,7 +67,7 @@ QByteArray Http::toByteArray(Response response)
QString Http::httpDate()
{
// [RFC 7231] 7.1.1.1. Date/Time Formats
// example: "Sun, 06 Nov 1994 08:49:37 GMT"
// example: "Sun, 06 Nov 1994 08:49:37 GMT"
return QLocale::c().toString(QDateTime::currentDateTimeUtc(), QLatin1String("ddd, dd MMM yyyy HH:mm:ss"))
.append(QLatin1String(" GMT"));

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Ishan Arora and Christophe Dumez
* Copyright (C) 2006 Ishan Arora and Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/

View File

@@ -34,7 +34,6 @@
#include <QNetworkProxy>
#include <QStringList>
#include <QTimer>
#ifndef QT_NO_OPENSSL
#include <QSslSocket>
#else
@@ -123,15 +122,13 @@ bool Server::setupHttps(const QByteArray &certificates, const QByteArray &key)
const QList<QSslCertificate> certs = QSslCertificate::fromData(certificates);
const bool areCertsValid = !certs.empty() && std::all_of(certs.begin(), certs.end(), [](const QSslCertificate &c) { return !c.isNull(); });
if (!sslKey.isNull() && areCertsValid)
{
if (!sslKey.isNull() && areCertsValid) {
m_key = sslKey;
m_certificates = certs;
m_https = true;
return true;
}
else
{
else {
disableHttps();
return false;
}
@@ -164,4 +161,4 @@ QList<QSslCipher> Server::safeCipherList() const
return safeCiphers;
}
#endif
#endif // QT_NO_OPENSSL

View File

@@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
@@ -46,13 +44,13 @@ namespace Http
class IRequestHandler;
class Connection;
class Server: public QTcpServer
class Server : public QTcpServer
{
Q_OBJECT
Q_DISABLE_COPY(Server)
public:
Server(IRequestHandler *requestHandler, QObject *parent = 0);
Server(IRequestHandler *requestHandler, QObject *parent = nullptr);
~Server();
#ifndef QT_NO_OPENSSL
@@ -67,7 +65,7 @@ namespace Http
void incomingConnection(qintptr socketDescriptor);
IRequestHandler *m_requestHandler;
QList<Connection *> m_connections; // for tracking persistence connections
QList<Connection *> m_connections; // for tracking persistent connections
#ifndef QT_NO_OPENSSL
QList<QSslCipher> safeCipherList() const;

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <QDebug>
@@ -34,8 +32,8 @@
#include <QUrlQuery>
#include "base/logger.h"
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "dnsupdater.h"
using namespace Net;
@@ -143,7 +141,7 @@ QString DNSUpdater::getUpdateUrl() const
Q_ASSERT(!m_lastIP.isNull());
// Service specific
switch(m_service) {
switch (m_service) {
case DNS::DYNDNS:
url.setHost("members.dyndns.org");
break;
@@ -230,7 +228,6 @@ void DNSUpdater::processIPUpdateReply(const QString &reply)
if (code == "abuse") {
logger->addMessage(tr("Dynamic DNS error: Your username was blocked due to abuse."), Log::CRITICAL);
m_state = FATAL;
return;
}
}
@@ -289,7 +286,7 @@ void DNSUpdater::updateCredentials()
QUrl DNSUpdater::getRegistrationUrl(int service)
{
switch(service) {
switch (service) {
case DNS::DYNDNS:
return QUrl("https://www.dyndns.com/account/services/hosts/add.html");
case DNS::NOIP:

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,16 +24,14 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef DNSUPDATER_H
#define DNSUPDATER_H
#include <QObject>
#include <QHostAddress>
#include <QDateTime>
#include <QHostAddress>
#include <QObject>
#include <QTimer>
#include "base/preferences.h"
@@ -41,12 +39,12 @@
namespace Net
{
// Based on http://www.dyndns.com/developers/specs/
class DNSUpdater: public QObject
class DNSUpdater : public QObject
{
Q_OBJECT
public:
explicit DNSUpdater(QObject *parent = 0);
explicit DNSUpdater(QObject *parent = nullptr);
~DNSUpdater();
static QUrl getRegistrationUrl(int service);

View File

@@ -27,20 +27,21 @@
* exception statement from your version.
*/
#include <QTemporaryFile>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkProxy>
#include <QNetworkCookie>
#include <QUrl>
#include "downloadhandler.h"
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkCookie>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QTemporaryFile>
#include <QUrl>
#include "base/utils/fs.h"
#include "base/utils/gzip.h"
#include "base/utils/misc.h"
#include "downloadmanager.h"
#include "downloadhandler.h"
static QString errorCodeToString(QNetworkReply::NetworkError status);
@@ -192,14 +193,14 @@ void DownloadHandler::handleRedirection(QUrl newUrl)
m_reply->deleteLater();
m_reply = tmp->m_reply;
init();
tmp->m_reply = 0;
tmp->m_reply = nullptr;
delete tmp;
}
}
QString errorCodeToString(QNetworkReply::NetworkError status)
{
switch(status) {
switch (status) {
case QNetworkReply::HostNotFoundError:
return QObject::tr("The remote host name was not found (invalid hostname)");
case QNetworkReply::OperationCanceledError:

View File

@@ -32,11 +32,9 @@
#include <QObject>
QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QNetworkReply;
class QUrl;
QT_END_NAMESPACE
namespace Net
{

View File

@@ -27,21 +27,22 @@
* exception statement from your version.
*/
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QHostAddress>
#include "geoipmanager.h"
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QHostAddress>
#include "base/logger.h"
#include "base/preferences.h"
#include "base/profile.h"
#include "base/utils/fs.h"
#include "base/utils/gzip.h"
#include "downloadmanager.h"
#include "downloadhandler.h"
#include "downloadmanager.h"
#include "private/geoipdatabase.h"
#include "geoipmanager.h"
static const char DATABASE_URL[] = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz";
static const char GEOIP_FOLDER[] = "GeoIP";
@@ -52,11 +53,11 @@ using namespace Net;
// GeoIPManager
GeoIPManager *GeoIPManager::m_instance = 0;
GeoIPManager *GeoIPManager::m_instance = nullptr;
GeoIPManager::GeoIPManager()
: m_enabled(false)
, m_geoIPDatabase(0)
, m_geoIPDatabase(nullptr)
{
configure();
connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure()));
@@ -78,7 +79,7 @@ void GeoIPManager::freeInstance()
{
if (m_instance) {
delete m_instance;
m_instance = 0;
m_instance = nullptr;
}
}
@@ -91,7 +92,7 @@ void GeoIPManager::loadDatabase()
{
if (m_geoIPDatabase) {
delete m_geoIPDatabase;
m_geoIPDatabase = 0;
m_geoIPDatabase = nullptr;
}
QString filepath = Utils::Fs::expandPathAbs(
@@ -407,7 +408,7 @@ void GeoIPManager::configure()
}
else if (!m_enabled && m_geoIPDatabase) {
delete m_geoIPDatabase;
m_geoIPDatabase = 0;
m_geoIPDatabase = nullptr;
}
}
}

View File

@@ -30,8 +30,8 @@
#ifndef NET_GEOIPMANAGER_H
#define NET_GEOIPMANAGER_H
#include <QObject>
#include <QCache>
#include <QObject>
class QHostAddress;
class QString;

View File

@@ -65,7 +65,7 @@ void PortForwarder::freeInstance()
{
if (m_instance) {
delete m_instance;
m_instance = 0;
m_instance = nullptr;
}
}
@@ -143,4 +143,4 @@ void PortForwarder::stop()
Logger::instance()->addMessage(tr("UPnP / NAT-PMP support [OFF]"), Log::INFO);
}
PortForwarder *PortForwarder::m_instance = 0;
PortForwarder *PortForwarder::m_instance = nullptr;

View File

@@ -29,8 +29,8 @@
#ifndef NET_PORTFORWARDER_H
#define NET_PORTFORWARDER_H
#include <QObject>
#include <QHash>
#include <QObject>
namespace libtorrent
{
@@ -56,7 +56,7 @@ namespace Net
void deletePort(quint16 port);
private:
explicit PortForwarder(libtorrent::session *const provider, QObject *parent = 0);
explicit PortForwarder(libtorrent::session *const provider, QObject *parent = nullptr);
~PortForwarder();
void start();

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
/*
@@ -33,22 +31,23 @@
*/
#include "smtp.h"
#include "base/preferences.h"
#include "base/logger.h"
#include <QCryptographicHash>
#include <QDebug>
#include <QHostAddress>
#include <QHostInfo>
#include <QNetworkInterface>
#include <QStringList>
#include <QTextCodec>
#include <QTextStream>
#ifndef QT_NO_OPENSSL
#include <QSslSocket>
#else
#include <QTcpSocket>
#endif
#include <QTextCodec>
#include <QDebug>
#include <QHostAddress>
#include <QHostInfo>
#include <QNetworkInterface>
#include <QCryptographicHash>
#include <QStringList>
#include "base/logger.h"
#include "base/preferences.h"
namespace
{

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
/*
@@ -35,22 +33,20 @@
#ifndef SMTP_H
#define SMTP_H
#include <QString>
#include <QObject>
#include <QAbstractSocket>
#include <QByteArray>
#include <QHash>
#include <QAbstractSocket>
#include <QMetaType>
#include <QObject>
#include <QString>
QT_BEGIN_NAMESPACE
class QTextStream;
#ifndef QT_NO_OPENSSL
class QSslSocket;
#else
class QTcpSocket;
#endif
class QTextCodec;
QT_END_NAMESPACE
class QTextStream;
namespace Net
{
@@ -59,7 +55,7 @@ namespace Net
Q_OBJECT
public:
Smtp(QObject *parent = 0);
Smtp(QObject *parent = nullptr);
~Smtp();
void sendMail(const QString &from, const QString &to, const QString &subject, const QString &body);
@@ -126,4 +122,4 @@ namespace Net
};
}
#endif
#endif // SMTP_H