Skip to content

Commit

Permalink
[addons] dont call normal enable hooks when checking system addons
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Mar 25, 2016
1 parent ec79f5d commit 0edad30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
8 changes: 4 additions & 4 deletions xbmc/addons/AddonDatabase.cpp
Expand Up @@ -187,7 +187,7 @@ void CAddonDatabase::UpdateTables(int version)
}
}

void CAddonDatabase::SyncInstalled(const std::set<std::string>& ids)
void CAddonDatabase::SyncInstalled(const std::set<std::string>& ids, const std::set<std::string>& enabled)
{
try
{
Expand Down Expand Up @@ -217,11 +217,11 @@ void CAddonDatabase::SyncInstalled(const std::set<std::string>& ids)
std::string now = CDateTime::GetCurrentDateTime().GetAsDBDateTime();
BeginMultipleExecute();
for (const auto& id : added)
m_pDS->exec(PrepareSQL("INSERT INTO installed(addonID, enabled, installDate) "
"VALUES('%s', 0, '%s')", id.c_str(), now.c_str()));
ExecuteQuery(PrepareSQL("INSERT INTO installed(addonID, enabled, installDate) "
"VALUES('%s', '%d', '%s')", id.c_str(), enabled.find(id) != enabled.end() ? 1 : 0, now.c_str()));

for (const auto& id : removed)
m_pDS->exec(PrepareSQL("DELETE FROM installed WHERE addonID='%s'", id.c_str()));
ExecuteQuery(PrepareSQL("DELETE FROM installed WHERE addonID='%s'", id.c_str()));
CommitMultipleExecute();
}
catch (...)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/AddonDatabase.h
Expand Up @@ -132,7 +132,7 @@ class CAddonDatabase : public CDatabase
/*! Clear internal fields that shouldn't be kept around indefinitely */
void OnPostUnInstall(const std::string& addonId);

void SyncInstalled(const std::set<std::string>& ids);
void SyncInstalled(const std::set<std::string>& ids, const std::set<std::string>& enabled);

void GetInstalled(std::vector<ADDON::CAddonBuilder>& addons);

Expand Down
23 changes: 9 additions & 14 deletions xbmc/addons/AddonManager.cpp
Expand Up @@ -326,21 +326,18 @@ bool CAddonMgr::Init()
return false;
}

m_database.Open();
if (!m_database.Open())
CLog::Log(LOGFATAL, "ADDONS: Failed to open database");

FindAddonsAndNotify();

//Ensure critical add-ons are installed and enabled
//Ensure required add-ons are installed and enabled
for (const auto& id : m_systemAddons)
{
AddonPtr addon;
if (!GetAddon(id, addon, ADDON_UNKNOWN, false))
if (!GetAddon(id, addon, ADDON_UNKNOWN))
{
CLog::Log(LOGFATAL, "addon '%s' is missing.", id.c_str());
return false;
}
if (!EnableAddon(id))
{
CLog::Log(LOGFATAL, "addon '%s' could not be enabled.", id.c_str());
CLog::Log(LOGFATAL, "addon '%s' not installed or not enabled.", id.c_str());
return false;
}
}
Expand All @@ -361,7 +358,6 @@ void CAddonMgr::DeInit()
m_cpluff->destroy_context(m_cp_context);
m_cpluff.reset();
m_database.Close();
m_disabled.clear();
}

bool CAddonMgr::HasAddons(const TYPE &type)
Expand Down Expand Up @@ -685,7 +681,7 @@ bool CAddonMgr::FindAddons()
for (int i = 0; i < n; ++i)
installed.insert(cp_addons[i]->identifier);
m_cpluff->release_info(m_cp_context, cp_addons);
m_database.SyncInstalled(installed);
m_database.SyncInstalled(installed, m_systemAddons);
}

// Reload caches
Expand Down Expand Up @@ -757,11 +753,10 @@ bool CAddonMgr::IsBlacklisted(const std::string& id) const
bool CAddonMgr::DisableAddon(const std::string& id)
{
CSingleLock lock(m_critSection);
if (m_disabled.find(id) != m_disabled.end())
return true; //already disabled

if (!CanAddonBeDisabled(id))
return false;
if (m_disabled.find(id) != m_disabled.end())
return true; //already disabled
if (!m_database.DisableAddon(id))
return false;
if (!m_disabled.insert(id).second)
Expand Down

0 comments on commit 0edad30

Please sign in to comment.