本文整理汇总了C++中addon::VECADDONS::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ VECADDONS::empty方法的具体用法?C++ VECADDONS::empty怎么用?C++ VECADDONS::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类addon::VECADDONS
的用法示例。
在下文中一共展示了VECADDONS::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRequest
int CHTTPWebinterfaceAddonsHandler::HandleRequest()
{
m_responseData = ADDON_HEADER;
ADDON::VECADDONS addons;
if (!ADDON::CAddonMgr::GetInstance().GetAddons(addons, ADDON::ADDON_WEB_INTERFACE) || addons.empty())
{
m_response.type = HTTPError;
m_response.status = MHD_HTTP_INTERNAL_SERVER_ERROR;
return MHD_YES;
}
for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
m_responseData += "<li><a href=/addons/" + (*addon)->ID() + "/>" + (*addon)->Name() + "</a></li>\n";
m_responseData += "</ul>\n</body></html>";
m_responseRange.SetData(m_responseData.c_str(), m_responseData.size());
m_response.type = HTTPMemoryDownloadNoFreeCopy;
m_response.status = MHD_HTTP_OK;
m_response.contentType = "text/html";
m_response.totalLength = m_responseData.size();
return MHD_YES;
}
示例2: 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;
}