本文整理汇总了C++中ADDONDEPS::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ADDONDEPS::size方法的具体用法?C++ ADDONDEPS::size怎么用?C++ ADDONDEPS::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADDONDEPS
的用法示例。
在下文中一共展示了ADDONDEPS::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Install
bool CAddonInstallJob::Install(const std::string &installFrom, const AddonPtr& repo)
{
SetText(g_localizeStrings.Get(24079));
ADDONDEPS deps = m_addon->GetDeps();
unsigned int totalSteps = static_cast<unsigned int>(deps.size());
if (ShouldCancel(0, totalSteps))
return false;
// The first thing we do is install dependencies
for (ADDONDEPS::iterator it = deps.begin(); it != deps.end(); ++it)
{
if (it->first != "xbmc.metadata")
{
const std::string &addonID = it->first;
const AddonVersion &version = it->second.first;
bool optional = it->second.second;
AddonPtr dependency;
bool haveAddon = CAddonMgr::GetInstance().GetAddon(addonID, dependency, ADDON_UNKNOWN, false);
if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
{
// we have it but our version isn't good enough, or we don't have it and we need it
// dependency is already queued up for install - ::Install will fail
// instead we wait until the Job has finished. note that we
// recall install on purpose in case prior installation failed
if (CAddonInstaller::GetInstance().HasJob(addonID))
{
while (CAddonInstaller::GetInstance().HasJob(addonID))
Sleep(50);
if (!CAddonMgr::GetInstance().IsAddonInstalled(addonID))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
// don't have the addon or the addon isn't new enough - grab it (no new job for these)
else if (IsModal())
{
RepositoryPtr repoForDep;
AddonPtr addon;
std::string hash;
if (!CAddonInstaller::GetRepoForAddon(addonID, repoForDep) ||
!CAddonInstallJob::GetAddonWithHash(addonID, repoForDep->ID(), addon, hash))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to find dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
CAddonInstallJob dependencyJob(addon, repoForDep, hash);
// pass our progress indicators to the temporary job and don't allow it to
// show progress or information updates (no progress, title or text changes)
dependencyJob.SetProgressIndicators(GetProgressBar(), GetProgressDialog(), false, false);
if (!dependencyJob.DoModal())
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
else if (!CAddonInstaller::GetInstance().InstallOrUpdate(addonID, false))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
}
if (ShouldCancel(std::distance(deps.begin(), it), totalSteps))
return false;
}
SetText(g_localizeStrings.Get(24086));
SetProgress(0);
// now that we have all our dependencies, we can install our add-on
if (repo != NULL)
{
CFileItemList dummy;
std::string s = StringUtils::Format("plugin://%s/?action=install&package=%s&version=%s", repo->ID().c_str(),
m_addon->ID().c_str(), m_addon->Version().asString().c_str());
if (!CDirectory::GetDirectory(s, dummy))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: installation of repository failed", m_addon->ID().c_str());
ReportInstallError(m_addon->ID(), m_addon->ID());
return false;
}
}
else
{
std::string addonFolder = installFrom;
URIUtils::RemoveSlashAtEnd(addonFolder);
addonFolder = URIUtils::AddFileToFolder("special://home/addons/", URIUtils::GetFileName(addonFolder));
//.........这里部分代码省略.........
示例2: Install
bool CAddonInstallJob::Install(const std::string &installFrom, const AddonPtr& repo)
{
SetText(g_localizeStrings.Get(24079));
ADDONDEPS deps = m_addon->GetDeps();
unsigned int totalSteps = static_cast<unsigned int>(deps.size());
if (ShouldCancel(0, totalSteps))
return false;
// The first thing we do is install dependencies
for (ADDONDEPS::iterator it = deps.begin(); it != deps.end(); ++it)
{
if (it->first != "xbmc.metadata")
{
const std::string &addonID = it->first;
const AddonVersion &version = it->second.first;
bool optional = it->second.second;
AddonPtr dependency;
bool haveAddon = CAddonMgr::GetInstance().GetAddon(addonID, dependency, ADDON_UNKNOWN, false);
if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
{
// we have it but our version isn't good enough, or we don't have it and we need it
// dependency is already queued up for install - ::Install will fail
// instead we wait until the Job has finished. note that we
// recall install on purpose in case prior installation failed
if (CAddonInstaller::GetInstance().HasJob(addonID))
{
while (CAddonInstaller::GetInstance().HasJob(addonID))
Sleep(50);
if (!CAddonMgr::GetInstance().IsAddonInstalled(addonID))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
// don't have the addon or the addon isn't new enough - grab it (no new job for these)
else if (IsModal())
{
RepositoryPtr repoForDep;
AddonPtr addon;
std::string hash;
if (!CAddonInstallJob::GetAddonWithHash(addonID, repoForDep, addon, hash))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to find dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
CAddonInstallJob dependencyJob(addon, repoForDep, hash, false);
// pass our progress indicators to the temporary job and don't allow it to
// show progress or information updates (no progress, title or text changes)
dependencyJob.SetProgressIndicators(GetProgressBar(), GetProgressDialog(), false, false);
if (!dependencyJob.DoModal())
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
else if (!CAddonInstaller::GetInstance().InstallOrUpdate(addonID, false))
{
CLog::Log(LOGERROR, "CAddonInstallJob[%s]: failed to install dependency %s", m_addon->ID().c_str(), addonID.c_str());
ReportInstallError(m_addon->ID(), m_addon->ID(), g_localizeStrings.Get(24085));
return false;
}
}
}
if (ShouldCancel(std::distance(deps.begin(), it), totalSteps))
return false;
}
SetText(g_localizeStrings.Get(24086));
SetProgress(0);
CFilesystemInstaller fsInstaller;
if (!fsInstaller.InstallToFilesystem(installFrom, m_addon->ID()))
{
ReportInstallError(m_addon->ID(), m_addon->ID());
return false;
}
SetProgress(100);
return true;
}