std::unique_ptr<CRepository> CRepository::FromExtension(CAddonInfo addonInfo, const cp_extension_t* ext) { DirList dirs; AddonVersion version("0.0.0"); AddonPtr addonver; if (CServiceBroker::GetAddonMgr().GetAddon("xbmc.addon", addonver)) version = addonver->Version(); for (size_t i = 0; i < ext->configuration->num_children; ++i) { cp_cfg_element_t* element = &ext->configuration->children[i]; if(element->name && strcmp(element->name, "dir") == 0) { DirInfo dir = ParseDirConfiguration(element); if (dir.version <= version) { dirs.push_back(std::move(dir)); } } } if (!CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "info").empty()) { dirs.push_back(ParseDirConfiguration(ext->configuration)); } return std::unique_ptr<CRepository>(new CRepository(std::move(addonInfo), std::move(dirs))); }
std::unique_ptr<CRepository> CRepository::FromExtension(CAddonInfo addonInfo, const cp_extension_t* ext) { DirList dirs; AddonVersion version("0.0.0"); AddonPtr addonver; if (CServiceBroker::GetAddonMgr().GetAddon("xbmc.addon", addonver)) version = addonver->Version(); for (size_t i = 0; i < ext->configuration->num_children; ++i) { if(ext->configuration->children[i].name && strcmp(ext->configuration->children[i].name, "dir") == 0) { AddonVersion min_version(CServiceBroker::GetAddonMgr().GetExtValue(&ext->configuration->children[i], "@minversion")); if (min_version <= version) { DirInfo dir; dir.version = min_version; dir.checksum = CServiceBroker::GetAddonMgr().GetExtValue(&ext->configuration->children[i], "checksum"); dir.info = CServiceBroker::GetAddonMgr().GetExtValue(&ext->configuration->children[i], "info"); dir.datadir = CServiceBroker::GetAddonMgr().GetExtValue(&ext->configuration->children[i], "datadir"); dir.hashes = CServiceBroker::GetAddonMgr().GetExtValue(&ext->configuration->children[i], "hashes") == "true"; dirs.push_back(std::move(dir)); } } } if (!CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "info").empty()) { DirInfo info; info.checksum = CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "checksum"); info.info = CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "info"); info.datadir = CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "datadir"); info.hashes = CServiceBroker::GetAddonMgr().GetExtValue(ext->configuration, "hashes") == "true"; dirs.push_back(std::move(info)); } return std::unique_ptr<CRepository>(new CRepository(std::move(addonInfo), std::move(dirs))); }