bool CAddonDatabase::Search(const CStdString& search, VECADDONS& addons) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; CStdString strSQL; strSQL=PrepareSQL("SELECT addonID FROM addon WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", search.c_str(), search.c_str(), search.c_str()); CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str()); if (!m_pDS->query(strSQL.c_str())) return false; if (m_pDS->num_rows() == 0) return false; while (!m_pDS->eof()) { AddonPtr addon; GetAddon(m_pDS->fv(0).get_asString(),addon); if (addon->Type() >= ADDON_UNKNOWN+1 && addon->Type() < ADDON_SCRAPER_LIBRARY) addons.push_back(addon); m_pDS->next(); } m_pDS->close(); return true; } catch (...) { CLog::Log(LOGERROR, "%s failed", __FUNCTION__); } return false; }
bool CAddonDatabase::GetAddons(VECADDONS& addons) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS2.get()) return false; CStdString sql = PrepareSQL("select distinct addonID from addon"); m_pDS->query(sql.c_str()); while (!m_pDS->eof()) { AddonPtr addon; if (GetAddon(m_pDS->fv(0).get_asString(),addon)) addons.push_back(addon); m_pDS->next(); } m_pDS->close(); return true; } catch (...) { CLog::Log(LOGERROR, "%s failed", __FUNCTION__); } return false; }
int CAddonDatabase::AddRepository(const CStdString& id, const VECADDONS& addons, const CStdString& checksum) { try { if (NULL == m_pDB.get()) return -1; if (NULL == m_pDS.get()) return -1; CStdString sql; int idRepo = GetRepoChecksum(id,sql); if (idRepo > -1) DeleteRepository(idRepo); BeginTransaction(); CDateTime time = CDateTime::GetCurrentDateTime(); sql = PrepareSQL("insert into repo (id,addonID,checksum,lastcheck) values (NULL,'%s','%s','%s')",id.c_str(),checksum.c_str(),time.GetAsDBDateTime().c_str()); m_pDS->exec(sql.c_str()); idRepo = (int)m_pDS->lastinsertid(); for (unsigned int i=0;i<addons.size();++i) AddAddon(addons[i],idRepo); CommitTransaction(); return idRepo; } catch (...) { CLog::Log(LOGERROR, "%s failed on repo '%s'", __FUNCTION__, id.c_str()); RollbackTransaction(); } return -1; }
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; }
void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemList &items, bool reposAsFolders) { CStdString xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc/addons"); items.ClearItems(); for (unsigned i=0; i < addons.size(); i++) { AddonPtr addon = addons[i]; CFileItemPtr pItem; if (reposAsFolders && addon->Type() == ADDON_REPOSITORY) pItem = FileItemFromAddon(addon, "addons://", true); else pItem = FileItemFromAddon(addon, path.Get(), false); AddonPtr addon2; if (CAddonMgr::Get().GetAddon(addon->ID(),addon2)) pItem->SetProperty("Addon.Status",g_localizeStrings.Get(305)); else if ((addon->Type() == ADDON_PVRDLL) && (CStdString(pItem->GetProperty("Addon.Path").asString()).Left(xbmcPath.size()).Equals(xbmcPath))) pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24023)); if (!addon->Props().broken.IsEmpty()) pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24098)); if (addon2 && addon2->Version() < addon->Version()) { pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24068)); pItem->SetProperty("Addon.UpdateAvail", true); } CAddonDatabase::SetPropertiesFromAddon(addon,pItem); items.Add(pItem); } }
void CGUIControllerWindow::UpdateButtons(void) { using namespace ADDON; VECADDONS addons; CONTROL_ENABLE_ON_CONDITION(CONTROL_GET_MORE, CAddonMgr::GetInstance().GetInstallableAddons(addons, ADDON::ADDON_GAME_CONTROLLER) && !addons.empty()); }
bool CAddonDatabase::FindByAddonId(const std::string& addonId, ADDON::VECADDONS& result) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; std::string sql = PrepareSQL( "SELECT addons.version, addons.name, addons.summary, addons.description, addons.metadata," "repo.addonID AS repoID FROM addons " "JOIN addonlinkrepo ON addonlinkrepo.idAddon=addons.id " "JOIN repo ON repo.id=addonlinkrepo.idRepo " "WHERE " "repo.checksum IS NOT NULL AND repo.checksum != '' " "AND EXISTS (SELECT * FROM installed WHERE installed.addonID=repoID AND installed.enabled=1) " "AND addons.addonID='%s'", addonId.c_str()); VECADDONS addons; m_pDS->query(sql.c_str()); while (!m_pDS->eof()) { CAddonBuilder builder; builder.SetId(addonId); builder.SetVersion(AddonVersion(m_pDS->fv(0).get_asString())); builder.SetName(m_pDS->fv(1).get_asString()); builder.SetSummary(m_pDS->fv(2).get_asString()); builder.SetDescription(m_pDS->fv(3).get_asString()); DeserializeMetadata(m_pDS->fv(4).get_asString(), builder); builder.SetOrigin(m_pDS->fv(5).get_asString()); auto addon = builder.Build(); if (addon) addons.push_back(std::move(addon)); else CLog::Log(LOGERROR, "CAddonDatabase: failed to build %s", addonId.c_str()); m_pDS->next(); } m_pDS->close(); result = std::move(addons); return true; } catch (...) { CLog::Log(LOGERROR, "%s failed on addon %s", __FUNCTION__, addonId.c_str()); } return false; }
void CGUIDialogContentSettings::FillContentTypes(const CONTENT_TYPE &content) { // grab all scrapers which support this content-type VECADDONS addons; TYPE type = ScraperTypeFromContent(content); if (!CAddonMgr::Get().GetAddons(type, addons)) return; AddonPtr addon; CStdString defaultID; if (CAddonMgr::Get().GetDefault(type, addon)) defaultID = addon->ID(); for (IVECADDONS it = addons.begin(); it != addons.end(); it++) { bool isDefault = ((*it)->ID() == defaultID); map<CONTENT_TYPE,VECADDONS>::iterator iter=m_scrapers.find(content); AddonPtr scraper = (*it)->Clone((*it)); if (m_scraper && m_scraper->ID() == (*it)->ID()) { // don't overwrite preconfigured scraper scraper = m_scraper; } if (iter != m_scrapers.end()) { if (isDefault) iter->second.insert(iter->second.begin(), scraper); else iter->second.push_back(scraper); } else { VECADDONS vec; vec.push_back(scraper); m_scrapers.insert(make_pair(content,vec)); } } // add CONTENT type to spinner CGUIMessage msg(GUI_MSG_LABEL_ADD,GetID(),CONTROL_CONTENT_TYPE); msg.SetLabel(TranslateContent(content, true)); msg.SetParam1((int) content); g_windowManager.SendMessage(msg); }
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */) { CSingleLock lock(m_critSection); addons.clear(); cp_status_t status; int num; CStdString ext_point(TranslateType(type)); cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num); for(int i=0; i <num; i++) { AddonPtr addon(Factory(exts[i])); if (addon && m_database.IsAddonDisabled(addon->ID()) != enabled) addons.push_back(addon); } m_cpluff->release_info(m_cp_context, exts); return addons.size() > 0; }
std::vector<std::string> CAddonSystemSettings::MigrateAddons(std::function<void(void)> onMigrate) { auto getIncompatible = [](){ VECADDONS incompatible; CServiceBroker::GetAddonMgr().GetAddons(incompatible); incompatible.erase(std::remove_if(incompatible.begin(), incompatible.end(), [](const AddonPtr a){ return CServiceBroker::GetAddonMgr().IsCompatible(*a); }), incompatible.end()); return incompatible; }; if (getIncompatible().empty()) return std::vector<std::string>(); if (CServiceBroker::GetSettings().GetInt(CSettings::SETTING_ADDONS_AUTOUPDATES) == AUTO_UPDATES_ON) { onMigrate(); if (CServiceBroker::GetRepositoryUpdater().CheckForUpdates()) CServiceBroker::GetRepositoryUpdater().Await(); CLog::Log(LOGINFO, "ADDON: waiting for add-ons to update..."); CAddonInstaller::GetInstance().InstallUpdatesAndWait(); } auto incompatible = getIncompatible(); for (const auto& addon : incompatible) CLog::Log(LOGNOTICE, "ADDON: %s version %s is incompatible", addon->ID().c_str(), addon->Version().asString().c_str()); std::vector<std::string> changed; for (const auto& addon : incompatible) { if (!UnsetActive(addon)) { CLog::Log(LOGWARNING, "ADDON: failed to unset %s", addon->ID().c_str()); continue; } if (!CServiceBroker::GetAddonMgr().DisableAddon(addon->ID())) { CLog::Log(LOGWARNING, "ADDON: failed to disable %s", addon->ID().c_str()); } changed.push_back(addon->Name()); } return changed; }
bool CAddonMgr::StartServices() { CLog::Log(LOGDEBUG, "ADDON: Starting service addons."); VECADDONS services; if (!GetAddons(ADDON_SERVICE, services)) return false; bool ret = true; for (IVECADDONS it = services.begin(); it != services.end(); ++it) { boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(*it); if (service) ret &= service->Start(); } return ret; }
bool CActiveAEDSP::UpdateAddons(void) { VECADDONS addons; AE_DSP_ADDON dspAddon; bool bReturn(CAddonMgr::GetInstance().GetAddons(ADDON_ADSPDLL, addons, true)); size_t usableAddons; if (bReturn) { CSingleLock lock(m_critUpdateSection); m_addons = addons; } usableAddons = m_addons.size(); /* handle "new" addons which aren't yet in the db - these have to be added first */ for (VECADDONS::const_iterator itr = addons.begin(); itr != addons.end(); ++itr) { dspAddon = std::dynamic_pointer_cast<CActiveAEDSPAddon>(*itr); bool newRegistration = false; if (RegisterAudioDSPAddon(dspAddon, &newRegistration) < 0 || newRegistration) { CAddonMgr::GetInstance().DisableAddon(dspAddon->ID()); --usableAddons; } } if ((!bReturn || usableAddons == 0) && !m_noAddonWarningDisplayed && !CAddonMgr::GetInstance().HasAddons(ADDON_ADSPDLL, false) && IsActivated()) { // No audio DSP add-ons could be found // You need a add-on installed for the process of audio DSP signal. System becomes disabled. m_noAddonWarningDisplayed = true; CGUIDialogOK::ShowAndGetInput(CVariant{19273}, CVariant{19274}); CSettings::GetInstance().SetBool(CSettings::SETTING_AUDIOOUTPUT_DSPADDONSENABLED, false); CGUIMessage msg(GUI_MSG_UPDATE, WINDOW_SETTINGS_SYSTEM, 0); g_windowManager.SendThreadMessage(msg, WINDOW_SETTINGS_SYSTEM); CApplicationMessenger::GetInstance().SendMsg(TMSG_SETAUDIODSPSTATE, ACTIVE_AE_DSP_STATE_OFF); } return bReturn; }
void CAddonInstallJob::OnPostInstall(bool reloadAddon) { if (m_addon->Type() < ADDON_VIZ_LIBRARY && g_settings.m_bAddonNotifications) { CGUIDialogKaiToast::QueueNotification(m_addon->Icon(), m_addon->Name(), g_localizeStrings.Get(m_update ? 24065 : 24064), TOAST_DISPLAY_TIME,false, TOAST_DISPLAY_TIME); } if (m_addon->Type() == ADDON_SKIN) { if (reloadAddon || (!m_update && CGUIDialogYesNo::ShowAndGetInput(m_addon->Name(), g_localizeStrings.Get(24099),"",""))) { g_guiSettings.SetString("lookandfeel.skin",m_addon->ID().c_str()); CGUIDialogKaiToast *toast = (CGUIDialogKaiToast *)g_windowManager.GetWindow(WINDOW_DIALOG_KAI_TOAST); if (toast) { toast->ResetTimer(); toast->Close(true); } CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin"); } } if (m_addon->Type() == ADDON_SERVICE) { // regrab from manager to have the correct path set AddonPtr addon; CAddonMgr::Get().GetAddon(m_addon->ID(), addon); boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(addon); if (service) service->Start(); } if (m_addon->Type() == ADDON_REPOSITORY) { VECADDONS addons; addons.push_back(m_addon); CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(addons), &CAddonInstaller::Get()); } }
void CRepositoryUpdater::OnJobComplete(unsigned int jobID, bool success, CJob* job) { CSingleLock lock(m_criticalSection); m_jobs.erase(std::find(m_jobs.begin(), m_jobs.end(), job)); if (m_jobs.empty()) { CLog::Log(LOGDEBUG, "CRepositoryUpdater: done."); m_doneEvent.Set(); VECADDONS updates = CAddonMgr::GetInstance().GetAvailableUpdates(); if (CSettings::GetInstance().GetInt(CSettings::SETTING_ADDONS_AUTOUPDATES) == AUTO_UPDATES_NOTIFY) { if (!updates.empty()) { if (updates.size() == 1) CGUIDialogKaiToast::QueueNotification( updates[0]->Icon(), updates[0]->Name(), g_localizeStrings.Get(24068), TOAST_DISPLAY_TIME, false, TOAST_DISPLAY_TIME); else CGUIDialogKaiToast::QueueNotification( "", g_localizeStrings.Get(24001), g_localizeStrings.Get(24061), TOAST_DISPLAY_TIME, false, TOAST_DISPLAY_TIME); for (const auto &addon : updates) CEventLog::GetInstance().Add(EventPtr(new CAddonManagementEvent(addon, 24068))); } } if (CSettings::GetInstance().GetInt(CSettings::SETTING_ADDONS_AUTOUPDATES) == AUTO_UPDATES_ON) { for (const auto& addon : updates) { if (!CAddonMgr::GetInstance().IsBlacklisted(addon->ID())) CAddonInstaller::GetInstance().InstallOrUpdate(addon->ID()); } } ScheduleUpdate(); m_events.Publish(RepositoryUpdated{}); } }
bool CGUIDialogAddonInfo::SetItem(const CFileItemPtr& item) { *m_item = *item; m_rollbackVersions.clear(); // grab the local addon, if it's available m_localAddon.reset(); m_addon.reset(); if (CAddonMgr::Get().GetAddon(item->GetProperty("Addon.ID").asString(), m_localAddon)) // sets m_addon if installed regardless of enabled state m_item->SetProperty("Addon.Enabled", "true"); else m_item->SetProperty("Addon.Enabled", "false"); m_item->SetProperty("Addon.Installed", m_addon ? "true" : "false"); CAddonDatabase database; database.Open(); database.GetAddon(item->GetProperty("Addon.ID").asString(),m_addon); if (TranslateType(item->GetProperty("Addon.intType").asString()) == ADDON_REPOSITORY) { CAddonDatabase database; database.Open(); VECADDONS addons; if (m_addon) database.GetRepository(m_addon->ID(), addons); else if (m_localAddon) // sanity database.GetRepository(m_localAddon->ID(), addons); int tot=0; for (int i = ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i) { int num=0; for (unsigned int j=0;j<addons.size();++j) { if (addons[j]->Type() == (TYPE)i) ++num; } m_item->SetProperty(CStdString("Repo.") + TranslateType((TYPE)i), num); tot += num; } m_item->SetProperty("Repo.Addons", tot); } return true; }
void CAddonMgr::StopServices(const bool onlylogin) { CLog::Log(LOGDEBUG, "ADDON: Stopping service addons."); VECADDONS services; if (!GetAddons(ADDON_SERVICE, services)) return; for (IVECADDONS it = services.begin(); it != services.end(); ++it) { boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(*it); if (service) { if ( (onlylogin && service->GetStartOption() == CService::LOGIN) || (!onlylogin) ) service->Stop(); } } }
void CAddonMgr::UpdateRepos(bool force) { CSingleLock lock(m_critSection); if (!force && m_watch.IsRunning() && m_watch.GetElapsedSeconds() < 600) return; m_watch.StartZero(); VECADDONS addons; GetAddons(ADDON_REPOSITORY,addons); for (unsigned int i=0;i<addons.size();++i) { RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addons[i]); CDateTime lastUpdate = m_database.GetRepoTimestamp(repo->ID()); if (force || !lastUpdate.IsValid() || lastUpdate + CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGDEBUG,"Checking repository %s for updates",repo->Name().c_str()); CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(repo), NULL); } } }
bool CGameUtils::HasGameExtension(const std::string &path) { using namespace ADDON; // Get filename from CURL so that top-level zip directories will become // normal paths: // // zip://%2Fpath_to_zip_file.zip/ -> /path_to_zip_file.zip // std::string filename = CURL(path).GetFileNameWithoutPath(); // Get the file extension std::string extension = URIUtils::GetExtension(filename); if (extension.empty()) return false; StringUtils::ToLower(extension); // Look for a game client that supports this extension VECADDONS gameClients; CBinaryAddonCache& addonCache = CServiceBroker::GetBinaryAddonCache(); addonCache.GetAddons(gameClients, ADDON_GAMEDLL); for (auto& gameClient : gameClients) { GameClientPtr gc(std::static_pointer_cast<CGameClient>(gameClient)); if (gc->IsExtensionValid(extension)) return true; } // Check remote add-ons gameClients.clear(); if (CServiceBroker::GetAddonMgr().GetInstallableAddons(gameClients, ADDON_GAMEDLL)) { for (auto& gameClient : gameClients) { GameClientPtr gc(std::static_pointer_cast<CGameClient>(gameClient)); if (gc->IsExtensionValid(extension)) return true; } } return false; }
ICodec* CodecFactory::CreateCodec(const CStdString& strFileType) { VECADDONS codecs; CAddonMgr::Get().GetAddons(ADDON_AUDIODECODER, codecs); for (size_t i=0;i<codecs.size();++i) { boost::shared_ptr<CAudioDecoder> dec(boost::static_pointer_cast<CAudioDecoder>(codecs[i])); if (dec->GetExtensions().find("."+strFileType) != std::string::npos) { CAudioDecoder* result = new CAudioDecoder(*dec); static_cast<AudioDecoderDll&>(*result).Create(); return result; } } if (strFileType.Equals("pcm") || strFileType.Equals("l16")) return new PCMCodec(); return new DVDPlayerCodec(); }
void CBinaryAddonCache::GetDisabledAddons(VECADDONS& addons, const TYPE& type) { VECADDONS myAddons; GetInstalledAddons(myAddons, type); for (auto &addon : myAddons) { if (CAddonMgr::GetInstance().IsAddonDisabled(addon->ID())) addons.emplace_back(std::move(addon)); } }
CDateTime CRepositoryUpdater::LastUpdated() const { VECADDONS repos; if (!CAddonMgr::GetInstance().GetAddons(repos, ADDON_REPOSITORY) || repos.empty()) return CDateTime(); CAddonDatabase db; db.Open(); std::vector<CDateTime> updateTimes; std::transform(repos.begin(), repos.end(), std::back_inserter(updateTimes), [&](const AddonPtr& repo) { auto lastCheck = db.LastChecked(repo->ID()); if (lastCheck.first.IsValid() && lastCheck.second == repo->Version()) return lastCheck.first; return CDateTime(); }); return *std::min_element(updateTimes.begin(), updateTimes.end()); }
ICodec* CodecFactory::CreateCodec(const std::string &strFileType) { std::string fileType = strFileType; StringUtils::ToLower(fileType); VECADDONS codecs; CAddonMgr::GetInstance().GetAddons(ADDON_AUDIODECODER, codecs); for (size_t i=0;i<codecs.size();++i) { std::shared_ptr<CAudioDecoder> dec(std::static_pointer_cast<CAudioDecoder>(codecs[i])); std::vector<std::string> exts = StringUtils::Split(dec->GetExtensions(), "|"); if (std::find(exts.begin(), exts.end(), "."+fileType) != exts.end()) { CAudioDecoder* result = new CAudioDecoder(*dec); static_cast<AudioDecoderDll&>(*result).Create(); return result; } } VideoPlayerCodec *dvdcodec = new VideoPlayerCodec(); return dvdcodec; }
bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool enabled /*= true*/) { CSingleLock lock(m_critSection); for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i) { VECADDONS temp; if (CAddonMgr::Get().GetAddons((TYPE)i, temp, enabled)) { AddonPtr repoAddon; for (unsigned int j = 0; j < temp.size(); j++) { if (!m_database.GetAddon(temp[j]->ID(), repoAddon)) continue; if (temp[j]->Version() < repoAddon->Version()) addons.push_back(repoAddon); } } } return !addons.empty(); }
void CGUIDialogSubtitles::FillServices() { std::string previousService = m_currentService; ClearServices(); VECADDONS addons; ADDON::CAddonMgr::GetInstance().GetAddons(addons, ADDON_SUBTITLE_MODULE); if (addons.empty()) { UpdateStatus(NO_SERVICES); return; } std::string defaultService; const CFileItem &item = g_application.CurrentUnstackedItem(); if (item.GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS || item.GetVideoContentType() == VIDEODB_CONTENT_EPISODES) // Set default service for tv shows defaultService = CSettings::GetInstance().GetString(CSettings::SETTING_SUBTITLES_TV); else // Set default service for filemode and movies defaultService = CSettings::GetInstance().GetString(CSettings::SETTING_SUBTITLES_MOVIE); std::string service = addons.front()->ID(); for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); ++addonIt) { CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addonIt, "plugin://" + (*addonIt)->ID(), false)); m_serviceItems->Add(item); // If we don't have used a previous service use the default service, otherwise use the previous service if ((previousService.empty() && (*addonIt)->ID() == defaultService) || (*addonIt)->ID() == previousService) service = (*addonIt)->ID(); } // Bind our services to the UI CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_SERVICELIST, 0, 0, m_serviceItems); OnMessage(msg); SetService(service); }
bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool enabled /*= true*/) { CSingleLock lock(m_critSection); for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i) { VECADDONS temp; if (CAddonMgr::Get().GetAddons((TYPE)i, temp, enabled)) { AddonPtr repoAddon; for (unsigned int j = 0; j < temp.size(); j++) { // Ignore duplicates due to add-ons with multiple extension points bool found = false; for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); addonIt++) { if ((*addonIt)->ID() == temp[j]->ID()) found = true; } if (found || !m_database.GetAddon(temp[j]->ID(), repoAddon)) continue; if (temp[j]->Version() < repoAddon->Version() && !m_database.IsAddonBlacklisted(temp[j]->ID(), repoAddon->Version().c_str())) addons.push_back(repoAddon); } } } return !addons.empty(); }
void CAddonInstaller::UpdateRepos(bool force, bool wait) { CSingleLock lock(m_critSection); if (m_repoUpdateJob) { if (wait) { // wait for our job to complete lock.Leave(); CLog::Log(LOGDEBUG, "%s - waiting for repository update job to finish...", __FUNCTION__); m_repoUpdateDone.Wait(); } return; } // don't run repo update jobs while on the login screen which runs under the master profile if((g_windowManager.GetActiveWindow() & WINDOW_ID_MASK) == WINDOW_LOGIN_SCREEN) return; if (!force && m_repoUpdateWatch.IsRunning() && m_repoUpdateWatch.GetElapsedSeconds() < 600) return; m_repoUpdateWatch.StartZero(); VECADDONS addons; CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons); for (unsigned int i=0;i<addons.size();++i) { CAddonDatabase database; database.Open(); CDateTime lastUpdate = database.GetRepoTimestamp(addons[i]->ID()); if (force || !lastUpdate.IsValid() || lastUpdate + CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGDEBUG,"Checking repositories for updates (triggered by %s)",addons[i]->Name().c_str()); m_repoUpdateJob = CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(addons), this); if (wait) { // wait for our job to complete lock.Leave(); CLog::Log(LOGDEBUG, "%s - waiting for this repository update job to finish...", __FUNCTION__); m_repoUpdateDone.Wait(); } return; } } }
bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItemList &items) { items.Clear(); CPluginSource::Content type = CPluginSource::Translate(content); if (type == CPluginSource::UNKNOWN) return false; VECADDONS addons; CAddonMgr::Get().GetAddons(ADDON_PLUGIN, addons); for (unsigned i=0; i<addons.size(); i++) { PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]); if (!plugin || !plugin->Provides(type)) continue; items.Add(FileItemFromAddon(addons[i], "plugin://", true)); } addons.clear(); CAddonMgr::Get().GetAddons(ADDON_SCRIPT, addons); for (unsigned i=0; i<addons.size(); i++) { PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]); if (!plugin || !plugin->Provides(type)) continue; items.Add(FileItemFromAddon(addons[i], "script://", false)); } CFileItemPtr item(new CFileItem("addons://more/"+content,false)); item->SetLabelPreformated(true); item->SetLabel(g_localizeStrings.Get(21452)); item->SetIconImage("DefaultAddon.png"); item->SetSpecialSort(SORT_ON_BOTTOM); items.Add(item); items.SetContent("addons"); return items.Size() > 0; }
bool CAddonMgr::StartServices(const bool beforelogin) { CLog::Log(LOGDEBUG, "ADDON: Starting service addons."); VECADDONS services; if (!GetAddons(ADDON_SERVICE, services)) return false; bool ret = true; for (IVECADDONS it = services.begin(); it != services.end(); ++it) { boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(*it); if (service) { if ( (beforelogin && service->GetStartOption() == CService::STARTUP) || (!beforelogin && service->GetStartOption() == CService::LOGIN) ) ret &= service->Start(); } } return ret; }
void CGUIDialogSubtitles::FillServices() { ClearServices(); VECADDONS addons; ADDON::CAddonMgr::Get().GetAddons(ADDON_SUBTITLE_MODULE, addons, true); if (addons.empty()) { UpdateStatus(NO_SERVICES); return; } std::string defaultService; const CFileItem &item = g_application.CurrentUnstackedItem(); if (item.GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS || item.GetVideoContentType() == VIDEODB_CONTENT_EPISODES) // Set default service for tv shows defaultService = CSettings::Get().GetString("subtitles.tv"); else // Set default service for filemode and movies defaultService = CSettings::Get().GetString("subtitles.movie"); std::string service = addons.front()->ID(); for (VECADDONS::const_iterator addonIt = addons.begin(); addonIt != addons.end(); addonIt++) { CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addonIt, "plugin://", false)); m_serviceItems->Add(item); if ((*addonIt)->ID() == defaultService) service = (*addonIt)->ID(); } // Bind our services to the UI CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_SERVICELIST, 0, 0, m_serviceItems); OnMessage(msg); SetService(service); }
bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItemList &items) { items.Clear(); VECADDONS addons; if (!GetScriptsAndPlugins(content, addons)) return false; for (unsigned i=0; i<addons.size(); i++) { if (addons[i]->Type() == ADDON_PLUGIN) items.Add(FileItemFromAddon(addons[i], "plugin://", true)); else items.Add(FileItemFromAddon(addons[i], "script://", false)); } items.Add(GetMoreItem(content)); items.SetContent("addons"); items.SetLabel(g_localizeStrings.Get(24001)); // Add-ons return items.Size() > 0; }