*/
#include "AddonManager.h"
#include "Addon.h"
+#include "AddonInstaller.h"
#include "DllLibCPluff.h"
#include "utils/StringUtils.h"
#include "utils/JobManager.h"
#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "tinyXML/tinyxml.h"
+#include "dialogs/GUIDialogYesNo.h"
#ifdef HAS_VISUALISATION
return addons.size() > 0;
}
-bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/)
+bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/, bool install /*= false*/)
{
CSingleLock lock(m_critSection);
return false;
return NULL != addon.get();
}
+ else
+ {
+ if (install)
+ {
+ if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
+ str.c_str(), g_localizeStrings.Get(24101)))
+ return false;
+
+ if (CAddonInstaller::Get().Install(str.c_str(), true, "", false))
+ {
+ cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
+ addon = GetAddonFromDescriptor(cpaddon);
+ m_cpluff->release_info(m_cp_context, cpaddon);
+ if (status == CP_OK && cpaddon)
+ return NULL != addon.get();
+ }
+ }
+ }
+
if (cpaddon)
m_cpluff->release_info(m_cp_context, cpaddon);
\param addon [out] the retrieved addon pointer - only use if the function returns true.
\param type type of addon to retrieve - defaults to any type.
\param enabledOnly whether we only want enabled addons - set to false to allow both enabled and disabled addons - defaults to true.
+ \param install whether to install the requested addon in case it's not yet installed - defaults to false.
\return true if an addon matching the id of the given type is available and is enabled (if enabledOnly is true).
*/
- bool GetAddon(const CStdString &id, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN, bool enabledOnly = true);
+ bool GetAddon(const CStdString &id, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN, bool enabledOnly = true, bool install = false);
bool HasAddons(const TYPE &type, bool enabled = true);
bool GetAddons(const TYPE &type, VECADDONS &addons, bool enabled = true);
bool GetAllAddons(VECADDONS &addons, bool enabled = true, bool allowRepos = false);
{
CURL url(strPath);
- if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_PLUGIN))
+ if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_PLUGIN, true, true))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;
return false;
AddonPtr addon;
- if (!CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_PLUGIN))
+ if (!CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_PLUGIN, true , true))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;