aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Amland <thomas.amland@gmail.com>2015-09-30 10:57:21 +0200
committerThomas Amland <thomas.amland@gmail.com>2015-10-17 13:22:12 +0200
commitb02c6c9962a59bef6a4765703a838fef85feaddd (patch)
tree96bb3c26267c40323d89a4663790fdd65fcfe044
parentdbb628e10a615e50506331d9232c9a3fe51c1619 (diff)
[addons] remove unused methods and database column for blacklisting
-rw-r--r--xbmc/addons/AddonDatabase.cpp38
-rw-r--r--xbmc/addons/AddonDatabase.h6
2 files changed, 13 insertions, 31 deletions
diff --git a/xbmc/addons/AddonDatabase.cpp b/xbmc/addons/AddonDatabase.cpp
index 6a56efeef9..f2a0083707 100644
--- a/xbmc/addons/AddonDatabase.cpp
+++ b/xbmc/addons/AddonDatabase.cpp
@@ -74,7 +74,7 @@ void CAddonDatabase::CreateTables()
m_pDS->exec("CREATE TABLE broken (id integer primary key, addonID text, reason text)\n");
CLog::Log(LOGINFO, "create blacklist table");
- m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
+ m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text)\n");
CLog::Log(LOGINFO, "create package table");
m_pDS->exec("CREATE TABLE package (id integer primary key, addonID text, filename text, hash text)\n");
@@ -116,6 +116,13 @@ void CAddonDatabase::UpdateTables(int version)
{
m_pDS->exec("CREATE TABLE system (id integer primary key, addonID text)\n");
}
+ if (version < 20)
+ {
+ m_pDS->exec("CREATE TABLE tmp (id INTEGER PRIMARY KEY, addonID TEXT)");
+ m_pDS->exec("INSERT INTO tmp (addonID) SELECT addonID FROM blacklist GROUP BY addonID");
+ m_pDS->exec("DROP TABLE blacklist");
+ m_pDS->exec("ALTER TABLE tmp RENAME TO blacklist");
+ }
}
int CAddonDatabase::GetAddonId(const ADDON::AddonPtr& item)
@@ -805,57 +812,36 @@ bool CAddonDatabase::HasDisabledAddons()
bool CAddonDatabase::BlacklistAddon(const std::string& addonID)
{
- return BlacklistAddon(addonID, "");
-}
-
-bool CAddonDatabase::BlacklistAddon(const std::string& addonID,
- const std::string& version)
-{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
- std::string sql = PrepareSQL("INSERT OR REPLACE INTO blacklist(id, addonID, version) "
- "VALUES(NULL, '%s', '%s')", addonID.c_str(), version.c_str());
+ std::string sql = PrepareSQL("INSERT INTO blacklist(id, addonID) VALUES(NULL, '%s')", addonID.c_str());
m_pDS->exec(sql);
-
return true;
}
catch (...)
{
- CLog::Log(LOGERROR, "%s failed on addon '%s' for version '%s'", __FUNCTION__, addonID.c_str(),version.c_str());
+ CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonID.c_str());
}
return false;
}
-bool CAddonDatabase::IsAddonBlacklisted(const std::string& addonID,
- const std::string& version)
-{
- std::string where = PrepareSQL("addonID='%s' and (version='%s' OR version='')",addonID.c_str(),version.c_str());
- return !GetSingleValue("blacklist","addonID",where).empty();
-}
-
bool CAddonDatabase::RemoveAddonFromBlacklist(const std::string& addonID)
{
- return RemoveAddonFromBlacklist(addonID, "");
-}
-
-bool CAddonDatabase::RemoveAddonFromBlacklist(const std::string& addonID,
- const std::string& version)
-{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
- std::string sql = PrepareSQL("delete from blacklist where addonID='%s' and version='%s'",addonID.c_str(),version.c_str());
+ std::string sql = PrepareSQL("DELETE FROM blacklist WHERE addonID='%s'", addonID.c_str());
m_pDS->exec(sql);
return true;
}
catch (...)
{
- CLog::Log(LOGERROR, "%s failed on addon '%s' for version '%s'", __FUNCTION__, addonID.c_str(),version.c_str());
+ CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonID.c_str());
}
return false;
}
diff --git a/xbmc/addons/AddonDatabase.h b/xbmc/addons/AddonDatabase.h
index 9328a40a58..021fb497dc 100644
--- a/xbmc/addons/AddonDatabase.h
+++ b/xbmc/addons/AddonDatabase.h
@@ -117,11 +117,7 @@ public:
std::string IsAddonBroken(const std::string &addonID);
bool BlacklistAddon(const std::string& addonID);
- bool BlacklistAddon(const std::string& addonID, const std::string& version);
- bool IsAddonBlacklisted(const std::string& addonID, const std::string& version);
bool RemoveAddonFromBlacklist(const std::string& addonID);
- bool RemoveAddonFromBlacklist(const std::string& addonID,
- const std::string& version);
bool GetBlacklisted(std::vector<std::string>& addons);
/*! \brief Store an addon's package filename and that file's hash for future verification
@@ -166,7 +162,7 @@ protected:
virtual void CreateAnalytics();
virtual void UpdateTables(int version);
virtual int GetMinSchemaVersion() const { return 15; }
- virtual int GetSchemaVersion() const { return 19; }
+ virtual int GetSchemaVersion() const { return 20; }
const char *GetBaseDBName() const { return "Addons"; }
bool GetAddon(int id, ADDON::AddonPtr& addon);