Skip to content

Commit

Permalink
Allow installing multiple add-ons by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Feb 11, 2023
1 parent 7c29e04 commit 2dc49da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 12 additions & 2 deletions xbmc/addons/AddonInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,21 @@ void CAddonInstaller::InstallAddons(const VECADDONS& addons,
bool wait,
AllowCheckForUpdates allowCheckForUpdates)
{
for (const auto& addon : addons)
std::vector<std::string> 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<std::string>& 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);
}
Expand Down
11 changes: 11 additions & 0 deletions xbmc/addons/AddonInstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& 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
Expand Down

0 comments on commit 2dc49da

Please sign in to comment.