Skip to content

Commit

Permalink
addons: extend CAddonDatabase::GetAddons() to support getting addons …
Browse files Browse the repository at this point in the history
…of a specific type
  • Loading branch information
Montellese committed Mar 6, 2015
1 parent afe4c91 commit 7659f21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion xbmc/addons/AddonDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,26 @@ bool CAddonDatabase::GetAddon(int id, AddonPtr &addon)
return false;
}

bool CAddonDatabase::GetAddons(VECADDONS& addons)
bool CAddonDatabase::GetAddons(VECADDONS& addons, const ADDON::TYPE &type /* = ADDON::ADDON_UNKNOWN */)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS2.get()) return false;

std::string sql = PrepareSQL("select distinct addonID from addon");
if (type != ADDON_UNKNOWN)
{
std::string strType;
if (type >= ADDON_VIDEO && type <= ADDON_EXECUTABLE)
strType = TranslateType(ADDON_PLUGIN);
else
strType = TranslateType(type);

if (!strType.empty())
sql += PrepareSQL(" where type = '%s'", strType.c_str());
}

m_pDS->query(sql.c_str());
while (!m_pDS->eof())
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/AddonDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CAddonDatabase : public CDatabase

int AddAddon(const ADDON::AddonPtr& item, int idRepo);
bool GetAddon(const std::string& addonID, ADDON::AddonPtr& addon);
bool GetAddons(ADDON::VECADDONS& addons);
bool GetAddons(ADDON::VECADDONS& addons, const ADDON::TYPE &type = ADDON::ADDON_UNKNOWN);

/*! \brief grab the (largest) add-on version for an add-on */
ADDON::AddonVersion GetAddonVersion(const std::string &id);
Expand Down

0 comments on commit 7659f21

Please sign in to comment.