Skip to content

Commit

Permalink
fix the API version check
Browse files Browse the repository at this point in the history
  • Loading branch information
svengcz committed Apr 21, 2023
1 parent 33991ff commit 8c1c9cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace {
const char *PLUGIN_NAME{ "vACDM" };
const char *PLUGIN_VERSION{ "@CMAKE_PROJECT_VERSION@" };
const char *PLUGIN_AUTHOR{ "-" };
const char *PLUGIN_LICENSE{ "-" };
const char* WEBAPI_VERSION{ "10" };
const char *PLUGIN_LICENSE{ "GPLv3" };

static constexpr std::uint8_t PLUGIN_VERSION_MAJOR = @CMAKE_PROJECT_VERSION_MAJOR@;
static constexpr std::uint8_t PLUGIN_VERSION_MINOR = @CMAKE_PROJECT_VERSION_MINOR@;
static constexpr std::uint8_t PLUGIN_VERSION_PATCH = @CMAKE_PROJECT_VERSION_PATCH@;
}
7 changes: 2 additions & 5 deletions com/Server.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#include "Server.h"
#include "Version.h"
#include "logging/Logger.h"

using namespace vacdm;
using namespace vacdm::com;

static constexpr std::uint8_t ApiMajorVersion = 0;
static constexpr std::uint8_t ApiMinorVersion = 0;
static constexpr std::uint8_t ApiPatchVersion = 1;

static std::string __receivedDeleteData;
static std::string __receivedGetData;
static std::string __receivedPatchData;
Expand Down Expand Up @@ -152,7 +149,7 @@ bool Server::checkWepApi() {

logging::Logger::instance().log("Server", logging::Logger::Level::System, "Received API-version-message: " + __receivedGetData);
if (reader->parse(__receivedGetData.c_str(), __receivedGetData.c_str() + __receivedGetData.length(), &root, &errors)) {
if (ApiMajorVersion != root.get("major", Json::Value(-1)).asInt()) {
if (PLUGIN_VERSION_MAJOR != root.get("major", Json::Value(-1)).asInt()) {
this->m_errorCode = "Backend-version is incompatible. Please update the plugin.";
this->m_validWebApi = false;
}
Expand Down

0 comments on commit 8c1c9cd

Please sign in to comment.