mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 04:38:04 -06:00
Rename literal operator
Qt 6.4 introduced `QString operator""_s()` and the previous `""_qs` is deprecated since Qt 6.8.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -47,13 +47,13 @@ void AuthController::loginAction()
|
||||
{
|
||||
if (m_sessionManager->session())
|
||||
{
|
||||
setResult(u"Ok."_qs);
|
||||
setResult(u"Ok."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString clientAddr {m_sessionManager->clientId()};
|
||||
const QString usernameFromWeb {params()[u"username"_qs]};
|
||||
const QString passwordFromWeb {params()[u"password"_qs]};
|
||||
const QString usernameFromWeb {params()[u"username"_s]};
|
||||
const QString passwordFromWeb {params()[u"password"_s]};
|
||||
|
||||
if (isBanned())
|
||||
{
|
||||
@@ -76,14 +76,14 @@ void AuthController::loginAction()
|
||||
m_clientFailedLogins.remove(clientAddr);
|
||||
|
||||
m_sessionManager->sessionStart();
|
||||
setResult(u"Ok."_qs);
|
||||
setResult(u"Ok."_s);
|
||||
LogMsg(tr("WebAPI login success. IP: %1").arg(clientAddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Preferences::instance()->getWebUIMaxAuthFailCount() > 0)
|
||||
increaseFailedAttempts();
|
||||
setResult(u"Fails."_qs);
|
||||
setResult(u"Fails."_s);
|
||||
LogMsg(tr("WebAPI login failure. Reason: invalid credentials, attempt count: %1, IP: %2, username: %3")
|
||||
.arg(QString::number(failedAttemptsCount()), clientAddr, usernameFromWeb)
|
||||
, Log::WARNING);
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
#include "base/logger.h"
|
||||
#include "base/utils/string.h"
|
||||
|
||||
const QString KEY_LOG_ID = u"id"_qs;
|
||||
const QString KEY_LOG_TIMESTAMP = u"timestamp"_qs;
|
||||
const QString KEY_LOG_MSG_TYPE = u"type"_qs;
|
||||
const QString KEY_LOG_MSG_MESSAGE = u"message"_qs;
|
||||
const QString KEY_LOG_PEER_IP = u"ip"_qs;
|
||||
const QString KEY_LOG_PEER_BLOCKED = u"blocked"_qs;
|
||||
const QString KEY_LOG_PEER_REASON = u"reason"_qs;
|
||||
const QString KEY_LOG_ID = u"id"_s;
|
||||
const QString KEY_LOG_TIMESTAMP = u"timestamp"_s;
|
||||
const QString KEY_LOG_MSG_TYPE = u"type"_s;
|
||||
const QString KEY_LOG_MSG_MESSAGE = u"message"_s;
|
||||
const QString KEY_LOG_PEER_IP = u"ip"_s;
|
||||
const QString KEY_LOG_PEER_BLOCKED = u"blocked"_s;
|
||||
const QString KEY_LOG_PEER_REASON = u"reason"_s;
|
||||
|
||||
// Returns the log in JSON format.
|
||||
// The return value is an array of dictionaries.
|
||||
@@ -61,13 +61,13 @@ void LogController::mainAction()
|
||||
{
|
||||
using Utils::String::parseBool;
|
||||
|
||||
const bool isNormal = parseBool(params()[u"normal"_qs]).value_or(true);
|
||||
const bool isInfo = parseBool(params()[u"info"_qs]).value_or(true);
|
||||
const bool isWarning = parseBool(params()[u"warning"_qs]).value_or(true);
|
||||
const bool isCritical = parseBool(params()[u"critical"_qs]).value_or(true);
|
||||
const bool isNormal = parseBool(params()[u"normal"_s]).value_or(true);
|
||||
const bool isInfo = parseBool(params()[u"info"_s]).value_or(true);
|
||||
const bool isWarning = parseBool(params()[u"warning"_s]).value_or(true);
|
||||
const bool isCritical = parseBool(params()[u"critical"_s]).value_or(true);
|
||||
|
||||
bool ok = false;
|
||||
int lastKnownId = params()[u"last_known_id"_qs].toInt(&ok);
|
||||
int lastKnownId = params()[u"last_known_id"_s].toInt(&ok);
|
||||
if (!ok)
|
||||
lastKnownId = -1;
|
||||
|
||||
@@ -107,7 +107,7 @@ void LogController::mainAction()
|
||||
void LogController::peersAction()
|
||||
{
|
||||
bool ok = false;
|
||||
int lastKnownId = params()[u"last_known_id"_qs].toInt(&ok);
|
||||
int lastKnownId = params()[u"last_known_id"_s].toInt(&ok);
|
||||
if (!ok)
|
||||
lastKnownId = -1;
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ using Utils::String::parseBool;
|
||||
|
||||
void RSSController::addFolderAction()
|
||||
{
|
||||
requireParams({u"path"_qs});
|
||||
requireParams({u"path"_s});
|
||||
|
||||
const QString path = params()[u"path"_qs].trimmed();
|
||||
const QString path = params()[u"path"_s].trimmed();
|
||||
const nonstd::expected<void, QString> result = RSS::Session::instance()->addFolder(path);
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, result.error());
|
||||
@@ -57,10 +57,10 @@ void RSSController::addFolderAction()
|
||||
|
||||
void RSSController::addFeedAction()
|
||||
{
|
||||
requireParams({u"url"_qs, u"path"_qs});
|
||||
requireParams({u"url"_s, u"path"_s});
|
||||
|
||||
const QString url = params()[u"url"_qs].trimmed();
|
||||
const QString path = params()[u"path"_qs].trimmed();
|
||||
const QString url = params()[u"url"_s].trimmed();
|
||||
const QString path = params()[u"path"_s].trimmed();
|
||||
const nonstd::expected<void, QString> result = RSS::Session::instance()->addFeed(url, (path.isEmpty() ? url : path));
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, result.error());
|
||||
@@ -68,10 +68,10 @@ void RSSController::addFeedAction()
|
||||
|
||||
void RSSController::setFeedURLAction()
|
||||
{
|
||||
requireParams({u"path"_qs, u"url"_qs});
|
||||
requireParams({u"path"_s, u"url"_s});
|
||||
|
||||
const QString path = params()[u"path"_qs].trimmed();
|
||||
const QString url = params()[u"url"_qs].trimmed();
|
||||
const QString path = params()[u"path"_s].trimmed();
|
||||
const QString url = params()[u"url"_s].trimmed();
|
||||
const nonstd::expected<void, QString> result = RSS::Session::instance()->setFeedURL(path, url);
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, result.error());
|
||||
@@ -79,9 +79,9 @@ void RSSController::setFeedURLAction()
|
||||
|
||||
void RSSController::removeItemAction()
|
||||
{
|
||||
requireParams({u"path"_qs});
|
||||
requireParams({u"path"_s});
|
||||
|
||||
const QString path = params()[u"path"_qs].trimmed();
|
||||
const QString path = params()[u"path"_s].trimmed();
|
||||
const nonstd::expected<void, QString> result = RSS::Session::instance()->removeItem(path);
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, result.error());
|
||||
@@ -89,10 +89,10 @@ void RSSController::removeItemAction()
|
||||
|
||||
void RSSController::moveItemAction()
|
||||
{
|
||||
requireParams({u"itemPath"_qs, u"destPath"_qs});
|
||||
requireParams({u"itemPath"_s, u"destPath"_s});
|
||||
|
||||
const QString itemPath = params()[u"itemPath"_qs].trimmed();
|
||||
const QString destPath = params()[u"destPath"_qs].trimmed();
|
||||
const QString itemPath = params()[u"itemPath"_s].trimmed();
|
||||
const QString destPath = params()[u"destPath"_s].trimmed();
|
||||
const nonstd::expected<void, QString> result = RSS::Session::instance()->moveItem(itemPath, destPath);
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, result.error());
|
||||
@@ -100,7 +100,7 @@ void RSSController::moveItemAction()
|
||||
|
||||
void RSSController::itemsAction()
|
||||
{
|
||||
const bool withData {parseBool(params()[u"withData"_qs]).value_or(false)};
|
||||
const bool withData {parseBool(params()[u"withData"_s]).value_or(false)};
|
||||
|
||||
const auto jsonVal = RSS::Session::instance()->rootFolder()->toJsonValue(withData);
|
||||
setResult(jsonVal.toObject());
|
||||
@@ -108,10 +108,10 @@ void RSSController::itemsAction()
|
||||
|
||||
void RSSController::markAsReadAction()
|
||||
{
|
||||
requireParams({u"itemPath"_qs});
|
||||
requireParams({u"itemPath"_s});
|
||||
|
||||
const QString itemPath {params()[u"itemPath"_qs]};
|
||||
const QString articleId {params()[u"articleId"_qs]};
|
||||
const QString itemPath {params()[u"itemPath"_s]};
|
||||
const QString articleId {params()[u"articleId"_s]};
|
||||
|
||||
RSS::Item *item = RSS::Session::instance()->itemByPath(itemPath);
|
||||
if (!item) return;
|
||||
@@ -134,9 +134,9 @@ void RSSController::markAsReadAction()
|
||||
|
||||
void RSSController::refreshItemAction()
|
||||
{
|
||||
requireParams({u"itemPath"_qs});
|
||||
requireParams({u"itemPath"_s});
|
||||
|
||||
const QString itemPath {params()[u"itemPath"_qs]};
|
||||
const QString itemPath {params()[u"itemPath"_s]};
|
||||
RSS::Item *item = RSS::Session::instance()->itemByPath(itemPath);
|
||||
if (item)
|
||||
item->refresh();
|
||||
@@ -144,10 +144,10 @@ void RSSController::refreshItemAction()
|
||||
|
||||
void RSSController::setRuleAction()
|
||||
{
|
||||
requireParams({u"ruleName"_qs, u"ruleDef"_qs});
|
||||
requireParams({u"ruleName"_s, u"ruleDef"_s});
|
||||
|
||||
const QString ruleName {params()[u"ruleName"_qs].trimmed()};
|
||||
const QByteArray ruleDef {params()[u"ruleDef"_qs].trimmed().toUtf8()};
|
||||
const QString ruleName {params()[u"ruleName"_s].trimmed()};
|
||||
const QByteArray ruleDef {params()[u"ruleDef"_s].trimmed().toUtf8()};
|
||||
|
||||
const auto jsonObj = QJsonDocument::fromJson(ruleDef).object();
|
||||
RSS::AutoDownloader::instance()->setRule(RSS::AutoDownloadRule::fromJsonObject(jsonObj, ruleName));
|
||||
@@ -155,19 +155,19 @@ void RSSController::setRuleAction()
|
||||
|
||||
void RSSController::renameRuleAction()
|
||||
{
|
||||
requireParams({u"ruleName"_qs, u"newRuleName"_qs});
|
||||
requireParams({u"ruleName"_s, u"newRuleName"_s});
|
||||
|
||||
const QString ruleName {params()[u"ruleName"_qs].trimmed()};
|
||||
const QString newRuleName {params()[u"newRuleName"_qs].trimmed()};
|
||||
const QString ruleName {params()[u"ruleName"_s].trimmed()};
|
||||
const QString newRuleName {params()[u"newRuleName"_s].trimmed()};
|
||||
|
||||
RSS::AutoDownloader::instance()->renameRule(ruleName, newRuleName);
|
||||
}
|
||||
|
||||
void RSSController::removeRuleAction()
|
||||
{
|
||||
requireParams({u"ruleName"_qs});
|
||||
requireParams({u"ruleName"_s});
|
||||
|
||||
const QString ruleName {params()[u"ruleName"_qs].trimmed()};
|
||||
const QString ruleName {params()[u"ruleName"_s].trimmed()};
|
||||
RSS::AutoDownloader::instance()->removeRule(ruleName);
|
||||
}
|
||||
|
||||
@@ -183,9 +183,9 @@ void RSSController::rulesAction()
|
||||
|
||||
void RSSController::matchingArticlesAction()
|
||||
{
|
||||
requireParams({u"ruleName"_qs});
|
||||
requireParams({u"ruleName"_s});
|
||||
|
||||
const QString ruleName {params()[u"ruleName"_qs]};
|
||||
const QString ruleName {params()[u"ruleName"_s]};
|
||||
const RSS::AutoDownloadRule rule = RSS::AutoDownloader::instance()->ruleByName(ruleName);
|
||||
|
||||
QJsonObject jsonObj;
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace
|
||||
{
|
||||
QJsonArray categoriesInfo
|
||||
{QJsonObject {
|
||||
{u"id"_qs, u"all"_qs},
|
||||
{u"name"_qs, SearchPluginManager::categoryFullName(u"all"_qs)}
|
||||
{u"id"_s, u"all"_s},
|
||||
{u"name"_s, SearchPluginManager::categoryFullName(u"all"_s)}
|
||||
}};
|
||||
|
||||
categories.sort(Qt::CaseInsensitive);
|
||||
@@ -68,8 +68,8 @@ namespace
|
||||
{
|
||||
categoriesInfo << QJsonObject
|
||||
{
|
||||
{u"id"_qs, category},
|
||||
{u"name"_qs, SearchPluginManager::categoryFullName(category)}
|
||||
{u"id"_s, category},
|
||||
{u"name"_s, SearchPluginManager::categoryFullName(category)}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ namespace
|
||||
|
||||
void SearchController::startAction()
|
||||
{
|
||||
requireParams({u"pattern"_qs, u"category"_qs, u"plugins"_qs});
|
||||
requireParams({u"pattern"_s, u"category"_s, u"plugins"_s});
|
||||
|
||||
if (!Utils::ForeignApps::pythonInfo().isValid())
|
||||
throw APIError(APIErrorType::Conflict, tr("Python must be installed to use the Search Engine."));
|
||||
|
||||
const QString pattern = params()[u"pattern"_qs].trimmed();
|
||||
const QString category = params()[u"category"_qs].trimmed();
|
||||
const QStringList plugins = params()[u"plugins"_qs].split(u'|');
|
||||
const QString pattern = params()[u"pattern"_s].trimmed();
|
||||
const QString category = params()[u"category"_s].trimmed();
|
||||
const QStringList plugins = params()[u"plugins"_s].split(u'|');
|
||||
|
||||
QStringList pluginsToUse;
|
||||
if (plugins.size() == 1)
|
||||
@@ -116,15 +116,15 @@ void SearchController::startAction()
|
||||
|
||||
m_activeSearches.insert(id);
|
||||
|
||||
const QJsonObject result = {{u"id"_qs, id}};
|
||||
const QJsonObject result = {{u"id"_s, id}};
|
||||
setResult(result);
|
||||
}
|
||||
|
||||
void SearchController::stopAction()
|
||||
{
|
||||
requireParams({u"id"_qs});
|
||||
requireParams({u"id"_s});
|
||||
|
||||
const int id = params()[u"id"_qs].toInt();
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
@@ -141,7 +141,7 @@ void SearchController::stopAction()
|
||||
|
||||
void SearchController::statusAction()
|
||||
{
|
||||
const int id = params()[u"id"_qs].toInt();
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
|
||||
if ((id != 0) && !m_searchHandlers.contains(id))
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -154,9 +154,9 @@ void SearchController::statusAction()
|
||||
const std::shared_ptr<SearchHandler> &searchHandler = m_searchHandlers[searchId];
|
||||
statusArray << QJsonObject
|
||||
{
|
||||
{u"id"_qs, searchId},
|
||||
{u"status"_qs, searchHandler->isActive() ? u"Running"_qs : u"Stopped"_qs},
|
||||
{u"total"_qs, searchHandler->results().size()}
|
||||
{u"id"_s, searchId},
|
||||
{u"status"_s, searchHandler->isActive() ? u"Running"_s : u"Stopped"_s},
|
||||
{u"total"_s, searchHandler->results().size()}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -165,11 +165,11 @@ void SearchController::statusAction()
|
||||
|
||||
void SearchController::resultsAction()
|
||||
{
|
||||
requireParams({u"id"_qs});
|
||||
requireParams({u"id"_s});
|
||||
|
||||
const int id = params()[u"id"_qs].toInt();
|
||||
int limit = params()[u"limit"_qs].toInt();
|
||||
int offset = params()[u"offset"_qs].toInt();
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
int limit = params()[u"limit"_s].toInt();
|
||||
int offset = params()[u"offset"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
@@ -198,9 +198,9 @@ void SearchController::resultsAction()
|
||||
|
||||
void SearchController::deleteAction()
|
||||
{
|
||||
requireParams({u"id"_qs});
|
||||
requireParams({u"id"_s});
|
||||
|
||||
const int id = params()[u"id"_qs].toInt();
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
@@ -220,28 +220,28 @@ void SearchController::pluginsAction()
|
||||
|
||||
void SearchController::installPluginAction()
|
||||
{
|
||||
requireParams({u"sources"_qs});
|
||||
requireParams({u"sources"_s});
|
||||
|
||||
const QStringList sources = params()[u"sources"_qs].split(u'|');
|
||||
const QStringList sources = params()[u"sources"_s].split(u'|');
|
||||
for (const QString &source : sources)
|
||||
SearchPluginManager::instance()->installPlugin(source);
|
||||
}
|
||||
|
||||
void SearchController::uninstallPluginAction()
|
||||
{
|
||||
requireParams({u"names"_qs});
|
||||
requireParams({u"names"_s});
|
||||
|
||||
const QStringList names = params()[u"names"_qs].split(u'|');
|
||||
const QStringList names = params()[u"names"_s].split(u'|');
|
||||
for (const QString &name : names)
|
||||
SearchPluginManager::instance()->uninstallPlugin(name.trimmed());
|
||||
}
|
||||
|
||||
void SearchController::enablePluginAction()
|
||||
{
|
||||
requireParams({u"names"_qs, u"enable"_qs});
|
||||
requireParams({u"names"_s, u"enable"_s});
|
||||
|
||||
const QStringList names = params()[u"names"_qs].split(u'|');
|
||||
const bool enable = Utils::String::parseBool(params()[u"enable"_qs].trimmed()).value_or(false);
|
||||
const QStringList names = params()[u"names"_s].split(u'|');
|
||||
const bool enable = Utils::String::parseBool(params()[u"enable"_s].trimmed()).value_or(false);
|
||||
|
||||
for (const QString &name : names)
|
||||
SearchPluginManager::instance()->enablePlugin(name.trimmed(), enable);
|
||||
@@ -309,21 +309,21 @@ QJsonObject SearchController::getResults(const QList<SearchResult> &searchResult
|
||||
{
|
||||
searchResultsArray << QJsonObject
|
||||
{
|
||||
{u"fileName"_qs, searchResult.fileName},
|
||||
{u"fileUrl"_qs, searchResult.fileUrl},
|
||||
{u"fileSize"_qs, searchResult.fileSize},
|
||||
{u"nbSeeders"_qs, searchResult.nbSeeders},
|
||||
{u"nbLeechers"_qs, searchResult.nbLeechers},
|
||||
{u"siteUrl"_qs, searchResult.siteUrl},
|
||||
{u"descrLink"_qs, searchResult.descrLink}
|
||||
{u"fileName"_s, searchResult.fileName},
|
||||
{u"fileUrl"_s, searchResult.fileUrl},
|
||||
{u"fileSize"_s, searchResult.fileSize},
|
||||
{u"nbSeeders"_s, searchResult.nbSeeders},
|
||||
{u"nbLeechers"_s, searchResult.nbLeechers},
|
||||
{u"siteUrl"_s, searchResult.siteUrl},
|
||||
{u"descrLink"_s, searchResult.descrLink}
|
||||
};
|
||||
}
|
||||
|
||||
const QJsonObject result =
|
||||
{
|
||||
{u"status"_qs, isSearchActive ? u"Running"_qs : u"Stopped"_qs},
|
||||
{u"results"_qs, searchResultsArray},
|
||||
{u"total"_qs, totalResults}
|
||||
{u"status"_s, isSearchActive ? u"Running"_s : u"Stopped"_s},
|
||||
{u"results"_s, searchResultsArray},
|
||||
{u"total"_s, totalResults}
|
||||
};
|
||||
|
||||
return result;
|
||||
@@ -352,12 +352,12 @@ QJsonArray SearchController::getPluginsInfo(const QStringList &plugins) const
|
||||
|
||||
pluginsArray << QJsonObject
|
||||
{
|
||||
{u"name"_qs, pluginInfo->name},
|
||||
{u"version"_qs, pluginInfo->version.toString()},
|
||||
{u"fullName"_qs, pluginInfo->fullName},
|
||||
{u"url"_qs, pluginInfo->url},
|
||||
{u"supportedCategories"_qs, getPluginCategories(pluginInfo->supportedCategories)},
|
||||
{u"enabled"_qs, pluginInfo->enabled}
|
||||
{u"name"_s, pluginInfo->name},
|
||||
{u"version"_s, pluginInfo->version.toString()},
|
||||
{u"fullName"_s, pluginInfo->fullName},
|
||||
{u"url"_s, pluginInfo->url},
|
||||
{u"supportedCategories"_s, getPluginCategories(pluginInfo->supportedCategories)},
|
||||
{u"enabled"_s, pluginInfo->enabled}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,43 +45,43 @@ namespace
|
||||
switch (state)
|
||||
{
|
||||
case BitTorrent::TorrentState::Error:
|
||||
return u"error"_qs;
|
||||
return u"error"_s;
|
||||
case BitTorrent::TorrentState::MissingFiles:
|
||||
return u"missingFiles"_qs;
|
||||
return u"missingFiles"_s;
|
||||
case BitTorrent::TorrentState::Uploading:
|
||||
return u"uploading"_qs;
|
||||
return u"uploading"_s;
|
||||
case BitTorrent::TorrentState::PausedUploading:
|
||||
return u"pausedUP"_qs;
|
||||
return u"pausedUP"_s;
|
||||
case BitTorrent::TorrentState::QueuedUploading:
|
||||
return u"queuedUP"_qs;
|
||||
return u"queuedUP"_s;
|
||||
case BitTorrent::TorrentState::StalledUploading:
|
||||
return u"stalledUP"_qs;
|
||||
return u"stalledUP"_s;
|
||||
case BitTorrent::TorrentState::CheckingUploading:
|
||||
return u"checkingUP"_qs;
|
||||
return u"checkingUP"_s;
|
||||
case BitTorrent::TorrentState::ForcedUploading:
|
||||
return u"forcedUP"_qs;
|
||||
return u"forcedUP"_s;
|
||||
case BitTorrent::TorrentState::Downloading:
|
||||
return u"downloading"_qs;
|
||||
return u"downloading"_s;
|
||||
case BitTorrent::TorrentState::DownloadingMetadata:
|
||||
return u"metaDL"_qs;
|
||||
return u"metaDL"_s;
|
||||
case BitTorrent::TorrentState::ForcedDownloadingMetadata:
|
||||
return u"forcedMetaDL"_qs;
|
||||
return u"forcedMetaDL"_s;
|
||||
case BitTorrent::TorrentState::PausedDownloading:
|
||||
return u"pausedDL"_qs;
|
||||
return u"pausedDL"_s;
|
||||
case BitTorrent::TorrentState::QueuedDownloading:
|
||||
return u"queuedDL"_qs;
|
||||
return u"queuedDL"_s;
|
||||
case BitTorrent::TorrentState::StalledDownloading:
|
||||
return u"stalledDL"_qs;
|
||||
return u"stalledDL"_s;
|
||||
case BitTorrent::TorrentState::CheckingDownloading:
|
||||
return u"checkingDL"_qs;
|
||||
return u"checkingDL"_s;
|
||||
case BitTorrent::TorrentState::ForcedDownloading:
|
||||
return u"forcedDL"_qs;
|
||||
return u"forcedDL"_s;
|
||||
case BitTorrent::TorrentState::CheckingResumeData:
|
||||
return u"checkingResumeData"_qs;
|
||||
return u"checkingResumeData"_s;
|
||||
case BitTorrent::TorrentState::Moving:
|
||||
return u"moving"_qs;
|
||||
return u"moving"_s;
|
||||
default:
|
||||
return u"unknown"_qs;
|
||||
return u"unknown"_s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
|
||||
{KEY_TORRENT_FIRST_LAST_PIECE_PRIO, torrent.hasFirstLastPiecePriority()},
|
||||
|
||||
{KEY_TORRENT_CATEGORY, torrent.category()},
|
||||
{KEY_TORRENT_TAGS, torrent.tags().join(u", "_qs)},
|
||||
{KEY_TORRENT_TAGS, torrent.tags().join(u", "_s)},
|
||||
{KEY_TORRENT_SUPER_SEEDING, torrent.superSeeding()},
|
||||
{KEY_TORRENT_FORCE_START, torrent.isForced()},
|
||||
{KEY_TORRENT_SAVE_PATH, torrent.savePath().toString()},
|
||||
|
||||
@@ -39,54 +39,54 @@ namespace BitTorrent
|
||||
|
||||
// Torrent keys
|
||||
// TODO: Rename it to `id`.
|
||||
inline const QString KEY_TORRENT_ID = u"hash"_qs;
|
||||
inline const QString KEY_TORRENT_INFOHASHV1 = u"infohash_v1"_qs;
|
||||
inline const QString KEY_TORRENT_INFOHASHV2 = u"infohash_v2"_qs;
|
||||
inline const QString KEY_TORRENT_NAME = u"name"_qs;
|
||||
inline const QString KEY_TORRENT_MAGNET_URI = u"magnet_uri"_qs;
|
||||
inline const QString KEY_TORRENT_SIZE = u"size"_qs;
|
||||
inline const QString KEY_TORRENT_PROGRESS = u"progress"_qs;
|
||||
inline const QString KEY_TORRENT_DLSPEED = u"dlspeed"_qs;
|
||||
inline const QString KEY_TORRENT_UPSPEED = u"upspeed"_qs;
|
||||
inline const QString KEY_TORRENT_QUEUE_POSITION = u"priority"_qs;
|
||||
inline const QString KEY_TORRENT_SEEDS = u"num_seeds"_qs;
|
||||
inline const QString KEY_TORRENT_NUM_COMPLETE = u"num_complete"_qs;
|
||||
inline const QString KEY_TORRENT_LEECHS = u"num_leechs"_qs;
|
||||
inline const QString KEY_TORRENT_NUM_INCOMPLETE = u"num_incomplete"_qs;
|
||||
inline const QString KEY_TORRENT_RATIO = u"ratio"_qs;
|
||||
inline const QString KEY_TORRENT_ETA = u"eta"_qs;
|
||||
inline const QString KEY_TORRENT_STATE = u"state"_qs;
|
||||
inline const QString KEY_TORRENT_SEQUENTIAL_DOWNLOAD = u"seq_dl"_qs;
|
||||
inline const QString KEY_TORRENT_FIRST_LAST_PIECE_PRIO = u"f_l_piece_prio"_qs;
|
||||
inline const QString KEY_TORRENT_CATEGORY = u"category"_qs;
|
||||
inline const QString KEY_TORRENT_TAGS = u"tags"_qs;
|
||||
inline const QString KEY_TORRENT_SUPER_SEEDING = u"super_seeding"_qs;
|
||||
inline const QString KEY_TORRENT_FORCE_START = u"force_start"_qs;
|
||||
inline const QString KEY_TORRENT_SAVE_PATH = u"save_path"_qs;
|
||||
inline const QString KEY_TORRENT_DOWNLOAD_PATH = u"download_path"_qs;
|
||||
inline const QString KEY_TORRENT_CONTENT_PATH = u"content_path"_qs;
|
||||
inline const QString KEY_TORRENT_ADDED_ON = u"added_on"_qs;
|
||||
inline const QString KEY_TORRENT_COMPLETION_ON = u"completion_on"_qs;
|
||||
inline const QString KEY_TORRENT_TRACKER = u"tracker"_qs;
|
||||
inline const QString KEY_TORRENT_TRACKERS_COUNT = u"trackers_count"_qs;
|
||||
inline const QString KEY_TORRENT_DL_LIMIT = u"dl_limit"_qs;
|
||||
inline const QString KEY_TORRENT_UP_LIMIT = u"up_limit"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_DOWNLOADED = u"downloaded"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_UPLOADED = u"uploaded"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION = u"downloaded_session"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_UPLOADED_SESSION = u"uploaded_session"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_LEFT = u"amount_left"_qs;
|
||||
inline const QString KEY_TORRENT_AMOUNT_COMPLETED = u"completed"_qs;
|
||||
inline const QString KEY_TORRENT_MAX_RATIO = u"max_ratio"_qs;
|
||||
inline const QString KEY_TORRENT_MAX_SEEDING_TIME = u"max_seeding_time"_qs;
|
||||
inline const QString KEY_TORRENT_RATIO_LIMIT = u"ratio_limit"_qs;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME_LIMIT = u"seeding_time_limit"_qs;
|
||||
inline const QString KEY_TORRENT_LAST_SEEN_COMPLETE_TIME = u"seen_complete"_qs;
|
||||
inline const QString KEY_TORRENT_LAST_ACTIVITY_TIME = u"last_activity"_qs;
|
||||
inline const QString KEY_TORRENT_TOTAL_SIZE = u"total_size"_qs;
|
||||
inline const QString KEY_TORRENT_AUTO_TORRENT_MANAGEMENT = u"auto_tmm"_qs;
|
||||
inline const QString KEY_TORRENT_TIME_ACTIVE = u"time_active"_qs;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME = u"seeding_time"_qs;
|
||||
inline const QString KEY_TORRENT_AVAILABILITY = u"availability"_qs;
|
||||
inline const QString KEY_TORRENT_ID = u"hash"_s;
|
||||
inline const QString KEY_TORRENT_INFOHASHV1 = u"infohash_v1"_s;
|
||||
inline const QString KEY_TORRENT_INFOHASHV2 = u"infohash_v2"_s;
|
||||
inline const QString KEY_TORRENT_NAME = u"name"_s;
|
||||
inline const QString KEY_TORRENT_MAGNET_URI = u"magnet_uri"_s;
|
||||
inline const QString KEY_TORRENT_SIZE = u"size"_s;
|
||||
inline const QString KEY_TORRENT_PROGRESS = u"progress"_s;
|
||||
inline const QString KEY_TORRENT_DLSPEED = u"dlspeed"_s;
|
||||
inline const QString KEY_TORRENT_UPSPEED = u"upspeed"_s;
|
||||
inline const QString KEY_TORRENT_QUEUE_POSITION = u"priority"_s;
|
||||
inline const QString KEY_TORRENT_SEEDS = u"num_seeds"_s;
|
||||
inline const QString KEY_TORRENT_NUM_COMPLETE = u"num_complete"_s;
|
||||
inline const QString KEY_TORRENT_LEECHS = u"num_leechs"_s;
|
||||
inline const QString KEY_TORRENT_NUM_INCOMPLETE = u"num_incomplete"_s;
|
||||
inline const QString KEY_TORRENT_RATIO = u"ratio"_s;
|
||||
inline const QString KEY_TORRENT_ETA = u"eta"_s;
|
||||
inline const QString KEY_TORRENT_STATE = u"state"_s;
|
||||
inline const QString KEY_TORRENT_SEQUENTIAL_DOWNLOAD = u"seq_dl"_s;
|
||||
inline const QString KEY_TORRENT_FIRST_LAST_PIECE_PRIO = u"f_l_piece_prio"_s;
|
||||
inline const QString KEY_TORRENT_CATEGORY = u"category"_s;
|
||||
inline const QString KEY_TORRENT_TAGS = u"tags"_s;
|
||||
inline const QString KEY_TORRENT_SUPER_SEEDING = u"super_seeding"_s;
|
||||
inline const QString KEY_TORRENT_FORCE_START = u"force_start"_s;
|
||||
inline const QString KEY_TORRENT_SAVE_PATH = u"save_path"_s;
|
||||
inline const QString KEY_TORRENT_DOWNLOAD_PATH = u"download_path"_s;
|
||||
inline const QString KEY_TORRENT_CONTENT_PATH = u"content_path"_s;
|
||||
inline const QString KEY_TORRENT_ADDED_ON = u"added_on"_s;
|
||||
inline const QString KEY_TORRENT_COMPLETION_ON = u"completion_on"_s;
|
||||
inline const QString KEY_TORRENT_TRACKER = u"tracker"_s;
|
||||
inline const QString KEY_TORRENT_TRACKERS_COUNT = u"trackers_count"_s;
|
||||
inline const QString KEY_TORRENT_DL_LIMIT = u"dl_limit"_s;
|
||||
inline const QString KEY_TORRENT_UP_LIMIT = u"up_limit"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_DOWNLOADED = u"downloaded"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_UPLOADED = u"uploaded"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION = u"downloaded_session"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_UPLOADED_SESSION = u"uploaded_session"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_LEFT = u"amount_left"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_COMPLETED = u"completed"_s;
|
||||
inline const QString KEY_TORRENT_MAX_RATIO = u"max_ratio"_s;
|
||||
inline const QString KEY_TORRENT_MAX_SEEDING_TIME = u"max_seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_RATIO_LIMIT = u"ratio_limit"_s;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME_LIMIT = u"seeding_time_limit"_s;
|
||||
inline const QString KEY_TORRENT_LAST_SEEN_COMPLETE_TIME = u"seen_complete"_s;
|
||||
inline const QString KEY_TORRENT_LAST_ACTIVITY_TIME = u"last_activity"_s;
|
||||
inline const QString KEY_TORRENT_TOTAL_SIZE = u"total_size"_s;
|
||||
inline const QString KEY_TORRENT_AUTO_TORRENT_MANAGEMENT = u"auto_tmm"_s;
|
||||
inline const QString KEY_TORRENT_TIME_ACTIVE = u"time_active"_s;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME = u"seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_AVAILABILITY = u"availability"_s;
|
||||
|
||||
QVariantMap serialize(const BitTorrent::Torrent &torrent);
|
||||
|
||||
@@ -58,70 +58,70 @@ namespace
|
||||
const int FREEDISKSPACE_CHECK_TIMEOUT = 30000;
|
||||
|
||||
// Sync main data keys
|
||||
const QString KEY_SYNC_MAINDATA_QUEUEING = u"queueing"_qs;
|
||||
const QString KEY_SYNC_MAINDATA_REFRESH_INTERVAL = u"refresh_interval"_qs;
|
||||
const QString KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS = u"use_alt_speed_limits"_qs;
|
||||
const QString KEY_SYNC_MAINDATA_USE_SUBCATEGORIES = u"use_subcategories"_qs;
|
||||
const QString KEY_SYNC_MAINDATA_QUEUEING = u"queueing"_s;
|
||||
const QString KEY_SYNC_MAINDATA_REFRESH_INTERVAL = u"refresh_interval"_s;
|
||||
const QString KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS = u"use_alt_speed_limits"_s;
|
||||
const QString KEY_SYNC_MAINDATA_USE_SUBCATEGORIES = u"use_subcategories"_s;
|
||||
|
||||
// Sync torrent peers keys
|
||||
const QString KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS = u"show_flags"_qs;
|
||||
const QString KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS = u"show_flags"_s;
|
||||
|
||||
// Peer keys
|
||||
const QString KEY_PEER_CLIENT = u"client"_qs;
|
||||
const QString KEY_PEER_ID_CLIENT = u"peer_id_client"_qs;
|
||||
const QString KEY_PEER_CONNECTION_TYPE = u"connection"_qs;
|
||||
const QString KEY_PEER_COUNTRY = u"country"_qs;
|
||||
const QString KEY_PEER_COUNTRY_CODE = u"country_code"_qs;
|
||||
const QString KEY_PEER_DOWN_SPEED = u"dl_speed"_qs;
|
||||
const QString KEY_PEER_FILES = u"files"_qs;
|
||||
const QString KEY_PEER_FLAGS = u"flags"_qs;
|
||||
const QString KEY_PEER_FLAGS_DESCRIPTION = u"flags_desc"_qs;
|
||||
const QString KEY_PEER_IP = u"ip"_qs;
|
||||
const QString KEY_PEER_PORT = u"port"_qs;
|
||||
const QString KEY_PEER_PROGRESS = u"progress"_qs;
|
||||
const QString KEY_PEER_RELEVANCE = u"relevance"_qs;
|
||||
const QString KEY_PEER_TOT_DOWN = u"downloaded"_qs;
|
||||
const QString KEY_PEER_TOT_UP = u"uploaded"_qs;
|
||||
const QString KEY_PEER_UP_SPEED = u"up_speed"_qs;
|
||||
const QString KEY_PEER_CLIENT = u"client"_s;
|
||||
const QString KEY_PEER_ID_CLIENT = u"peer_id_client"_s;
|
||||
const QString KEY_PEER_CONNECTION_TYPE = u"connection"_s;
|
||||
const QString KEY_PEER_COUNTRY = u"country"_s;
|
||||
const QString KEY_PEER_COUNTRY_CODE = u"country_code"_s;
|
||||
const QString KEY_PEER_DOWN_SPEED = u"dl_speed"_s;
|
||||
const QString KEY_PEER_FILES = u"files"_s;
|
||||
const QString KEY_PEER_FLAGS = u"flags"_s;
|
||||
const QString KEY_PEER_FLAGS_DESCRIPTION = u"flags_desc"_s;
|
||||
const QString KEY_PEER_IP = u"ip"_s;
|
||||
const QString KEY_PEER_PORT = u"port"_s;
|
||||
const QString KEY_PEER_PROGRESS = u"progress"_s;
|
||||
const QString KEY_PEER_RELEVANCE = u"relevance"_s;
|
||||
const QString KEY_PEER_TOT_DOWN = u"downloaded"_s;
|
||||
const QString KEY_PEER_TOT_UP = u"uploaded"_s;
|
||||
const QString KEY_PEER_UP_SPEED = u"up_speed"_s;
|
||||
|
||||
// TransferInfo keys
|
||||
const QString KEY_TRANSFER_CONNECTION_STATUS = u"connection_status"_qs;
|
||||
const QString KEY_TRANSFER_DHT_NODES = u"dht_nodes"_qs;
|
||||
const QString KEY_TRANSFER_DLDATA = u"dl_info_data"_qs;
|
||||
const QString KEY_TRANSFER_DLRATELIMIT = u"dl_rate_limit"_qs;
|
||||
const QString KEY_TRANSFER_DLSPEED = u"dl_info_speed"_qs;
|
||||
const QString KEY_TRANSFER_FREESPACEONDISK = u"free_space_on_disk"_qs;
|
||||
const QString KEY_TRANSFER_UPDATA = u"up_info_data"_qs;
|
||||
const QString KEY_TRANSFER_UPRATELIMIT = u"up_rate_limit"_qs;
|
||||
const QString KEY_TRANSFER_UPSPEED = u"up_info_speed"_qs;
|
||||
const QString KEY_TRANSFER_CONNECTION_STATUS = u"connection_status"_s;
|
||||
const QString KEY_TRANSFER_DHT_NODES = u"dht_nodes"_s;
|
||||
const QString KEY_TRANSFER_DLDATA = u"dl_info_data"_s;
|
||||
const QString KEY_TRANSFER_DLRATELIMIT = u"dl_rate_limit"_s;
|
||||
const QString KEY_TRANSFER_DLSPEED = u"dl_info_speed"_s;
|
||||
const QString KEY_TRANSFER_FREESPACEONDISK = u"free_space_on_disk"_s;
|
||||
const QString KEY_TRANSFER_UPDATA = u"up_info_data"_s;
|
||||
const QString KEY_TRANSFER_UPRATELIMIT = u"up_rate_limit"_s;
|
||||
const QString KEY_TRANSFER_UPSPEED = u"up_info_speed"_s;
|
||||
|
||||
// Statistics keys
|
||||
const QString KEY_TRANSFER_ALLTIME_DL = u"alltime_dl"_qs;
|
||||
const QString KEY_TRANSFER_ALLTIME_UL = u"alltime_ul"_qs;
|
||||
const QString KEY_TRANSFER_AVERAGE_TIME_QUEUE = u"average_time_queue"_qs;
|
||||
const QString KEY_TRANSFER_GLOBAL_RATIO = u"global_ratio"_qs;
|
||||
const QString KEY_TRANSFER_QUEUED_IO_JOBS = u"queued_io_jobs"_qs;
|
||||
const QString KEY_TRANSFER_READ_CACHE_HITS = u"read_cache_hits"_qs;
|
||||
const QString KEY_TRANSFER_READ_CACHE_OVERLOAD = u"read_cache_overload"_qs;
|
||||
const QString KEY_TRANSFER_TOTAL_BUFFERS_SIZE = u"total_buffers_size"_qs;
|
||||
const QString KEY_TRANSFER_TOTAL_PEER_CONNECTIONS = u"total_peer_connections"_qs;
|
||||
const QString KEY_TRANSFER_TOTAL_QUEUED_SIZE = u"total_queued_size"_qs;
|
||||
const QString KEY_TRANSFER_TOTAL_WASTE_SESSION = u"total_wasted_session"_qs;
|
||||
const QString KEY_TRANSFER_WRITE_CACHE_OVERLOAD = u"write_cache_overload"_qs;
|
||||
const QString KEY_TRANSFER_ALLTIME_DL = u"alltime_dl"_s;
|
||||
const QString KEY_TRANSFER_ALLTIME_UL = u"alltime_ul"_s;
|
||||
const QString KEY_TRANSFER_AVERAGE_TIME_QUEUE = u"average_time_queue"_s;
|
||||
const QString KEY_TRANSFER_GLOBAL_RATIO = u"global_ratio"_s;
|
||||
const QString KEY_TRANSFER_QUEUED_IO_JOBS = u"queued_io_jobs"_s;
|
||||
const QString KEY_TRANSFER_READ_CACHE_HITS = u"read_cache_hits"_s;
|
||||
const QString KEY_TRANSFER_READ_CACHE_OVERLOAD = u"read_cache_overload"_s;
|
||||
const QString KEY_TRANSFER_TOTAL_BUFFERS_SIZE = u"total_buffers_size"_s;
|
||||
const QString KEY_TRANSFER_TOTAL_PEER_CONNECTIONS = u"total_peer_connections"_s;
|
||||
const QString KEY_TRANSFER_TOTAL_QUEUED_SIZE = u"total_queued_size"_s;
|
||||
const QString KEY_TRANSFER_TOTAL_WASTE_SESSION = u"total_wasted_session"_s;
|
||||
const QString KEY_TRANSFER_WRITE_CACHE_OVERLOAD = u"write_cache_overload"_s;
|
||||
|
||||
const QString KEY_SUFFIX_REMOVED = u"_removed"_qs;
|
||||
const QString KEY_SUFFIX_REMOVED = u"_removed"_s;
|
||||
|
||||
const QString KEY_CATEGORIES = u"categories"_qs;
|
||||
const QString KEY_CATEGORIES = u"categories"_s;
|
||||
const QString KEY_CATEGORIES_REMOVED = KEY_CATEGORIES + KEY_SUFFIX_REMOVED;
|
||||
const QString KEY_TAGS = u"tags"_qs;
|
||||
const QString KEY_TAGS = u"tags"_s;
|
||||
const QString KEY_TAGS_REMOVED = KEY_TAGS + KEY_SUFFIX_REMOVED;
|
||||
const QString KEY_TORRENTS = u"torrents"_qs;
|
||||
const QString KEY_TORRENTS = u"torrents"_s;
|
||||
const QString KEY_TORRENTS_REMOVED = KEY_TORRENTS + KEY_SUFFIX_REMOVED;
|
||||
const QString KEY_TRACKERS = u"trackers"_qs;
|
||||
const QString KEY_TRACKERS = u"trackers"_s;
|
||||
const QString KEY_TRACKERS_REMOVED = KEY_TRACKERS + KEY_SUFFIX_REMOVED;
|
||||
const QString KEY_SERVER_STATE = u"server_state"_qs;
|
||||
const QString KEY_FULL_UPDATE = u"full_update"_qs;
|
||||
const QString KEY_RESPONSE_ID = u"rid"_qs;
|
||||
const QString KEY_SERVER_STATE = u"server_state"_s;
|
||||
const QString KEY_FULL_UPDATE = u"full_update"_s;
|
||||
const QString KEY_RESPONSE_ID = u"rid"_s;
|
||||
|
||||
void processMap(const QVariantMap &prevData, const QVariantMap &data, QVariantMap &syncData);
|
||||
void processHash(QVariantHash prevData, const QVariantHash &data, QVariantMap &syncData, QVariantList &removedItems);
|
||||
@@ -147,19 +147,19 @@ namespace
|
||||
map[KEY_TRANSFER_ALLTIME_DL] = atd;
|
||||
map[KEY_TRANSFER_ALLTIME_UL] = atu;
|
||||
map[KEY_TRANSFER_TOTAL_WASTE_SESSION] = sessionStatus.totalWasted;
|
||||
map[KEY_TRANSFER_GLOBAL_RATIO] = ((atd > 0) && (atu > 0)) ? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2) : u"-"_qs;
|
||||
map[KEY_TRANSFER_GLOBAL_RATIO] = ((atd > 0) && (atu > 0)) ? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2) : u"-"_s;
|
||||
map[KEY_TRANSFER_TOTAL_PEER_CONNECTIONS] = sessionStatus.peersCount;
|
||||
|
||||
const qreal readRatio = cacheStatus.readRatio; // TODO: remove when LIBTORRENT_VERSION_NUM >= 20000
|
||||
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : u"0"_qs;
|
||||
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : u"0"_s;
|
||||
map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024;
|
||||
|
||||
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (sessionStatus.peersCount > 0))
|
||||
? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue / sessionStatus.peersCount), 2)
|
||||
: u"0"_qs;
|
||||
: u"0"_s;
|
||||
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (sessionStatus.peersCount > 0))
|
||||
? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue / sessionStatus.peersCount), 2)
|
||||
: u"0"_qs;
|
||||
: u"0"_s;
|
||||
|
||||
map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength;
|
||||
map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime;
|
||||
@@ -167,8 +167,8 @@ namespace
|
||||
|
||||
map[KEY_TRANSFER_DHT_NODES] = sessionStatus.dhtNodes;
|
||||
map[KEY_TRANSFER_CONNECTION_STATUS] = session->isListening()
|
||||
? (sessionStatus.hasIncomingConnections ? u"connected"_qs : u"firewalled"_qs)
|
||||
: u"disconnected"_qs;
|
||||
? (sessionStatus.hasIncomingConnections ? u"connected"_s : u"firewalled"_s)
|
||||
: u"disconnected"_s;
|
||||
|
||||
return map;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ namespace
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT_X(false, "processMap"
|
||||
, u"Unexpected type: %1"_qs
|
||||
, u"Unexpected type: %1"_s
|
||||
.arg(QString::fromLatin1(QMetaType::typeName(static_cast<QMetaType::Type>(value.type()))))
|
||||
.toUtf8().constData());
|
||||
}
|
||||
@@ -485,7 +485,7 @@ void SyncController::maindataAction()
|
||||
connect(btSession, &BitTorrent::Session::trackersChanged, this, &SyncController::onTorrentTrackersChanged);
|
||||
}
|
||||
|
||||
const int acceptedID = params()[u"rid"_qs].toInt();
|
||||
const int acceptedID = params()[u"rid"_s].toInt();
|
||||
bool fullUpdate = true;
|
||||
if ((acceptedID > 0) && (m_maindataLastSentID > 0))
|
||||
{
|
||||
@@ -534,8 +534,8 @@ void SyncController::makeMaindataSnapshot()
|
||||
const BitTorrent::CategoryOptions categoryOptions = session->categoryOptions(categoryName);
|
||||
QJsonObject category = categoryOptions.toJSON();
|
||||
// adjust it to be compatible with existing WebAPI
|
||||
category[u"savePath"_qs] = category.take(u"save_path"_qs);
|
||||
category.insert(u"name"_qs, categoryName);
|
||||
category[u"savePath"_s] = category.take(u"save_path"_s);
|
||||
category.insert(u"name"_s, categoryName);
|
||||
m_maindataSnapshot.categories[categoryName] = category.toVariantMap();
|
||||
}
|
||||
|
||||
@@ -589,8 +589,8 @@ QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fu
|
||||
const BitTorrent::CategoryOptions categoryOptions = session->categoryOptions(categoryName);
|
||||
auto category = categoryOptions.toJSON().toVariantMap();
|
||||
// adjust it to be compatible with existing WebAPI
|
||||
category[u"savePath"_qs] = category.take(u"save_path"_qs);
|
||||
category.insert(u"name"_qs, categoryName);
|
||||
category[u"savePath"_s] = category.take(u"save_path"_s);
|
||||
category.insert(u"name"_s, categoryName);
|
||||
|
||||
auto &categorySnapshot = m_maindataSnapshot.categories[categoryName];
|
||||
processMap(categorySnapshot, category, m_maindataSyncBuf.categories[categoryName]);
|
||||
@@ -723,7 +723,7 @@ QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fu
|
||||
// - rid (int): last response id
|
||||
void SyncController::torrentPeersAction()
|
||||
{
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
const BitTorrent::Torrent *torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -776,9 +776,9 @@ void SyncController::torrentPeersAction()
|
||||
|
||||
peers[pi.address().toString()] = peer;
|
||||
}
|
||||
data[u"peers"_qs] = peers;
|
||||
data[u"peers"_s] = peers;
|
||||
|
||||
const int acceptedResponseId = params()[u"rid"_qs].toInt();
|
||||
const int acceptedResponseId = params()[u"rid"_s].toInt();
|
||||
setResult(generateSyncData(acceptedResponseId, data, m_lastAcceptedPeersResponse, m_lastPeersResponse));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,64 +57,64 @@
|
||||
#include "serialize/serialize_torrent.h"
|
||||
|
||||
// Tracker keys
|
||||
const QString KEY_TRACKER_URL = u"url"_qs;
|
||||
const QString KEY_TRACKER_STATUS = u"status"_qs;
|
||||
const QString KEY_TRACKER_TIER = u"tier"_qs;
|
||||
const QString KEY_TRACKER_MSG = u"msg"_qs;
|
||||
const QString KEY_TRACKER_PEERS_COUNT = u"num_peers"_qs;
|
||||
const QString KEY_TRACKER_SEEDS_COUNT = u"num_seeds"_qs;
|
||||
const QString KEY_TRACKER_LEECHES_COUNT = u"num_leeches"_qs;
|
||||
const QString KEY_TRACKER_DOWNLOADED_COUNT = u"num_downloaded"_qs;
|
||||
const QString KEY_TRACKER_URL = u"url"_s;
|
||||
const QString KEY_TRACKER_STATUS = u"status"_s;
|
||||
const QString KEY_TRACKER_TIER = u"tier"_s;
|
||||
const QString KEY_TRACKER_MSG = u"msg"_s;
|
||||
const QString KEY_TRACKER_PEERS_COUNT = u"num_peers"_s;
|
||||
const QString KEY_TRACKER_SEEDS_COUNT = u"num_seeds"_s;
|
||||
const QString KEY_TRACKER_LEECHES_COUNT = u"num_leeches"_s;
|
||||
const QString KEY_TRACKER_DOWNLOADED_COUNT = u"num_downloaded"_s;
|
||||
|
||||
// Web seed keys
|
||||
const QString KEY_WEBSEED_URL = u"url"_qs;
|
||||
const QString KEY_WEBSEED_URL = u"url"_s;
|
||||
|
||||
// Torrent keys (Properties)
|
||||
const QString KEY_PROP_TIME_ELAPSED = u"time_elapsed"_qs;
|
||||
const QString KEY_PROP_SEEDING_TIME = u"seeding_time"_qs;
|
||||
const QString KEY_PROP_ETA = u"eta"_qs;
|
||||
const QString KEY_PROP_CONNECT_COUNT = u"nb_connections"_qs;
|
||||
const QString KEY_PROP_CONNECT_COUNT_LIMIT = u"nb_connections_limit"_qs;
|
||||
const QString KEY_PROP_DOWNLOADED = u"total_downloaded"_qs;
|
||||
const QString KEY_PROP_DOWNLOADED_SESSION = u"total_downloaded_session"_qs;
|
||||
const QString KEY_PROP_UPLOADED = u"total_uploaded"_qs;
|
||||
const QString KEY_PROP_UPLOADED_SESSION = u"total_uploaded_session"_qs;
|
||||
const QString KEY_PROP_DL_SPEED = u"dl_speed"_qs;
|
||||
const QString KEY_PROP_DL_SPEED_AVG = u"dl_speed_avg"_qs;
|
||||
const QString KEY_PROP_UP_SPEED = u"up_speed"_qs;
|
||||
const QString KEY_PROP_UP_SPEED_AVG = u"up_speed_avg"_qs;
|
||||
const QString KEY_PROP_DL_LIMIT = u"dl_limit"_qs;
|
||||
const QString KEY_PROP_UP_LIMIT = u"up_limit"_qs;
|
||||
const QString KEY_PROP_WASTED = u"total_wasted"_qs;
|
||||
const QString KEY_PROP_SEEDS = u"seeds"_qs;
|
||||
const QString KEY_PROP_SEEDS_TOTAL = u"seeds_total"_qs;
|
||||
const QString KEY_PROP_PEERS = u"peers"_qs;
|
||||
const QString KEY_PROP_PEERS_TOTAL = u"peers_total"_qs;
|
||||
const QString KEY_PROP_RATIO = u"share_ratio"_qs;
|
||||
const QString KEY_PROP_REANNOUNCE = u"reannounce"_qs;
|
||||
const QString KEY_PROP_TOTAL_SIZE = u"total_size"_qs;
|
||||
const QString KEY_PROP_PIECES_NUM = u"pieces_num"_qs;
|
||||
const QString KEY_PROP_PIECE_SIZE = u"piece_size"_qs;
|
||||
const QString KEY_PROP_PIECES_HAVE = u"pieces_have"_qs;
|
||||
const QString KEY_PROP_CREATED_BY = u"created_by"_qs;
|
||||
const QString KEY_PROP_LAST_SEEN = u"last_seen"_qs;
|
||||
const QString KEY_PROP_ADDITION_DATE = u"addition_date"_qs;
|
||||
const QString KEY_PROP_COMPLETION_DATE = u"completion_date"_qs;
|
||||
const QString KEY_PROP_CREATION_DATE = u"creation_date"_qs;
|
||||
const QString KEY_PROP_SAVE_PATH = u"save_path"_qs;
|
||||
const QString KEY_PROP_DOWNLOAD_PATH = u"download_path"_qs;
|
||||
const QString KEY_PROP_COMMENT = u"comment"_qs;
|
||||
const QString KEY_PROP_ISPRIVATE = u"is_private"_qs;
|
||||
const QString KEY_PROP_TIME_ELAPSED = u"time_elapsed"_s;
|
||||
const QString KEY_PROP_SEEDING_TIME = u"seeding_time"_s;
|
||||
const QString KEY_PROP_ETA = u"eta"_s;
|
||||
const QString KEY_PROP_CONNECT_COUNT = u"nb_connections"_s;
|
||||
const QString KEY_PROP_CONNECT_COUNT_LIMIT = u"nb_connections_limit"_s;
|
||||
const QString KEY_PROP_DOWNLOADED = u"total_downloaded"_s;
|
||||
const QString KEY_PROP_DOWNLOADED_SESSION = u"total_downloaded_session"_s;
|
||||
const QString KEY_PROP_UPLOADED = u"total_uploaded"_s;
|
||||
const QString KEY_PROP_UPLOADED_SESSION = u"total_uploaded_session"_s;
|
||||
const QString KEY_PROP_DL_SPEED = u"dl_speed"_s;
|
||||
const QString KEY_PROP_DL_SPEED_AVG = u"dl_speed_avg"_s;
|
||||
const QString KEY_PROP_UP_SPEED = u"up_speed"_s;
|
||||
const QString KEY_PROP_UP_SPEED_AVG = u"up_speed_avg"_s;
|
||||
const QString KEY_PROP_DL_LIMIT = u"dl_limit"_s;
|
||||
const QString KEY_PROP_UP_LIMIT = u"up_limit"_s;
|
||||
const QString KEY_PROP_WASTED = u"total_wasted"_s;
|
||||
const QString KEY_PROP_SEEDS = u"seeds"_s;
|
||||
const QString KEY_PROP_SEEDS_TOTAL = u"seeds_total"_s;
|
||||
const QString KEY_PROP_PEERS = u"peers"_s;
|
||||
const QString KEY_PROP_PEERS_TOTAL = u"peers_total"_s;
|
||||
const QString KEY_PROP_RATIO = u"share_ratio"_s;
|
||||
const QString KEY_PROP_REANNOUNCE = u"reannounce"_s;
|
||||
const QString KEY_PROP_TOTAL_SIZE = u"total_size"_s;
|
||||
const QString KEY_PROP_PIECES_NUM = u"pieces_num"_s;
|
||||
const QString KEY_PROP_PIECE_SIZE = u"piece_size"_s;
|
||||
const QString KEY_PROP_PIECES_HAVE = u"pieces_have"_s;
|
||||
const QString KEY_PROP_CREATED_BY = u"created_by"_s;
|
||||
const QString KEY_PROP_LAST_SEEN = u"last_seen"_s;
|
||||
const QString KEY_PROP_ADDITION_DATE = u"addition_date"_s;
|
||||
const QString KEY_PROP_COMPLETION_DATE = u"completion_date"_s;
|
||||
const QString KEY_PROP_CREATION_DATE = u"creation_date"_s;
|
||||
const QString KEY_PROP_SAVE_PATH = u"save_path"_s;
|
||||
const QString KEY_PROP_DOWNLOAD_PATH = u"download_path"_s;
|
||||
const QString KEY_PROP_COMMENT = u"comment"_s;
|
||||
const QString KEY_PROP_ISPRIVATE = u"is_private"_s;
|
||||
|
||||
// File keys
|
||||
const QString KEY_FILE_INDEX = u"index"_qs;
|
||||
const QString KEY_FILE_NAME = u"name"_qs;
|
||||
const QString KEY_FILE_SIZE = u"size"_qs;
|
||||
const QString KEY_FILE_PROGRESS = u"progress"_qs;
|
||||
const QString KEY_FILE_PRIORITY = u"priority"_qs;
|
||||
const QString KEY_FILE_IS_SEED = u"is_seed"_qs;
|
||||
const QString KEY_FILE_PIECE_RANGE = u"piece_range"_qs;
|
||||
const QString KEY_FILE_AVAILABILITY = u"availability"_qs;
|
||||
const QString KEY_FILE_INDEX = u"index"_s;
|
||||
const QString KEY_FILE_NAME = u"name"_s;
|
||||
const QString KEY_FILE_SIZE = u"size"_s;
|
||||
const QString KEY_FILE_PROGRESS = u"progress"_s;
|
||||
const QString KEY_FILE_PRIORITY = u"priority"_s;
|
||||
const QString KEY_FILE_IS_SEED = u"is_seed"_s;
|
||||
const QString KEY_FILE_PIECE_RANGE = u"piece_range"_s;
|
||||
const QString KEY_FILE_AVAILABILITY = u"availability"_s;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -185,9 +185,9 @@ namespace
|
||||
|
||||
const QJsonObject dht
|
||||
{
|
||||
{KEY_TRACKER_URL, u"** [DHT] **"_qs},
|
||||
{KEY_TRACKER_URL, u"** [DHT] **"_s},
|
||||
{KEY_TRACKER_TIER, -1},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_qs)},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_s)},
|
||||
{KEY_TRACKER_STATUS, ((BitTorrent::Session::instance()->isDHTEnabled() && !isTorrentPrivate) ? working : disabled)},
|
||||
{KEY_TRACKER_PEERS_COUNT, 0},
|
||||
{KEY_TRACKER_DOWNLOADED_COUNT, 0},
|
||||
@@ -197,9 +197,9 @@ namespace
|
||||
|
||||
const QJsonObject pex
|
||||
{
|
||||
{KEY_TRACKER_URL, u"** [PeX] **"_qs},
|
||||
{KEY_TRACKER_URL, u"** [PeX] **"_s},
|
||||
{KEY_TRACKER_TIER, -1},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_qs)},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_s)},
|
||||
{KEY_TRACKER_STATUS, ((BitTorrent::Session::instance()->isPeXEnabled() && !isTorrentPrivate) ? working : disabled)},
|
||||
{KEY_TRACKER_PEERS_COUNT, 0},
|
||||
{KEY_TRACKER_DOWNLOADED_COUNT, 0},
|
||||
@@ -209,9 +209,9 @@ namespace
|
||||
|
||||
const QJsonObject lsd
|
||||
{
|
||||
{KEY_TRACKER_URL, u"** [LSD] **"_qs},
|
||||
{KEY_TRACKER_URL, u"** [LSD] **"_s},
|
||||
{KEY_TRACKER_TIER, -1},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_qs)},
|
||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : u""_s)},
|
||||
{KEY_TRACKER_STATUS, ((BitTorrent::Session::instance()->isLSDEnabled() && !isTorrentPrivate) ? working : disabled)},
|
||||
{KEY_TRACKER_PEERS_COUNT, 0},
|
||||
{KEY_TRACKER_DOWNLOADED_COUNT, 0},
|
||||
@@ -264,14 +264,14 @@ namespace
|
||||
// - offset (int): set offset (if less than 0 - offset from end)
|
||||
void TorrentsController::infoAction()
|
||||
{
|
||||
const QString filter {params()[u"filter"_qs]};
|
||||
const std::optional<QString> category = getOptionalString(params(), u"category"_qs);
|
||||
const std::optional<QString> tag = getOptionalString(params(), u"tag"_qs);
|
||||
const QString sortedColumn {params()[u"sort"_qs]};
|
||||
const bool reverse {parseBool(params()[u"reverse"_qs]).value_or(false)};
|
||||
int limit {params()[u"limit"_qs].toInt()};
|
||||
int offset {params()[u"offset"_qs].toInt()};
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|', Qt::SkipEmptyParts)};
|
||||
const QString filter {params()[u"filter"_s]};
|
||||
const std::optional<QString> category = getOptionalString(params(), u"category"_s);
|
||||
const std::optional<QString> tag = getOptionalString(params(), u"tag"_s);
|
||||
const QString sortedColumn {params()[u"sort"_s]};
|
||||
const bool reverse {parseBool(params()[u"reverse"_s]).value_or(false)};
|
||||
int limit {params()[u"limit"_s].toInt()};
|
||||
int offset {params()[u"offset"_s].toInt()};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|', Qt::SkipEmptyParts)};
|
||||
|
||||
std::optional<TorrentIDSet> idSet;
|
||||
if (!hashes.isEmpty())
|
||||
@@ -394,9 +394,9 @@ void TorrentsController::infoAction()
|
||||
// - "name": Torrent name
|
||||
void TorrentsController::propertiesAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -471,9 +471,9 @@ void TorrentsController::propertiesAction()
|
||||
// - "msg": Tracker message (last)
|
||||
void TorrentsController::trackersAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -504,9 +504,9 @@ void TorrentsController::trackersAction()
|
||||
// - "url": Web seed URL
|
||||
void TorrentsController::webseedsAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -536,16 +536,16 @@ void TorrentsController::webseedsAction()
|
||||
// and the second number is the ending piece index (inclusive)
|
||||
void TorrentsController::filesAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const int filesCount = torrent->filesCount();
|
||||
QVector<int> fileIndexes;
|
||||
const auto idxIt = params().constFind(u"indexes"_qs);
|
||||
const auto idxIt = params().constFind(u"indexes"_s);
|
||||
if (idxIt != params().cend())
|
||||
{
|
||||
const QStringList indexStrings = idxIt.value().split(u'|');
|
||||
@@ -606,9 +606,9 @@ void TorrentsController::filesAction()
|
||||
// The return value is a JSON-formatted array of strings (hex strings).
|
||||
void TorrentsController::pieceHashesAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -631,9 +631,9 @@ void TorrentsController::pieceHashesAction()
|
||||
// 2: piece already downloaded
|
||||
void TorrentsController::pieceStatesAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
@@ -655,32 +655,32 @@ void TorrentsController::pieceStatesAction()
|
||||
|
||||
void TorrentsController::addAction()
|
||||
{
|
||||
const QString urls = params()[u"urls"_qs];
|
||||
const QString cookie = params()[u"cookie"_qs];
|
||||
const QString urls = params()[u"urls"_s];
|
||||
const QString cookie = params()[u"cookie"_s];
|
||||
|
||||
const bool skipChecking = parseBool(params()[u"skip_checking"_qs]).value_or(false);
|
||||
const bool seqDownload = parseBool(params()[u"sequentialDownload"_qs]).value_or(false);
|
||||
const bool firstLastPiece = parseBool(params()[u"firstLastPiecePrio"_qs]).value_or(false);
|
||||
const std::optional<bool> addToQueueTop = parseBool(params()[u"addToTopOfQueue"_qs]);
|
||||
const std::optional<bool> addPaused = parseBool(params()[u"paused"_qs]);
|
||||
const QString savepath = params()[u"savepath"_qs].trimmed();
|
||||
const QString downloadPath = params()[u"downloadPath"_qs].trimmed();
|
||||
const std::optional<bool> useDownloadPath = parseBool(params()[u"useDownloadPath"_qs]);
|
||||
const QString category = params()[u"category"_qs];
|
||||
const QStringList tags = params()[u"tags"_qs].split(u',', Qt::SkipEmptyParts);
|
||||
const QString torrentName = params()[u"rename"_qs].trimmed();
|
||||
const int upLimit = parseInt(params()[u"upLimit"_qs]).value_or(-1);
|
||||
const int dlLimit = parseInt(params()[u"dlLimit"_qs]).value_or(-1);
|
||||
const double ratioLimit = parseDouble(params()[u"ratioLimit"_qs]).value_or(BitTorrent::Torrent::USE_GLOBAL_RATIO);
|
||||
const int seedingTimeLimit = parseInt(params()[u"seedingTimeLimit"_qs]).value_or(BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME);
|
||||
const std::optional<bool> autoTMM = parseBool(params()[u"autoTMM"_qs]);
|
||||
const bool skipChecking = parseBool(params()[u"skip_checking"_s]).value_or(false);
|
||||
const bool seqDownload = parseBool(params()[u"sequentialDownload"_s]).value_or(false);
|
||||
const bool firstLastPiece = parseBool(params()[u"firstLastPiecePrio"_s]).value_or(false);
|
||||
const std::optional<bool> addToQueueTop = parseBool(params()[u"addToTopOfQueue"_s]);
|
||||
const std::optional<bool> addPaused = parseBool(params()[u"paused"_s]);
|
||||
const QString savepath = params()[u"savepath"_s].trimmed();
|
||||
const QString downloadPath = params()[u"downloadPath"_s].trimmed();
|
||||
const std::optional<bool> useDownloadPath = parseBool(params()[u"useDownloadPath"_s]);
|
||||
const QString category = params()[u"category"_s];
|
||||
const QStringList tags = params()[u"tags"_s].split(u',', Qt::SkipEmptyParts);
|
||||
const QString torrentName = params()[u"rename"_s].trimmed();
|
||||
const int upLimit = parseInt(params()[u"upLimit"_s]).value_or(-1);
|
||||
const int dlLimit = parseInt(params()[u"dlLimit"_s]).value_or(-1);
|
||||
const double ratioLimit = parseDouble(params()[u"ratioLimit"_s]).value_or(BitTorrent::Torrent::USE_GLOBAL_RATIO);
|
||||
const int seedingTimeLimit = parseInt(params()[u"seedingTimeLimit"_s]).value_or(BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME);
|
||||
const std::optional<bool> autoTMM = parseBool(params()[u"autoTMM"_s]);
|
||||
|
||||
const QString stopConditionParam = params()[u"stopCondition"_qs];
|
||||
const QString stopConditionParam = params()[u"stopCondition"_s];
|
||||
const std::optional<BitTorrent::Torrent::StopCondition> stopCondition = (!stopConditionParam.isEmpty()
|
||||
? Utils::String::toEnum(stopConditionParam, BitTorrent::Torrent::StopCondition::None)
|
||||
: std::optional<BitTorrent::Torrent::StopCondition> {});
|
||||
|
||||
const QString contentLayoutParam = params()[u"contentLayout"_qs];
|
||||
const QString contentLayoutParam = params()[u"contentLayout"_s];
|
||||
const std::optional<BitTorrent::TorrentContentLayout> contentLayout = (!contentLayoutParam.isEmpty()
|
||||
? Utils::String::toEnum(contentLayoutParam, BitTorrent::TorrentContentLayout::Original)
|
||||
: std::optional<BitTorrent::TorrentContentLayout> {});
|
||||
@@ -688,7 +688,7 @@ void TorrentsController::addAction()
|
||||
QList<QNetworkCookie> cookies;
|
||||
if (!cookie.isEmpty())
|
||||
{
|
||||
const QStringList cookiesStr = cookie.split(u"; "_qs);
|
||||
const QStringList cookiesStr = cookie.split(u"; "_s);
|
||||
for (QString cookieStr : cookiesStr)
|
||||
{
|
||||
cookieStr = cookieStr.trimmed();
|
||||
@@ -748,31 +748,31 @@ void TorrentsController::addAction()
|
||||
}
|
||||
|
||||
if (partialSuccess)
|
||||
setResult(u"Ok."_qs);
|
||||
setResult(u"Ok."_s);
|
||||
else
|
||||
setResult(u"Fails."_qs);
|
||||
setResult(u"Fails."_s);
|
||||
}
|
||||
|
||||
void TorrentsController::addTrackersAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"urls"_qs});
|
||||
requireParams({u"hash"_s, u"urls"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const QVector<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(params()[u"urls"_qs]);
|
||||
const QVector<BitTorrent::TrackerEntry> entries = BitTorrent::parseTrackerEntries(params()[u"urls"_s]);
|
||||
torrent->addTrackers(entries);
|
||||
}
|
||||
|
||||
void TorrentsController::editTrackerAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"origUrl"_qs, u"newUrl"_qs});
|
||||
requireParams({u"hash"_s, u"origUrl"_s, u"newUrl"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const QString origUrl = params()[u"origUrl"_qs];
|
||||
const QString newUrl = params()[u"newUrl"_qs];
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
const QString origUrl = params()[u"origUrl"_s];
|
||||
const QString newUrl = params()[u"newUrl"_s];
|
||||
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
@@ -783,7 +783,7 @@ void TorrentsController::editTrackerAction()
|
||||
if (origTrackerUrl == newTrackerUrl)
|
||||
return;
|
||||
if (!newTrackerUrl.isValid())
|
||||
throw APIError(APIErrorType::BadParams, u"New tracker URL is invalid"_qs);
|
||||
throw APIError(APIErrorType::BadParams, u"New tracker URL is invalid"_s);
|
||||
|
||||
QVector<BitTorrent::TrackerEntry> trackers = torrent->trackers();
|
||||
bool match = false;
|
||||
@@ -791,7 +791,7 @@ void TorrentsController::editTrackerAction()
|
||||
{
|
||||
const QUrl trackerUrl {tracker.url};
|
||||
if (trackerUrl == newTrackerUrl)
|
||||
throw APIError(APIErrorType::Conflict, u"New tracker URL already exists"_qs);
|
||||
throw APIError(APIErrorType::Conflict, u"New tracker URL already exists"_s);
|
||||
if (trackerUrl == origTrackerUrl)
|
||||
{
|
||||
match = true;
|
||||
@@ -799,7 +799,7 @@ void TorrentsController::editTrackerAction()
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
throw APIError(APIErrorType::Conflict, u"Tracker not found"_qs);
|
||||
throw APIError(APIErrorType::Conflict, u"Tracker not found"_s);
|
||||
|
||||
torrent->replaceTrackers(trackers);
|
||||
|
||||
@@ -809,14 +809,14 @@ void TorrentsController::editTrackerAction()
|
||||
|
||||
void TorrentsController::removeTrackersAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"urls"_qs});
|
||||
requireParams({u"hash"_s, u"urls"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const QStringList urls = params()[u"urls"_qs].split(u'|');
|
||||
const QStringList urls = params()[u"urls"_s].split(u'|');
|
||||
torrent->removeTrackers(urls);
|
||||
|
||||
if (!torrent->isPaused())
|
||||
@@ -825,10 +825,10 @@ void TorrentsController::removeTrackersAction()
|
||||
|
||||
void TorrentsController::addPeersAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"peers"_qs});
|
||||
requireParams({u"hashes"_s, u"peers"_s});
|
||||
|
||||
const QStringList hashes = params()[u"hashes"_qs].split(u'|');
|
||||
const QStringList peers = params()[u"peers"_qs].split(u'|');
|
||||
const QStringList hashes = params()[u"hashes"_s].split(u'|');
|
||||
const QStringList peers = params()[u"peers"_s].split(u'|');
|
||||
|
||||
QVector<BitTorrent::PeerAddress> peerList;
|
||||
peerList.reserve(peers.size());
|
||||
@@ -840,7 +840,7 @@ void TorrentsController::addPeersAction()
|
||||
}
|
||||
|
||||
if (peerList.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, u"No valid peers were specified"_qs);
|
||||
throw APIError(APIErrorType::BadParams, u"No valid peers were specified"_s);
|
||||
|
||||
QJsonObject results;
|
||||
|
||||
@@ -853,8 +853,8 @@ void TorrentsController::addPeersAction()
|
||||
|
||||
results[torrent->id().toString()] = QJsonObject
|
||||
{
|
||||
{u"added"_qs, peersAdded},
|
||||
{u"failed"_qs, (peers.size() - peersAdded)}
|
||||
{u"added"_s, peersAdded},
|
||||
{u"failed"_s, (peers.size() - peersAdded)}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -863,27 +863,27 @@ void TorrentsController::addPeersAction()
|
||||
|
||||
void TorrentsController::pauseAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes = params()[u"hashes"_qs].split(u'|');
|
||||
const QStringList hashes = params()[u"hashes"_s].split(u'|');
|
||||
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->pause(); });
|
||||
}
|
||||
|
||||
void TorrentsController::resumeAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList idStrings = params()[u"hashes"_qs].split(u'|');
|
||||
const QStringList idStrings = params()[u"hashes"_s].split(u'|');
|
||||
applyToTorrents(idStrings, [](BitTorrent::Torrent *const torrent) { torrent->resume(); });
|
||||
}
|
||||
|
||||
void TorrentsController::filePrioAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"id"_qs, u"priority"_qs});
|
||||
requireParams({u"hash"_s, u"id"_s, u"priority"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
bool ok = false;
|
||||
const auto priority = static_cast<BitTorrent::DownloadPriority>(params()[u"priority"_qs].toInt(&ok));
|
||||
const auto priority = static_cast<BitTorrent::DownloadPriority>(params()[u"priority"_s].toInt(&ok));
|
||||
if (!ok)
|
||||
throw APIError(APIErrorType::BadParams, tr("Priority must be an integer"));
|
||||
|
||||
@@ -899,7 +899,7 @@ void TorrentsController::filePrioAction()
|
||||
const int filesCount = torrent->filesCount();
|
||||
QVector<BitTorrent::DownloadPriority> priorities = torrent->filePriorities();
|
||||
bool priorityChanged = false;
|
||||
for (const QString &fileID : params()[u"id"_qs].split(u'|'))
|
||||
for (const QString &fileID : params()[u"id"_s].split(u'|'))
|
||||
{
|
||||
const int id = fileID.toInt(&ok);
|
||||
if (!ok)
|
||||
@@ -920,9 +920,9 @@ void TorrentsController::filePrioAction()
|
||||
|
||||
void TorrentsController::uploadLimitAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList idList {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList idList {params()[u"hashes"_s].split(u'|')};
|
||||
QJsonObject map;
|
||||
for (const QString &id : idList)
|
||||
{
|
||||
@@ -938,9 +938,9 @@ void TorrentsController::uploadLimitAction()
|
||||
|
||||
void TorrentsController::downloadLimitAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList idList {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList idList {params()[u"hashes"_s].split(u'|')};
|
||||
QJsonObject map;
|
||||
for (const QString &id : idList)
|
||||
{
|
||||
@@ -956,35 +956,35 @@ void TorrentsController::downloadLimitAction()
|
||||
|
||||
void TorrentsController::setUploadLimitAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"limit"_qs});
|
||||
requireParams({u"hashes"_s, u"limit"_s});
|
||||
|
||||
qlonglong limit = params()[u"limit"_qs].toLongLong();
|
||||
qlonglong limit = params()[u"limit"_s].toLongLong();
|
||||
if (limit == 0)
|
||||
limit = -1;
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setUploadLimit(limit); });
|
||||
}
|
||||
|
||||
void TorrentsController::setDownloadLimitAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"limit"_qs});
|
||||
requireParams({u"hashes"_s, u"limit"_s});
|
||||
|
||||
qlonglong limit = params()[u"limit"_qs].toLongLong();
|
||||
qlonglong limit = params()[u"limit"_s].toLongLong();
|
||||
if (limit == 0)
|
||||
limit = -1;
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setDownloadLimit(limit); });
|
||||
}
|
||||
|
||||
void TorrentsController::setShareLimitsAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"ratioLimit"_qs, u"seedingTimeLimit"_qs});
|
||||
requireParams({u"hashes"_s, u"ratioLimit"_s, u"seedingTimeLimit"_s});
|
||||
|
||||
const qreal ratioLimit = params()[u"ratioLimit"_qs].toDouble();
|
||||
const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_qs].toLongLong();
|
||||
const QStringList hashes = params()[u"hashes"_qs].split(u'|');
|
||||
const qreal ratioLimit = params()[u"ratioLimit"_s].toDouble();
|
||||
const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_s].toLongLong();
|
||||
const QStringList hashes = params()[u"hashes"_s].split(u'|');
|
||||
|
||||
applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
@@ -995,35 +995,35 @@ void TorrentsController::setShareLimitsAction()
|
||||
|
||||
void TorrentsController::toggleSequentialDownloadAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleSequentialDownload(); });
|
||||
}
|
||||
|
||||
void TorrentsController::toggleFirstLastPiecePrioAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleFirstLastPiecePriority(); });
|
||||
}
|
||||
|
||||
void TorrentsController::setSuperSeedingAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"value"_qs});
|
||||
requireParams({u"hashes"_s, u"value"_s});
|
||||
|
||||
const bool value {parseBool(params()[u"value"_qs]).value_or(false)};
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const bool value {parseBool(params()[u"value"_s]).value_or(false)};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent) { torrent->setSuperSeeding(value); });
|
||||
}
|
||||
|
||||
void TorrentsController::setForceStartAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"value"_qs});
|
||||
requireParams({u"hashes"_s, u"value"_s});
|
||||
|
||||
const bool value {parseBool(params()[u"value"_qs]).value_or(false)};
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const bool value {parseBool(params()[u"value"_s]).value_or(false)};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
torrent->resume(value ? BitTorrent::TorrentOperatingMode::Forced : BitTorrent::TorrentOperatingMode::AutoManaged);
|
||||
@@ -1032,10 +1032,10 @@ void TorrentsController::setForceStartAction()
|
||||
|
||||
void TorrentsController::deleteAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"deleteFiles"_qs});
|
||||
requireParams({u"hashes"_s, u"deleteFiles"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const DeleteOption deleteOption = parseBool(params()[u"deleteFiles"_qs]).value_or(false)
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const DeleteOption deleteOption = parseBool(params()[u"deleteFiles"_s]).value_or(false)
|
||||
? DeleteTorrentAndFiles : DeleteTorrent;
|
||||
applyToTorrents(hashes, [deleteOption](const BitTorrent::Torrent *torrent)
|
||||
{
|
||||
@@ -1045,54 +1045,54 @@ void TorrentsController::deleteAction()
|
||||
|
||||
void TorrentsController::increasePrioAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
BitTorrent::Session::instance()->increaseTorrentsQueuePos(toTorrentIDs(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::decreasePrioAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
BitTorrent::Session::instance()->decreaseTorrentsQueuePos(toTorrentIDs(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::topPrioAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
BitTorrent::Session::instance()->topTorrentsQueuePos(toTorrentIDs(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::bottomPrioAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
BitTorrent::Session::instance()->bottomTorrentsQueuePos(toTorrentIDs(hashes));
|
||||
}
|
||||
|
||||
void TorrentsController::setLocationAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"location"_qs});
|
||||
requireParams({u"hashes"_s, u"location"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const Path newLocation {params()[u"location"_qs].trimmed()};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const Path newLocation {params()[u"location"_s].trimmed()};
|
||||
|
||||
if (newLocation.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, tr("Save path cannot be empty"));
|
||||
@@ -1112,10 +1112,10 @@ void TorrentsController::setLocationAction()
|
||||
|
||||
void TorrentsController::setSavePathAction()
|
||||
{
|
||||
requireParams({u"id"_qs, u"path"_qs});
|
||||
requireParams({u"id"_s, u"path"_s});
|
||||
|
||||
const QStringList ids {params()[u"id"_qs].split(u'|')};
|
||||
const Path newPath {params()[u"path"_qs]};
|
||||
const QStringList ids {params()[u"id"_s].split(u'|')};
|
||||
const Path newPath {params()[u"path"_s]};
|
||||
|
||||
if (newPath.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, tr("Save path cannot be empty"));
|
||||
@@ -1137,10 +1137,10 @@ void TorrentsController::setSavePathAction()
|
||||
|
||||
void TorrentsController::setDownloadPathAction()
|
||||
{
|
||||
requireParams({u"id"_qs, u"path"_qs});
|
||||
requireParams({u"id"_s, u"path"_s});
|
||||
|
||||
const QStringList ids {params()[u"id"_qs].split(u'|')};
|
||||
const Path newPath {params()[u"path"_qs]};
|
||||
const QStringList ids {params()[u"id"_s].split(u'|')};
|
||||
const Path newPath {params()[u"path"_s]};
|
||||
|
||||
if (!newPath.isEmpty())
|
||||
{
|
||||
@@ -1162,10 +1162,10 @@ void TorrentsController::setDownloadPathAction()
|
||||
|
||||
void TorrentsController::renameAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"name"_qs});
|
||||
requireParams({u"hash"_s, u"name"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
QString name = params()[u"name"_qs].trimmed();
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
QString name = params()[u"name"_s].trimmed();
|
||||
|
||||
if (name.isEmpty())
|
||||
throw APIError(APIErrorType::Conflict, tr("Incorrect torrent name"));
|
||||
@@ -1174,16 +1174,16 @@ void TorrentsController::renameAction()
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
name.replace(QRegularExpression(u"\r?\n|\r"_qs), u" "_qs);
|
||||
name.replace(QRegularExpression(u"\r?\n|\r"_s), u" "_s);
|
||||
torrent->setName(name);
|
||||
}
|
||||
|
||||
void TorrentsController::setAutoManagementAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"enable"_qs});
|
||||
requireParams({u"hashes"_s, u"enable"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const bool isEnabled {parseBool(params()[u"enable"_qs]).value_or(false)};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const bool isEnabled {parseBool(params()[u"enable"_s]).value_or(false)};
|
||||
|
||||
applyToTorrents(hashes, [isEnabled](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
@@ -1193,26 +1193,26 @@ void TorrentsController::setAutoManagementAction()
|
||||
|
||||
void TorrentsController::recheckAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceRecheck(); });
|
||||
}
|
||||
|
||||
void TorrentsController::reannounceAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceReannounce(); });
|
||||
}
|
||||
|
||||
void TorrentsController::setCategoryAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"category"_qs});
|
||||
requireParams({u"hashes"_s, u"category"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QString category {params()[u"category"_qs]};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const QString category {params()[u"category"_s]};
|
||||
|
||||
applyToTorrents(hashes, [category](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
@@ -1223,22 +1223,22 @@ void TorrentsController::setCategoryAction()
|
||||
|
||||
void TorrentsController::createCategoryAction()
|
||||
{
|
||||
requireParams({u"category"_qs});
|
||||
requireParams({u"category"_s});
|
||||
|
||||
const QString category = params()[u"category"_qs];
|
||||
const QString category = params()[u"category"_s];
|
||||
if (category.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, tr("Category cannot be empty"));
|
||||
|
||||
if (!BitTorrent::Session::isValidCategoryName(category))
|
||||
throw APIError(APIErrorType::Conflict, tr("Incorrect category name"));
|
||||
|
||||
const Path savePath {params()[u"savePath"_qs]};
|
||||
const auto useDownloadPath = parseBool(params()[u"downloadPathEnabled"_qs]);
|
||||
const Path savePath {params()[u"savePath"_s]};
|
||||
const auto useDownloadPath = parseBool(params()[u"downloadPathEnabled"_s]);
|
||||
BitTorrent::CategoryOptions categoryOptions;
|
||||
categoryOptions.savePath = savePath;
|
||||
if (useDownloadPath.has_value())
|
||||
{
|
||||
const Path downloadPath {params()[u"downloadPath"_qs]};
|
||||
const Path downloadPath {params()[u"downloadPath"_s]};
|
||||
categoryOptions.downloadPath = {useDownloadPath.value(), downloadPath};
|
||||
}
|
||||
|
||||
@@ -1248,19 +1248,19 @@ void TorrentsController::createCategoryAction()
|
||||
|
||||
void TorrentsController::editCategoryAction()
|
||||
{
|
||||
requireParams({u"category"_qs, u"savePath"_qs});
|
||||
requireParams({u"category"_s, u"savePath"_s});
|
||||
|
||||
const QString category = params()[u"category"_qs];
|
||||
const QString category = params()[u"category"_s];
|
||||
if (category.isEmpty())
|
||||
throw APIError(APIErrorType::BadParams, tr("Category cannot be empty"));
|
||||
|
||||
const Path savePath {params()[u"savePath"_qs]};
|
||||
const auto useDownloadPath = parseBool(params()[u"downloadPathEnabled"_qs]);
|
||||
const Path savePath {params()[u"savePath"_s]};
|
||||
const auto useDownloadPath = parseBool(params()[u"downloadPathEnabled"_s]);
|
||||
BitTorrent::CategoryOptions categoryOptions;
|
||||
categoryOptions.savePath = savePath;
|
||||
if (useDownloadPath.has_value())
|
||||
{
|
||||
const Path downloadPath {params()[u"downloadPath"_qs]};
|
||||
const Path downloadPath {params()[u"downloadPath"_s]};
|
||||
categoryOptions.downloadPath = {useDownloadPath.value(), downloadPath};
|
||||
}
|
||||
|
||||
@@ -1270,9 +1270,9 @@ void TorrentsController::editCategoryAction()
|
||||
|
||||
void TorrentsController::removeCategoriesAction()
|
||||
{
|
||||
requireParams({u"categories"_qs});
|
||||
requireParams({u"categories"_s});
|
||||
|
||||
const QStringList categories {params()[u"categories"_qs].split(u'\n')};
|
||||
const QStringList categories {params()[u"categories"_s].split(u'\n')};
|
||||
for (const QString &category : categories)
|
||||
BitTorrent::Session::instance()->removeCategory(category);
|
||||
}
|
||||
@@ -1288,8 +1288,8 @@ void TorrentsController::categoriesAction()
|
||||
const BitTorrent::CategoryOptions categoryOptions = session->categoryOptions(categoryName);
|
||||
QJsonObject category = categoryOptions.toJSON();
|
||||
// adjust it to be compatible with existing WebAPI
|
||||
category[u"savePath"_qs] = category.take(u"save_path"_qs);
|
||||
category.insert(u"name"_qs, categoryName);
|
||||
category[u"savePath"_s] = category.take(u"save_path"_s);
|
||||
category.insert(u"name"_s, categoryName);
|
||||
categories[categoryName] = category;
|
||||
}
|
||||
|
||||
@@ -1298,10 +1298,10 @@ void TorrentsController::categoriesAction()
|
||||
|
||||
void TorrentsController::addTagsAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs, u"tags"_qs});
|
||||
requireParams({u"hashes"_s, u"tags"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList tags {params()[u"tags"_qs].split(u',', Qt::SkipEmptyParts)};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags)
|
||||
{
|
||||
@@ -1315,10 +1315,10 @@ void TorrentsController::addTagsAction()
|
||||
|
||||
void TorrentsController::removeTagsAction()
|
||||
{
|
||||
requireParams({u"hashes"_qs});
|
||||
requireParams({u"hashes"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_qs].split(u'|')};
|
||||
const QStringList tags {params()[u"tags"_qs].split(u',', Qt::SkipEmptyParts)};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags)
|
||||
{
|
||||
@@ -1340,9 +1340,9 @@ void TorrentsController::removeTagsAction()
|
||||
|
||||
void TorrentsController::createTagsAction()
|
||||
{
|
||||
requireParams({u"tags"_qs});
|
||||
requireParams({u"tags"_s});
|
||||
|
||||
const QStringList tags {params()[u"tags"_qs].split(u',', Qt::SkipEmptyParts)};
|
||||
const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)};
|
||||
|
||||
for (const QString &tag : tags)
|
||||
BitTorrent::Session::instance()->addTag(tag.trimmed());
|
||||
@@ -1350,9 +1350,9 @@ void TorrentsController::createTagsAction()
|
||||
|
||||
void TorrentsController::deleteTagsAction()
|
||||
{
|
||||
requireParams({u"tags"_qs});
|
||||
requireParams({u"tags"_s});
|
||||
|
||||
const QStringList tags {params()[u"tags"_qs].split(u',', Qt::SkipEmptyParts)};
|
||||
const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)};
|
||||
for (const QString &tag : tags)
|
||||
BitTorrent::Session::instance()->removeTag(tag.trimmed());
|
||||
}
|
||||
@@ -1367,15 +1367,15 @@ void TorrentsController::tagsAction()
|
||||
|
||||
void TorrentsController::renameFileAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"oldPath"_qs, u"newPath"_qs});
|
||||
requireParams({u"hash"_s, u"oldPath"_s, u"newPath"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const Path oldPath {params()[u"oldPath"_qs]};
|
||||
const Path newPath {params()[u"newPath"_qs]};
|
||||
const Path oldPath {params()[u"oldPath"_s]};
|
||||
const Path newPath {params()[u"newPath"_s]};
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1389,15 +1389,15 @@ void TorrentsController::renameFileAction()
|
||||
|
||||
void TorrentsController::renameFolderAction()
|
||||
{
|
||||
requireParams({u"hash"_qs, u"oldPath"_qs, u"newPath"_qs});
|
||||
requireParams({u"hash"_s, u"oldPath"_s, u"newPath"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const Path oldPath {params()[u"oldPath"_qs]};
|
||||
const Path newPath {params()[u"newPath"_qs]};
|
||||
const Path oldPath {params()[u"oldPath"_s]};
|
||||
const Path newPath {params()[u"newPath"_s]};
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1411,9 +1411,9 @@ void TorrentsController::renameFolderAction()
|
||||
|
||||
void TorrentsController::exportAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
requireParams({u"hash"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
#include "base/utils/string.h"
|
||||
#include "apierror.h"
|
||||
|
||||
const QString KEY_TRANSFER_DLSPEED = u"dl_info_speed"_qs;
|
||||
const QString KEY_TRANSFER_DLDATA = u"dl_info_data"_qs;
|
||||
const QString KEY_TRANSFER_DLRATELIMIT = u"dl_rate_limit"_qs;
|
||||
const QString KEY_TRANSFER_UPSPEED = u"up_info_speed"_qs;
|
||||
const QString KEY_TRANSFER_UPDATA = u"up_info_data"_qs;
|
||||
const QString KEY_TRANSFER_UPRATELIMIT = u"up_rate_limit"_qs;
|
||||
const QString KEY_TRANSFER_DHT_NODES = u"dht_nodes"_qs;
|
||||
const QString KEY_TRANSFER_CONNECTION_STATUS = u"connection_status"_qs;
|
||||
const QString KEY_TRANSFER_DLSPEED = u"dl_info_speed"_s;
|
||||
const QString KEY_TRANSFER_DLDATA = u"dl_info_data"_s;
|
||||
const QString KEY_TRANSFER_DLRATELIMIT = u"dl_rate_limit"_s;
|
||||
const QString KEY_TRANSFER_UPSPEED = u"up_info_speed"_s;
|
||||
const QString KEY_TRANSFER_UPDATA = u"up_info_data"_s;
|
||||
const QString KEY_TRANSFER_UPRATELIMIT = u"up_rate_limit"_s;
|
||||
const QString KEY_TRANSFER_DHT_NODES = u"dht_nodes"_s;
|
||||
const QString KEY_TRANSFER_CONNECTION_STATUS = u"connection_status"_s;
|
||||
|
||||
// Returns the global transfer information in JSON format.
|
||||
// The return value is a JSON-formatted dictionary.
|
||||
@@ -73,9 +73,9 @@ void TransferController::infoAction()
|
||||
dict[KEY_TRANSFER_UPRATELIMIT] = BitTorrent::Session::instance()->uploadSpeedLimit();
|
||||
dict[KEY_TRANSFER_DHT_NODES] = static_cast<qint64>(sessionStatus.dhtNodes);
|
||||
if (!BitTorrent::Session::instance()->isListening())
|
||||
dict[KEY_TRANSFER_CONNECTION_STATUS] = u"disconnected"_qs;
|
||||
dict[KEY_TRANSFER_CONNECTION_STATUS] = u"disconnected"_s;
|
||||
else
|
||||
dict[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections ? u"connected"_qs : u"firewalled"_qs;
|
||||
dict[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections ? u"connected"_s : u"firewalled"_s;
|
||||
|
||||
setResult(dict);
|
||||
}
|
||||
@@ -92,8 +92,8 @@ void TransferController::downloadLimitAction()
|
||||
|
||||
void TransferController::setUploadLimitAction()
|
||||
{
|
||||
requireParams({u"limit"_qs});
|
||||
qlonglong limit = params()[u"limit"_qs].toLongLong();
|
||||
requireParams({u"limit"_s});
|
||||
qlonglong limit = params()[u"limit"_s].toLongLong();
|
||||
if (limit == 0) limit = -1;
|
||||
|
||||
BitTorrent::Session::instance()->setUploadSpeedLimit(limit);
|
||||
@@ -101,8 +101,8 @@ void TransferController::setUploadLimitAction()
|
||||
|
||||
void TransferController::setDownloadLimitAction()
|
||||
{
|
||||
requireParams({u"limit"_qs});
|
||||
qlonglong limit = params()[u"limit"_qs].toLongLong();
|
||||
requireParams({u"limit"_s});
|
||||
qlonglong limit = params()[u"limit"_s].toLongLong();
|
||||
if (limit == 0) limit = -1;
|
||||
|
||||
BitTorrent::Session::instance()->setDownloadSpeedLimit(limit);
|
||||
@@ -121,9 +121,9 @@ void TransferController::speedLimitsModeAction()
|
||||
|
||||
void TransferController::setSpeedLimitsModeAction()
|
||||
{
|
||||
requireParams({u"mode"_qs});
|
||||
requireParams({u"mode"_s});
|
||||
|
||||
const std::optional<int> mode = Utils::String::parseInt(params().value(u"mode"_qs));
|
||||
const std::optional<int> mode = Utils::String::parseInt(params().value(u"mode"_s));
|
||||
if (!mode)
|
||||
throw APIError(APIErrorType::BadParams, tr("'mode': invalid argument"));
|
||||
|
||||
@@ -133,9 +133,9 @@ void TransferController::setSpeedLimitsModeAction()
|
||||
|
||||
void TransferController::banPeersAction()
|
||||
{
|
||||
requireParams({u"peers"_qs});
|
||||
requireParams({u"peers"_s});
|
||||
|
||||
const QStringList peers = params()[u"peers"_qs].split(u'|');
|
||||
const QStringList peers = params()[u"peers"_s].split(u'|');
|
||||
for (const QString &peer : peers)
|
||||
{
|
||||
const BitTorrent::PeerAddress addr = BitTorrent::PeerAddress::parse(peer.trimmed());
|
||||
|
||||
Reference in New Issue
Block a user