diff --git a/src/webui/requesthandler.cpp b/src/webui/requesthandler.cpp index a13720b69..02689faaa 100644 --- a/src/webui/requesthandler.cpp +++ b/src/webui/requesthandler.cpp @@ -51,6 +51,9 @@ using namespace libtorrent; +static const int API_VERSION = 2; +static const int API_VERSION_MIN = 2; + const QString WWW_FOLDER = ":/www/public/"; const QString PRIVATE_FOLDER = ":/www/private/"; const QString DEFAULT_SCOPE = "public"; @@ -58,6 +61,7 @@ const QString SCOPE_IMAGES = "images"; const QString SCOPE_THEME = "theme"; const QString DEFAULT_ACTION = "index"; const QString WEBUI_ACTION = "webui"; +const QString VERSION_INFO = "version"; #define ADD_ACTION(scope, action) actions[#scope][#action] = &RequestHandler::action_##scope##_##action @@ -102,6 +106,8 @@ QMap > RequestHandler::initialize ADD_ACTION(command, topPrio); ADD_ACTION(command, bottomPrio); ADD_ACTION(command, recheck); + ADD_ACTION(version, api); + ADD_ACTION(version, api_min); return actions; } @@ -209,6 +215,16 @@ void RequestHandler::action_json_propertiesFiles() print(btjson::getFilesForTorrent(args_.front()), CONTENT_TYPE_JS); } +void RequestHandler::action_version_api() +{ + print(QString::number(API_VERSION), CONTENT_TYPE_TXT); +} + +void RequestHandler::action_version_api_min() +{ + print(QString::number(API_VERSION_MIN), CONTENT_TYPE_TXT); +} + void RequestHandler::action_command_shutdown() { qDebug() << "Shutdown request from Web UI"; @@ -489,7 +505,7 @@ void RequestHandler::action_command_recheck() bool RequestHandler::isPublicScope() { - return (scope_ == DEFAULT_SCOPE); + return (scope_ == DEFAULT_SCOPE || scope_ == VERSION_INFO); } void RequestHandler::processRequest() diff --git a/src/webui/requesthandler.h b/src/webui/requesthandler.h index 49d4e24b9..6e83b7a1a 100644 --- a/src/webui/requesthandler.h +++ b/src/webui/requesthandler.h @@ -81,6 +81,8 @@ private: void action_command_topPrio(); void action_command_bottomPrio(); void action_command_recheck(); + void action_version_api(); + void action_version_api_min(); typedef void (RequestHandler::*Action)();