bool CAddonMgr::AddonsFromRepoXML(const TiXmlElement *root, VECADDONS &addons) { // create a context for these addons cp_status_t status; cp_context_t *context = m_cpluff->create_context(&status); if (!root || !context) return false; // each addon XML should have a UTF-8 declaration TiXmlDeclaration decl("1.0", "UTF-8", ""); const TiXmlElement *element = root->FirstChildElement("addon"); while (element) { // dump the XML back to text std::string xml; xml << decl; xml << *element; cp_status_t status; cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor_from_memory(context, xml.c_str(), xml.size(), &status); if (info) { AddonPtr addon = GetAddonFromDescriptor(info); if (addon.get()) addons.push_back(addon); m_cpluff->release_info(context, info); } element = element->NextSiblingElement("addon"); } m_cpluff->destroy_context(context); return true; }
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/) { CSingleLock lock(m_critSection); cp_status_t status; cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status); if (status == CP_OK && cpaddon) { addon = GetAddonFromDescriptor(cpaddon, type==ADDON_UNKNOWN?"":TranslateType(type)); m_cpluff->release_info(m_cp_context, cpaddon); if (addon && addon.get()) { if (enabledOnly && m_database.IsAddonDisabled(addon->ID())) return false; if (addon->Type() == ADDON_PVRDLL && g_PVRManager.IsStarted()) { AddonPtr pvrAddon; if (g_PVRClients->GetClient(addon->ID(), pvrAddon)) addon = pvrAddon; } } return NULL != addon.get(); } if (cpaddon) m_cpluff->release_info(m_cp_context, cpaddon); return false; }
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/) { CSingleLock lock(m_critSection); CStdString xbmcPath = _P("special://xbmc/addons"); cp_status_t status; cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status); if (status == CP_OK && cpaddon) { addon = GetAddonFromDescriptor(cpaddon); m_cpluff->release_info(m_cp_context, cpaddon); if (addon && addon.get() && enabledOnly) { if (addon->Type() == ADDON_PVRDLL && addon->Path().Left(xbmcPath.size()).Equals(xbmcPath)) { if (!m_database.IsSystemPVRAddonEnabled(addon->ID())) return false; } else if (m_database.IsAddonDisabled(addon->ID())) return false; } return NULL != addon.get(); } if (cpaddon) m_cpluff->release_info(m_cp_context, cpaddon); return false; }
bool CAddonMgr::GetAddon(const std::string &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/) { CSingleLock lock(m_critSection); cp_status_t status; cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status); if (status == CP_OK && cpaddon) { addon = GetAddonFromDescriptor(cpaddon, type==ADDON_UNKNOWN?"":TranslateType(type)); m_cpluff->release_info(m_cp_context, cpaddon); if (addon) { if (enabledOnly && IsAddonDisabled(addon->ID())) return false; // if the addon has a running instance, grab that AddonPtr runningAddon = addon->GetRunningInstance(); if (runningAddon) addon = runningAddon; } return NULL != addon.get(); } if (cpaddon) m_cpluff->release_info(m_cp_context, cpaddon); return false; }
// FIXME: This function may not be required bool CAddonMgr::LoadAddonDescription(const CStdString &path, AddonPtr &addon) { cp_status_t status; cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor(m_cp_context, _P(path).c_str(), &status); if (info) { addon = GetAddonFromDescriptor(info); m_cpluff->release_info(m_cp_context, info); return NULL != addon.get(); } return false; }
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/, bool install /*= false*/) { CSingleLock lock(m_critSection); cp_status_t status; cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status); if (status == CP_OK && cpaddon) { addon = GetAddonFromDescriptor(cpaddon); m_cpluff->release_info(m_cp_context, cpaddon); if (addon.get() && enabledOnly && m_database.IsAddonDisabled(addon->ID())) 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); return false; }
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/) { CSingleLock lock(m_critSection); cp_status_t status; cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status); if (status == CP_OK && cpaddon) { addon = GetAddonFromDescriptor(cpaddon); m_cpluff->release_info(m_cp_context, cpaddon); if (addon.get() && enabledOnly && m_database.IsAddonDisabled(addon->ID())) return false; return NULL != addon.get(); } if (cpaddon) m_cpluff->release_info(m_cp_context, cpaddon); return false; }
bool CAddonMgr::LoadAddonDescriptionFromMemory(const TiXmlElement *root, AddonPtr &addon) { // create a context for these addons cp_status_t status; cp_context_t *context = m_cpluff->create_context(&status); if (!root || !context) return false; // dump the XML back to text std::string xml; xml << TiXmlDeclaration("1.0", "UTF-8", ""); xml << *root; cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor_from_memory(context, xml.c_str(), xml.size(), &status); if (info) { addon = GetAddonFromDescriptor(info); m_cpluff->release_info(context, info); } m_cpluff->destroy_context(context); return addon != NULL; }