本文整理汇总了C++中CAddonDatabase::GetAddons方法的典型用法代码示例。如果您正苦于以下问题:C++ CAddonDatabase::GetAddons方法的具体用法?C++ CAddonDatabase::GetAddons怎么用?C++ CAddonDatabase::GetAddons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAddonDatabase
的用法示例。
在下文中一共展示了CAddonDatabase::GetAddons方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, vector<string> &addonIDs, bool showNone /* = false */, bool showDetails /* = true */, bool multipleSelection /* = true */, bool showInstalled /* = true */, bool showInstallable /* = false */, bool showMore /* = true */)
{
// if we shouldn't show neither installed nor installable addons the list will be empty
if (!showInstalled && !showInstallable)
return 0;
// can't show the "Get More" button if we already show installable addons
if (showInstallable)
showMore = false;
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return 0;
// get rid of any invalid addon types
vector<ADDON::TYPE> validTypes(types.size());
std::copy_if(types.begin(), types.end(), validTypes.begin(), [](ADDON::TYPE type) { return type != ADDON_UNKNOWN; });
if (validTypes.empty())
return 0;
// get all addons to show
VECADDONS addons;
if (showInstalled)
{
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
VECADDONS typeAddons;
if (*type == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio", typeAddons);
else if (*type == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable", typeAddons);
else if (*type == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image", typeAddons);
else if (*type == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video", typeAddons);
else
CAddonMgr::Get().GetAddons(*type, typeAddons);
addons.insert(addons.end(), typeAddons.begin(), typeAddons.end());
}
}
if (showInstallable || showMore)
{
VECADDONS installableAddons;
CAddonDatabase database;
if (database.Open() && database.GetAddons(installableAddons))
{
for (ADDON::IVECADDONS addon = installableAddons.begin(); addon != installableAddons.end();)
{
AddonPtr pAddon = *addon;
// check if the addon matches one of the provided addon types
bool matchesType = false;
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
if (pAddon->IsType(*type))
{
matchesType = true;
break;
}
}
// only show addons that match one of the provided addon types and that aren't disabled
if (matchesType && !CAddonMgr::Get().IsAddonDisabled(pAddon->ID()))
{
// check if the addon is installed
bool isInstalled = CAddonMgr::Get().IsAddonInstalled(pAddon->ID());
// check if the addon is installed or can be installed
if ((showInstallable || showMore) && !isInstalled && CAddonMgr::Get().CanAddonBeInstalled(pAddon))
{
++addon;
continue;
}
}
addon = installableAddons.erase(addon);
}
if (showInstallable)
addons.insert(addons.end(), installableAddons.begin(), installableAddons.end());
else if (showMore)
showMore = !installableAddons.empty();
}
}
if (addons.empty() && !showNone)
return 0;
// turn the addons into items
std::map<std::string, AddonPtr> addonMap;
CFileItemList items;
for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addon, (*addon)->ID()));
if (!items.Contains(item->GetPath()))
{
items.Add(item);
//.........这里部分代码省略.........
示例2: GetDirectory
bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CStdString path1(strPath);
URIUtils::RemoveSlashAtEnd(path1);
CURL path(path1);
items.ClearProperties();
items.SetContent("addons");
VECADDONS addons;
// get info from repository
bool reposAsFolders = true;
if (path.GetHostName().Equals("enabled"))
{
CAddonMgr::Get().GetAllAddons(addons, true);
items.SetProperty("reponame",g_localizeStrings.Get(24062));
items.SetLabel(g_localizeStrings.Get(24062));
}
else if (path.GetHostName().Equals("disabled"))
{ // grab all disabled addons, including disabled repositories
reposAsFolders = false;
CAddonMgr::Get().GetAllAddons(addons, false, true);
items.SetProperty("reponame",g_localizeStrings.Get(24039));
items.SetLabel(g_localizeStrings.Get(24039));
}
else if (path.GetHostName().Equals("outdated"))
{
reposAsFolders = false;
CAddonMgr::Get().GetAllOutdatedAddons(addons);
items.SetProperty("reponame",g_localizeStrings.Get(24043));
items.SetLabel(g_localizeStrings.Get(24043));
}
else if (path.GetHostName().Equals("repos"))
{
CAddonMgr::Get().GetAddons(ADDON_REPOSITORY,addons,true);
items.SetLabel(g_localizeStrings.Get(24033)); // Get Add-ons
}
else if (path.GetHostName().Equals("sources"))
{
return GetScriptsAndPlugins(path.GetFileName(), items);
}
else if (path.GetHostName().Equals("all"))
{
CAddonDatabase database;
database.Open();
database.GetAddons(addons);
items.SetProperty("reponame",g_localizeStrings.Get(24032));
items.SetLabel(g_localizeStrings.Get(24032));
}
else if (path.GetHostName().Equals("search"))
{
CStdString search(path.GetFileName());
if (search.IsEmpty() && !GetKeyboardInput(16017, search))
return false;
items.SetProperty("reponame",g_localizeStrings.Get(283));
items.SetLabel(g_localizeStrings.Get(283));
CAddonDatabase database;
database.Open();
database.Search(search, addons);
GenerateListing(path, addons, items, true);
path.SetFileName(search);
items.SetPath(path.Get());
return true;
}
else
{
reposAsFolders = false;
AddonPtr addon;
CAddonMgr::Get().GetAddon(path.GetHostName(),addon);
if (!addon)
return false;
// ensure our repos are up to date
CAddonInstaller::Get().UpdateRepos(false, true);
CAddonDatabase database;
database.Open();
database.GetRepository(addon->ID(),addons);
items.SetProperty("reponame",addon->Name());
items.SetLabel(addon->Name());
}
if (path.GetFileName().IsEmpty())
{
if (!path.GetHostName().Equals("repos"))
{
for (int i=ADDON_UNKNOWN+1;i<ADDON_VIZ_LIBRARY;++i)
{
for (unsigned int j=0;j<addons.size();++j)
{
if (addons[j]->IsType((TYPE)i))
{
CFileItemPtr item(new CFileItem(TranslateType((TYPE)i,true)));
item->SetPath(URIUtils::AddFileToFolder(strPath,TranslateType((TYPE)i,false)));
item->m_bIsFolder = true;
CStdString thumb = GetIcon((TYPE)i);
if (!thumb.IsEmpty() && g_TextureManager.HasTexture(thumb))
item->SetArt("thumb", thumb);
//.........这里部分代码省略.........
示例3: SetLanguage
bool CLangInfo::SetLanguage(bool& fallback, const std::string &strLanguage /* = "" */, bool reloadServices /* = true */)
{
fallback = false;
std::string language = strLanguage;
if (language.empty())
{
language = CSettings::GetInstance().GetString(CSettings::SETTING_LOCALE_LANGUAGE);
if (language.empty())
{
CLog::Log(LOGFATAL, "CLangInfo: cannot load empty language.");
return false;
}
}
LanguageResourcePtr languageAddon = GetLanguageAddon(language);
if (languageAddon == NULL)
{
CLog::Log(LOGWARNING, "CLangInfo: unable to load language \"%s\". Trying to determine matching language addon...", language.c_str());
// we may have to fall back to the default language
std::string defaultLanguage = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_LOCALE_LANGUAGE))->GetDefault();
std::string newLanguage = defaultLanguage;
// try to determine a language addon matching the given language in name
if (!ADDON::CLanguageResource::FindLanguageAddonByName(language, newLanguage))
{
CLog::Log(LOGWARNING, "CLangInfo: unable to find an installed language addon matching \"%s\". Trying to find an installable language...", language.c_str());
bool foundMatchingAddon = false;
CAddonDatabase addondb;
if (addondb.Open())
{
// update the addon repositories to check if there's a matching language addon available for download
CAddonInstaller::GetInstance().UpdateRepos(true, true);
ADDON::VECADDONS languageAddons;
if (addondb.GetAddons(languageAddons, ADDON::ADDON_RESOURCE_LANGUAGE) && !languageAddons.empty())
{
// try to get the proper language addon by its name from all available language addons
if (ADDON::CLanguageResource::FindLanguageAddonByName(language, newLanguage, languageAddons))
{
if (CAddonInstaller::GetInstance().Install(newLanguage, true, "", false, false))
{
CLog::Log(LOGINFO, "CLangInfo: successfully installed language addon \"%s\" matching current language \"%s\"", newLanguage.c_str(), language.c_str());
foundMatchingAddon = true;
}
else
CLog::Log(LOGERROR, "CLangInfo: failed to installed language addon \"%s\" matching current language \"%s\"", newLanguage.c_str(), language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: unable to match old language \"%s\" to any available language addon", language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: no language addons available to match against \"%s\"", language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: unable to open addon database to look for a language addon matching \"%s\"", language.c_str());
// if the new language matches the default language we are loading the
// default language as a fallback
if (!foundMatchingAddon && newLanguage == defaultLanguage)
{
CLog::Log(LOGINFO, "CLangInfo: fall back to the default language \"%s\"", defaultLanguage.c_str());
fallback = true;
}
}
if (!CSettings::GetInstance().SetString(CSettings::SETTING_LOCALE_LANGUAGE, newLanguage))
return false;
CSettings::GetInstance().Save();
return true;
}
CLog::Log(LOGINFO, "CLangInfo: loading %s language information...", language.c_str());
if (!Load(language))
{
CLog::LogF(LOGFATAL, "CLangInfo: failed to load %s language information", language.c_str());
return false;
}
CLog::Log(LOGINFO, "CLangInfo: loading %s language strings...", language.c_str());
if (!g_localizeStrings.Load(GetLanguagePath(), language))
{
CLog::LogF(LOGFATAL, "CLangInfo: failed to load %s language strings", language.c_str());
return false;
}
if (reloadServices)
{
// also tell our weather and skin to reload as these are localized
g_weatherManager.Refresh();
g_PVRManager.LocalizationChanged();
CApplicationMessenger::GetInstance().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "ReloadSkin");
}
return true;
}