Browse Source

Add rough code for synchronizing module whitelist from VCV Library.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
3265e33802
2 changed files with 35 additions and 1 deletions
  1. +1
    -1
      include/plugin.hpp
  2. +34
    -0
      src/plugin.cpp

+ 1
- 1
include/plugin.hpp View File

@@ -9,7 +9,7 @@
namespace rack { namespace rack {




/** Plugin loader and plugin manager
/** Plugin loader and VCV Library synchronizer
*/ */
namespace plugin { namespace plugin {




+ 34
- 0
src/plugin.cpp View File

@@ -414,6 +414,40 @@ void queryUpdates() {
updates.push_back(update); 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<std::string, std::set<std::string>> 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 = ""; updateStatus = "";
} }




Loading…
Cancel
Save