Skip to content

Commit

Permalink
CAddonInstaller: rename PromptForInstall() to InstallModal()
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Mar 1, 2015
1 parent 72bee19 commit b356481
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions xbmc/addons/AddonInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool CAddonInstaller::Cancel(const std::string &addonID)
return false;
}

bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &addon)
bool CAddonInstaller::InstallModal(const std::string &addonID, ADDON::AddonPtr &addon, bool promptForInstall /* = true */)
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return false;
Expand All @@ -176,9 +176,11 @@ bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &add
database.Open();
if (database.GetAddon(addonID, addon))
{ // yes - ask user if they want it installed
if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
if (promptForInstall &&
!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
addon->Name().c_str(), g_localizeStrings.Get(24101)))
return false;

if (Install(addonID, true))
{
CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
Expand All @@ -190,6 +192,7 @@ bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &add
progress->SetLine(2, "");
progress->SetPercentage(0);
progress->StartModal();

while (true)
{
progress->Progress();
Expand All @@ -199,12 +202,15 @@ bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &add
Cancel(addonID);
break;
}

if (!GetProgress(addonID, percent))
break;

progress->SetPercentage(percent);
}
progress->Close();
}

return CAddonMgr::Get().GetAddon(addonID, addon);
}
}
Expand Down
5 changes: 3 additions & 2 deletions xbmc/addons/AddonInstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ class CAddonInstaller : public IJobCallback
bool GetProgress(const std::string &addonID, unsigned int &percent) const;
bool Cancel(const std::string &addonID);

/*! \brief Prompt the user as to whether they wish to install an addon.
/*! \brief Installs the addon while showing a modal progress dialog
\param addonID the addon ID of the item to install.
\param addon [out] the installed addon for later use.
\param promptForInstall Whether or not to prompt the user before installing the addon.
\return true on successful install, false otherwise.
\sa Install
*/
bool PromptForInstall(const std::string &addonID, ADDON::AddonPtr &addon);
bool InstallModal(const std::string &addonID, ADDON::AddonPtr &addon, bool promptForInstall = true);

/*! \brief Install an addon if it is available in a repository
\param addonID the addon ID of the item to install
Expand Down
4 changes: 2 additions & 2 deletions xbmc/filesystem/PluginDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool CPluginDirectory::StartScript(const std::string& strPath, bool retrievingDi
// try the plugin type first, and if not found, try an unknown type
if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_PLUGIN) &&
!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_UNKNOWN) &&
!CAddonInstaller::Get().PromptForInstall(url.GetHostName(), m_addon))
!CAddonInstaller::Get().InstallModal(url.GetHostName(), m_addon))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;
Expand Down Expand Up @@ -424,7 +424,7 @@ bool CPluginDirectory::RunScriptWithParams(const std::string& strPath)
return false;

AddonPtr addon;
if (!CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_PLUGIN) && !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), addon))
if (!CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_PLUGIN) && !CAddonInstaller::Get().InstallModal(url.GetHostName(), addon))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;
Expand Down

0 comments on commit b356481

Please sign in to comment.