mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-26 17:58:19 +03:00
Improve legacy API params handling
This commit is contained in:
parent
a4ad5c8d11
commit
2075533468
1 changed files with 56 additions and 62 deletions
|
@ -268,66 +268,67 @@ void WebApplication::doProcessRequest()
|
||||||
{
|
{
|
||||||
QString scope;
|
QString scope;
|
||||||
QString action;
|
QString action;
|
||||||
|
std::function<void ()> convertFunc;
|
||||||
};
|
};
|
||||||
const QMap<QString, APICompatInfo> APICompatMapping {
|
const QMap<QString, APICompatInfo> APICompatMapping {
|
||||||
{"sync/maindata", {"sync", "maindata"}},
|
{"sync/maindata", {"sync", "maindata", nullptr}},
|
||||||
{"sync/torrent_peers", {"sync", "torrentPeers"}},
|
{"sync/torrent_peers", {"sync", "torrentPeers", nullptr}},
|
||||||
|
|
||||||
{"login", {"auth", "login"}},
|
{"login", {"auth", "login", nullptr}},
|
||||||
{"logout", {"auth", "logout"}},
|
{"logout", {"auth", "logout", nullptr}},
|
||||||
|
|
||||||
{"command/shutdown", {"app", "shutdown"}},
|
{"command/shutdown", {"app", "shutdown", nullptr}},
|
||||||
{"query/preferences", {"app", "preferences"}},
|
{"query/preferences", {"app", "preferences", nullptr}},
|
||||||
{"command/setPreferences", {"app", "setPreferences"}},
|
{"command/setPreferences", {"app", "setPreferences", nullptr}},
|
||||||
{"command/getSavePath", {"app", "defaultSavePath"}},
|
{"command/getSavePath", {"app", "defaultSavePath", nullptr}},
|
||||||
|
|
||||||
{"query/getLog", {"log", "main"}},
|
{"query/getLog", {"log", "main", nullptr}},
|
||||||
{"query/getPeerLog", {"log", "peers"}},
|
{"query/getPeerLog", {"log", "peers", nullptr}},
|
||||||
|
|
||||||
{"query/torrents", {"torrents", "info"}},
|
{"query/torrents", {"torrents", "info", nullptr}},
|
||||||
{"query/propertiesGeneral", {"torrents", "properties"}},
|
{"query/propertiesGeneral", {"torrents", "properties", nullptr}},
|
||||||
{"query/propertiesTrackers", {"torrents", "trackers"}},
|
{"query/propertiesTrackers", {"torrents", "trackers", nullptr}},
|
||||||
{"query/propertiesWebSeeds", {"torrents", "webseeds"}},
|
{"query/propertiesWebSeeds", {"torrents", "webseeds", nullptr}},
|
||||||
{"query/propertiesFiles", {"torrents", "files"}},
|
{"query/propertiesFiles", {"torrents", "files", nullptr}},
|
||||||
{"query/getPieceHashes", {"torrents", "pieceHashes"}},
|
{"query/getPieceHashes", {"torrents", "pieceHashes", nullptr}},
|
||||||
{"query/getPieceStates", {"torrents", "pieceStates"}},
|
{"query/getPieceStates", {"torrents", "pieceStates", nullptr}},
|
||||||
{"command/resume", {"torrents", "resume"}},
|
{"command/resume", {"torrents", "resume", nullptr}},
|
||||||
{"command/pause", {"torrents", "pause"}},
|
{"command/pause", {"torrents", "pause", nullptr}},
|
||||||
{"command/recheck", {"torrents", "recheck"}},
|
{"command/recheck", {"torrents", "recheck", nullptr}},
|
||||||
{"command/resumeAll", {"torrents", "resume"}},
|
{"command/resumeAll", {"torrents", "resume", [this]() { m_params["hashes"] = "all"; }}},
|
||||||
{"command/pauseAll", {"torrents", "pause"}},
|
{"command/pauseAll", {"torrents", "pause", [this]() { m_params["hashes"] = "all"; }}},
|
||||||
{"command/rename", {"torrents", "rename"}},
|
{"command/rename", {"torrents", "rename", nullptr}},
|
||||||
{"command/download", {"torrents", "add"}},
|
{"command/download", {"torrents", "add", nullptr}},
|
||||||
{"command/upload", {"torrents", "add"}},
|
{"command/upload", {"torrents", "add", nullptr}},
|
||||||
{"command/delete", {"torrents", "delete"}},
|
{"command/delete", {"torrents", "delete", [this]() { m_params["deleteFiles"] = "false"; }}},
|
||||||
{"command/deletePerm", {"torrents", "delete"}},
|
{"command/deletePerm", {"torrents", "delete", [this]() { m_params["deleteFiles"] = "true"; }}},
|
||||||
{"command/addTrackers", {"torrents", "addTrackers"}},
|
{"command/addTrackers", {"torrents", "addTrackers", nullptr}},
|
||||||
{"command/setFilePrio", {"torrents", "filePrio"}},
|
{"command/setFilePrio", {"torrents", "filePrio", nullptr}},
|
||||||
{"command/setCategory", {"torrents", "setCategory"}},
|
{"command/setCategory", {"torrents", "setCategory", nullptr}},
|
||||||
{"command/addCategory", {"torrents", "createCategory"}},
|
{"command/addCategory", {"torrents", "createCategory", nullptr}},
|
||||||
{"command/removeCategories", {"torrents", "removeCategories"}},
|
{"command/removeCategories", {"torrents", "removeCategories", nullptr}},
|
||||||
{"command/getTorrentsUpLimit", {"torrents", "uploadLimit"}},
|
{"command/getTorrentsUpLimit", {"torrents", "uploadLimit", nullptr}},
|
||||||
{"command/getTorrentsDlLimit", {"torrents", "downloadLimit"}},
|
{"command/getTorrentsDlLimit", {"torrents", "downloadLimit", nullptr}},
|
||||||
{"command/setTorrentsUpLimit", {"torrents", "setUploadLimit"}},
|
{"command/setTorrentsUpLimit", {"torrents", "setUploadLimit", nullptr}},
|
||||||
{"command/setTorrentsDlLimit", {"torrents", "setDownloadLimit"}},
|
{"command/setTorrentsDlLimit", {"torrents", "setDownloadLimit", nullptr}},
|
||||||
{"command/increasePrio", {"torrents", "increasePrio"}},
|
{"command/increasePrio", {"torrents", "increasePrio", nullptr}},
|
||||||
{"command/decreasePrio", {"torrents", "decreasePrio"}},
|
{"command/decreasePrio", {"torrents", "decreasePrio", nullptr}},
|
||||||
{"command/topPrio", {"torrents", "topPrio"}},
|
{"command/topPrio", {"torrents", "topPrio", nullptr}},
|
||||||
{"command/bottomPrio", {"torrents", "bottomPrio"}},
|
{"command/bottomPrio", {"torrents", "bottomPrio", nullptr}},
|
||||||
{"command/setLocation", {"torrents", "setLocation"}},
|
{"command/setLocation", {"torrents", "setLocation", nullptr}},
|
||||||
{"command/setAutoTMM", {"torrents", "setAutoManagement"}},
|
{"command/setAutoTMM", {"torrents", "setAutoManagement", nullptr}},
|
||||||
{"command/setSuperSeeding", {"torrents", "setSuperSeeding"}},
|
{"command/setSuperSeeding", {"torrents", "setSuperSeeding", nullptr}},
|
||||||
{"command/setForceStart", {"torrents", "setForceStart"}},
|
{"command/setForceStart", {"torrents", "setForceStart", nullptr}},
|
||||||
{"command/toggleSequentialDownload", {"torrents", "toggleSequentialDownload"}},
|
{"command/toggleSequentialDownload", {"torrents", "toggleSequentialDownload", nullptr}},
|
||||||
{"command/toggleFirstLastPiecePrio", {"torrents", "toggleFirstLastPiecePrio"}},
|
{"command/toggleFirstLastPiecePrio", {"torrents", "toggleFirstLastPiecePrio", nullptr}},
|
||||||
|
|
||||||
{"query/transferInfo", {"transfer", "info"}},
|
{"query/transferInfo", {"transfer", "info", nullptr}},
|
||||||
{"command/alternativeSpeedLimitsEnabled", {"transfer", "speedLimitsMode"}},
|
{"command/alternativeSpeedLimitsEnabled", {"transfer", "speedLimitsMode", nullptr}},
|
||||||
{"command/toggleAlternativeSpeedLimits", {"transfer", "toggleSpeedLimitsMode"}},
|
{"command/toggleAlternativeSpeedLimits", {"transfer", "toggleSpeedLimitsMode", nullptr}},
|
||||||
{"command/getGlobalUpLimit", {"transfer", "uploadLimit"}},
|
{"command/getGlobalUpLimit", {"transfer", "uploadLimit", nullptr}},
|
||||||
{"command/getGlobalDlLimit", {"transfer", "downloadLimit"}},
|
{"command/getGlobalDlLimit", {"transfer", "downloadLimit", nullptr}},
|
||||||
{"command/setGlobalUpLimit", {"transfer", "setUploadLimit"}},
|
{"command/setGlobalUpLimit", {"transfer", "setUploadLimit", nullptr}},
|
||||||
{"command/setGlobalDlLimit", {"transfer", "setDownloadLimit"}}
|
{"command/setGlobalDlLimit", {"transfer", "setDownloadLimit", nullptr}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString legacyAction {match.captured(QLatin1String("action"))};
|
const QString legacyAction {match.captured(QLatin1String("action"))};
|
||||||
|
@ -335,15 +336,8 @@ void WebApplication::doProcessRequest()
|
||||||
|
|
||||||
scope = compatInfo.scope;
|
scope = compatInfo.scope;
|
||||||
action = compatInfo.action;
|
action = compatInfo.action;
|
||||||
|
if (compatInfo.convertFunc)
|
||||||
if (legacyAction == QLatin1String("command/pauseAll"))
|
compatInfo.convertFunc();
|
||||||
m_params["hashes"] = "all";
|
|
||||||
else if (legacyAction == QLatin1String("command/resumeAll"))
|
|
||||||
m_params["hashes"] = "all";
|
|
||||||
else if (legacyAction == QLatin1String("command/delete"))
|
|
||||||
m_params["deleteFiles"] = "false";
|
|
||||||
else if (legacyAction == QLatin1String("command/deletePerm"))
|
|
||||||
m_params["deleteFiles"] = "true";
|
|
||||||
|
|
||||||
const QString hash {match.captured(QLatin1String("hash"))};
|
const QString hash {match.captured(QLatin1String("hash"))};
|
||||||
if (!hash.isEmpty())
|
if (!hash.isEmpty())
|
||||||
|
|
Loading…
Reference in a new issue