Browse Source

WebAPI: Add endpoint to set speed limit mode

adaptive-webui-19844
Vladimir Golovnev 3 years ago committed by GitHub
parent
commit
7d97905716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/webui/api/transfercontroller.cpp
  2. 1
      src/webui/api/transfercontroller.h
  3. 2
      src/webui/webapplication.h

12
src/webui/api/transfercontroller.cpp

@ -117,6 +117,18 @@ void TransferController::speedLimitsModeAction() @@ -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});

1
src/webui/api/transfercontroller.h

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

2
src/webui/webapplication.h

@ -48,7 +48,7 @@ @@ -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;

Loading…
Cancel
Save