WebAPI: Add endpoint to set speed limit mode

This commit is contained in:
Vladimir Golovnev 2022-06-18 06:12:43 +03:00 committed by GitHub
parent 3dd616f6ff
commit 7d97905716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -117,6 +117,18 @@ void TransferController::speedLimitsModeAction()
setResult(QString::number(BitTorrent::Session::instance()->isAltGlobalSpeedLimitEnabled()));
}
void TransferController::setSpeedLimitsModeAction()
{
requireParams({u"mode"_qs});
const std::optional<int> mode = Utils::String::parseInt(params().value(u"mode"_qs));
if (!mode)
throw APIError(APIErrorType::BadParams, tr("'mode': invalid argument"));
// Any non-zero values are considered as alternative mode
BitTorrent::Session::instance()->setAltGlobalSpeedLimitEnabled(mode != 0);
}
void TransferController::banPeersAction()
{
requireParams({u"peers"_qs});

View File

@ -41,6 +41,7 @@ public:
private slots:
void infoAction();
void speedLimitsModeAction();
void setSpeedLimitsModeAction();
void toggleSpeedLimitsModeAction();
void uploadLimitAction();
void downloadLimitAction();

View File

@ -48,7 +48,7 @@
#include "base/utils/version.h"
#include "api/isessionmanager.h"
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 13};
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 14};
class APIController;
class AuthController;