| 227 | const char* modulesKey; |
| 228 | json_t* modulesJ; |
| 229 | json_object_foreach(pluginsJ, modulesKey, modulesJ) { |
| 230 | std::string pluginSlug = modulesKey; |
| 231 | // Get plugin manifest |
| 232 | json_t* manifestJ = json_object_get(manifestsJ, pluginSlug.c_str()); |
| 233 | if (!manifestJ) { |
| 234 | // Skip plugin silently |
| 235 | continue; |
| 236 | } |
| 237 | |
| 238 | // Don't replace existing UpdateInfo, even if version is newer. |
| 239 | // This keeps things sane and ensures that only one version of each plugin is downloaded to `plugins/` at a time. |
| 240 | auto it = updateInfos.find(pluginSlug); |
| 241 | if (it != updateInfos.end()) { |
| 242 | continue; |
| 243 | } |
| 244 | UpdateInfo update; |
| 245 | |
| 246 | // Get plugin name |
| 247 | json_t* nameJ = json_object_get(manifestJ, "name"); |
| 248 | if (nameJ) |
| 249 | update.name = json_string_value(nameJ); |
| 250 | |
| 251 | // Get version |
| 252 | json_t* versionJ = json_object_get(manifestJ, "version"); |
| 253 | if (!versionJ) { |
| 254 | // WARN("Plugin %s has no version in manifest", pluginSlug.c_str()); |
| 255 | continue; |
| 256 | } |
| 257 | update.version = json_string_value(versionJ); |
| 258 | // Reject plugins with ABI mismatch |
| 259 | if (!string::startsWith(update.version, APP_VERSION_MAJOR + ".")) { |
| 260 | continue; |
| 261 | } |
| 262 | |
| 263 | // Check that update is needed |
| 264 | plugin::Plugin* p = plugin::getPlugin(pluginSlug); |
| 265 | if (p) { |
| 266 | if (update.version == p->version) |
| 267 | continue; |
| 268 | if (string::Version(update.version) < string::Version(p->version)) |
| 269 | continue; |
| 270 | } |
| 271 | |
| 272 | // Check that plugin is available for this arch |
| 273 | json_t* archesJ = json_object_get(manifestJ, "arches"); |
| 274 | if (!archesJ) |
| 275 | continue; |
| 276 | std::string arch = APP_OS + "-" + APP_CPU; |
| 277 | json_t* archJ = json_object_get(archesJ, arch.c_str()); |
| 278 | if (!json_boolean_value(archJ)) |
| 279 | continue; |
| 280 | |
| 281 | // Get changelog URL |
| 282 | json_t* changelogUrlJ = json_object_get(manifestJ, "changelogUrl"); |
| 283 | if (changelogUrlJ) |
| 284 | update.changelogUrl = json_string_value(changelogUrlJ); |
| 285 | |
| 286 | // Get minRackVersion |
nothing calls this directly
no test coverage detected