Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
ADDON::CAddonDatabase Class Reference

#include <AddonDatabase.h>

Inheritance diagram for ADDON::CAddonDatabase:
CDatabase

Classes

struct  RepoUpdateData
 

Public Member Functions

 CAddonDatabase ()
 
 ~CAddonDatabase () override
 
bool Open () override
 
bool GetAddon (const std::string &addonID, const ADDON::CAddonVersion &version, const std::string &repoId, ADDON::AddonPtr &addon)
 Get an addon with a specific version and repository.
 
bool GetDisabled (std::map< std::string, ADDON::AddonDisabledReason > &addons)
 
bool FindByAddonId (const std::string &addonId, ADDON::VECADDONS &addons) const
 
bool UpdateRepositoryContent (const std::string &repositoryId, const ADDON::CAddonVersion &version, const std::string &checksum, const std::vector< AddonInfoPtr > &addons)
 
int GetRepoChecksum (const std::string &id, std::string &checksum)
 
bool GetRepositoryContent (const std::string &id, ADDON::VECADDONS &addons) const
 Get addons in repository id
 
bool GetRepositoryContent (ADDON::VECADDONS &addons) const
 
int SetRepoUpdateData (const std::string &id, const RepoUpdateData &updateData)
 Set data concerning repository update (last/next date etc.), and create the repo if needed.
 
RepoUpdateData GetRepoUpdateData (const std::string &id)
 Retrieve repository update data (last/next date etc.)
 
bool Search (const std::string &search, ADDON::VECADDONS &items)
 
bool DisableAddon (const std::string &addonID, ADDON::AddonDisabledReason disabledReason)
 Disable an addon. Sets a flag that this addon has been disabled. If disabled, it is usually still available on disk.
 
bool EnableAddon (const std::string &addonID)
 Enable an addon. Enables an addon that has previously been disabled.
 
bool AddUpdateRuleForAddon (const std::string &addonID, ADDON::AddonUpdateRule updateRule)
 Write dataset with addon-id and rule to the db.
 
bool RemoveAllUpdateRulesForAddon (const std::string &addonID)
 Remove all rule datasets for an addon-id from the db.
 
bool RemoveUpdateRuleForAddon (const std::string &addonID, AddonUpdateRule updateRule)
 Remove a single rule dataset for an addon-id from the db.
 
bool GetAddonUpdateRules (std::map< std::string, std::vector< AddonUpdateRule > > &rulesMap) const
 Retrieve all rule datasets from db and store them into map.
 
bool AddPackage (const std::string &addonID, const std::string &packageFileName, const std::string &hash)
 Store an addon's package filename and that file's hash for future verification.
 
bool GetPackageHash (const std::string &addonID, const std::string &packageFileName, std::string &hash)
 Query the MD5 checksum of the given given addon's given package.
 
bool RemovePackage (const std::string &packageFileName)
 Remove a package's info from the database.
 
void OnPostUnInstall (const std::string &addonId)
 
void SyncInstalled (const std::set< std::string > &ids, const std::set< std::string > &system, const std::set< std::string > &optional)
 
bool SetLastUpdated (const std::string &addonId, const CDateTime &dateTime)
 
bool SetOrigin (const std::string &addonId, const std::string &origin)
 
bool SetLastUsed (const std::string &addonId, const CDateTime &dateTime)
 
void GetInstallData (const ADDON::AddonInfoPtr &addon)
 
bool AddInstalledAddon (const std::shared_ptr< CAddonInfo > &addon, const std::string &origin)
 Add dataset for a new installed addon to the database.
 
- Public Member Functions inherited from CDatabase
 CDatabase ()
 
virtual ~CDatabase (void)
 
bool IsOpen ()
 
virtual void Close ()
 
bool Compress (bool bForce=true)
 
void Interrupt ()
 
bool Open (const DatabaseSettings &db)
 
void BeginTransaction ()
 
virtual bool CommitTransaction ()
 
void RollbackTransaction ()
 
void CopyDB (const std::string &latestDb)
 
void DropAnalytics ()
 
std::string PrepareSQL (std::string strStmt,...) const
 
std::string GetSingleValue (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single value from a table.
 
std::string GetSingleValue (const std::string &query) const
 
std::string GetSingleValue (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single value from a query on a dataset.
 
int GetSingleValueInt (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single integer value from a table.
 
int GetSingleValueInt (const std::string &query) const
 
int GetSingleValueInt (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single integer value from a query on a dataset.
 
bool DeleteValues (const std::string &strTable, const Filter &filter=Filter())
 Delete values from a table.
 
bool ExecuteQuery (const std::string &strQuery)
 Execute a query that does not return any result. Note that if BeginMultipleExecute() has been called, the query will be queued until CommitMultipleExecute() is called.
 
bool ResultQuery (const std::string &strQuery) const
 Execute a query that returns a result.
 
bool BeginMultipleExecute ()
 Start a multiple execution queue. Any ExecuteQuery() function following this call will be queued rather than executed until CommitMultipleExecute() is performed. NOTE: Queries that rely on any queued execute query will not function as expected during this period!
 
bool CommitMultipleExecute ()
 Commit the multiple execution queue to the database. Queries are performed within a transaction, and the transaction is rolled back should any one query fail.
 
bool QueueInsertQuery (const std::string &strQuery)
 Put an INSERT or REPLACE query in the queue.
 
bool CommitInsertQueries ()
 Commit all queries in the queue.
 
size_t GetInsertQueriesCount ()
 Get the number of INSERT queries in the queue.
 
bool QueueDeleteQuery (const std::string &strQuery)
 Put a DELETE query in the queue.
 
bool CommitDeleteQueries ()
 Commit all queued DELETE queries.
 
size_t GetDeleteQueriesCount ()
 Get the number of DELETE queries in the queue.
 
virtual bool GetFilter (CDbUrl &dbUrl, Filter &filter, SortDescription &sorting)
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl)
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl, SortDescription &sorting)
 
bool Connect (const std::string &dbName, const DatabaseSettings &db, bool create)
 

Protected Member Functions

void CreateTables () override
 
void CreateAnalytics () override
 
void UpdateTables (int version) override
 
int GetMinSchemaVersion () const override
 
int GetSchemaVersion () const override
 
const char * GetBaseDBName () const override
 
bool GetAddon (int id, ADDON::AddonPtr &addon)
 
void DeleteRepository (const std::string &id)
 
void DeleteRepositoryContents (const std::string &id)
 
int GetRepositoryId (const std::string &addonId)
 
- Protected Member Functions inherited from CDatabase
void Split (const std::string &strFileNameAndPath, std::string &strPath, std::string &strFileName)
 
bool CreateDatabase ()
 Create database tables and analytics as needed. Calls CreateTables() and CreateAnalytics() on child classes.
 
int GetDBVersion ()
 
bool BuildSQL (const std::string &strQuery, const Filter &filter, std::string &strSQL) const
 

Additional Inherited Members

- Protected Attributes inherited from CDatabase
bool m_sqlite
 whether we use sqlite (defaults to true)
 
std::unique_ptr< dbiplus::Databasem_pDB
 
std::unique_ptr< dbiplus::Datasetm_pDS
 
std::unique_ptr< dbiplus::Datasetm_pDS2
 
const CProfileManagerm_profileManager
 

Constructor & Destructor Documentation

◆ CAddonDatabase()

CAddonDatabase::CAddonDatabase ( )
default

◆ ~CAddonDatabase()

CAddonDatabase::~CAddonDatabase ( )
overridedefault

Member Function Documentation

◆ AddInstalledAddon()

bool CAddonDatabase::AddInstalledAddon ( const std::shared_ptr< CAddonInfo > & addon,
const std::string & origin )

Add dataset for a new installed addon to the database.

Parameters
addonthe addon to insert
originthe origin it was installed from
Returns
true on success, false otherwise

◆ AddPackage()

bool CAddonDatabase::AddPackage ( const std::string & addonID,
const std::string & packageFileName,
const std::string & hash )

Store an addon's package filename and that file's hash for future verification.

Parameters
addonIDid of the addon we're adding a package for
packageFileNamefilename of the package
hashMD5 checksum of the package
Returns
Whether or not the info successfully made it into the DB.
See also
GetPackageHash, RemovePackage

◆ AddUpdateRuleForAddon()

bool CAddonDatabase::AddUpdateRuleForAddon ( const std::string & addonID,
ADDON::AddonUpdateRule updateRule )

Write dataset with addon-id and rule to the db.

Parameters
addonIDthe addonID
updateRulethe rule value to be written
Returns
true on success, false otherwise

◆ CreateAnalytics()

void CAddonDatabase::CreateAnalytics ( )
overrideprotectedvirtual

Implements CDatabase.

◆ CreateTables()

void CAddonDatabase::CreateTables ( )
overrideprotectedvirtual

Implements CDatabase.

◆ DeleteRepository()

void CAddonDatabase::DeleteRepository ( const std::string & id)
protected

◆ DeleteRepositoryContents()

void CAddonDatabase::DeleteRepositoryContents ( const std::string & id)
protected

◆ DisableAddon()

bool CAddonDatabase::DisableAddon ( const std::string & addonID,
ADDON::AddonDisabledReason disabledReason )

Disable an addon. Sets a flag that this addon has been disabled. If disabled, it is usually still available on disk.

Parameters
addonIDid of the addon to disable
disabledReasonthe reason why the addon is being disabled
Returns
true on success, false on failure
See also
IsAddonDisabled, HasDisabledAddons, EnableAddon

◆ EnableAddon()

bool CAddonDatabase::EnableAddon ( const std::string & addonID)

Enable an addon. Enables an addon that has previously been disabled.

Parameters
addonIDid of the addon to enable
Returns
true on success, false on failure
See also
DisableAddon, IsAddonDisabled, HasDisabledAddons

◆ FindByAddonId()

bool CAddonDatabase::FindByAddonId ( const std::string & addonId,
ADDON::VECADDONS & addons ) const

Returns all addons in the repositories with id addonId.

◆ GetAddon() [1/2]

bool CAddonDatabase::GetAddon ( const std::string & addonID,
const ADDON::CAddonVersion & version,
const std::string & repoId,
ADDON::AddonPtr & addon )

Get an addon with a specific version and repository.

◆ GetAddon() [2/2]

bool CAddonDatabase::GetAddon ( int id,
ADDON::AddonPtr & addon )
protected

◆ GetAddonUpdateRules()

bool CAddonDatabase::GetAddonUpdateRules ( std::map< std::string, std::vector< AddonUpdateRule > > & rulesMap) const

Retrieve all rule datasets from db and store them into map.

Parameters
rulesMaptarget map
Returns
true on success, false otherwise

◆ GetBaseDBName()

const char * ADDON::CAddonDatabase::GetBaseDBName ( ) const
inlineoverrideprotectedvirtual

Implements CDatabase.

◆ GetDisabled()

bool CAddonDatabase::GetDisabled ( std::map< std::string, ADDON::AddonDisabledReason > & addons)

Get the addon IDs that have been set to disabled

◆ GetInstallData()

void CAddonDatabase::GetInstallData ( const ADDON::AddonInfoPtr & addon)

◆ GetMinSchemaVersion()

int CAddonDatabase::GetMinSchemaVersion ( ) const
overrideprotectedvirtual

Reimplemented from CDatabase.

◆ GetPackageHash()

bool CAddonDatabase::GetPackageHash ( const std::string & addonID,
const std::string & packageFileName,
std::string & hash )

Query the MD5 checksum of the given given addon's given package.

Parameters
addonIDid of the addon we're who's package we're querying
packageFileNamefilename of the package
hashreturn the MD5 checksum of the package
Returns
Whether or not we found a hash for the given addon's given package
See also
AddPackage, RemovePackage

◆ GetRepoChecksum()

int CAddonDatabase::GetRepoChecksum ( const std::string & id,
std::string & checksum )

◆ GetRepositoryContent() [1/2]

bool CAddonDatabase::GetRepositoryContent ( ADDON::VECADDONS & addons) const

Get addons across all repositories

◆ GetRepositoryContent() [2/2]

bool CAddonDatabase::GetRepositoryContent ( const std::string & id,
ADDON::VECADDONS & addons ) const

Get addons in repository id

Parameters
idid of the repository
Returns
true on success, false on error or if repository have never been synced.

◆ GetRepositoryId()

int CAddonDatabase::GetRepositoryId ( const std::string & addonId)
protected

◆ GetRepoUpdateData()

CAddonDatabase::RepoUpdateData CAddonDatabase::GetRepoUpdateData ( const std::string & id)

Retrieve repository update data (last/next date etc.)

Parameters
idadd-on id of the repo
Returns
update data of the repository

◆ GetSchemaVersion()

int CAddonDatabase::GetSchemaVersion ( ) const
overrideprotectedvirtual

Implements CDatabase.

◆ OnPostUnInstall()

void CAddonDatabase::OnPostUnInstall ( const std::string & addonId)

Clear internal fields that shouldn't be kept around indefinitely

Todo
should be done before uninstall to avoid any race conditions

◆ Open()

bool CAddonDatabase::Open ( )
overridevirtual

Reimplemented from CDatabase.

◆ RemoveAllUpdateRulesForAddon()

bool CAddonDatabase::RemoveAllUpdateRulesForAddon ( const std::string & addonID)

Remove all rule datasets for an addon-id from the db.

Parameters
addonIDthe addonID
Returns
true on success, false otherwise

◆ RemovePackage()

bool CAddonDatabase::RemovePackage ( const std::string & packageFileName)

Remove a package's info from the database.

Parameters
packageFileNamefilename of the package
Returns
Whether or not we succeeded in removing the package
See also
AddPackage, GetPackageHash

◆ RemoveUpdateRuleForAddon()

bool CAddonDatabase::RemoveUpdateRuleForAddon ( const std::string & addonID,
AddonUpdateRule updateRule )

Remove a single rule dataset for an addon-id from the db.

Note
specifying AddonUpdateRule::ANY will remove all rules. use RemoveAllUpdateRulesForAddon() instead
Parameters
addonIDthe addonID
updateRulethe rule to remove
Returns
true on success, false otherwise

◆ Search()

bool CAddonDatabase::Search ( const std::string & search,
ADDON::VECADDONS & items )

◆ SetLastUpdated()

bool CAddonDatabase::SetLastUpdated ( const std::string & addonId,
const CDateTime & dateTime )

◆ SetLastUsed()

bool CAddonDatabase::SetLastUsed ( const std::string & addonId,
const CDateTime & dateTime )

◆ SetOrigin()

bool CAddonDatabase::SetOrigin ( const std::string & addonId,
const std::string & origin )

◆ SetRepoUpdateData()

int CAddonDatabase::SetRepoUpdateData ( const std::string & id,
const RepoUpdateData & updateData )

Set data concerning repository update (last/next date etc.), and create the repo if needed.

Parameters
idadd-on id of the repository
updateDataupdate data to set
Returns
id of the repository, or -1 on error.

◆ SyncInstalled()

void CAddonDatabase::SyncInstalled ( const std::set< std::string > & ids,
const std::set< std::string > & system,
const std::set< std::string > & optional )

◆ UpdateRepositoryContent()

bool CAddonDatabase::UpdateRepositoryContent ( const std::string & repositoryId,
const ADDON::CAddonVersion & version,
const std::string & checksum,
const std::vector< AddonInfoPtr > & addons )

◆ UpdateTables()

void CAddonDatabase::UpdateTables ( int version)
overrideprotectedvirtual

Reimplemented from CDatabase.


The documentation for this class was generated from the following files: