Browse Source

Add "minRackVersion" plugin manifest property. Don't download plugin update if Rack version is lower than the plugin's minRackVersion.

tags/v2.4.0
Andrew Belt 1 year ago
parent
commit
16900d4c8e
3 changed files with 36 additions and 8 deletions
  1. +2
    -0
      include/library.hpp
  2. +19
    -8
      src/app/MenuBar.cpp
  3. +15
    -0
      src/library.cpp

+ 2
- 0
include/library.hpp View File

@@ -13,6 +13,8 @@ struct UpdateInfo {
std::string name; std::string name;
std::string version; std::string version;
std::string changelogUrl; std::string changelogUrl;
/** Only defined if plugin does not meet Rack version requirement */
std::string minRackVersion;
bool downloaded = false; bool downloaded = false;
}; };




+ 19
- 8
src/app/MenuBar.cpp View File

@@ -664,26 +664,37 @@ struct SyncUpdateItem : ui::MenuItem {
return NULL; return NULL;
library::UpdateInfo update = it->second; library::UpdateInfo update = it->second;


if (update.changelogUrl == "")
return NULL;

ui::Menu* menu = new ui::Menu; ui::Menu* menu = new ui::Menu;


std::string changelogUrl = update.changelogUrl;
menu->addChild(createMenuItem("Changelog", "", [=]() {
system::openBrowser(changelogUrl);
}));
if (update.minRackVersion != "") {
menu->addChild(createMenuLabel(string::f("Requires Rack %s+", update.minRackVersion.c_str())));
}

if (update.changelogUrl != "") {
std::string changelogUrl = update.changelogUrl;
menu->addChild(createMenuItem("Changelog", "", [=]() {
system::openBrowser(changelogUrl);
}));
}


if (menu->children.empty()) {
delete menu;
return NULL;
}
return menu; return menu;
} }


void step() override { void step() override {
disabled = library::isSyncing;
if (library::isSyncing)
disabled = true;


auto it = library::updateInfos.find(slug); auto it = library::updateInfos.find(slug);
if (it != library::updateInfos.end()) { if (it != library::updateInfos.end()) {
library::UpdateInfo update = it->second; library::UpdateInfo update = it->second;


if (update.minRackVersion != "")
disabled = true;

if (update.downloaded) { if (update.downloaded) {
rightText = CHECKMARK_STRING; rightText = CHECKMARK_STRING;
disabled = true; disabled = true;


+ 15
- 0
src/library.cpp View File

@@ -12,6 +12,7 @@
#include <asset.hpp> #include <asset.hpp>
#include <settings.hpp> #include <settings.hpp>
#include <plugin.hpp> #include <plugin.hpp>
#include <string.hpp>




namespace rack { namespace rack {
@@ -278,6 +279,16 @@ void checkUpdates() {
if (changelogUrlJ) if (changelogUrlJ)
update.changelogUrl = json_string_value(changelogUrlJ); update.changelogUrl = json_string_value(changelogUrlJ);


// Get minRackVersion
json_t* minRackVersionJ = json_object_get(manifestJ, "minRackVersion");
if (minRackVersionJ) {
std::string minRackVersion = json_string_value(minRackVersionJ);
// Check that Rack version is at least minRackVersion
if (string::Version(APP_VERSION) < string::Version(minRackVersion)) {
update.minRackVersion = minRackVersion;
}
}

// Add update to updates map // Add update to updates map
updateInfos[pluginSlug] = update; updateInfos[pluginSlug] = update;
} }
@@ -349,6 +360,10 @@ void syncUpdate(std::string slug) {
return; return;
UpdateInfo update = it->second; UpdateInfo update = it->second;


// Don't update if not compatible with Rack version
if (update.minRackVersion != "")
return;

updateSlug = slug; updateSlug = slug;
DEFER({updateSlug = "";}); DEFER({updateSlug = "";});




Loading…
Cancel
Save