diff --git a/WebAPI_Changelog.md b/WebAPI_Changelog.md index ac372fa79..0ef76bc2a 100644 --- a/WebAPI_Changelog.md +++ b/WebAPI_Changelog.md @@ -1,5 +1,12 @@ # WebAPI Changelog +## 2.12.0 + +* [#22989](https://github.com/qbittorrent/qBittorrent/pull/22989) + * `sync/maindata` returns one new field: `share_limit_action` + * `torrents/setShareLimits` now requires a new `shareLimitAction` param that sets a torrent's shareLimitAction property + * possible values `Default`, `Stop`, `Remove`, `RemoveWithContent` and `EnableSuperSeeding` + ## 2.11.10 * [#22932](https://github.com/qbittorrent/qBittorrent/pull/22932) diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index 94c83a934..1a64bd797 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -171,6 +171,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent) {KEY_TORRENT_POPULARITY, torrent.popularity()}, {KEY_TORRENT_SEEDING_TIME_LIMIT, torrent.seedingTimeLimit()}, {KEY_TORRENT_INACTIVE_SEEDING_TIME_LIMIT, torrent.inactiveSeedingTimeLimit()}, + {KEY_TORRENT_SHARE_LIMIT_ACTION, Utils::String::fromEnum(torrent.shareLimitAction())}, {KEY_TORRENT_LAST_SEEN_COMPLETE_TIME, Utils::DateTime::toSecsSinceEpoch(torrent.lastSeenComplete())}, {KEY_TORRENT_AUTO_TORRENT_MANAGEMENT, torrent.isAutoTMMEnabled()}, {KEY_TORRENT_TIME_ACTIVE, torrent.activeTime()}, diff --git a/src/webui/api/serialize/serialize_torrent.h b/src/webui/api/serialize/serialize_torrent.h index 438960e7f..6f57a9940 100644 --- a/src/webui/api/serialize/serialize_torrent.h +++ b/src/webui/api/serialize/serialize_torrent.h @@ -85,6 +85,7 @@ inline const QString KEY_TORRENT_MAX_INACTIVE_SEEDING_TIME = u"max_inactive_seed 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_INACTIVE_SEEDING_TIME_LIMIT = u"inactive_seeding_time_limit"_s; +inline const QString KEY_TORRENT_SHARE_LIMIT_ACTION = u"share_limit_action"_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; diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index 469f58459..b324fd541 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -497,6 +497,7 @@ void SyncController::updateFreeDiskSpace(const qint64 freeDiskSpace) // - "max_seeding_time": Upload max seeding time // - "ratio_limit": Upload share ratio limit // - "seeding_time_limit": Upload seeding time limit +// - "share_limit_action": Action to execute when the limit is reached // - "seen_complete": Indicates the time when the torrent was last seen complete/whole // - "last_activity": Last time when a chunk was downloaded/uploaded // - "total_size": Size including unwanted data diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 310f7c405..d0c5f54af 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1360,18 +1360,21 @@ void TorrentsController::setDownloadLimitAction() void TorrentsController::setShareLimitsAction() { - requireParams({u"hashes"_s, u"ratioLimit"_s, u"seedingTimeLimit"_s, u"inactiveSeedingTimeLimit"_s}); + requireParams({u"hashes"_s, u"ratioLimit"_s, u"seedingTimeLimit"_s, u"inactiveSeedingTimeLimit"_s, u"shareLimitAction"_s}); const qreal ratioLimit = params()[u"ratioLimit"_s].toDouble(); const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_s].toLongLong(); const qlonglong inactiveSeedingTimeLimit = params()[u"inactiveSeedingTimeLimit"_s].toLongLong(); + const BitTorrent::ShareLimitAction shareLimitAction = Utils::String::toEnum(params()[u"shareLimitAction"_s], BitTorrent::ShareLimitAction::Default); + const QStringList hashes = params()[u"hashes"_s].split(u'|'); - applyToTorrents(hashes, [ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit](BitTorrent::Torrent *const torrent) + applyToTorrents(hashes, [ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit, shareLimitAction](BitTorrent::Torrent *const torrent) { torrent->setRatioLimit(ratioLimit); torrent->setSeedingTimeLimit(seedingTimeLimit); torrent->setInactiveSeedingTimeLimit(inactiveSeedingTimeLimit); + torrent->setShareLimitAction(shareLimitAction); }); setResult(QString()); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index 2098e3635..da3d0211d 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -53,7 +53,7 @@ #include "base/utils/version.h" #include "api/isessionmanager.h" -inline const Utils::Version<3, 2> API_VERSION {2, 11, 10}; +inline const Utils::Version<3, 2> API_VERSION {2, 12, 0}; class APIController; class AuthController; diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 52a6306ed..63c5232b8 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -385,7 +385,7 @@ const initializeWindows = () => { const hash = hashes[i]; const row = torrentsTable.getRow(hash).full_data; const origValues = `${row.ratio_limit}|${row.seeding_time_limit}|${row.inactive_seeding_time_limit}|${row.max_ratio}` - + `|${row.max_seeding_time}|${row.max_inactive_seeding_time}`; + + `|${row.max_seeding_time}|${row.max_inactive_seeding_time}|${row.share_limit_action}`; // initialize value if (shareRatio === null) @@ -414,8 +414,8 @@ const initializeWindows = () => { maximizable: false, paddingVertical: 0, paddingHorizontal: 0, - width: window.qBittorrent.Dialog.limitWidthToViewport(424), - height: 220 + width: window.qBittorrent.Dialog.limitWidthToViewport(500), + height: 250 }); }; diff --git a/src/webui/www/private/shareratio.html b/src/webui/www/private/shareratio.html index 1a4db9554..2b80c4682 100644 --- a/src/webui/www/private/shareratio.html +++ b/src/webui/www/private/shareratio.html @@ -12,8 +12,11 @@ const UseGlobalLimit = -2; const NoLimit = -1; + let limitReachedActionsEl; window.addEventListener("DOMContentLoaded", (event) => { + limitReachedActionsEl = document.getElementById("limitReachedActions"); + window.addEventListener("keydown", (event) => { switch (event.key) { case "Enter": @@ -36,7 +39,8 @@ inactiveSeedingTimeLimit: Number(origValues[2]), maxRatio: Number(origValues[3]), maxSeedingTime: Number(origValues[4]), - maxInactiveSeedingTime: Number(origValues[5]) + maxInactiveSeedingTime: Number(origValues[5]), + shareLimitAction: String(origValues[6]) }; // select default when orig values not passed. using double equals to compare string and int @@ -65,6 +69,8 @@ document.getElementById("setInactiveMinutes").checked = true; document.getElementById("inactiveMinutes").value = values.inactiveSeedingTimeLimit; } + + limitReachedActionsEl.value = values.shareLimitAction; } shareLimitChanged(); @@ -81,6 +87,7 @@ let ratioLimitValue = 0.00; let seedingTimeLimitValue = 0; let inactiveSeedingTimeLimitValue = 0; + let shareLimitActionValue = "Default"; if (shareLimit === "default") { ratioLimitValue = seedingTimeLimitValue = inactiveSeedingTimeLimitValue = UseGlobalLimit; @@ -92,6 +99,7 @@ ratioLimitValue = document.getElementById("setRatio").checked ? document.getElementById("ratio").value : -1; seedingTimeLimitValue = document.getElementById("setTotalMinutes").checked ? document.getElementById("totalMinutes").value : -1; inactiveSeedingTimeLimitValue = document.getElementById("setInactiveMinutes").checked ? document.getElementById("inactiveMinutes").value : -1; + shareLimitActionValue = limitReachedActionsEl.value; } else { return; @@ -103,7 +111,8 @@ hashes: searchParams.get("hashes"), ratioLimit: ratioLimitValue, seedingTimeLimit: seedingTimeLimitValue, - inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue + inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue, + shareLimitAction: shareLimitActionValue }) }) .then((response) => { @@ -140,6 +149,7 @@ document.getElementById("setRatio").disabled = !customShareLimit; document.getElementById("setTotalMinutes").disabled = !customShareLimit; document.getElementById("setInactiveMinutes").disabled = !customShareLimit; + limitReachedActionsEl.disabled = !customShareLimit; enableInputBoxes(); @@ -182,6 +192,16 @@ +
+ + +