mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 22:52:33 -06:00
@@ -103,8 +103,8 @@ BitTorrent::BencodeResumeDataStorage::BencodeResumeDataStorage(const Path &path,
|
||||
.arg(m_resumeDataPath.toString()));
|
||||
}
|
||||
|
||||
const QRegularExpression filenamePattern {QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$")};
|
||||
const QStringList filenames = QDir(m_resumeDataPath.data()).entryList(QStringList(QLatin1String("*.fastresume")), QDir::Files, QDir::Unsorted);
|
||||
const QRegularExpression filenamePattern {u"^([A-Fa-f0-9]{40})\\.fastresume$"_qs};
|
||||
const QStringList filenames = QDir(m_resumeDataPath.data()).entryList(QStringList(u"*.fastresume"_qs), QDir::Files, QDir::Unsorted);
|
||||
|
||||
m_registeredTorrents.reserve(filenames.size());
|
||||
for (const QString &filename : filenames)
|
||||
@@ -137,8 +137,8 @@ QVector<BitTorrent::TorrentID> BitTorrent::BencodeResumeDataStorage::registeredT
|
||||
std::optional<BitTorrent::LoadTorrentParams> BitTorrent::BencodeResumeDataStorage::load(const TorrentID &id) const
|
||||
{
|
||||
const QString idString = id.toString();
|
||||
const Path fastresumePath = m_resumeDataPath / Path(idString + QLatin1String(".fastresume"));
|
||||
const Path torrentFilePath = m_resumeDataPath / Path(idString + QLatin1String(".torrent"));
|
||||
const Path fastresumePath = m_resumeDataPath / Path(idString + u".fastresume");
|
||||
const Path torrentFilePath = m_resumeDataPath / Path(idString + u".torrent");
|
||||
|
||||
QFile resumeDataFile {fastresumePath.data()};
|
||||
if (!resumeDataFile.open(QIODevice::ReadOnly))
|
||||
@@ -284,7 +284,7 @@ void BitTorrent::BencodeResumeDataStorage::loadQueue(const Path &queueFilename)
|
||||
|
||||
if (queueFile.open(QFile::ReadOnly))
|
||||
{
|
||||
const QRegularExpression hashPattern {QLatin1String("^([A-Fa-f0-9]{40})$")};
|
||||
const QRegularExpression hashPattern {u"^([A-Fa-f0-9]{40})$"_qs};
|
||||
QString line;
|
||||
int start = 0;
|
||||
while (!(line = QString::fromLatin1(queueFile.readLine().trimmed())).isEmpty())
|
||||
@@ -353,7 +353,7 @@ void BitTorrent::BencodeResumeDataStorage::Worker::store(const TorrentID &id, co
|
||||
metadataDict.insert(dataDict.extract("created by"));
|
||||
metadataDict.insert(dataDict.extract("comment"));
|
||||
|
||||
const Path torrentFilepath = m_resumeDataDir / Path(QString::fromLatin1("%1.torrent").arg(id.toString()));
|
||||
const Path torrentFilepath = m_resumeDataDir / Path(u"%1.torrent"_qs.arg(id.toString()));
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(torrentFilepath, metadata);
|
||||
if (!result)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ void BitTorrent::BencodeResumeDataStorage::Worker::store(const TorrentID &id, co
|
||||
data["qBt-downloadPath"] = Profile::instance()->toPortablePath(resumeData.downloadPath).data().toStdString();
|
||||
}
|
||||
|
||||
const Path resumeFilepath = m_resumeDataDir / Path(QString::fromLatin1("%1.fastresume").arg(id.toString()));
|
||||
const Path resumeFilepath = m_resumeDataDir / Path(u"%1.fastresume"_qs.arg(id.toString()));
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(resumeFilepath, data);
|
||||
if (!result)
|
||||
{
|
||||
@@ -389,10 +389,10 @@ void BitTorrent::BencodeResumeDataStorage::Worker::store(const TorrentID &id, co
|
||||
|
||||
void BitTorrent::BencodeResumeDataStorage::Worker::remove(const TorrentID &id) const
|
||||
{
|
||||
const Path resumeFilename {QString::fromLatin1("%1.fastresume").arg(id.toString())};
|
||||
const Path resumeFilename {u"%1.fastresume"_qs.arg(id.toString())};
|
||||
Utils::Fs::removeFile(m_resumeDataDir / resumeFilename);
|
||||
|
||||
const Path torrentFilename {QString::fromLatin1("%1.torrent").arg(id.toString())};
|
||||
const Path torrentFilename {u"%1.torrent"_qs.arg(id.toString())};
|
||||
Utils::Fs::removeFile(m_resumeDataDir / torrentFilename);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
const QString OPTION_SAVEPATH {QStringLiteral("save_path")};
|
||||
const QString OPTION_DOWNLOADPATH {QStringLiteral("download_path")};
|
||||
#include "base/global.h"
|
||||
|
||||
const QString OPTION_SAVEPATH = u"save_path"_qs;
|
||||
const QString OPTION_DOWNLOADPATH = u"download_path"_qs;
|
||||
|
||||
BitTorrent::CategoryOptions BitTorrent::CategoryOptions::fromJSON(const QJsonObject &jsonObj)
|
||||
{
|
||||
|
||||
@@ -30,4 +30,6 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
inline const QString QB_EXT {QStringLiteral(".!qB")};
|
||||
#include "base/global.h"
|
||||
|
||||
inline const QString QB_EXT = u".!qB"_qs;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace
|
||||
|
||||
Column makeColumn(const char *columnName)
|
||||
{
|
||||
return {QLatin1String(columnName), (QLatin1Char(':') + QLatin1String(columnName))};
|
||||
return {QString::fromLatin1(columnName), (u':' + QString::fromLatin1(columnName))};
|
||||
}
|
||||
|
||||
const Column DB_COLUMN_ID = makeColumn("id");
|
||||
@@ -105,14 +105,14 @@ namespace
|
||||
|
||||
QString quoted(const QString &name)
|
||||
{
|
||||
const QLatin1Char quote {'`'};
|
||||
const QChar quote = u'`';
|
||||
|
||||
return (quote + name + quote);
|
||||
}
|
||||
|
||||
QString makeCreateTableStatement(const QString &tableName, const QStringList &items)
|
||||
{
|
||||
return QString::fromLatin1("CREATE TABLE %1 (%2)").arg(quoted(tableName), items.join(QLatin1Char(',')));
|
||||
return u"CREATE TABLE %1 (%2)"_qs.arg(quoted(tableName), items.join(u','));
|
||||
}
|
||||
|
||||
std::pair<QString, QString> joinColumns(const QVector<Column> &columns)
|
||||
@@ -131,8 +131,8 @@ namespace
|
||||
values.reserve(valuesSize);
|
||||
for (const Column &column : columns)
|
||||
{
|
||||
names.append(quoted(column.name) + QLatin1Char(','));
|
||||
values.append(column.placeholder + QLatin1Char(','));
|
||||
names.append(quoted(column.name) + u',');
|
||||
values.append(column.placeholder + u',');
|
||||
}
|
||||
names.chop(1);
|
||||
values.chop(1);
|
||||
@@ -143,27 +143,27 @@ namespace
|
||||
QString makeInsertStatement(const QString &tableName, const QVector<Column> &columns)
|
||||
{
|
||||
const auto [names, values] = joinColumns(columns);
|
||||
return QString::fromLatin1("INSERT INTO %1 (%2) VALUES (%3)")
|
||||
return u"INSERT INTO %1 (%2) VALUES (%3)"_qs
|
||||
.arg(quoted(tableName), names, values);
|
||||
}
|
||||
|
||||
QString makeUpdateStatement(const QString &tableName, const QVector<Column> &columns)
|
||||
{
|
||||
const auto [names, values] = joinColumns(columns);
|
||||
return QString::fromLatin1("UPDATE %1 SET (%2) = (%3)")
|
||||
return u"UPDATE %1 SET (%2) = (%3)"_qs
|
||||
.arg(quoted(tableName), names, values);
|
||||
}
|
||||
|
||||
QString makeOnConflictUpdateStatement(const Column &constraint, const QVector<Column> &columns)
|
||||
{
|
||||
const auto [names, values] = joinColumns(columns);
|
||||
return QString::fromLatin1(" ON CONFLICT (%1) DO UPDATE SET (%2) = (%3)")
|
||||
return u" ON CONFLICT (%1) DO UPDATE SET (%2) = (%3)"_qs
|
||||
.arg(quoted(constraint.name), names, values);
|
||||
}
|
||||
|
||||
QString makeColumnDefinition(const Column &column, const char *definition)
|
||||
{
|
||||
return QString::fromLatin1("%1 %2").arg(quoted(column.name), QLatin1String(definition));
|
||||
return u"%1 %2"_qs.arg(quoted(column.name), QString::fromLatin1(definition));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ BitTorrent::DBResumeDataStorage::DBResumeDataStorage(const Path &dbPath, QObject
|
||||
{
|
||||
const bool needCreateDB = !dbPath.exists();
|
||||
|
||||
auto db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), DB_CONNECTION_NAME);
|
||||
auto db = QSqlDatabase::addDatabase(u"QSQLITE"_qs, DB_CONNECTION_NAME);
|
||||
db.setDatabaseName(dbPath.data());
|
||||
if (!db.open())
|
||||
throw RuntimeError(db.lastError().text());
|
||||
@@ -211,7 +211,7 @@ BitTorrent::DBResumeDataStorage::DBResumeDataStorage(const Path &dbPath, QObject
|
||||
updateDBFromVersion1();
|
||||
}
|
||||
|
||||
m_asyncWorker = new Worker(dbPath, QLatin1String("ResumeDataStorageWorker"));
|
||||
m_asyncWorker = new Worker(dbPath, u"ResumeDataStorageWorker"_qs);
|
||||
m_asyncWorker->moveToThread(m_ioThread);
|
||||
connect(m_ioThread, &QThread::finished, m_asyncWorker, &QObject::deleteLater);
|
||||
m_ioThread->start();
|
||||
@@ -244,7 +244,7 @@ BitTorrent::DBResumeDataStorage::~DBResumeDataStorage()
|
||||
|
||||
QVector<BitTorrent::TorrentID> BitTorrent::DBResumeDataStorage::registeredTorrents() const
|
||||
{
|
||||
const auto selectTorrentIDStatement = QString::fromLatin1("SELECT %1 FROM %2 ORDER BY %3;")
|
||||
const auto selectTorrentIDStatement = u"SELECT %1 FROM %2 ORDER BY %3;"_qs
|
||||
.arg(quoted(DB_COLUMN_TORRENT_ID.name), quoted(DB_TABLE_TORRENTS), quoted(DB_COLUMN_QUEUE_POSITION.name));
|
||||
|
||||
auto db = QSqlDatabase::database(DB_CONNECTION_NAME);
|
||||
@@ -263,9 +263,8 @@ QVector<BitTorrent::TorrentID> BitTorrent::DBResumeDataStorage::registeredTorren
|
||||
|
||||
std::optional<BitTorrent::LoadTorrentParams> BitTorrent::DBResumeDataStorage::load(const TorrentID &id) const
|
||||
{
|
||||
const QString selectTorrentStatement =
|
||||
QString(QLatin1String("SELECT * FROM %1 WHERE %2 = %3;"))
|
||||
.arg(quoted(DB_TABLE_TORRENTS), quoted(DB_COLUMN_TORRENT_ID.name), DB_COLUMN_TORRENT_ID.placeholder);
|
||||
const QString selectTorrentStatement = u"SELECT * FROM %1 WHERE %2 = %3;"_qs
|
||||
.arg(quoted(DB_TABLE_TORRENTS), quoted(DB_COLUMN_TORRENT_ID.name), DB_COLUMN_TORRENT_ID.placeholder);
|
||||
|
||||
auto db = QSqlDatabase::database(DB_CONNECTION_NAME);
|
||||
QSqlQuery query {db};
|
||||
@@ -295,7 +294,7 @@ std::optional<BitTorrent::LoadTorrentParams> BitTorrent::DBResumeDataStorage::lo
|
||||
const QString tagsData = query.value(DB_COLUMN_TAGS.name).toString();
|
||||
if (!tagsData.isEmpty())
|
||||
{
|
||||
const QStringList tagList = tagsData.split(QLatin1Char(','));
|
||||
const QStringList tagList = tagsData.split(u',');
|
||||
resumeData.tags.insert(tagList.cbegin(), tagList.cend());
|
||||
}
|
||||
resumeData.hasSeedStatus = query.value(DB_COLUMN_HAS_SEED_STATUS.name).toBool();
|
||||
@@ -361,7 +360,7 @@ void BitTorrent::DBResumeDataStorage::storeQueue(const QVector<TorrentID> &queue
|
||||
|
||||
int BitTorrent::DBResumeDataStorage::currentDBVersion() const
|
||||
{
|
||||
const auto selectDBVersionStatement = QString::fromLatin1("SELECT %1 FROM %2 WHERE %3 = %4;")
|
||||
const auto selectDBVersionStatement = u"SELECT %1 FROM %2 WHERE %3 = %4;"_qs
|
||||
.arg(quoted(DB_COLUMN_VALUE.name), quoted(DB_TABLE_META), quoted(DB_COLUMN_NAME.name), DB_COLUMN_NAME.placeholder);
|
||||
|
||||
auto db = QSqlDatabase::database(DB_CONNECTION_NAME);
|
||||
@@ -459,7 +458,7 @@ void BitTorrent::DBResumeDataStorage::updateDBFromVersion1() const
|
||||
|
||||
try
|
||||
{
|
||||
const auto alterTableTorrentsQuery = QString::fromLatin1("ALTER TABLE %1 ADD %2")
|
||||
const auto alterTableTorrentsQuery = u"ALTER TABLE %1 ADD %2"_qs
|
||||
.arg(quoted(DB_TABLE_TORRENTS), makeColumnDefinition(DB_COLUMN_DOWNLOAD_PATH, "TEXT"));
|
||||
if (!query.exec(alterTableTorrentsQuery))
|
||||
throw RuntimeError(query.lastError().text());
|
||||
@@ -492,7 +491,7 @@ BitTorrent::DBResumeDataStorage::Worker::Worker(const Path &dbPath, const QStrin
|
||||
|
||||
void BitTorrent::DBResumeDataStorage::Worker::openDatabase() const
|
||||
{
|
||||
auto db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), m_connectionName);
|
||||
auto db = QSqlDatabase::addDatabase(u"QSQLITE"_qs, m_connectionName);
|
||||
db.setDatabaseName(m_path.data());
|
||||
if (!db.open())
|
||||
throw RuntimeError(db.lastError().text());
|
||||
@@ -592,7 +591,7 @@ void BitTorrent::DBResumeDataStorage::Worker::store(const TorrentID &id, const L
|
||||
query.bindValue(DB_COLUMN_NAME.placeholder, resumeData.name);
|
||||
query.bindValue(DB_COLUMN_CATEGORY.placeholder, resumeData.category);
|
||||
query.bindValue(DB_COLUMN_TAGS.placeholder, (resumeData.tags.isEmpty()
|
||||
? QVariant(QVariant::String) : resumeData.tags.join(QLatin1String(","))));
|
||||
? QVariant(QVariant::String) : resumeData.tags.join(u","_qs)));
|
||||
query.bindValue(DB_COLUMN_CONTENT_LAYOUT.placeholder, Utils::String::fromEnum(resumeData.contentLayout));
|
||||
query.bindValue(DB_COLUMN_RATIO_LIMIT.placeholder, static_cast<int>(resumeData.ratioLimit * 1000));
|
||||
query.bindValue(DB_COLUMN_SEEDING_TIME_LIMIT.placeholder, resumeData.seedingTimeLimit);
|
||||
@@ -623,7 +622,7 @@ void BitTorrent::DBResumeDataStorage::Worker::store(const TorrentID &id, const L
|
||||
|
||||
void BitTorrent::DBResumeDataStorage::Worker::remove(const TorrentID &id) const
|
||||
{
|
||||
const auto deleteTorrentStatement = QString::fromLatin1("DELETE FROM %1 WHERE %2 = %3;")
|
||||
const auto deleteTorrentStatement = u"DELETE FROM %1 WHERE %2 = %3;"_qs
|
||||
.arg(quoted(DB_TABLE_TORRENTS), quoted(DB_COLUMN_TORRENT_ID.name), DB_COLUMN_TORRENT_ID.placeholder);
|
||||
|
||||
auto db = QSqlDatabase::database(m_connectionName);
|
||||
@@ -647,7 +646,7 @@ void BitTorrent::DBResumeDataStorage::Worker::remove(const TorrentID &id) const
|
||||
|
||||
void BitTorrent::DBResumeDataStorage::Worker::storeQueue(const QVector<TorrentID> &queue) const
|
||||
{
|
||||
const auto updateQueuePosStatement = QString::fromLatin1("UPDATE %1 SET %2 = %3 WHERE %4 = %5;")
|
||||
const auto updateQueuePosStatement = u"UPDATE %1 SET %2 = %3 WHERE %4 = %5;"_qs
|
||||
.arg(quoted(DB_TABLE_TORRENTS), quoted(DB_COLUMN_QUEUE_POSITION.name), DB_COLUMN_QUEUE_POSITION.placeholder
|
||||
, quoted(DB_COLUMN_TORRENT_ID.name), DB_COLUMN_TORRENT_ID.placeholder);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QDataStream>
|
||||
#include <QFile>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
|
||||
namespace
|
||||
@@ -617,17 +618,17 @@ void FilterParserThread::run()
|
||||
{
|
||||
qDebug("Processing filter file");
|
||||
int ruleCount = 0;
|
||||
if (m_filePath.hasExtension(QLatin1String(".p2p")))
|
||||
if (m_filePath.hasExtension(u".p2p"_qs))
|
||||
{
|
||||
// PeerGuardian p2p file
|
||||
ruleCount = parseP2PFilterFile();
|
||||
}
|
||||
else if (m_filePath.hasExtension(QLatin1String(".p2b")))
|
||||
else if (m_filePath.hasExtension(u".p2b"_qs))
|
||||
{
|
||||
// PeerGuardian p2b file
|
||||
ruleCount = parseP2BFilterFile();
|
||||
}
|
||||
else if (m_filePath.hasExtension(QLatin1String(".dat")))
|
||||
else if (m_filePath.hasExtension(u".dat"_qs))
|
||||
{
|
||||
// eMule DAT format
|
||||
ruleCount = parseDATFilterFile();
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "infohash.h"
|
||||
|
||||
namespace
|
||||
@@ -52,9 +53,9 @@ namespace
|
||||
const int V1_BASE32_SIZE = SHA1Hash::length() * 1.6;
|
||||
|
||||
return ((((string.size() == V1_HEX_SIZE))
|
||||
&& !string.contains(QRegularExpression(QLatin1String("[^0-9A-Fa-f]"))))
|
||||
&& !string.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs)))
|
||||
|| ((string.size() == V1_BASE32_SIZE)
|
||||
&& !string.contains(QRegularExpression(QLatin1String("[^2-7A-Za-z]")))));
|
||||
&& !string.contains(QRegularExpression(u"[^2-7A-Za-z]"_qs))));
|
||||
}
|
||||
|
||||
bool isV2Hash(const QString &string)
|
||||
@@ -65,7 +66,7 @@ namespace
|
||||
const int V2_HEX_SIZE = SHA256Hash::length() * 2;
|
||||
|
||||
return (string.size() == V2_HEX_SIZE)
|
||||
&& !string.contains(QRegularExpression(QLatin1String("[^0-9A-Fa-f]")));
|
||||
&& !string.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +81,9 @@ MagnetUri::MagnetUri(const QString &source)
|
||||
if (source.isEmpty()) return;
|
||||
|
||||
if (isV2Hash(source))
|
||||
m_url = QString::fromLatin1("magnet:?xt=urn:btmh:1220") + source; // 0x12 0x20 is the "multihash format" tag for the SHA-256 hashing scheme.
|
||||
m_url = u"magnet:?xt=urn:btmh:1220" + source; // 0x12 0x20 is the "multihash format" tag for the SHA-256 hashing scheme.
|
||||
else if (isV1Hash(source))
|
||||
m_url = QString::fromLatin1("magnet:?xt=urn:btih:") + source;
|
||||
m_url = u"magnet:?xt=urn:btih:" + source;
|
||||
|
||||
lt::error_code ec;
|
||||
lt::parse_magnet_uri(m_url.toStdString(), m_addTorrentParams, ec);
|
||||
|
||||
@@ -36,9 +36,9 @@ PeerAddress PeerAddress::parse(const QStringView address)
|
||||
{
|
||||
QList<QStringView> ipPort;
|
||||
|
||||
if (address.startsWith(u'[') && address.contains(QLatin1String("]:")))
|
||||
if (address.startsWith(u'[') && address.contains(u"]:"))
|
||||
{ // IPv6
|
||||
ipPort = address.split(QString::fromLatin1("]:"));
|
||||
ipPort = address.split(u"]:");
|
||||
ipPort[0] = ipPort[0].mid(1); // chop '['
|
||||
}
|
||||
else if (address.contains(u':'))
|
||||
|
||||
@@ -217,8 +217,8 @@ QString PeerInfo::connectionType() const
|
||||
return C_UTP;
|
||||
|
||||
return (m_nativeInfo.connection_type == lt::peer_info::standard_bittorrent)
|
||||
? QLatin1String {"BT"}
|
||||
: QLatin1String {"Web"};
|
||||
? u"BT"_qs
|
||||
: u"Web"_qs;
|
||||
}
|
||||
|
||||
qreal PeerInfo::calcRelevance(const Torrent *torrent) const
|
||||
@@ -242,8 +242,8 @@ void PeerInfo::determineFlags()
|
||||
{
|
||||
const auto updateFlags = [this](const QChar specifier, const QString &explanation)
|
||||
{
|
||||
m_flags += (specifier + QLatin1Char(' '));
|
||||
m_flagsDescription += QString::fromLatin1("%1 = %2\n").arg(specifier, explanation);
|
||||
m_flags += (specifier + u' ');
|
||||
m_flagsDescription += u"%1 = %2\n"_qs.arg(specifier, explanation);
|
||||
};
|
||||
|
||||
if (isInteresting())
|
||||
@@ -251,12 +251,12 @@ void PeerInfo::determineFlags()
|
||||
if (isRemoteChocked())
|
||||
{
|
||||
// d = Your client wants to download, but peer doesn't want to send (interested and choked)
|
||||
updateFlags(QLatin1Char('d'), tr("Interested (local) and choked (peer)"));
|
||||
updateFlags(u'd', tr("Interested (local) and choked (peer)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// D = Currently downloading (interested and not choked)
|
||||
updateFlags(QLatin1Char('D'), tr("Interested (local) and unchoked (peer)"));
|
||||
updateFlags(u'D', tr("Interested (local) and unchoked (peer)"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,58 +265,58 @@ void PeerInfo::determineFlags()
|
||||
if (isChocked())
|
||||
{
|
||||
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
|
||||
updateFlags(QLatin1Char('u'), tr("Interested (peer) and choked (local)"));
|
||||
updateFlags(u'u', tr("Interested (peer) and choked (local)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// U = Currently uploading (interested and not choked)
|
||||
updateFlags(QLatin1Char('U'), tr("Interested (peer) and unchoked (local)"));
|
||||
updateFlags(u'U', tr("Interested (peer) and unchoked (local)"));
|
||||
}
|
||||
}
|
||||
|
||||
// K = Peer is unchoking your client, but your client is not interested
|
||||
if (!isRemoteChocked() && !isInteresting())
|
||||
updateFlags(QLatin1Char('K'), tr("Not interested (local) and unchoked (peer)"));
|
||||
updateFlags(u'K', tr("Not interested (local) and unchoked (peer)"));
|
||||
|
||||
// ? = Your client unchoked the peer but the peer is not interested
|
||||
if (!isChocked() && !isRemoteInterested())
|
||||
updateFlags(QLatin1Char('?'), tr("Not interested (peer) and unchoked (local)"));
|
||||
updateFlags(u'?', tr("Not interested (peer) and unchoked (local)"));
|
||||
|
||||
// O = Optimistic unchoke
|
||||
if (optimisticUnchoke())
|
||||
updateFlags(QLatin1Char('O'), tr("Optimistic unchoke"));
|
||||
updateFlags(u'O', tr("Optimistic unchoke"));
|
||||
|
||||
// S = Peer is snubbed
|
||||
if (isSnubbed())
|
||||
updateFlags(QLatin1Char('S'), tr("Peer snubbed"));
|
||||
updateFlags(u'S', tr("Peer snubbed"));
|
||||
|
||||
// I = Peer is an incoming connection
|
||||
if (!isLocalConnection())
|
||||
updateFlags(QLatin1Char('I'), tr("Incoming connection"));
|
||||
updateFlags(u'I', tr("Incoming connection"));
|
||||
|
||||
// H = Peer was obtained through DHT
|
||||
if (fromDHT())
|
||||
updateFlags(QLatin1Char('H'), tr("Peer from DHT"));
|
||||
updateFlags(u'H', tr("Peer from DHT"));
|
||||
|
||||
// X = Peer was included in peerlists obtained through Peer Exchange (PEX)
|
||||
if (fromPeX())
|
||||
updateFlags(QLatin1Char('X'), tr("Peer from PEX"));
|
||||
updateFlags(u'X', tr("Peer from PEX"));
|
||||
|
||||
// L = Peer is local
|
||||
if (fromLSD())
|
||||
updateFlags(QLatin1Char('L'), tr("Peer from LSD"));
|
||||
updateFlags(u'L', tr("Peer from LSD"));
|
||||
|
||||
// E = Peer is using Protocol Encryption (all traffic)
|
||||
if (isRC4Encrypted())
|
||||
updateFlags(QLatin1Char('E'), tr("Encrypted traffic"));
|
||||
updateFlags(u'E', tr("Encrypted traffic"));
|
||||
|
||||
// e = Peer is using Protocol Encryption (handshake)
|
||||
if (isPlaintextEncrypted())
|
||||
updateFlags(QLatin1Char('e'), tr("Encrypted handshake"));
|
||||
updateFlags(u'e', tr("Encrypted handshake"));
|
||||
|
||||
// P = Peer is using uTorrent uTP
|
||||
if (useUTPSocket())
|
||||
updateFlags(QLatin1Char('P'), C_UTP);
|
||||
updateFlags(u'P', C_UTP);
|
||||
|
||||
m_flags.chop(1);
|
||||
m_flagsDescription.chop(1);
|
||||
|
||||
@@ -186,33 +186,33 @@ namespace
|
||||
{
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
case lt::socket_type_t::http:
|
||||
return QLatin1String("HTTP");
|
||||
return u"HTTP"_qs;
|
||||
case lt::socket_type_t::http_ssl:
|
||||
return QLatin1String("HTTP_SSL");
|
||||
return u"HTTP_SSL"_qs;
|
||||
#endif
|
||||
case lt::socket_type_t::i2p:
|
||||
return QLatin1String("I2P");
|
||||
return u"I2P"_qs;
|
||||
case lt::socket_type_t::socks5:
|
||||
return QLatin1String("SOCKS5");
|
||||
return u"SOCKS5"_qs;
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
case lt::socket_type_t::socks5_ssl:
|
||||
return QLatin1String("SOCKS5_SSL");
|
||||
return u"SOCKS5_SSL"_qs;
|
||||
#endif
|
||||
case lt::socket_type_t::tcp:
|
||||
return QLatin1String("TCP");
|
||||
return u"TCP"_qs;
|
||||
case lt::socket_type_t::tcp_ssl:
|
||||
return QLatin1String("TCP_SSL");
|
||||
return u"TCP_SSL"_qs;
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
case lt::socket_type_t::utp:
|
||||
return QLatin1String("UTP");
|
||||
return u"UTP"_qs;
|
||||
#else
|
||||
case lt::socket_type_t::udp:
|
||||
return QLatin1String("UDP");
|
||||
return u"UDP"_qs;
|
||||
#endif
|
||||
case lt::socket_type_t::utp_ssl:
|
||||
return QLatin1String("UTP_SSL");
|
||||
return u"UTP_SSL"_qs;
|
||||
}
|
||||
return QLatin1String("INVALID");
|
||||
return u"INVALID"_qs;
|
||||
}
|
||||
|
||||
QString toString(const lt::address &address)
|
||||
@@ -1523,7 +1523,7 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack)
|
||||
|
||||
endpoints << ((isIPv6 ? (u'[' + ip + u']') : ip) + portString);
|
||||
|
||||
if ((ip != QLatin1String("0.0.0.0")) && (ip != QLatin1String("::")))
|
||||
if ((ip != u"0.0.0.0") && (ip != u"::"))
|
||||
outgoingInterfaces << ip;
|
||||
}
|
||||
else
|
||||
@@ -1709,23 +1709,23 @@ void Session::processShareLimits()
|
||||
|
||||
if (m_maxRatioAction == Remove)
|
||||
{
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Removed torrent."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Removed torrent."), torrentName));
|
||||
deleteTorrent(torrent->id());
|
||||
}
|
||||
else if (m_maxRatioAction == DeleteFiles)
|
||||
{
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Removed torrent and deleted its content."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Removed torrent and deleted its content."), torrentName));
|
||||
deleteTorrent(torrent->id(), DeleteTorrentAndFiles);
|
||||
}
|
||||
else if ((m_maxRatioAction == Pause) && !torrent->isPaused())
|
||||
{
|
||||
torrent->pause();
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Torrent paused."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Torrent paused."), torrentName));
|
||||
}
|
||||
else if ((m_maxRatioAction == EnableSuperSeeding) && !torrent->isPaused() && !torrent->superSeeding())
|
||||
{
|
||||
torrent->setSuperSeeding(true);
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Super seeding enabled."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Super seeding enabled."), torrentName));
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -1752,23 +1752,23 @@ void Session::processShareLimits()
|
||||
|
||||
if (m_maxRatioAction == Remove)
|
||||
{
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Removed torrent."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Removed torrent."), torrentName));
|
||||
deleteTorrent(torrent->id());
|
||||
}
|
||||
else if (m_maxRatioAction == DeleteFiles)
|
||||
{
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Removed torrent and deleted its content."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Removed torrent and deleted its content."), torrentName));
|
||||
deleteTorrent(torrent->id(), DeleteTorrentAndFiles);
|
||||
}
|
||||
else if ((m_maxRatioAction == Pause) && !torrent->isPaused())
|
||||
{
|
||||
torrent->pause();
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Torrent paused."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Torrent paused."), torrentName));
|
||||
}
|
||||
else if ((m_maxRatioAction == EnableSuperSeeding) && !torrent->isPaused() && !torrent->superSeeding())
|
||||
{
|
||||
torrent->setSuperSeeding(true);
|
||||
LogMsg(QString::fromLatin1("%1 %2 %3").arg(description, tr("Super seeding enabled."), torrentName));
|
||||
LogMsg(u"%1 %2 %3"_qs.arg(description, tr("Super seeding enabled."), torrentName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2448,13 +2448,13 @@ void Session::exportTorrentFile(const TorrentInfo &torrentInfo, const Path &fold
|
||||
return;
|
||||
|
||||
const QString validName = Utils::Fs::toValidFileName(baseName);
|
||||
QString torrentExportFilename = QString::fromLatin1("%1.torrent").arg(validName);
|
||||
QString torrentExportFilename = u"%1.torrent"_qs.arg(validName);
|
||||
Path newTorrentPath = folderPath / Path(torrentExportFilename);
|
||||
int counter = 0;
|
||||
while (newTorrentPath.exists())
|
||||
{
|
||||
// Append number to torrent name to make it unique
|
||||
torrentExportFilename = QString::fromLatin1("%1 %2.torrent").arg(validName).arg(++counter);
|
||||
torrentExportFilename = u"%1 %2.torrent"_qs.arg(validName).arg(++counter);
|
||||
newTorrentPath = folderPath / Path(torrentExportFilename);
|
||||
}
|
||||
|
||||
@@ -2626,8 +2626,8 @@ QStringList Session::getListeningIPs() const
|
||||
const QString ifaceName = networkInterface();
|
||||
const QString ifaceAddr = networkInterfaceAddress();
|
||||
const QHostAddress configuredAddr(ifaceAddr);
|
||||
const bool allIPv4 = (ifaceAddr == QLatin1String("0.0.0.0")); // Means All IPv4 addresses
|
||||
const bool allIPv6 = (ifaceAddr == QLatin1String("::")); // Means All IPv6 addresses
|
||||
const bool allIPv4 = (ifaceAddr == u"0.0.0.0"); // Means All IPv4 addresses
|
||||
const bool allIPv6 = (ifaceAddr == u"::"); // Means All IPv6 addresses
|
||||
|
||||
if (!ifaceAddr.isEmpty() && !allIPv4 && !allIPv6 && configuredAddr.isNull())
|
||||
{
|
||||
@@ -2643,13 +2643,13 @@ QStringList Session::getListeningIPs() const
|
||||
if (ifaceName.isEmpty())
|
||||
{
|
||||
if (ifaceAddr.isEmpty())
|
||||
return {QLatin1String("0.0.0.0"), QLatin1String("::")}; // Indicates all interfaces + all addresses (aka default)
|
||||
return {u"0.0.0.0"_qs, u"::"_qs}; // Indicates all interfaces + all addresses (aka default)
|
||||
|
||||
if (allIPv4)
|
||||
return {QLatin1String("0.0.0.0")};
|
||||
return {u"0.0.0.0"_qs};
|
||||
|
||||
if (allIPv6)
|
||||
return {QLatin1String("::")};
|
||||
return {u"::"_qs};
|
||||
}
|
||||
|
||||
const auto checkAndAddIP = [allIPv4, allIPv6, &IPs](const QHostAddress &addr, const QHostAddress &match)
|
||||
@@ -4160,7 +4160,7 @@ void Session::handleTorrentFinished(TorrentImpl *const torrent)
|
||||
// Check if there are torrent files inside
|
||||
for (const Path &torrentRelpath : asConst(torrent->filePaths()))
|
||||
{
|
||||
if (torrentRelpath.hasExtension(QLatin1String(".torrent")))
|
||||
if (torrentRelpath.hasExtension(u".torrent"_qs))
|
||||
{
|
||||
qDebug("Found possible recursive torrent download.");
|
||||
const Path torrentFullpath = torrent->actualStorageLocation() / torrentRelpath;
|
||||
@@ -4458,7 +4458,7 @@ void Session::recursiveTorrentDownload(const TorrentID &id)
|
||||
|
||||
for (const Path &torrentRelpath : asConst(torrent->filePaths()))
|
||||
{
|
||||
if (torrentRelpath.hasExtension(QLatin1String(".torrent")))
|
||||
if (torrentRelpath.hasExtension(u".torrent"_qs))
|
||||
{
|
||||
LogMsg(tr("Recursive download .torrent file within torrent. Source torrent: \"%1\". File: \"%2\"")
|
||||
.arg(torrent->name(), torrentRelpath.toString()));
|
||||
|
||||
@@ -93,7 +93,7 @@ void Statistics::save() const
|
||||
if (!m_dirty || ((now - m_lastWrite) < SAVE_INTERVAL))
|
||||
return;
|
||||
|
||||
SettingsPtr s = Profile::instance()->applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
SettingsPtr s = Profile::instance()->applicationSettings(u"qBittorrent-data"_qs);
|
||||
QVariantHash v;
|
||||
v.insert(u"AlltimeDL"_qs, m_alltimeDL + m_sessionDL);
|
||||
v.insert(u"AlltimeUL"_qs, m_alltimeUL + m_sessionUL);
|
||||
@@ -104,7 +104,7 @@ void Statistics::save() const
|
||||
|
||||
void Statistics::load()
|
||||
{
|
||||
const SettingsPtr s = Profile::instance()->applicationSettings(QLatin1String("qBittorrent-data"));
|
||||
const SettingsPtr s = Profile::instance()->applicationSettings(u"qBittorrent-data"_qs);
|
||||
const QVariantHash v = s->value(u"Stats/AllStats"_qs).toHash();
|
||||
|
||||
m_alltimeDL = v[u"AlltimeDL"_qs].toULongLong();
|
||||
|
||||
@@ -317,7 +317,7 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession
|
||||
const Path filepath = filePath(i);
|
||||
// Move "unwanted" files back to their original folder
|
||||
const Path parentRelPath = filepath.parentPath();
|
||||
if (parentRelPath.filename() == QLatin1String(".unwanted"))
|
||||
if (parentRelPath.filename() == u".unwanted")
|
||||
{
|
||||
const QString oldName = filepath.filename();
|
||||
const Path newRelPath = parentRelPath.parentPath();
|
||||
@@ -1050,10 +1050,8 @@ QString TorrentImpl::error() const
|
||||
|
||||
if (m_nativeStatus.flags & lt::torrent_flags::upload_mode)
|
||||
{
|
||||
const QString writeErrorStr = tr("Couldn't write to file.");
|
||||
const QString uploadModeStr = tr("Torrent is now in \"upload only\" mode.");
|
||||
const QString errorMessage = tr("Reason:") + QLatin1Char(' ') + QString::fromLocal8Bit(m_lastFileError.error.message().c_str());
|
||||
return QString::fromLatin1("%1 %2 %3").arg(writeErrorStr, errorMessage, uploadModeStr);
|
||||
return tr("Couldn't write to file. Reason: \"%1\". Torrent is now in \"upload only\" mode.")
|
||||
.arg(QString::fromLocal8Bit(m_lastFileError.error.message().c_str()));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user