diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index e8838f834..7e2ef2489 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -115,6 +115,8 @@ QMap > WebApplication::initialize ADD_ACTION(command, bottomPrio); ADD_ACTION(command, recheck); ADD_ACTION(command, setCategory); + ADD_ACTION(command, addCategory); + ADD_ACTION(command, removeCategories); ADD_ACTION(command, getSavePath); ADD_ACTION(version, api); ADD_ACTION(version, api_min); @@ -728,6 +730,31 @@ void WebApplication::action_command_setCategory() } } +void WebApplication::action_command_addCategory() +{ + CHECK_URI(0); + CHECK_PARAMETERS("category"); + + QString category = request().posts["category"].trimmed(); + + if (!BitTorrent::Session::isValidCategoryName(category) && !category.isEmpty()) { + status(400, tr("Incorrect category name")); + return; + } + + BitTorrent::Session::instance()->addCategory(category); +} + +void WebApplication::action_command_removeCategories() +{ + CHECK_URI(0); + CHECK_PARAMETERS("categories"); + + QStringList categories = request().posts["categories"].split('\n'); + foreach (const QString &category, categories) + BitTorrent::Session::instance()->removeCategory(category); +} + void WebApplication::action_command_getSavePath() { CHECK_URI(0); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index a87acc8f8..722f7d5e4 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -88,6 +88,8 @@ private: void action_command_bottomPrio(); void action_command_recheck(); void action_command_setCategory(); + void action_command_addCategory(); + void action_command_removeCategories(); void action_command_getSavePath(); void action_version_api(); void action_version_api_min(); diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 8c2855988..b51ba30e7 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -100,7 +100,7 @@
-