mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-09 21:34:20 +00:00
Give better name to parameter checking function
This function will throw exceptions if the required parameters do not exsit hence a stronger word is more appropriate here. Also change the function parameter type to QVector. We don't need the duplicate entries checking as currently we only use 3 fields at max and can be easily checked by hand. So drop back to QVector which can be constructed more efficiently.
This commit is contained in:
parent
9cb07db84b
commit
9b5df92078
@ -69,7 +69,7 @@ const DataMap &APIController::data() const
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIController::checkParams(const QSet<QString> &requiredParams) const
|
void APIController::requireParams(const QVector<QString> &requiredParams) const
|
||||||
{
|
{
|
||||||
const bool hasAllRequiredParams = std::all_of(requiredParams.cbegin(), requiredParams.cend()
|
const bool hasAllRequiredParams = std::all_of(requiredParams.cbegin(), requiredParams.cend()
|
||||||
, [this](const QString &requiredParam)
|
, [this](const QString &requiredParam)
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
const StringMap ¶ms() const;
|
const StringMap ¶ms() const;
|
||||||
const DataMap &data() const;
|
const DataMap &data() const;
|
||||||
void checkParams(const QSet<QString> &requiredParams) const;
|
void requireParams(const QVector<QString> &requiredParams) const;
|
||||||
|
|
||||||
void setResult(const QString &result);
|
void setResult(const QString &result);
|
||||||
void setResult(const QJsonArray &result);
|
void setResult(const QJsonArray &result);
|
||||||
|
@ -316,7 +316,7 @@ void AppController::preferencesAction()
|
|||||||
|
|
||||||
void AppController::setPreferencesAction()
|
void AppController::setPreferencesAction()
|
||||||
{
|
{
|
||||||
checkParams({"json"});
|
requireParams({"json"});
|
||||||
|
|
||||||
Preferences *const pref = Preferences::instance();
|
Preferences *const pref = Preferences::instance();
|
||||||
auto session = BitTorrent::Session::instance();
|
auto session = BitTorrent::Session::instance();
|
||||||
@ -762,7 +762,7 @@ void AppController::networkInterfaceListAction()
|
|||||||
|
|
||||||
void AppController::networkInterfaceAddressListAction()
|
void AppController::networkInterfaceAddressListAction()
|
||||||
{
|
{
|
||||||
checkParams({"iface"});
|
requireParams({"iface"});
|
||||||
|
|
||||||
const QString ifaceName = params().value("iface");
|
const QString ifaceName = params().value("iface");
|
||||||
QJsonArray addressList;
|
QJsonArray addressList;
|
||||||
|
@ -43,7 +43,7 @@ using Utils::String::parseBool;
|
|||||||
|
|
||||||
void RSSController::addFolderAction()
|
void RSSController::addFolderAction()
|
||||||
{
|
{
|
||||||
checkParams({"path"});
|
requireParams({"path"});
|
||||||
|
|
||||||
const QString path = params()["path"].trimmed();
|
const QString path = params()["path"].trimmed();
|
||||||
QString error;
|
QString error;
|
||||||
@ -53,7 +53,7 @@ void RSSController::addFolderAction()
|
|||||||
|
|
||||||
void RSSController::addFeedAction()
|
void RSSController::addFeedAction()
|
||||||
{
|
{
|
||||||
checkParams({"url", "path"});
|
requireParams({"url", "path"});
|
||||||
|
|
||||||
const QString url = params()["url"].trimmed();
|
const QString url = params()["url"].trimmed();
|
||||||
const QString path = params()["path"].trimmed();
|
const QString path = params()["path"].trimmed();
|
||||||
@ -64,7 +64,7 @@ void RSSController::addFeedAction()
|
|||||||
|
|
||||||
void RSSController::removeItemAction()
|
void RSSController::removeItemAction()
|
||||||
{
|
{
|
||||||
checkParams({"path"});
|
requireParams({"path"});
|
||||||
|
|
||||||
const QString path = params()["path"].trimmed();
|
const QString path = params()["path"].trimmed();
|
||||||
QString error;
|
QString error;
|
||||||
@ -74,7 +74,7 @@ void RSSController::removeItemAction()
|
|||||||
|
|
||||||
void RSSController::moveItemAction()
|
void RSSController::moveItemAction()
|
||||||
{
|
{
|
||||||
checkParams({"itemPath", "destPath"});
|
requireParams({"itemPath", "destPath"});
|
||||||
|
|
||||||
const QString itemPath = params()["itemPath"].trimmed();
|
const QString itemPath = params()["itemPath"].trimmed();
|
||||||
const QString destPath = params()["destPath"].trimmed();
|
const QString destPath = params()["destPath"].trimmed();
|
||||||
@ -93,7 +93,7 @@ void RSSController::itemsAction()
|
|||||||
|
|
||||||
void RSSController::refreshItemAction()
|
void RSSController::refreshItemAction()
|
||||||
{
|
{
|
||||||
checkParams({"itemPath"});
|
requireParams({"itemPath"});
|
||||||
|
|
||||||
const QString itemPath {params()["itemPath"]};
|
const QString itemPath {params()["itemPath"]};
|
||||||
RSS::Item *item = RSS::Session::instance()->itemByPath(itemPath);
|
RSS::Item *item = RSS::Session::instance()->itemByPath(itemPath);
|
||||||
@ -103,7 +103,7 @@ void RSSController::refreshItemAction()
|
|||||||
|
|
||||||
void RSSController::setRuleAction()
|
void RSSController::setRuleAction()
|
||||||
{
|
{
|
||||||
checkParams({"ruleName", "ruleDef"});
|
requireParams({"ruleName", "ruleDef"});
|
||||||
|
|
||||||
const QString ruleName {params()["ruleName"].trimmed()};
|
const QString ruleName {params()["ruleName"].trimmed()};
|
||||||
const QByteArray ruleDef {params()["ruleDef"].trimmed().toUtf8()};
|
const QByteArray ruleDef {params()["ruleDef"].trimmed().toUtf8()};
|
||||||
@ -114,7 +114,7 @@ void RSSController::setRuleAction()
|
|||||||
|
|
||||||
void RSSController::renameRuleAction()
|
void RSSController::renameRuleAction()
|
||||||
{
|
{
|
||||||
checkParams({"ruleName", "newRuleName"});
|
requireParams({"ruleName", "newRuleName"});
|
||||||
|
|
||||||
const QString ruleName {params()["ruleName"].trimmed()};
|
const QString ruleName {params()["ruleName"].trimmed()};
|
||||||
const QString newRuleName {params()["newRuleName"].trimmed()};
|
const QString newRuleName {params()["newRuleName"].trimmed()};
|
||||||
@ -124,7 +124,7 @@ void RSSController::renameRuleAction()
|
|||||||
|
|
||||||
void RSSController::removeRuleAction()
|
void RSSController::removeRuleAction()
|
||||||
{
|
{
|
||||||
checkParams({"ruleName"});
|
requireParams({"ruleName"});
|
||||||
|
|
||||||
const QString ruleName {params()["ruleName"].trimmed()};
|
const QString ruleName {params()["ruleName"].trimmed()};
|
||||||
RSS::AutoDownloader::instance()->removeRule(ruleName);
|
RSS::AutoDownloader::instance()->removeRule(ruleName);
|
||||||
|
@ -63,7 +63,7 @@ namespace
|
|||||||
|
|
||||||
void SearchController::startAction()
|
void SearchController::startAction()
|
||||||
{
|
{
|
||||||
checkParams({"pattern", "category", "plugins"});
|
requireParams({"pattern", "category", "plugins"});
|
||||||
|
|
||||||
if (!Utils::ForeignApps::pythonInfo().isValid())
|
if (!Utils::ForeignApps::pythonInfo().isValid())
|
||||||
throw APIError(APIErrorType::Conflict, "Python must be installed to use the Search Engine.");
|
throw APIError(APIErrorType::Conflict, "Python must be installed to use the Search Engine.");
|
||||||
@ -109,7 +109,7 @@ void SearchController::startAction()
|
|||||||
|
|
||||||
void SearchController::stopAction()
|
void SearchController::stopAction()
|
||||||
{
|
{
|
||||||
checkParams({"id"});
|
requireParams({"id"});
|
||||||
|
|
||||||
const int id = params()["id"].toInt();
|
const int id = params()["id"].toInt();
|
||||||
ISession *const session = sessionManager()->session();
|
ISession *const session = sessionManager()->session();
|
||||||
@ -151,7 +151,7 @@ void SearchController::statusAction()
|
|||||||
|
|
||||||
void SearchController::resultsAction()
|
void SearchController::resultsAction()
|
||||||
{
|
{
|
||||||
checkParams({"id"});
|
requireParams({"id"});
|
||||||
|
|
||||||
const int id = params()["id"].toInt();
|
const int id = params()["id"].toInt();
|
||||||
int limit = params()["limit"].toInt();
|
int limit = params()["limit"].toInt();
|
||||||
@ -184,7 +184,7 @@ void SearchController::resultsAction()
|
|||||||
|
|
||||||
void SearchController::deleteAction()
|
void SearchController::deleteAction()
|
||||||
{
|
{
|
||||||
checkParams({"id"});
|
requireParams({"id"});
|
||||||
|
|
||||||
const int id = params()["id"].toInt();
|
const int id = params()["id"].toInt();
|
||||||
ISession *const session = sessionManager()->session();
|
ISession *const session = sessionManager()->session();
|
||||||
@ -222,7 +222,7 @@ void SearchController::pluginsAction()
|
|||||||
|
|
||||||
void SearchController::installPluginAction()
|
void SearchController::installPluginAction()
|
||||||
{
|
{
|
||||||
checkParams({"sources"});
|
requireParams({"sources"});
|
||||||
|
|
||||||
const QStringList sources = params()["sources"].split('|');
|
const QStringList sources = params()["sources"].split('|');
|
||||||
for (const QString &source : sources)
|
for (const QString &source : sources)
|
||||||
@ -231,7 +231,7 @@ void SearchController::installPluginAction()
|
|||||||
|
|
||||||
void SearchController::uninstallPluginAction()
|
void SearchController::uninstallPluginAction()
|
||||||
{
|
{
|
||||||
checkParams({"names"});
|
requireParams({"names"});
|
||||||
|
|
||||||
const QStringList names = params()["names"].split('|');
|
const QStringList names = params()["names"].split('|');
|
||||||
for (const QString &name : names)
|
for (const QString &name : names)
|
||||||
@ -240,7 +240,7 @@ void SearchController::uninstallPluginAction()
|
|||||||
|
|
||||||
void SearchController::enablePluginAction()
|
void SearchController::enablePluginAction()
|
||||||
{
|
{
|
||||||
checkParams({"names", "enable"});
|
requireParams({"names", "enable"});
|
||||||
|
|
||||||
const QStringList names = params()["names"].split('|');
|
const QStringList names = params()["names"].split('|');
|
||||||
const bool enable = Utils::String::parseBool(params()["enable"].trimmed(), false);
|
const bool enable = Utils::String::parseBool(params()["enable"].trimmed(), false);
|
||||||
|
@ -317,7 +317,7 @@ void TorrentsController::infoAction()
|
|||||||
// - "comment": Torrent comment
|
// - "comment": Torrent comment
|
||||||
void TorrentsController::propertiesAction()
|
void TorrentsController::propertiesAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QJsonObject dataDict;
|
QJsonObject dataDict;
|
||||||
@ -385,7 +385,7 @@ void TorrentsController::propertiesAction()
|
|||||||
// - "msg": Tracker message (last)
|
// - "msg": Tracker message (last)
|
||||||
void TorrentsController::trackersAction()
|
void TorrentsController::trackersAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
@ -419,7 +419,7 @@ void TorrentsController::trackersAction()
|
|||||||
// - "url": Web seed URL
|
// - "url": Web seed URL
|
||||||
void TorrentsController::webseedsAction()
|
void TorrentsController::webseedsAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QJsonArray webSeedList;
|
QJsonArray webSeedList;
|
||||||
@ -448,7 +448,7 @@ void TorrentsController::webseedsAction()
|
|||||||
// and the second number is the ending piece index (inclusive)
|
// and the second number is the ending piece index (inclusive)
|
||||||
void TorrentsController::filesAction()
|
void TorrentsController::filesAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QJsonArray fileList;
|
QJsonArray fileList;
|
||||||
@ -491,7 +491,7 @@ void TorrentsController::filesAction()
|
|||||||
// The return value is a JSON-formatted array of strings (hex strings).
|
// The return value is a JSON-formatted array of strings (hex strings).
|
||||||
void TorrentsController::pieceHashesAction()
|
void TorrentsController::pieceHashesAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QJsonArray pieceHashes;
|
QJsonArray pieceHashes;
|
||||||
@ -513,7 +513,7 @@ void TorrentsController::pieceHashesAction()
|
|||||||
// 2: piece already downloaded
|
// 2: piece already downloaded
|
||||||
void TorrentsController::pieceStatesAction()
|
void TorrentsController::pieceStatesAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash"});
|
requireParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QJsonArray pieceStates;
|
QJsonArray pieceStates;
|
||||||
@ -606,7 +606,7 @@ void TorrentsController::addAction()
|
|||||||
|
|
||||||
void TorrentsController::addTrackersAction()
|
void TorrentsController::addTrackersAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash", "urls"});
|
requireParams({"hash", "urls"});
|
||||||
|
|
||||||
const QString hash = params()["hash"];
|
const QString hash = params()["hash"];
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ void TorrentsController::addTrackersAction()
|
|||||||
|
|
||||||
void TorrentsController::editTrackerAction()
|
void TorrentsController::editTrackerAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash", "origUrl", "newUrl"});
|
requireParams({"hash", "origUrl", "newUrl"});
|
||||||
|
|
||||||
const QString hash = params()["hash"];
|
const QString hash = params()["hash"];
|
||||||
const QString origUrl = params()["origUrl"];
|
const QString origUrl = params()["origUrl"];
|
||||||
@ -666,7 +666,7 @@ void TorrentsController::editTrackerAction()
|
|||||||
|
|
||||||
void TorrentsController::removeTrackersAction()
|
void TorrentsController::removeTrackersAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash", "urls"});
|
requireParams({"hash", "urls"});
|
||||||
|
|
||||||
const QString hash = params()["hash"];
|
const QString hash = params()["hash"];
|
||||||
const QStringList urls = params()["urls"].split('|');
|
const QStringList urls = params()["urls"].split('|');
|
||||||
@ -694,7 +694,7 @@ void TorrentsController::removeTrackersAction()
|
|||||||
|
|
||||||
void TorrentsController::addPeersAction()
|
void TorrentsController::addPeersAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "peers"});
|
requireParams({"hashes", "peers"});
|
||||||
|
|
||||||
const QStringList hashes = params()["hashes"].split('|');
|
const QStringList hashes = params()["hashes"].split('|');
|
||||||
const QStringList peers = params()["peers"].split('|');
|
const QStringList peers = params()["peers"].split('|');
|
||||||
@ -730,7 +730,7 @@ void TorrentsController::addPeersAction()
|
|||||||
|
|
||||||
void TorrentsController::pauseAction()
|
void TorrentsController::pauseAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes = params()["hashes"].split('|');
|
const QStringList hashes = params()["hashes"].split('|');
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->pause(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->pause(); });
|
||||||
@ -738,7 +738,7 @@ void TorrentsController::pauseAction()
|
|||||||
|
|
||||||
void TorrentsController::resumeAction()
|
void TorrentsController::resumeAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes = params()["hashes"].split('|');
|
const QStringList hashes = params()["hashes"].split('|');
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->resume(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->resume(); });
|
||||||
@ -746,7 +746,7 @@ void TorrentsController::resumeAction()
|
|||||||
|
|
||||||
void TorrentsController::filePrioAction()
|
void TorrentsController::filePrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash", "id", "priority"});
|
requireParams({"hash", "id", "priority"});
|
||||||
|
|
||||||
const QString hash = params()["hash"];
|
const QString hash = params()["hash"];
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -785,7 +785,7 @@ void TorrentsController::filePrioAction()
|
|||||||
|
|
||||||
void TorrentsController::uploadLimitAction()
|
void TorrentsController::uploadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QJsonObject map;
|
QJsonObject map;
|
||||||
@ -802,7 +802,7 @@ void TorrentsController::uploadLimitAction()
|
|||||||
|
|
||||||
void TorrentsController::downloadLimitAction()
|
void TorrentsController::downloadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QJsonObject map;
|
QJsonObject map;
|
||||||
@ -819,7 +819,7 @@ void TorrentsController::downloadLimitAction()
|
|||||||
|
|
||||||
void TorrentsController::setUploadLimitAction()
|
void TorrentsController::setUploadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "limit"});
|
requireParams({"hashes", "limit"});
|
||||||
|
|
||||||
qlonglong limit = params()["limit"].toLongLong();
|
qlonglong limit = params()["limit"].toLongLong();
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
@ -831,7 +831,7 @@ void TorrentsController::setUploadLimitAction()
|
|||||||
|
|
||||||
void TorrentsController::setDownloadLimitAction()
|
void TorrentsController::setDownloadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "limit"});
|
requireParams({"hashes", "limit"});
|
||||||
|
|
||||||
qlonglong limit = params()["limit"].toLongLong();
|
qlonglong limit = params()["limit"].toLongLong();
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
@ -843,7 +843,7 @@ void TorrentsController::setDownloadLimitAction()
|
|||||||
|
|
||||||
void TorrentsController::setShareLimitsAction()
|
void TorrentsController::setShareLimitsAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "ratioLimit", "seedingTimeLimit"});
|
requireParams({"hashes", "ratioLimit", "seedingTimeLimit"});
|
||||||
|
|
||||||
const qreal ratioLimit = params()["ratioLimit"].toDouble();
|
const qreal ratioLimit = params()["ratioLimit"].toDouble();
|
||||||
const qlonglong seedingTimeLimit = params()["seedingTimeLimit"].toLongLong();
|
const qlonglong seedingTimeLimit = params()["seedingTimeLimit"].toLongLong();
|
||||||
@ -858,7 +858,7 @@ void TorrentsController::setShareLimitsAction()
|
|||||||
|
|
||||||
void TorrentsController::toggleSequentialDownloadAction()
|
void TorrentsController::toggleSequentialDownloadAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleSequentialDownload(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleSequentialDownload(); });
|
||||||
@ -866,7 +866,7 @@ void TorrentsController::toggleSequentialDownloadAction()
|
|||||||
|
|
||||||
void TorrentsController::toggleFirstLastPiecePrioAction()
|
void TorrentsController::toggleFirstLastPiecePrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleFirstLastPiecePriority(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleFirstLastPiecePriority(); });
|
||||||
@ -874,7 +874,7 @@ void TorrentsController::toggleFirstLastPiecePrioAction()
|
|||||||
|
|
||||||
void TorrentsController::setSuperSeedingAction()
|
void TorrentsController::setSuperSeedingAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "value"});
|
requireParams({"hashes", "value"});
|
||||||
|
|
||||||
const bool value {parseBool(params()["value"], false)};
|
const bool value {parseBool(params()["value"], false)};
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
@ -883,7 +883,7 @@ void TorrentsController::setSuperSeedingAction()
|
|||||||
|
|
||||||
void TorrentsController::setForceStartAction()
|
void TorrentsController::setForceStartAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "value"});
|
requireParams({"hashes", "value"});
|
||||||
|
|
||||||
const bool value {parseBool(params()["value"], false)};
|
const bool value {parseBool(params()["value"], false)};
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
@ -892,7 +892,7 @@ void TorrentsController::setForceStartAction()
|
|||||||
|
|
||||||
void TorrentsController::deleteAction()
|
void TorrentsController::deleteAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "deleteFiles"});
|
requireParams({"hashes", "deleteFiles"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const DeleteOption deleteOption = parseBool(params()["deleteFiles"], false)
|
const DeleteOption deleteOption = parseBool(params()["deleteFiles"], false)
|
||||||
@ -905,7 +905,7 @@ void TorrentsController::deleteAction()
|
|||||||
|
|
||||||
void TorrentsController::increasePrioAction()
|
void TorrentsController::increasePrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||||
@ -916,7 +916,7 @@ void TorrentsController::increasePrioAction()
|
|||||||
|
|
||||||
void TorrentsController::decreasePrioAction()
|
void TorrentsController::decreasePrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||||
@ -927,7 +927,7 @@ void TorrentsController::decreasePrioAction()
|
|||||||
|
|
||||||
void TorrentsController::topPrioAction()
|
void TorrentsController::topPrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||||
@ -938,7 +938,7 @@ void TorrentsController::topPrioAction()
|
|||||||
|
|
||||||
void TorrentsController::bottomPrioAction()
|
void TorrentsController::bottomPrioAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled())
|
||||||
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
throw APIError(APIErrorType::Conflict, tr("Torrent queueing must be enabled"));
|
||||||
@ -949,7 +949,7 @@ void TorrentsController::bottomPrioAction()
|
|||||||
|
|
||||||
void TorrentsController::setLocationAction()
|
void TorrentsController::setLocationAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "location"});
|
requireParams({"hashes", "location"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const QString newLocation {params()["location"].trimmed()};
|
const QString newLocation {params()["location"].trimmed()};
|
||||||
@ -975,7 +975,7 @@ void TorrentsController::setLocationAction()
|
|||||||
|
|
||||||
void TorrentsController::renameAction()
|
void TorrentsController::renameAction()
|
||||||
{
|
{
|
||||||
checkParams({"hash", "name"});
|
requireParams({"hash", "name"});
|
||||||
|
|
||||||
const QString hash = params()["hash"];
|
const QString hash = params()["hash"];
|
||||||
QString name = params()["name"].trimmed();
|
QString name = params()["name"].trimmed();
|
||||||
@ -993,7 +993,7 @@ void TorrentsController::renameAction()
|
|||||||
|
|
||||||
void TorrentsController::setAutoManagementAction()
|
void TorrentsController::setAutoManagementAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "enable"});
|
requireParams({"hashes", "enable"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const bool isEnabled {parseBool(params()["enable"], false)};
|
const bool isEnabled {parseBool(params()["enable"], false)};
|
||||||
@ -1006,7 +1006,7 @@ void TorrentsController::setAutoManagementAction()
|
|||||||
|
|
||||||
void TorrentsController::recheckAction()
|
void TorrentsController::recheckAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceRecheck(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceRecheck(); });
|
||||||
@ -1014,7 +1014,7 @@ void TorrentsController::recheckAction()
|
|||||||
|
|
||||||
void TorrentsController::reannounceAction()
|
void TorrentsController::reannounceAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceReannounce(); });
|
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceReannounce(); });
|
||||||
@ -1022,7 +1022,7 @@ void TorrentsController::reannounceAction()
|
|||||||
|
|
||||||
void TorrentsController::setCategoryAction()
|
void TorrentsController::setCategoryAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "category"});
|
requireParams({"hashes", "category"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const QString category {params()["category"].trimmed()};
|
const QString category {params()["category"].trimmed()};
|
||||||
@ -1036,7 +1036,7 @@ void TorrentsController::setCategoryAction()
|
|||||||
|
|
||||||
void TorrentsController::createCategoryAction()
|
void TorrentsController::createCategoryAction()
|
||||||
{
|
{
|
||||||
checkParams({"category"});
|
requireParams({"category"});
|
||||||
|
|
||||||
const QString category {params()["category"].trimmed()};
|
const QString category {params()["category"].trimmed()};
|
||||||
const QString savePath {params()["savePath"]};
|
const QString savePath {params()["savePath"]};
|
||||||
@ -1053,7 +1053,7 @@ void TorrentsController::createCategoryAction()
|
|||||||
|
|
||||||
void TorrentsController::editCategoryAction()
|
void TorrentsController::editCategoryAction()
|
||||||
{
|
{
|
||||||
checkParams({"category", "savePath"});
|
requireParams({"category", "savePath"});
|
||||||
|
|
||||||
const QString category {params()["category"].trimmed()};
|
const QString category {params()["category"].trimmed()};
|
||||||
const QString savePath {params()["savePath"]};
|
const QString savePath {params()["savePath"]};
|
||||||
@ -1067,7 +1067,7 @@ void TorrentsController::editCategoryAction()
|
|||||||
|
|
||||||
void TorrentsController::removeCategoriesAction()
|
void TorrentsController::removeCategoriesAction()
|
||||||
{
|
{
|
||||||
checkParams({"categories"});
|
requireParams({"categories"});
|
||||||
|
|
||||||
const QStringList categories {params()["categories"].split('\n')};
|
const QStringList categories {params()["categories"].split('\n')};
|
||||||
for (const QString &category : categories)
|
for (const QString &category : categories)
|
||||||
@ -1091,7 +1091,7 @@ void TorrentsController::categoriesAction()
|
|||||||
|
|
||||||
void TorrentsController::addTagsAction()
|
void TorrentsController::addTagsAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes", "tags"});
|
requireParams({"hashes", "tags"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||||
@ -1107,7 +1107,7 @@ void TorrentsController::addTagsAction()
|
|||||||
|
|
||||||
void TorrentsController::removeTagsAction()
|
void TorrentsController::removeTagsAction()
|
||||||
{
|
{
|
||||||
checkParams({"hashes"});
|
requireParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||||
@ -1130,7 +1130,7 @@ void TorrentsController::removeTagsAction()
|
|||||||
|
|
||||||
void TorrentsController::createTagsAction()
|
void TorrentsController::createTagsAction()
|
||||||
{
|
{
|
||||||
checkParams({"tags"});
|
requireParams({"tags"});
|
||||||
|
|
||||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||||
|
|
||||||
@ -1140,7 +1140,7 @@ void TorrentsController::createTagsAction()
|
|||||||
|
|
||||||
void TorrentsController::deleteTagsAction()
|
void TorrentsController::deleteTagsAction()
|
||||||
{
|
{
|
||||||
checkParams({"tags"});
|
requireParams({"tags"});
|
||||||
|
|
||||||
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)};
|
||||||
for (const QString &tag : tags)
|
for (const QString &tag : tags)
|
||||||
|
@ -90,7 +90,7 @@ void TransferController::downloadLimitAction()
|
|||||||
|
|
||||||
void TransferController::setUploadLimitAction()
|
void TransferController::setUploadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"limit"});
|
requireParams({"limit"});
|
||||||
qlonglong limit = params()["limit"].toLongLong();
|
qlonglong limit = params()["limit"].toLongLong();
|
||||||
if (limit == 0) limit = -1;
|
if (limit == 0) limit = -1;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ void TransferController::setUploadLimitAction()
|
|||||||
|
|
||||||
void TransferController::setDownloadLimitAction()
|
void TransferController::setDownloadLimitAction()
|
||||||
{
|
{
|
||||||
checkParams({"limit"});
|
requireParams({"limit"});
|
||||||
qlonglong limit = params()["limit"].toLongLong();
|
qlonglong limit = params()["limit"].toLongLong();
|
||||||
if (limit == 0) limit = -1;
|
if (limit == 0) limit = -1;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ void TransferController::speedLimitsModeAction()
|
|||||||
|
|
||||||
void TransferController::banPeersAction()
|
void TransferController::banPeersAction()
|
||||||
{
|
{
|
||||||
checkParams({"peers"});
|
requireParams({"peers"});
|
||||||
|
|
||||||
const QStringList peers = params()["peers"].split('|');
|
const QStringList peers = params()["peers"].split('|');
|
||||||
for (const QString &peer : peers) {
|
for (const QString &peer : peers) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user