Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / xbmc / addons / AddonUpdateRules.h
blob1538b748cb7e85b3f86ad744b78ae4a1c865deb6
1 /*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "threads/CriticalSection.h"
13 #include <map>
14 #include <string>
15 #include <vector>
17 namespace ADDON
20 class CAddonDatabase;
22 enum class AddonUpdateRule;
24 /**
25 * Class - CAddonUpdateRules
26 * Manages information about the updateability of addons by defining
27 * and handling certain rules.
29 class CAddonUpdateRules
31 public:
32 /* \brief Refresh addon update rules map from the database
33 * \param db database connection
34 * \return true on success, false otherwise
36 bool RefreshRulesMap(const CAddonDatabase& db);
38 /* \brief Check if an addon version is auto updateable
39 * \param id addon id to be checked
40 * \return true is addon is auto updateable, false otherwise
42 bool IsAutoUpdateable(const std::string& id) const;
44 /* \brief Add a single rule to the update rules list for an addon
45 * \param db database connection
46 * \param id addon-id to set rule for
47 * \param the rule to set
48 * \return true on success, false otherwise
50 bool AddUpdateRuleToList(CAddonDatabase& db, const std::string& id, AddonUpdateRule updateRule);
52 /* \brief Remove a single rule from the update rules list for an addon
53 * \param db database connection
54 * \param id addon-id to remove rule for
55 * \param the rule to remove
56 * \return true on success, false otherwise
58 bool RemoveUpdateRuleFromList(CAddonDatabase& db,
59 const std::string& id,
60 AddonUpdateRule updateRule);
62 /* \brief Remove all rules from the update rules list for an addon
63 * \param db database connection
64 * \param id addon-id to remove rules for
65 * \return true on success, false otherwise
67 bool RemoveAllUpdateRulesFromList(CAddonDatabase& db, const std::string& id);
69 private:
70 /* \brief Checks if an addon version is updateable with a specific rule
71 * \param id addon id to be checked
72 * \param updateRule the rule to check for
73 * \return true is addon is updateable by that updateRule, false otherwise
74 * \sa CAddonUpdateRules::IsAutoUpdateable()
76 bool IsUpdateableByRule(const std::string& id, AddonUpdateRule updateRule) const;
78 /* \brief Executor for @ref RemoveUpdateRuleFromList() and @ref RemoveAllUpdateRulesFromList()
80 bool RemoveFromUpdateRuleslist(CAddonDatabase& db,
81 const std::string& id,
82 AddonUpdateRule updateRule);
84 mutable CCriticalSection m_critSection;
85 std::map<std::string, std::vector<AddonUpdateRule>> m_updateRules;
88 }; /* namespace ADDON */