mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #7396 from thalieht/updownratio
Properly pre-select the selected torrent's current ratio limiting options in UpDownRatioDlg
This commit is contained in:
commit
083bc71315
@ -195,7 +195,7 @@ bool upgrade(bool ask = true)
|
||||
resumeData["qBt-forced"] = false;
|
||||
|
||||
resumeData["qBt-savePath"] = oldTorrent.value("save_path").toString().toStdString();
|
||||
resumeData["qBt-ratioLimit"] = QString::number(oldTorrent.value("max_ratio", -2).toReal()).toStdString();
|
||||
resumeData["qBt-ratioLimit"] = static_cast<int>(oldTorrent.value("max_ratio", -2).toReal() * 1000);
|
||||
resumeData["qBt-label"] = oldTorrent.value("label").toString().toStdString();
|
||||
resumeData["qBt-name"] = oldTorrent.value("name").toString().toStdString();
|
||||
resumeData["qBt-seedStatus"] = oldTorrent.value("seed").toBool();
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
@ -374,7 +367,6 @@ void PeerInfo::determineFlags()
|
||||
}
|
||||
|
||||
// P = Peer is using uTorrent uTP
|
||||
|
||||
if (useUTPSocket()) {
|
||||
m_flags += "P ";
|
||||
m_flagsDescription += QString::fromUtf8(C_UTP);
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -29,9 +29,9 @@
|
||||
#ifndef RESUMEDATASAVINGMANAGER_H
|
||||
#define RESUMEDATASAVINGMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
|
||||
class ResumeDataSavingManager : public QObject
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -4,7 +4,10 @@
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
namespace BitTorrent { class Session; }
|
||||
namespace BitTorrent
|
||||
{
|
||||
class Session;
|
||||
}
|
||||
|
||||
class Statistics : QObject
|
||||
{
|
||||
|
@ -29,6 +29,11 @@
|
||||
|
||||
#include "session.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
@ -43,10 +48,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 +72,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"
|
||||
@ -3384,7 +3385,7 @@ bool Session::isKnownTorrent(const InfoHash &hash) const
|
||||
|
||||
void Session::updateSeedingLimitTimer()
|
||||
{
|
||||
if ((globalMaxRatio() == -1) && !hasPerTorrentRatioLimit()
|
||||
if ((globalMaxRatio() == TorrentHandle::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit()
|
||||
&& (globalMaxSeedingMinutes() == TorrentHandle::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit()) {
|
||||
if (m_seedingLimitTimer->isActive())
|
||||
m_seedingLimitTimer->stop();
|
||||
@ -4372,7 +4373,12 @@ namespace
|
||||
|
||||
torrentData.savePath = Profile::instance().fromPortablePath(
|
||||
Utils::Fs::fromNativePath(QString::fromStdString(fast.dict_find_string_value("qBt-savePath"))));
|
||||
torrentData.ratioLimit = QString::fromStdString(fast.dict_find_string_value("qBt-ratioLimit")).toDouble();
|
||||
|
||||
std::string ratioLimitString = fast.dict_find_string_value("qBt-ratioLimit");
|
||||
if (ratioLimitString.empty())
|
||||
torrentData.ratioLimit = fast.dict_find_int_value("qBt-ratioLimit", TorrentHandle::USE_GLOBAL_RATIO * 1000) / 1000.0;
|
||||
else
|
||||
torrentData.ratioLimit = QString::fromStdString(ratioLimitString).toDouble();
|
||||
torrentData.seedingTimeLimit = fast.dict_find_int_value("qBt-seedingTimeLimit", TorrentHandle::USE_GLOBAL_SEEDING_TIME);
|
||||
// **************************************************************************************
|
||||
// Workaround to convert legacy label to category
|
||||
|
@ -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"};
|
||||
|
||||
@ -1180,38 +1181,20 @@ qreal TorrentHandle::distributedCopies() const
|
||||
return m_nativeStatus.distributed_copies;
|
||||
}
|
||||
|
||||
qreal TorrentHandle::maxRatio(bool *usesGlobalRatio) const
|
||||
qreal TorrentHandle::maxRatio() const
|
||||
{
|
||||
qreal ratioLimit = m_ratioLimit;
|
||||
if (m_ratioLimit == USE_GLOBAL_RATIO)
|
||||
return m_session->globalMaxRatio();
|
||||
|
||||
if (ratioLimit == USE_GLOBAL_RATIO) {
|
||||
ratioLimit = m_session->globalMaxRatio();
|
||||
if (usesGlobalRatio)
|
||||
*usesGlobalRatio = true;
|
||||
}
|
||||
else {
|
||||
if (usesGlobalRatio)
|
||||
*usesGlobalRatio = false;
|
||||
return m_ratioLimit;
|
||||
}
|
||||
|
||||
return ratioLimit;
|
||||
}
|
||||
|
||||
int TorrentHandle::maxSeedingTime(bool *usesGlobalSeedingTime) const
|
||||
int TorrentHandle::maxSeedingTime() const
|
||||
{
|
||||
int seedingTimeLimit = m_seedingTimeLimit;
|
||||
if (m_seedingTimeLimit == USE_GLOBAL_SEEDING_TIME)
|
||||
return m_session->globalMaxSeedingMinutes();
|
||||
|
||||
if (seedingTimeLimit == USE_GLOBAL_SEEDING_TIME) {
|
||||
seedingTimeLimit = m_session->globalMaxSeedingMinutes();
|
||||
if (usesGlobalSeedingTime)
|
||||
*usesGlobalSeedingTime = true;
|
||||
}
|
||||
else {
|
||||
if (usesGlobalSeedingTime)
|
||||
*usesGlobalSeedingTime = false;
|
||||
}
|
||||
|
||||
return seedingTimeLimit;
|
||||
return m_seedingTimeLimit;
|
||||
}
|
||||
|
||||
qreal TorrentHandle::realRatio() const
|
||||
@ -1687,8 +1670,8 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert
|
||||
resumeData["save_path"] = Profile::instance().toPortablePath(QString::fromStdString(savePath)).toStdString();
|
||||
}
|
||||
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance().toPortablePath(m_savePath).toStdString();
|
||||
resumeData["qBt-ratioLimit"] = QString::number(m_ratioLimit).toStdString();
|
||||
resumeData["qBt-seedingTimeLimit"] = QString::number(m_seedingTimeLimit).toStdString();
|
||||
resumeData["qBt-ratioLimit"] = static_cast<int>(m_ratioLimit * 1000);
|
||||
resumeData["qBt-seedingTimeLimit"] = m_seedingTimeLimit;
|
||||
resumeData["qBt-category"] = m_category.toStdString();
|
||||
resumeData["qBt-tags"] = setToEntryList(m_tags);
|
||||
resumeData["qBt-name"] = m_name.toStdString();
|
||||
|
@ -328,8 +328,8 @@ namespace BitTorrent
|
||||
QBitArray downloadingPieces() const;
|
||||
QVector<int> pieceAvailability() const;
|
||||
qreal distributedCopies() const;
|
||||
qreal maxRatio(bool *usesGlobalRatio = 0) const;
|
||||
int maxSeedingTime(bool *usesGlobalSeedingTime = 0) const;
|
||||
qreal maxRatio() const;
|
||||
int maxSeedingTime() const;
|
||||
qreal realRatio() const;
|
||||
int uploadPayloadRate() const;
|
||||
int downloadPayloadRate() const;
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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,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 "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");
|
||||
@ -64,37 +63,37 @@ RequestParser::ErrorCode RequestParser::parseHttpRequest(const QByteArray& data,
|
||||
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;
|
||||
@ -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)
|
||||
{
|
||||
// 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,12 +309,12 @@ 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;
|
||||
|
@ -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
|
||||
|
@ -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"));
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
||||
@ -52,7 +50,7 @@ namespace Http
|
||||
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;
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
@ -46,7 +44,7 @@ namespace Net
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DNSUpdater(QObject *parent = 0);
|
||||
explicit DNSUpdater(QObject *parent = nullptr);
|
||||
~DNSUpdater();
|
||||
|
||||
static QUrl getRegistrationUrl(int service);
|
||||
|
@ -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,7 +193,7 @@ void DownloadHandler::handleRedirection(QUrl newUrl)
|
||||
m_reply->deleteLater();
|
||||
m_reply = tmp->m_reply;
|
||||
init();
|
||||
tmp->m_reply = 0;
|
||||
tmp->m_reply = nullptr;
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,9 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class QUrl;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Net
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@
|
||||
#ifndef NET_GEOIPMANAGER_H
|
||||
#define NET_GEOIPMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QCache>
|
||||
#include <QObject>
|
||||
|
||||
class QHostAddress;
|
||||
class QString;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
#include "banlistoptions.h"
|
||||
#include "ui_banlistoptions.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QHostAddress>
|
||||
#include <QMessageBox>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStringListModel>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "ui_banlistoptions.h"
|
||||
|
||||
BanListOptions::BanListOptions(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
|
@ -44,7 +44,7 @@ class BanListOptions: public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BanListOptions(QWidget *parent = 0);
|
||||
explicit BanListOptions(QWidget *parent = nullptr);
|
||||
~BanListOptions();
|
||||
|
||||
private slots:
|
||||
|
@ -30,10 +30,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/settingsstorage.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "base/settingsstorage.h"
|
||||
#include "cookiesmodel.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "ui_cookiesdialog.h"
|
||||
|
||||
#define SETTINGS_KEY(name) "CookiesDialog/" name
|
||||
|
@ -43,7 +43,7 @@ class CookiesDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CookiesDialog(QWidget *parent = 0);
|
||||
explicit CookiesDialog(QWidget *parent = nullptr);
|
||||
~CookiesDialog();
|
||||
|
||||
public slots:
|
||||
|
@ -26,9 +26,10 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QDateTime>
|
||||
#include "cookiesmodel.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
CookiesModel::CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_cookies(cookies)
|
||||
@ -43,8 +44,7 @@ QList<QNetworkCookie> CookiesModel::cookies() const
|
||||
QVariant CookiesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) {
|
||||
switch (section)
|
||||
{
|
||||
switch (section) {
|
||||
case COL_DOMAIN:
|
||||
return tr("Domain");
|
||||
case COL_PATH:
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
NB_COLUMNS
|
||||
};
|
||||
|
||||
explicit CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent = 0);
|
||||
explicit CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent = nullptr);
|
||||
|
||||
QList<QNetworkCookie> cookies() const;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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,36 +24,39 @@
|
||||
* 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 PREVIEWLISTDELEGATE_H
|
||||
#define PREVIEWLISTDELEGATE_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QItemDelegate>
|
||||
#include <QStyleOptionProgressBar>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QModelIndex>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QProxyStyle>
|
||||
#endif
|
||||
#include <QStyleOptionProgressBar>
|
||||
#include <QStyleOptionViewItem>
|
||||
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "previewselectdialog.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QProxyStyle>
|
||||
#endif
|
||||
|
||||
class PreviewListDelegate: public QItemDelegate {
|
||||
class PreviewListDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
|
||||
PreviewListDelegate(QObject *parent = nullptr)
|
||||
: QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
~PreviewListDelegate() {}
|
||||
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
|
||||
|
||||
@ -79,18 +82,20 @@ class PreviewListDelegate: public QItemDelegate {
|
||||
QProxyStyle st("fusion");
|
||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
|
||||
QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
|
||||
{
|
||||
// No editor here
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PREVIEWLISTDELEGATE_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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 PEERLISTDELEGATE_H
|
||||
@ -77,10 +75,9 @@ public:
|
||||
QItemDelegate::drawBackground(painter, opt, index);
|
||||
|
||||
switch (index.column()) {
|
||||
case PORT: {
|
||||
case PORT:
|
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString());
|
||||
}
|
||||
break;
|
||||
case TOT_DOWN:
|
||||
case TOT_UP: {
|
||||
|
@ -39,7 +39,7 @@ class PeerListSortModel: public QSortFilterProxyModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PeerListSortModel(QObject *parent = 0)
|
||||
PeerListSortModel(QObject *parent = nullptr)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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,36 +24,34 @@
|
||||
* 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 "peerlistwidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStandardItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSet>
|
||||
#include <QClipboard>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QClipboard>
|
||||
#include <QMessageBox>
|
||||
#include <QWheelEvent>
|
||||
#include <QSet>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include "base/net/reverseresolution.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "base/bittorrent/peerinfo.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "propertieswidget.h"
|
||||
#include "base/net/geoipmanager.h"
|
||||
#include "peersadditiondlg.h"
|
||||
#include "speedlimitdlg.h"
|
||||
#include "base/net/reverseresolution.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "peerlistdelegate.h"
|
||||
#include "peerlistsortmodel.h"
|
||||
#include "peersadditiondlg.h"
|
||||
#include "propertieswidget.h"
|
||||
#include "speedlimitdlg.h"
|
||||
|
||||
PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||
: QTreeView(parent)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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,18 +24,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 PEERLISTWIDGET_H
|
||||
#define PEERLISTWIDGET_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QHash>
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QShortcut>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace Net
|
||||
{
|
||||
@ -46,11 +44,9 @@ class PeerListDelegate;
|
||||
class PeerListSortModel;
|
||||
class PropertiesWidget;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSortFilterProxyModel;
|
||||
class QStandardItem;
|
||||
class QStandardItemModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QMap>
|
||||
|
||||
class QPen;
|
||||
|
||||
class SpeedPlotView : public QGraphicsView
|
||||
@ -71,7 +72,7 @@ public:
|
||||
int y[NB_GRAPHS];
|
||||
};
|
||||
|
||||
explicit SpeedPlotView(QWidget *parent = 0);
|
||||
explicit SpeedPlotView(QWidget *parent = nullptr);
|
||||
|
||||
void setGraphEnable(GraphID id, bool enable);
|
||||
void setViewableLastPoints(TimePeriod period);
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "htmlbrowser.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkDiskCache>
|
||||
#include <QStyle>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QNetworkDiskCache>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QScrollBar>
|
||||
#include <QStyle>
|
||||
|
||||
#include "base/profile.h"
|
||||
|
||||
@ -37,7 +37,7 @@ QVariant HtmlBrowser::loadResource(int type, const QUrl &name)
|
||||
url.setScheme("http");
|
||||
|
||||
QIODevice *dev = m_diskCache->data(url);
|
||||
if(dev != 0) {
|
||||
if (dev != nullptr) {
|
||||
qDebug() << "HtmlBrowser::loadResource() cache " << url.toString();
|
||||
QByteArray res = dev->readAll();
|
||||
delete dev;
|
||||
@ -62,7 +62,7 @@ void HtmlBrowser::resourceLoaded(QNetworkReply *reply)
|
||||
{
|
||||
m_activeRequests.remove(reply->request().url());
|
||||
|
||||
if(reply->error() == QNetworkReply::NoError && reply->size() > 0) {
|
||||
if ((reply->error() == QNetworkReply::NoError) && (reply->size() > 0)) {
|
||||
qDebug() << "HtmlBrowser::resourceLoaded() save " << reply->request().url().toString();
|
||||
}
|
||||
else {
|
||||
@ -79,8 +79,8 @@ void HtmlBrowser::resourceLoaded(QNetworkReply *reply)
|
||||
metaData.setLastModified(QDateTime::currentDateTime());
|
||||
metaData.setExpirationDate(QDateTime::currentDateTime().addDays(1));
|
||||
QIODevice *dev = m_diskCache->prepare(metaData);
|
||||
if(!dev)
|
||||
return;
|
||||
if (!dev) return;
|
||||
|
||||
QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(32, 32).save(dev, "PNG");
|
||||
m_diskCache->insert(dev);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef HTMLBROWSER_H
|
||||
#define HTMLBROWSER_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QHash>
|
||||
#include <QTextBrowser>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkDiskCache;
|
||||
@ -13,7 +13,7 @@ class HtmlBrowser: public QTextBrowser
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HtmlBrowser(QWidget* parent = 0);
|
||||
explicit HtmlBrowser(QWidget* parent = nullptr);
|
||||
~HtmlBrowser();
|
||||
|
||||
virtual QVariant loadResource(int type, const QUrl &name);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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,14 +24,12 @@
|
||||
* 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 "speedlimitdlg.h"
|
||||
|
||||
#include "ui_bandwidth_limit.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "ui_bandwidth_limit.h"
|
||||
|
||||
SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* 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 BANDWIDTH_ALLOCATION_H
|
||||
@ -33,16 +31,19 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include "base/utils/misc.h"
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/misc.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class bandwidth_dlg;
|
||||
}
|
||||
|
||||
class SpeedLimitDialog : public QDialog {
|
||||
class SpeedLimitDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpeedLimitDialog(QWidget *parent);
|
||||
~SpeedLimitDialog();
|
||||
@ -58,4 +59,4 @@ private:
|
||||
Ui::bandwidth_dlg *m_ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // BANDWIDTH_ALLOCATION_H
|
||||
|
@ -627,14 +627,18 @@ void TransferListWidget::setMaxRatioSelectedTorrents()
|
||||
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
|
||||
if (torrents.isEmpty()) return;
|
||||
|
||||
bool useGlobalValue = true;
|
||||
qreal currentMaxRatio = BitTorrent::Session::instance()->globalMaxRatio();
|
||||
if (torrents.count() == 1)
|
||||
currentMaxRatio = torrents[0]->maxRatio(&useGlobalValue);
|
||||
currentMaxRatio = torrents[0]->maxRatio();
|
||||
|
||||
int currentMaxSeedingTime = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
|
||||
if (torrents.count() == 1)
|
||||
currentMaxSeedingTime = torrents[0]->maxSeedingTime(&useGlobalValue);
|
||||
currentMaxSeedingTime = torrents[0]->maxSeedingTime();
|
||||
|
||||
bool useGlobalValue = true;
|
||||
if (torrents.count() == 1)
|
||||
useGlobalValue = (torrents[0]->ratioLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_RATIO)
|
||||
&& (torrents[0]->seedingTimeLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME);
|
||||
|
||||
UpDownRatioDlg dlg(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO,
|
||||
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2011 Christian Kandeler, Christophe Dumez
|
||||
* Copyright (C) 2011 Christian Kandeler
|
||||
* 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 +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 "updownratiodlg.h"
|
||||
@ -33,53 +32,52 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
|
||||
#include "ui_updownratiodlg.h"
|
||||
|
||||
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
|
||||
qreal maxRatioValue, int initialTimeValue,
|
||||
int maxTimeValue, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::UpDownRatioDlg)
|
||||
, m_ui(new Ui::UpDownRatioDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (useDefault) {
|
||||
ui->useDefaultButton->setChecked(true);
|
||||
m_ui->useDefaultButton->setChecked(true);
|
||||
}
|
||||
else if ((initialRatioValue == -1) && (initialTimeValue == -1)) {
|
||||
ui->noLimitButton->setChecked(true);
|
||||
else if ((initialRatioValue == -1.) && (initialTimeValue == -1)) {
|
||||
m_ui->noLimitButton->setChecked(true);
|
||||
initialRatioValue = BitTorrent::Session::instance()->globalMaxRatio();
|
||||
initialTimeValue = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
|
||||
}
|
||||
else {
|
||||
ui->torrentLimitButton->setChecked(true);
|
||||
m_ui->torrentLimitButton->setChecked(true);
|
||||
|
||||
if (initialRatioValue >= 0)
|
||||
ui->checkMaxRatio->setChecked(true);
|
||||
m_ui->checkMaxRatio->setChecked(true);
|
||||
|
||||
if (initialTimeValue >= 0)
|
||||
ui->checkMaxTime->setChecked(true);
|
||||
m_ui->checkMaxTime->setChecked(true);
|
||||
}
|
||||
|
||||
ui->ratioSpinBox->setMinimum(0);
|
||||
ui->ratioSpinBox->setMaximum(maxRatioValue);
|
||||
ui->ratioSpinBox->setValue(initialRatioValue);
|
||||
m_ui->ratioSpinBox->setMinimum(0);
|
||||
m_ui->ratioSpinBox->setMaximum(maxRatioValue);
|
||||
m_ui->ratioSpinBox->setValue(initialRatioValue);
|
||||
|
||||
ui->timeSpinBox->setMinimum(0);
|
||||
ui->timeSpinBox->setMaximum(maxTimeValue);
|
||||
ui->timeSpinBox->setValue(initialTimeValue);
|
||||
m_ui->timeSpinBox->setMinimum(0);
|
||||
m_ui->timeSpinBox->setMaximum(maxTimeValue);
|
||||
m_ui->timeSpinBox->setValue(initialTimeValue);
|
||||
|
||||
connect(ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
|
||||
connect(ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin()));
|
||||
connect(ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
|
||||
connect(m_ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
|
||||
connect(m_ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin()));
|
||||
connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
|
||||
|
||||
handleRatioTypeChanged();
|
||||
}
|
||||
|
||||
void UpDownRatioDlg::accept()
|
||||
{
|
||||
if (ui->torrentLimitButton->isChecked() && !ui->checkMaxRatio->isChecked() && !ui->checkMaxTime->isChecked())
|
||||
if (m_ui->torrentLimitButton->isChecked() && !m_ui->checkMaxRatio->isChecked() && !m_ui->checkMaxTime->isChecked())
|
||||
QMessageBox::critical(this, tr("No share limit method selected"),
|
||||
tr("Please select a limit method first"));
|
||||
else
|
||||
@ -88,40 +86,40 @@ void UpDownRatioDlg::accept()
|
||||
|
||||
bool UpDownRatioDlg::useDefault() const
|
||||
{
|
||||
return ui->useDefaultButton->isChecked();
|
||||
return m_ui->useDefaultButton->isChecked();
|
||||
}
|
||||
|
||||
qreal UpDownRatioDlg::ratio() const
|
||||
{
|
||||
return (ui->noLimitButton->isChecked() || !ui->checkMaxRatio->isChecked()) ? -1 : ui->ratioSpinBox->value();
|
||||
return (m_ui->noLimitButton->isChecked() || !m_ui->checkMaxRatio->isChecked()) ? -1. : m_ui->ratioSpinBox->value();
|
||||
}
|
||||
|
||||
int UpDownRatioDlg::seedingTime() const
|
||||
{
|
||||
return (ui->noLimitButton->isChecked() || !ui->checkMaxTime->isChecked()) ? -1 : ui->timeSpinBox->value();
|
||||
return (m_ui->noLimitButton->isChecked() || !m_ui->checkMaxTime->isChecked()) ? -1 : m_ui->timeSpinBox->value();
|
||||
}
|
||||
|
||||
void UpDownRatioDlg::handleRatioTypeChanged()
|
||||
{
|
||||
// ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked());
|
||||
ui->checkMaxRatio->setEnabled(ui->torrentLimitButton->isChecked());
|
||||
ui->checkMaxTime->setEnabled(ui->torrentLimitButton->isChecked());
|
||||
m_ui->checkMaxRatio->setEnabled(m_ui->torrentLimitButton->isChecked());
|
||||
m_ui->checkMaxTime->setEnabled(m_ui->torrentLimitButton->isChecked());
|
||||
|
||||
ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxRatio->isChecked());
|
||||
ui->timeSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxTime->isChecked());
|
||||
m_ui->ratioSpinBox->setEnabled(m_ui->torrentLimitButton->isChecked() && m_ui->checkMaxRatio->isChecked());
|
||||
m_ui->timeSpinBox->setEnabled(m_ui->torrentLimitButton->isChecked() && m_ui->checkMaxTime->isChecked());
|
||||
}
|
||||
|
||||
void UpDownRatioDlg::enableRatioSpin()
|
||||
{
|
||||
ui->ratioSpinBox->setEnabled(ui->checkMaxRatio->isChecked());
|
||||
m_ui->ratioSpinBox->setEnabled(m_ui->checkMaxRatio->isChecked());
|
||||
}
|
||||
|
||||
void UpDownRatioDlg::enableTimeSpin()
|
||||
{
|
||||
ui->timeSpinBox->setEnabled(ui->checkMaxTime->isChecked());
|
||||
m_ui->timeSpinBox->setEnabled(m_ui->checkMaxTime->isChecked());
|
||||
}
|
||||
|
||||
UpDownRatioDlg::~UpDownRatioDlg()
|
||||
{
|
||||
delete ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt4 and libtorrent.
|
||||
* Copyright (C) 2011 Christian Kandeler, Christophe Dumez
|
||||
*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2011 Christian Kandeler
|
||||
* 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
@ -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 UPDOWNRATIODLG_H
|
||||
@ -33,20 +31,19 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class UpDownRatioDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class UpDownRatioDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UpDownRatioDlg(bool useDefault, qreal initialValue, qreal maxValue,
|
||||
UpDownRatioDlg(bool useDefault, qreal initialValue, qreal maxValue,
|
||||
int initialTimeValue, int maxTimeValue,
|
||||
QWidget *parent = 0);
|
||||
QWidget *parent = nullptr);
|
||||
~UpDownRatioDlg();
|
||||
|
||||
bool useDefault() const;
|
||||
@ -62,7 +59,7 @@ private slots:
|
||||
void enableTimeSpin();
|
||||
|
||||
private:
|
||||
Ui::UpDownRatioDlg *ui;
|
||||
Ui::UpDownRatioDlg *m_ui;
|
||||
};
|
||||
|
||||
#endif // UPDOWNRATIODLG_H
|
||||
|
@ -26,15 +26,17 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
#include <QCryptographicHash>
|
||||
#include <QRegularExpression>
|
||||
#include "webapplication.h"
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "base/bittorrent/torrentinfo.h"
|
||||
@ -50,7 +52,6 @@
|
||||
#include "btjson.h"
|
||||
#include "jsonutils.h"
|
||||
#include "prefjson.h"
|
||||
#include "webapplication.h"
|
||||
#include "websessiondata.h"
|
||||
|
||||
static const int API_VERSION = 15;
|
||||
@ -565,12 +566,12 @@ void WebApplication::action_command_setFilePrio()
|
||||
CHECK_URI(0);
|
||||
CHECK_PARAMETERS("hash" << "id" << "priority");
|
||||
QString hash = request().posts["hash"];
|
||||
int file_id = request().posts["id"].toInt();
|
||||
int fileID = request().posts["id"].toInt();
|
||||
int priority = request().posts["priority"].toInt();
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
|
||||
if (torrent && torrent->hasMetadata())
|
||||
torrent->setFilePriority(file_id, priority);
|
||||
torrent->setFilePriority(fileID, priority);
|
||||
}
|
||||
|
||||
void WebApplication::action_command_getGlobalUpLimit()
|
||||
@ -801,15 +802,13 @@ void WebApplication::action_command_setLocation()
|
||||
QStringList hashes = request().posts["hashes"].split("|");
|
||||
QString newLocation = request().posts["location"].trimmed();
|
||||
|
||||
// check location exists
|
||||
// check if the location exists
|
||||
if (newLocation.isEmpty() || !QDir(newLocation).exists())
|
||||
return;
|
||||
|
||||
foreach (const QString &hash, hashes) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
if (torrent) {
|
||||
// get old location
|
||||
const QString oldLocation = torrent->savePath();
|
||||
Logger::instance()->addMessage(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"").arg(torrent->name()).arg(torrent->savePath()).arg(newLocation));
|
||||
|
||||
torrent->move(Utils::Fs::expandPathAbs(newLocation));
|
||||
|
@ -37,7 +37,7 @@ class WebApplication: public AbstractWebApplication
|
||||
Q_DISABLE_COPY(WebApplication)
|
||||
|
||||
public:
|
||||
explicit WebApplication(QObject* parent = 0);
|
||||
explicit WebApplication(QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
// Actions
|
||||
|
Loading…
Reference in New Issue
Block a user