diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index 0a0d1694dda90..538bf99b6c081 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -590,11 +590,21 @@ void CAddonInstaller::InstallAddons(const VECADDONS& addons, bool wait, AllowCheckForUpdates allowCheckForUpdates) { - for (const auto& addon : addons) + std::vector addonIds; + std::transform(addons.cbegin(), addons.cend(), std::back_inserter(addonIds), + [](const AddonPtr& addon) { return addon->ID(); }); + InstallAddons(addonIds, wait, allowCheckForUpdates); +} + +void CAddonInstaller::InstallAddons(const std::vector& addonIds, + bool wait, + AllowCheckForUpdates allowCheckForUpdates) +{ + for (const auto& addonId : addonIds) { AddonPtr toInstall; RepositoryPtr repo; - if (CAddonInstallJob::GetAddon(addon->ID(), repo, toInstall)) + if (CAddonInstallJob::GetAddon(addonId, repo, toInstall)) DoInstall(toInstall, repo, BackgroundJob::CHOICE_NO, ModalJob::CHOICE_NO, AutoUpdateJob::CHOICE_YES, DependencyJob::CHOICE_NO, allowCheckForUpdates); } diff --git a/xbmc/addons/AddonInstaller.h b/xbmc/addons/AddonInstaller.h index db723873f8e27..5aa0de2519665 100644 --- a/xbmc/addons/AddonInstaller.h +++ b/xbmc/addons/AddonInstaller.h @@ -139,6 +139,17 @@ class CAddonInstaller : public IJobCallback bool wait, AllowCheckForUpdates allowCheckForUpdates); + /*! \brief Installs a vector of addons by their addon ID + * \param addons the list of addon IDs to install + * \param wait if the method should wait for all the DoInstall jobs to finish or if it should return right away + * \param allowCheckForUpdates indicates if content update checks are allowed + * after installation of a repository addon from the vector + * \sa DoInstall + */ + void InstallAddons(const std::vector& addonIds, + bool wait, + AllowCheckForUpdates allowCheckForUpdates); + /*! \brief Install an addon from the given zip path \param path the zip file to install from \return true if successful, false otherwise