本文整理汇总了C++中CAddonDatabase类的典型用法代码示例。如果您正苦于以下问题:C++ CAddonDatabase类的具体用法?C++ CAddonDatabase怎么用?C++ CAddonDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAddonDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnInstall
void CGUIDialogAddonInfo::OnInstall()
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return;
if (m_localAddon || !m_item->HasAddonInfo())
return;
std::string addonId = m_item->GetAddonInfo()->ID();
std::vector<std::pair<AddonVersion, std::string>> versions;
CAddonDatabase database;
if (!database.Open() || !database.GetAvailableVersions(addonId, versions) || versions.empty())
{
CLog::Log(LOGERROR, "ADDON: no available versions of %s", addonId.c_str());
return;
}
int i = versions.size() == 1 ? 0 : AskForVersion(versions);
if (i != -1)
{
Close();
CAddonInstaller::GetInstance().Install(addonId, versions[i].first, versions[i].second);
}
}
示例2: GrabRollbackVersions
void CGUIDialogAddonInfo::GrabRollbackVersions()
{
CFileItemList items;
XFILE::CDirectory::GetDirectory("special://home/addons/packages/",items,".zip",DIR_FLAG_NO_FILE_DIRS);
items.Sort(SortByLabel, SortOrderAscending);
CAddonDatabase db;
db.Open();
for (int i=0;i<items.Size();++i)
{
if (items[i]->m_bIsFolder)
continue;
std::string ID, version;
AddonVersion::SplitFileName(ID,version,items[i]->GetLabel());
if (ID == m_localAddon->ID())
{
std::string hash, path(items[i]->GetPath());
if (db.GetPackageHash(m_localAddon->ID(), path, hash))
{
std::string md5 = CUtil::GetFileMD5(path);
if (md5 == hash)
m_rollbackVersions.push_back(version);
else /* The package has been corrupted */
{
CLog::Log(LOGWARNING, "%s: Removing corrupt addon package %s.", __FUNCTION__, path.c_str());
CFile::Delete(path);
db.RemovePackage(path);
}
}
}
}
}
示例3: OnRollback
void CGUIDialogAddonInfo::OnRollback()
{
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)
{
CStdString label(m_rollbackVersions[i]);
if (m_rollbackVersions[i].Equals(m_localAddon->Version().c_str()))
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]);
CStdString path = "special://home/addons/packages/";
path += m_localAddon->ID()+"-"+m_rollbackVersions[choice]+".zip";
// needed as cpluff won't downgrade
if (!m_localAddon->IsType(ADDON_SERVICE))
//we will handle this for service addons in CAddonInstallJob::OnPostInstall
CAddonMgr::Get().RemoveAddon(m_localAddon->ID());
CAddonInstaller::Get().InstallFromZip(path);
database.RemoveAddonFromBlacklist(m_localAddon->ID(),m_rollbackVersions[choice]);
Close();
}
}
示例4: OnPostUnInstall
void CAddonUnInstallJob::OnPostUnInstall()
{
if (m_addon->Type() == ADDON_REPOSITORY)
{
CAddonDatabase database;
database.Open();
database.DeleteRepository(m_addon->ID());
}
bool bSave(false);
CFileItemList items;
XFILE::CFavouritesDirectory::Load(items);
for (int i=0; i < items.Size(); ++i)
{
if (items[i]->GetPath().find(m_addon->ID()) != std::string::npos)
{
items.Remove(items[i].get());
bSave = true;
}
}
if (bSave)
CFavouritesDirectory::Save(items);
if (m_addon->Type() == ADDON_PVRDLL)
{
if (CSettings::Get().GetBool("pvrmanager.enabled"))
PVR::CPVRManager::Get().Start(true);
}
}
示例5: ClearFavourites
bool CAddonUnInstallJob::DoWork()
{
ADDON::OnPreUnInstall(m_addon);
//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)));
CAddonMgr::GetInstance().OnPostUnInstall(m_addon->ID());
database.OnPostUnInstall(m_addon->ID());
ADDON::OnPostUnInstall(m_addon);
return true;
}
示例6: Install
bool CAddonInstaller::Install(const std::string &addonID, bool force, const std::string &referer, bool background)
{
AddonPtr addon;
bool addonInstalled = CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false);
if (addonInstalled && !force)
return true;
if (referer.empty())
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return false;
}
// check whether we have it available in a repository
CAddonDatabase database;
database.Open();
if (database.GetAddon(addonID, addon))
{
std::string repo;
database.GetRepoForAddon(addonID,repo);
AddonPtr ptr;
CAddonMgr::Get().GetAddon(repo,ptr);
RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(ptr);
std::string hash;
if (therepo)
hash = therepo->GetAddonHash(addon);
return DoInstall(addon, hash, addonInstalled, referer, background);
}
return false;
}
示例7: OnUninstall
void CGUIDialogAddonInfo::OnUninstall()
{
if (!m_localAddon.get())
return;
// ensure the addon is not a dependency of other installed addons
VECADDONS addons;
CStdStringArray deps;
CAddonMgr::Get().GetAllAddons(addons);
for (VECADDONS::iterator it = addons.begin();
it != addons.end();++it)
{
if ((*it)->GetDeps().find(m_localAddon->ID()) != (*it)->GetDeps().end())
deps.push_back((*it)->Name());
}
if (!CAddonInstaller::Get().CheckDependencies(m_localAddon) && deps.size())
{
CStdString strLine0, strLine1;
StringUtils::JoinString(deps, ", ", strLine1);
strLine0.Format(g_localizeStrings.Get(24046), m_localAddon->Name().c_str());
CGUIDialogOK::ShowAndGetInput(24037, strLine0, strLine1, 24047);
return;
}
// ensure the addon isn't disabled in our database
CAddonDatabase database;
database.Open();
database.DisableAddon(m_localAddon->ID(), false);
CJobManager::GetInstance().AddJob(new CAddonUnInstallJob(m_localAddon),
&CAddonInstaller::Get());
CAddonMgr::Get().RemoveAddon(m_localAddon->ID());
Close();
}
示例8: assert
bool CAddonInstaller::CheckDependencies(const AddonPtr &addon)
{
assert(addon.get());
ADDONDEPS deps = addon->GetDeps();
CAddonDatabase database;
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());
return false;
}
}
// at this point we have our dep, so check that it's OK as well
// TODO: should we assume that installed deps are OK?
if (!CheckDependencies(dep))
return false;
}
return true;
}
示例9: OnPreInstall
bool CAddonInstallJob::OnPreInstall()
{
// check whether this is an active skin - we need to unload it if so
if (g_guiSettings.GetString("lookandfeel.skin") == m_addon->ID())
{
CApplicationMessenger::Get().ExecBuiltIn("UnloadSkin", true);
return true;
}
if (m_addon->Type() == ADDON_SERVICE)
{
CAddonDatabase database;
database.Open();
bool running = !database.IsAddonDisabled(m_addon->ID()); //grab a current state
database.DisableAddon(m_addon->ID(),false); // enable it so we can remove it??
// regrab from manager to have the correct path set
AddonPtr addon;
ADDON::CAddonMgr::Get().GetAddon(m_addon->ID(), addon);
boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(addon);
if (service)
service->Stop();
CAddonMgr::Get().RemoveAddon(m_addon->ID()); // remove it
return running;
}
if (m_addon->Type() == ADDON_PVRDLL)
{
// stop the pvr manager, so running pvr add-ons are stopped and closed
PVR::CPVRManager::Get().Stop();
}
return false;
}
示例10: FileItemFromAddon
void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemList &items, bool reposAsFolders)
{
CStdString xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc/addons");
items.ClearItems();
CAddonDatabase db;
db.Open();
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 (db.IsOpen() && db.IsAddonDisabled(addon->ID()))
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);
}
db.Close();
}
示例11: 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);
g_application.m_guiDialogKaiToast.QueueNotification(
addon->Icon(),
addon->Name(),
g_localizeStrings.Get(addon2 ? 113 : 114),
TOAST_DISPLAY_TIME, false);
}
else
{
g_application.m_guiDialogKaiToast.QueueNotification(
CGUIDialogKaiToast::Error,
fileName,
g_localizeStrings.Get(114),
TOAST_DISPLAY_TIME, false);
}
}
示例12: InstallGameClient
bool CRetroPlayerDialogs::InstallGameClient(const string &strId, const CFileItem &file, GameClientPtr &result)
{
// First, make sure the game client isn't installed
CLog::Log(LOGDEBUG, "RetroPlayer: Trying to install game client %s", strId.c_str());
AddonPtr addon;
bool installed = CAddonMgr::Get().GetAddon(strId, addon, ADDON_GAMEDLL, false);
if (installed && addon)
return false;
// Now make sure it exists in a remote repository
CAddonDatabase database;
if (database.Open() && database.GetAddon(strId, addon))
{
GameClientPtr gc = boost::dynamic_pointer_cast<CGameClient>(addon);
if (gc && gc->CanOpen(file))
{
CLog::Log(LOGDEBUG, "RetroPlayer: Installing game client %s", strId.c_str());
addon.reset();
if (CAddonInstaller::Get().PromptForInstall(strId, addon))
{
gc = boost::dynamic_pointer_cast<CGameClient>(addon);
if (gc)
{
result = gc;
return true;
}
}
}
}
return false;
}
示例13: InstallModal
bool CAddonInstaller::InstallModal(const std::string &addonID, ADDON::AddonPtr &addon, bool promptForInstall /* = true */)
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return false;
// we assume that addons that are enabled don't get to this routine (i.e. that GetAddon() has been called)
if (CAddonMgr::GetInstance().GetAddon(addonID, addon, ADDON_UNKNOWN, false))
return false; // addon is installed but disabled, and the user has specifically activated something that needs
// the addon - should we enable it?
// check we have it available
CAddonDatabase database;
database.Open();
if (!database.GetAddon(addonID, addon))
return false;
// if specified ask the user if he wants it installed
if (promptForInstall)
{
if (HELPERS::ShowYesNoDialogLines(CVariant{24076}, CVariant{24100}, CVariant{addon->Name()}, CVariant{24101}) !=
DialogResponse::YES)
{
return false;
}
}
if (!InstallOrUpdate(addonID, false, true))
return false;
return CAddonMgr::GetInstance().GetAddon(addonID, addon);
}
示例14: OnPostUnInstall
void CAddonUnInstallJob::OnPostUnInstall()
{
if (m_addon->Type() == ADDON_REPOSITORY)
{
CAddonDatabase database;
database.Open();
database.DeleteRepository(m_addon->ID());
}
}
示例15: GetSources
VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
{
m_sources.clear();
// we always have some enabled addons
{
CMediaSource share;
share.strPath = "addons://enabled/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24062);
m_sources.push_back(share);
}
CAddonDatabase db;
if (db.Open() && db.HasDisabledAddons())
{
CMediaSource share;
share.strPath = "addons://disabled/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24039);
m_sources.push_back(share);
}
if (CAddonMgr::Get().HasOutdatedAddons())
{
CMediaSource share;
share.strPath = "addons://outdated/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24043);
m_sources.push_back(share);
}
if (CAddonMgr::Get().HasAddons(ADDON_REPOSITORY,true))
{
CMediaSource share;
share.strPath = "addons://repos/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24033);
m_sources.push_back(share);
}
// add "install from zip"
{
CMediaSource share;
share.strPath = "addons://install/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24041);
m_sources.push_back(share);
}
// add "search"
{
CMediaSource share;
share.strPath = "addons://search/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(137);
m_sources.push_back(share);
}
return CGUIViewState::GetSources();
}