diff --git a/include/plugin.hpp b/include/plugin.hpp index b1efe072..69918dbb 100644 --- a/include/plugin.hpp +++ b/include/plugin.hpp @@ -9,7 +9,7 @@ namespace rack { -/** Plugin loader and plugin manager +/** Plugin loader and VCV Library synchronizer */ namespace plugin { diff --git a/src/plugin.cpp b/src/plugin.cpp index 8cdf7e67..9147f6e4 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -414,6 +414,40 @@ void queryUpdates() { updates.push_back(update); } + + // Get module whitelist + { + std::string whitelistUrl = API_URL + "/moduleWhitelist"; + json_t* whitelistResJ = network::requestJson(network::METHOD_GET, whitelistUrl, NULL, cookies); + if (!whitelistResJ) { + WARN("Request for module whitelist failed"); + updateStatus = "Could not query updates"; + return; + } + DEFER({ + json_decref(whitelistResJ); + }); + + std::map> moduleWhitelist; + json_t* pluginsJ = json_object_get(whitelistResJ, "plugins"); + + // Iterate plugins + const char* pluginSlug; + json_t* modulesJ; + json_object_foreach(pluginsJ, pluginSlug, modulesJ) { + // Iterate modules in plugin + size_t moduleIndex; + json_t* moduleSlugJ; + json_array_foreach(modulesJ, moduleIndex, moduleSlugJ) { + std::string moduleSlug = json_string_value(moduleSlugJ); + // Insert module in whitelist + moduleWhitelist[pluginSlug].insert(moduleSlug); + } + } + + settings::moduleWhitelist = moduleWhitelist; + } + updateStatus = ""; }