本文整理汇总了C++中CAddonDatabase::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ CAddonDatabase::Open方法的具体用法?C++ CAddonDatabase::Open怎么用?C++ CAddonDatabase::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAddonDatabase
的用法示例。
在下文中一共展示了CAddonDatabase::Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Install
void CAddonInstaller::Install(const std::string& addonId, const AddonVersion& version, const std::string& repoId)
{
CLog::Log(LOGDEBUG, "CAddonInstaller: installing '%s' version '%s' from repository '%s'",
addonId.c_str(), version.asString().c_str(), repoId.c_str());
AddonPtr addon;
CAddonDatabase database;
if (!database.Open() || !database.GetAddon(addonId, version, repoId, addon))
return;
AddonPtr repo;
if (!CAddonMgr::GetInstance().GetAddon(repoId, repo, ADDON_REPOSITORY))
return;
std::string hash;
if (!std::static_pointer_cast<CRepository>(repo)->GetAddonHash(addon, hash))
return;
DoInstall(addon, std::static_pointer_cast<CRepository>(repo), hash, true, false);
}
示例2: GetInstallList
void CAddonInstaller::GetInstallList(VECADDONS &addons) const
{
CSingleLock lock(m_critSection);
std::vector<std::string> addonIDs;
for (JobMap::const_iterator i = m_downloadJobs.begin(); i != m_downloadJobs.end(); ++i)
{
if (i->second.jobID)
addonIDs.push_back(i->first);
}
lock.Leave();
CAddonDatabase database;
database.Open();
for (std::vector<std::string>::iterator it = addonIDs.begin(); it != addonIDs.end(); ++it)
{
AddonPtr addon;
if (database.GetAddon(*it, addon))
addons.push_back(addon);
}
}
示例3: OnEnable
void CGUIDialogAddonInfo::OnEnable(bool enable)
{
if (!m_localAddon.get())
return;
CStdString xbmcPath = _P("special://xbmc/addons");
CAddonDatabase database;
database.Open();
if (m_localAddon->Type() == ADDON_PVRDLL && m_localAddon->Path().Left(xbmcPath.size()).Equals(xbmcPath))
database.EnableSystemPVRAddon(m_localAddon->ID(), enable);
else
database.DisableAddon(m_localAddon->ID(), !enable);
if (m_localAddon->Type() == ADDON_PVRDLL && enable)
g_application.StartPVRManager();
SetItem(m_item);
UpdateControls();
g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
}
示例4: LastUpdated
CDateTime CRepositoryUpdater::LastUpdated() const
{
VECADDONS repos;
if (!CAddonMgr::GetInstance().GetAddons(ADDON_REPOSITORY, repos) || 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());
}
示例5: UpdateRepos
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;
}
}
}
示例6: DoWork
bool CAddonUnInstallJob::DoWork()
{
ADDON::OnPreUnInstall(m_addon);
//TODO: looks broken. it just calls the repo with the most recent version, not the owner
RepositoryPtr repoPtr;
CAddonInstaller::GetRepoForAddon(m_addon->ID(), repoPtr);
if (repoPtr != NULL && !repoPtr->Props().libname.empty())
{
CFileItemList dummy;
std::string s = StringUtils::Format("plugin://%s/?action=uninstall&package=%s", repoPtr->ID().c_str(), m_addon->ID().c_str());
if (!CDirectory::GetDirectory(s, dummy))
return false;
}
else
{
//Unregister addon with the manager to ensure nothing tries
//to interact with it while we are uninstalling.
CAddonMgr::GetInstance().UnregisterAddon(m_addon->ID());
if (!DeleteAddon(m_addon->Path()))
{
CLog::Log(LOGERROR, "CAddonUnInstallJob[%s]: could not delete addon data.", m_addon->ID().c_str());
return false;
}
}
ClearFavourites();
AddonPtr addon;
CAddonDatabase database;
// try to get the addon object from the repository as the local one does not exist anymore
// if that doesn't work fall back to the local one
if (!database.Open() || !database.GetAddon(m_addon->ID(), addon) || addon == NULL)
addon = m_addon;
CEventLog::GetInstance().Add(EventPtr(new CAddonManagementEvent(addon, 24144)));
ADDON::OnPostUnInstall(m_addon);
return true;
}
示例7: OnRollback
void CGUIDialogAddonInfo::OnRollback()
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return;
CGUIDialogContextMenu* dlg = (CGUIDialogContextMenu*)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
CAddonDatabase database;
database.Open();
CContextButtons buttons;
for (unsigned int i=0;i<m_rollbackVersions.size();++i)
{
std::string label(m_rollbackVersions[i]);
if (m_rollbackVersions[i] == m_localAddon->Version().asString())
label += " "+g_localizeStrings.Get(24094);
if (database.IsAddonBlacklisted(m_localAddon->ID(),label))
label += " "+g_localizeStrings.Get(24095);
buttons.Add(i,label);
}
int choice;
if ((choice=dlg->ShowAndGetChoice(buttons)) > -1)
{
// blacklist everything newer
for (unsigned int j=choice+1;j<m_rollbackVersions.size();++j)
database.BlacklistAddon(m_localAddon->ID(),m_rollbackVersions[j]);
std::string path = "special://home/addons/packages/";
path += m_localAddon->ID()+"-"+m_rollbackVersions[choice]+".zip";
//FIXME: this is probably broken
// needed as cpluff won't downgrade
if (!m_localAddon->IsType(ADDON_SERVICE))
//we will handle this for service addons in CAddonInstallJob::OnPostInstall
CAddonMgr::Get().UnregisterAddon(m_localAddon->ID());
CAddonInstaller::Get().InstallFromZip(path);
database.RemoveAddonFromBlacklist(m_localAddon->ID(),m_rollbackVersions[choice]);
Close();
}
}
示例8: CheckDependencies
bool CAddonInstaller::CheckDependencies(const AddonPtr &addon,
std::vector<std::string>& preDeps, CAddonDatabase &database)
{
if (!addon.get())
return true; // a NULL addon has no dependencies
ADDONDEPS deps = addon->GetDeps();
database.Open();
for (ADDONDEPS::const_iterator i = deps.begin(); i != deps.end(); ++i)
{
const CStdString &addonID = i->first;
const AddonVersion &version = i->second.first;
bool optional = i->second.second;
AddonPtr dep;
bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dep);
if ((haveAddon && !dep->MeetsVersion(version)) || (!haveAddon && !optional))
{ // we have it but our version isn't good enough, or we don't have it and we need it
if (!database.GetAddon(addonID, dep) || !dep->MeetsVersion(version))
{ // we don't have it in a repo, or we have it but the version isn't good enough, so dep isn't satisfied.
CLog::Log(LOGDEBUG, "Addon %s requires %s version %s which is not available", addon->ID().c_str(), addonID.c_str(), version.c_str());
database.Close();
return false;
}
}
// at this point we have our dep, or the dep is optional (and we don't have it) so check that it's OK as well
// TODO: should we assume that installed deps are OK?
if (dep && std::find(preDeps.begin(), preDeps.end(), dep->ID()) == preDeps.end())
{
if (!CheckDependencies(dep, preDeps, database))
{
database.Close();
return false;
}
preDeps.push_back(dep->ID());
}
}
database.Close();
return true;
}
示例9: ReportInstallError
void CAddonInstallJob::ReportInstallError(const std::string& addonID, const std::string& fileName, const std::string& message /* = "" */)
{
AddonPtr addon;
CAddonDatabase database;
if (database.Open())
{
database.GetAddon(addonID, addon);
database.Close();
}
MarkFinished();
std::string msg = message;
EventPtr activity;
if (addon != NULL)
{
AddonPtr addon2;
CAddonMgr::GetInstance().GetAddon(addonID, addon2);
if (msg.empty())
msg = g_localizeStrings.Get(addon2 != NULL ? 113 : 114);
activity = EventPtr(new CAddonManagementEvent(addon, EventLevelError, msg));
if (IsModal())
CGUIDialogOK::ShowAndGetInput(CVariant{m_addon->Name()}, CVariant{msg});
}
else
{
activity =
EventPtr(new CNotificationEvent(EventLevelError, 24045,
!msg.empty() ? msg : StringUtils::Format(g_localizeStrings.Get(24143).c_str(),
fileName.c_str())));
if (IsModal())
CGUIDialogOK::ShowAndGetInput(CVariant{fileName}, CVariant{msg});
}
CEventLog::GetInstance().Add(activity, !IsModal(), false);
}
示例10: GetRepoForAddon
AddonPtr CAddonInstallJob::GetRepoForAddon(const AddonPtr& addon)
{
AddonPtr repoPtr;
CAddonDatabase database;
if (!database.Open())
return repoPtr;
std::string repo;
if (!database.GetRepoForAddon(addon->ID(), repo))
return repoPtr;
if (!CAddonMgr::GetInstance().GetAddon(repo, repoPtr))
return repoPtr;
if (std::dynamic_pointer_cast<CRepository>(repoPtr) == NULL)
{
repoPtr.reset();
return repoPtr;
}
return repoPtr;
}
示例11: DoWork
bool CAddonUnInstallJob::DoWork()
{
ADDON::OnPreUnInstall(m_addon);
//Unregister addon with the manager to ensure nothing tries
//to interact with it while we are uninstalling.
if (!CAddonMgr::GetInstance().UnloadAddon(m_addon))
{
CLog::Log(LOGERROR, "CAddonUnInstallJob[%s]: failed to unload addon.", m_addon->ID().c_str());
return false;
}
CFilesystemInstaller fsInstaller;
if (!fsInstaller.UnInstallFromFilesystem(m_addon->Path()))
{
CLog::Log(LOGERROR, "CAddonUnInstallJob[%s]: could not delete addon data.", m_addon->ID().c_str());
return false;
}
ClearFavourites();
if (m_removeData)
CFileUtils::DeleteItem("special://profile/addon_data/"+m_addon->ID()+"/", true);
AddonPtr addon;
CAddonDatabase database;
// try to get the addon object from the repository as the local one does not exist anymore
// if that doesn't work fall back to the local one
if (!database.Open() || !database.GetAddon(m_addon->ID(), addon) || addon == NULL)
addon = m_addon;
CEventLog::GetInstance().Add(EventPtr(new CAddonManagementEvent(addon, 24144)));
CAddonMgr::GetInstance().OnPostUnInstall(m_addon->ID());
database.OnPostUnInstall(m_addon->ID());
ADDON::OnPostUnInstall(m_addon);
return true;
}
示例12: ReportInstallError
void CAddonInstallJob::ReportInstallError(const CStdString& addonID,
const CStdString& fileName)
{
AddonPtr addon;
CAddonDatabase database;
database.Open();
database.GetAddon(addonID, addon);
if (addon)
{
AddonPtr addon2;
CAddonMgr::Get().GetAddon(addonID, addon2);
CGUIDialogKaiToast::QueueNotification(addon->Icon(),
addon->Name(),
g_localizeStrings.Get(addon2 ? 113 : 114),
TOAST_DISPLAY_TIME, false);
}
else
{
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error,
fileName,
g_localizeStrings.Get(114),
TOAST_DISPLAY_TIME, false);
}
}
示例13: Install
bool CAddonInstaller::Install(const CStdString &addonID, bool force, const CStdString &referer, bool background)
{
AddonPtr addon;
bool addonInstalled = CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false);
if (addonInstalled && !force)
return true;
// check whether we have it available in a repository
CAddonDatabase database;
database.Open();
if (database.GetAddon(addonID, addon))
{
CStdString repo;
database.GetRepoForAddon(addonID,repo);
AddonPtr ptr;
CAddonMgr::Get().GetAddon(repo,ptr);
RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(ptr);
CStdString hash;
if (therepo)
hash = therepo->GetAddonHash(addon);
return DoInstall(addon, hash, addonInstalled, referer, background);
}
return false;
}
示例14: 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;
}
示例15: DoWork
bool CRepositoryUpdateJob::DoWork()
{
CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[%s] checking for updates.", m_repo->ID().c_str());
CAddonDatabase database;
database.Open();
std::string oldChecksum;
if (database.GetRepoChecksum(m_repo->ID(), oldChecksum) == -1)
oldChecksum = "";
std::string newChecksum;
VECADDONS addons;
auto status = m_repo->FetchIfChanged(oldChecksum, newChecksum, addons);
database.SetLastChecked(m_repo->ID(), m_repo->Version(),
CDateTime::GetCurrentDateTime().GetAsDBDateTime());
MarkFinished();
if (status == CRepository::STATUS_ERROR)
return false;
if (status == CRepository::STATUS_NOT_MODIFIED)
{
CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[%s] checksum not changed.", m_repo->ID().c_str());
return true;
}
//Invalidate art.
{
CTextureDatabase textureDB;
textureDB.Open();
textureDB.BeginMultipleExecute();
for (const auto& addon : addons)
{
AddonPtr oldAddon;
if (database.GetAddon(addon->ID(), oldAddon) && addon->Version() > oldAddon->Version())
{
if (!oldAddon->Icon().empty() || !oldAddon->FanArt().empty() || !oldAddon->Screenshots().empty())
CLog::Log(LOGDEBUG, "CRepository: invalidating cached art for '%s'", addon->ID().c_str());
if (!oldAddon->Icon().empty())
textureDB.InvalidateCachedTexture(oldAddon->Icon());
if (!oldAddon->FanArt().empty())
textureDB.InvalidateCachedTexture(oldAddon->Icon());
for (const auto& path : oldAddon->Screenshots())
textureDB.InvalidateCachedTexture(path);
}
}
textureDB.CommitMultipleExecute();
}
database.UpdateRepositoryContent(m_repo->ID(), m_repo->Version(), newChecksum, addons);
//Notify about broken status changes
for (const auto& addon : addons)
{
AddonPtr localAddon;
if (!CAddonMgr::GetInstance().GetAddon(addon->ID(), localAddon))
continue;
if (localAddon && localAddon->Version() > addon->Version())
//We have a newer version locally
continue;
AddonPtr oldAddon;
database.GetAddon(addon->ID(), oldAddon);
if (database.GetAddonVersion(addon->ID()).first > addon->Version())
//Newer version in db (ie. in a different repo)
continue;
std::string broken = addon->Broken();
bool isBroken = !addon->Broken().empty();
bool isBrokenInDb = oldAddon && !oldAddon->Broken().empty();
if (isBroken && !isBrokenInDb)
{
//newly broken
if (HELPERS::ShowYesNoDialogLines(CVariant{addon->Name()}, CVariant{24096}, CVariant{24097}, CVariant{""})
== DialogResponse::YES)
{
CAddonMgr::GetInstance().DisableAddon(addon->ID());
}
CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[%s] addon '%s' marked broken. reason: \"%s\"",
m_repo->ID().c_str(), addon->ID().c_str(), broken.c_str());
CEventLog::GetInstance().Add(EventPtr(new CAddonManagementEvent(addon, 24096)));
}
else if (!isBroken && isBrokenInDb)
{
//Unbroken
CLog::Log(LOGDEBUG, "CRepositoryUpdateJob[%s] addon '%s' unbroken",
m_repo->ID().c_str(), addon->ID().c_str());
}
}
return true;
}