Coding style, use nullptr and other minor things

This commit is contained in:
thalieht
2017-09-07 03:00:04 +03:00
parent f27e75e8fa
commit 525fdd6c2b
54 changed files with 361 additions and 403 deletions

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