diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index c56ab79fad6..732fad4680b 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -123,6 +123,7 @@ void AppController::shutdownAction() { QCoreApplication::exit(); }); + setResult(u""_s); } void AppController::preferencesAction() @@ -1157,6 +1158,8 @@ void AppController::setPreferencesAction() // Save preferences pref->apply(); + + setResult(u""_s); } void AppController::defaultSavePathAction() @@ -1167,9 +1170,9 @@ void AppController::defaultSavePathAction() void AppController::sendTestEmailAction() { app()->sendTestEmail(); + setResult(u""_s); } - void AppController::getDirectoryContentAction() { requireParams({u"dirPath"_s}); @@ -1259,6 +1262,8 @@ void AppController::setCookiesAction() } Net::DownloadManager::instance()->setAllCookies(cookies); + + setResult(u""_s); } void AppController::networkInterfaceListAction() diff --git a/src/webui/api/authcontroller.cpp b/src/webui/api/authcontroller.cpp index eb1d1baf237..2e7fc2f6914 100644 --- a/src/webui/api/authcontroller.cpp +++ b/src/webui/api/authcontroller.cpp @@ -46,11 +46,13 @@ AuthController::AuthController(ISessionManager *sessionManager, IApplication *ap void AuthController::setUsername(const QString &username) { m_username = username; + setResult(u""_s); } void AuthController::setPasswordHash(const QByteArray &passwordHash) { m_passwordHash = passwordHash; + setResult(u""_s); } void AuthController::loginAction() @@ -99,6 +101,7 @@ void AuthController::loginAction() void AuthController::logoutAction() const { m_sessionManager->sessionEnd(); + setResult(u""_s); } bool AuthController::isBanned() const diff --git a/src/webui/api/rsscontroller.cpp b/src/webui/api/rsscontroller.cpp index d103d3198ba..7a54f0aba6f 100644 --- a/src/webui/api/rsscontroller.cpp +++ b/src/webui/api/rsscontroller.cpp @@ -53,6 +53,8 @@ void RSSController::addFolderAction() const nonstd::expected result = RSS::Session::instance()->addFolder(path); if (!result) throw APIError(APIErrorType::Conflict, result.error()); + + setResult(u""_s); } void RSSController::addFeedAction() @@ -64,6 +66,8 @@ void RSSController::addFeedAction() const nonstd::expected result = RSS::Session::instance()->addFeed(url, (path.isEmpty() ? url : path)); if (!result) throw APIError(APIErrorType::Conflict, result.error()); + + setResult(u""_s); } void RSSController::setFeedURLAction() @@ -75,6 +79,8 @@ void RSSController::setFeedURLAction() const nonstd::expected result = RSS::Session::instance()->setFeedURL(path, url); if (!result) throw APIError(APIErrorType::Conflict, result.error()); + + setResult(u""_s); } void RSSController::removeItemAction() @@ -85,6 +91,8 @@ void RSSController::removeItemAction() const nonstd::expected result = RSS::Session::instance()->removeItem(path); if (!result) throw APIError(APIErrorType::Conflict, result.error()); + + setResult(u""_s); } void RSSController::moveItemAction() @@ -96,6 +104,8 @@ void RSSController::moveItemAction() const nonstd::expected result = RSS::Session::instance()->moveItem(itemPath, destPath); if (!result) throw APIError(APIErrorType::Conflict, result.error()); + + setResult(u""_s); } void RSSController::itemsAction() @@ -130,6 +140,8 @@ void RSSController::markAsReadAction() { item->markAsRead(); } + + setResult(u""_s); } void RSSController::refreshItemAction() @@ -140,6 +152,8 @@ void RSSController::refreshItemAction() RSS::Item *item = RSS::Session::instance()->itemByPath(itemPath); if (item) item->refresh(); + + setResult(u""_s); } void RSSController::setRuleAction() @@ -151,6 +165,8 @@ void RSSController::setRuleAction() const auto jsonObj = QJsonDocument::fromJson(ruleDef).object(); RSS::AutoDownloader::instance()->setRule(RSS::AutoDownloadRule::fromJsonObject(jsonObj, ruleName)); + + setResult(u""_s); } void RSSController::renameRuleAction() @@ -161,6 +177,8 @@ void RSSController::renameRuleAction() const QString newRuleName {params()[u"newRuleName"_s].trimmed()}; RSS::AutoDownloader::instance()->renameRule(ruleName, newRuleName); + + setResult(u""_s); } void RSSController::removeRuleAction() @@ -169,6 +187,8 @@ void RSSController::removeRuleAction() const QString ruleName {params()[u"ruleName"_s].trimmed()}; RSS::AutoDownloader::instance()->removeRule(ruleName); + + setResult(u""_s); } void RSSController::rulesAction() diff --git a/src/webui/api/searchcontroller.cpp b/src/webui/api/searchcontroller.cpp index b954da11951..e15bead9fc6 100644 --- a/src/webui/api/searchcontroller.cpp +++ b/src/webui/api/searchcontroller.cpp @@ -142,6 +142,8 @@ void SearchController::stopAction() searchHandler->cancelSearch(); m_activeSearches.remove(id); } + + setResult(u""_s); } void SearchController::statusAction() @@ -215,6 +217,8 @@ void SearchController::deleteAction() searchHandler->cancelSearch(); m_activeSearches.remove(id); m_searchHandlers.erase(iter); + + setResult(u""_s); } void SearchController::downloadTorrentAction() @@ -238,6 +242,8 @@ void SearchController::downloadTorrentAction() downloadHandler->deleteLater(); }); } + + setResult(u""_s); } void SearchController::pluginsAction() @@ -253,6 +259,8 @@ void SearchController::installPluginAction() const QStringList sources = params()[u"sources"_s].split(u'|'); for (const QString &source : sources) SearchPluginManager::instance()->installPlugin(source); + + setResult(u""_s); } void SearchController::uninstallPluginAction() @@ -262,6 +270,8 @@ void SearchController::uninstallPluginAction() const QStringList names = params()[u"names"_s].split(u'|'); for (const QString &name : names) SearchPluginManager::instance()->uninstallPlugin(name.trimmed()); + + setResult(u""_s); } void SearchController::enablePluginAction() @@ -273,6 +283,8 @@ void SearchController::enablePluginAction() for (const QString &name : names) SearchPluginManager::instance()->enablePlugin(name.trimmed(), enable); + + setResult(u""_s); } void SearchController::updatePluginsAction() @@ -282,6 +294,8 @@ void SearchController::updatePluginsAction() connect(pluginManager, &SearchPluginManager::checkForUpdatesFinished, this, &SearchController::checkForUpdatesFinished); connect(pluginManager, &SearchPluginManager::checkForUpdatesFailed, this, &SearchController::checkForUpdatesFailed); pluginManager->checkForUpdates(); + + setResult(u""_s); } void SearchController::checkForUpdatesFinished(const QHash &updateInfo) @@ -300,6 +314,8 @@ void SearchController::checkForUpdatesFinished(const QHashupdatePlugin(pluginName); } + + setResult(u""_s); } void SearchController::checkForUpdatesFailed(const QString &reason) diff --git a/src/webui/api/torrentcreatorcontroller.cpp b/src/webui/api/torrentcreatorcontroller.cpp index ced5ec390c4..5874607baff 100644 --- a/src/webui/api/torrentcreatorcontroller.cpp +++ b/src/webui/api/torrentcreatorcontroller.cpp @@ -244,4 +244,6 @@ void TorrentCreatorController::deleteTaskAction() if (!m_torrentCreationManager->deleteTask(id)) throw APIError(APIErrorType::NotFound); + + setResult(u""_s); } diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index a34971da014..73acf855fd8 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -600,6 +600,8 @@ void TorrentsController::addWebSeedsAction() } torrent->addUrlSeeds(urls); + + setResult(u""_s); } void TorrentsController::editWebSeedAction() @@ -632,6 +634,8 @@ void TorrentsController::editWebSeedAction() torrent->removeUrlSeeds({origUrl}); torrent->addUrlSeeds({newUrl}); } + + setResult(u""_s); } void TorrentsController::removeWebSeedsAction() @@ -655,6 +659,8 @@ void TorrentsController::removeWebSeedsAction() } torrent->removeUrlSeeds(urls); + + setResult(u""_s); } // Returns the files in a torrent in JSON format. @@ -894,6 +900,8 @@ void TorrentsController::addTrackersAction() const QList entries = BitTorrent::parseTrackerEntries(params()[u"urls"_s]); torrent->addTrackers(entries); + + setResult(u""_s); } void TorrentsController::editTrackerAction() @@ -947,6 +955,8 @@ void TorrentsController::editTrackerAction() if (!torrent->isStopped()) torrent->forceReannounce(); + + setResult(u""_s); } void TorrentsController::removeTrackersAction() @@ -981,6 +991,8 @@ void TorrentsController::removeTrackersAction() for (BitTorrent::Torrent *const torrent : asConst(torrents)) torrent->removeTrackers(urls); + + setResult(u""_s); } void TorrentsController::addPeersAction() @@ -1027,6 +1039,8 @@ void TorrentsController::stopAction() const QStringList hashes = params()[u"hashes"_s].split(u'|'); applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->stop(); }); + + setResult(u""_s); } void TorrentsController::startAction() @@ -1035,6 +1049,8 @@ void TorrentsController::startAction() const QStringList idStrings = params()[u"hashes"_s].split(u'|'); applyToTorrents(idStrings, [](BitTorrent::Torrent *const torrent) { torrent->start(); }); + + setResult(u""_s); } void TorrentsController::filePrioAction() @@ -1076,6 +1092,8 @@ void TorrentsController::filePrioAction() if (priorityChanged) torrent->prioritizeFiles(priorities); + + setResult(u""_s); } void TorrentsController::uploadLimitAction() @@ -1124,6 +1142,8 @@ void TorrentsController::setUploadLimitAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setUploadLimit(limit); }); + + setResult(u""_s); } void TorrentsController::setDownloadLimitAction() @@ -1136,6 +1156,8 @@ void TorrentsController::setDownloadLimitAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setDownloadLimit(limit); }); + + setResult(u""_s); } void TorrentsController::setShareLimitsAction() @@ -1153,6 +1175,8 @@ void TorrentsController::setShareLimitsAction() torrent->setSeedingTimeLimit(seedingTimeLimit); torrent->setInactiveSeedingTimeLimit(inactiveSeedingTimeLimit); }); + + setResult(u""_s); } void TorrentsController::toggleSequentialDownloadAction() @@ -1161,6 +1185,8 @@ void TorrentsController::toggleSequentialDownloadAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleSequentialDownload(); }); + + setResult(u""_s); } void TorrentsController::toggleFirstLastPiecePrioAction() @@ -1169,6 +1195,8 @@ void TorrentsController::toggleFirstLastPiecePrioAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleFirstLastPiecePriority(); }); + + setResult(u""_s); } void TorrentsController::setSuperSeedingAction() @@ -1178,6 +1206,8 @@ void TorrentsController::setSuperSeedingAction() const bool value {parseBool(params()[u"value"_s]).value_or(false)}; const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent) { torrent->setSuperSeeding(value); }); + + setResult(u""_s); } void TorrentsController::setForceStartAction() @@ -1190,6 +1220,8 @@ void TorrentsController::setForceStartAction() { torrent->start(value ? BitTorrent::TorrentOperatingMode::Forced : BitTorrent::TorrentOperatingMode::AutoManaged); }); + + setResult(u""_s); } void TorrentsController::deleteAction() @@ -1203,6 +1235,8 @@ void TorrentsController::deleteAction() { BitTorrent::Session::instance()->removeTorrent(torrent->id(), deleteOption); }); + + setResult(u""_s); } void TorrentsController::increasePrioAction() @@ -1214,6 +1248,8 @@ void TorrentsController::increasePrioAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; BitTorrent::Session::instance()->increaseTorrentsQueuePos(toTorrentIDs(hashes)); + + setResult(u""_s); } void TorrentsController::decreasePrioAction() @@ -1225,6 +1261,8 @@ void TorrentsController::decreasePrioAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; BitTorrent::Session::instance()->decreaseTorrentsQueuePos(toTorrentIDs(hashes)); + + setResult(u""_s); } void TorrentsController::topPrioAction() @@ -1236,6 +1274,8 @@ void TorrentsController::topPrioAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; BitTorrent::Session::instance()->topTorrentsQueuePos(toTorrentIDs(hashes)); + + setResult(u""_s); } void TorrentsController::bottomPrioAction() @@ -1247,6 +1287,8 @@ void TorrentsController::bottomPrioAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; BitTorrent::Session::instance()->bottomTorrentsQueuePos(toTorrentIDs(hashes)); + + setResult(u""_s); } void TorrentsController::setLocationAction() @@ -1270,6 +1312,8 @@ void TorrentsController::setLocationAction() torrent->setAutoTMMEnabled(false); torrent->setSavePath(newLocation); }); + + setResult(u""_s); } void TorrentsController::setSavePathAction() @@ -1295,6 +1339,8 @@ void TorrentsController::setSavePathAction() if (!torrent->isAutoTMMEnabled()) torrent->setSavePath(newPath); }); + + setResult(u""_s); } void TorrentsController::setDownloadPathAction() @@ -1320,6 +1366,8 @@ void TorrentsController::setDownloadPathAction() if (!torrent->isAutoTMMEnabled()) torrent->setDownloadPath(newPath); }); + + setResult(u""_s); } void TorrentsController::renameAction() @@ -1338,6 +1386,8 @@ void TorrentsController::renameAction() name.replace(QRegularExpression(u"\r?\n|\r"_s), u" "_s); torrent->setName(name); + + setResult(u""_s); } void TorrentsController::setAutoManagementAction() @@ -1351,6 +1401,8 @@ void TorrentsController::setAutoManagementAction() { torrent->setAutoTMMEnabled(isEnabled); }); + + setResult(u""_s); } void TorrentsController::recheckAction() @@ -1359,6 +1411,8 @@ void TorrentsController::recheckAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceRecheck(); }); + + setResult(u""_s); } void TorrentsController::reannounceAction() @@ -1367,6 +1421,8 @@ void TorrentsController::reannounceAction() const QStringList hashes {params()[u"hashes"_s].split(u'|')}; applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceReannounce(); }); + + setResult(u""_s); } void TorrentsController::setCategoryAction() @@ -1381,6 +1437,8 @@ void TorrentsController::setCategoryAction() if (!torrent->setCategory(category)) throw APIError(APIErrorType::Conflict, tr("Incorrect category name")); }); + + setResult(u""_s); } void TorrentsController::createCategoryAction() @@ -1406,6 +1464,8 @@ void TorrentsController::createCategoryAction() if (!BitTorrent::Session::instance()->addCategory(category, categoryOptions)) throw APIError(APIErrorType::Conflict, tr("Unable to create category")); + + setResult(u""_s); } void TorrentsController::editCategoryAction() @@ -1428,6 +1488,8 @@ void TorrentsController::editCategoryAction() if (!BitTorrent::Session::instance()->editCategory(category, categoryOptions)) throw APIError(APIErrorType::Conflict, tr("Unable to edit category")); + + setResult(u""_s); } void TorrentsController::removeCategoriesAction() @@ -1437,6 +1499,8 @@ void TorrentsController::removeCategoriesAction() const QStringList categories {params()[u"categories"_s].split(u'\n')}; for (const QString &category : categories) BitTorrent::Session::instance()->removeCategory(category); + + setResult(u""_s); } void TorrentsController::categoriesAction() @@ -1472,6 +1536,8 @@ void TorrentsController::addTagsAction() torrent->addTag(Tag(tagStr)); }); } + + setResult(u""_s); } void TorrentsController::removeTagsAction() @@ -1496,6 +1562,8 @@ void TorrentsController::removeTagsAction() torrent->removeAllTags(); }); } + + setResult(u""_s); } void TorrentsController::createTagsAction() @@ -1506,6 +1574,8 @@ void TorrentsController::createTagsAction() for (const QString &tagStr : tags) BitTorrent::Session::instance()->addTag(Tag(tagStr)); + + setResult(u""_s); } void TorrentsController::deleteTagsAction() @@ -1515,6 +1585,8 @@ void TorrentsController::deleteTagsAction() const QStringList tags {params()[u"tags"_s].split(u',', Qt::SkipEmptyParts)}; for (const QString &tagStr : tags) BitTorrent::Session::instance()->removeTag(Tag(tagStr)); + + setResult(u""_s); } void TorrentsController::tagsAction() @@ -1545,6 +1617,8 @@ void TorrentsController::renameFileAction() { throw APIError(APIErrorType::Conflict, error.message()); } + + setResult(u""_s); } void TorrentsController::renameFolderAction() @@ -1567,6 +1641,8 @@ void TorrentsController::renameFolderAction() { throw APIError(APIErrorType::Conflict, error.message()); } + + setResult(u""_s); } void TorrentsController::exportAction() @@ -1623,4 +1699,6 @@ void TorrentsController::setSSLParametersAction() throw APIError(APIErrorType::BadData); torrent->setSSLParameters(sslParams); + + setResult(u""_s); } diff --git a/src/webui/api/transfercontroller.cpp b/src/webui/api/transfercontroller.cpp index 66ecb27470a..843dba2d237 100644 --- a/src/webui/api/transfercontroller.cpp +++ b/src/webui/api/transfercontroller.cpp @@ -104,6 +104,8 @@ void TransferController::setUploadLimitAction() if (limit == 0) limit = -1; BitTorrent::Session::instance()->setUploadSpeedLimit(limit); + + setResult(u""_s); } void TransferController::setDownloadLimitAction() @@ -113,12 +115,16 @@ void TransferController::setDownloadLimitAction() if (limit == 0) limit = -1; BitTorrent::Session::instance()->setDownloadSpeedLimit(limit); + + setResult(u""_s); } void TransferController::toggleSpeedLimitsModeAction() { BitTorrent::Session *const session = BitTorrent::Session::instance(); session->setAltGlobalSpeedLimitEnabled(!session->isAltGlobalSpeedLimitEnabled()); + + setResult(u""_s); } void TransferController::speedLimitsModeAction() @@ -136,6 +142,8 @@ void TransferController::setSpeedLimitsModeAction() // Any non-zero values are considered as alternative mode BitTorrent::Session::instance()->setAltGlobalSpeedLimitEnabled(mode != 0); + + setResult(u""_s); } void TransferController::banPeersAction() @@ -149,4 +157,6 @@ void TransferController::banPeersAction() if (!addr.ip.isNull()) BitTorrent::Session::instance()->banIP(addr.ip.toString()); } + + setResult(u""_s); }