kodi
AddonUpdateRules.h
1 /*
2  * Copyright (C) 2005-2020 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/CriticalSection.h"
12 
13 #include <map>
14 #include <string>
15 #include <vector>
16 
17 namespace ADDON
18 {
19 
20 class CAddonDatabase;
21 
22 enum class AddonUpdateRule;
23 
30 {
31 public:
32  /* \brief Refresh addon update rules map from the database
33  * \param db database connection
34  * \return true on success, false otherwise
35  */
36  bool RefreshRulesMap(const CAddonDatabase& db);
37 
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
41  */
42  bool IsAutoUpdateable(const std::string& id) const;
43 
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
49  */
50  bool AddUpdateRuleToList(CAddonDatabase& db, const std::string& id, AddonUpdateRule updateRule);
51 
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
57  */
58  bool RemoveUpdateRuleFromList(CAddonDatabase& db,
59  const std::string& id,
60  AddonUpdateRule updateRule);
61 
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
66  */
67  bool RemoveAllUpdateRulesFromList(CAddonDatabase& db, const std::string& id);
68 
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()
75  */
76  bool IsUpdateableByRule(const std::string& id, AddonUpdateRule updateRule) const;
77 
78  /* \brief Executor for @ref RemoveUpdateRuleFromList() and @ref RemoveAllUpdateRulesFromList()
79  */
80  bool RemoveFromUpdateRuleslist(CAddonDatabase& db,
81  const std::string& id,
82  AddonUpdateRule updateRule);
83 
84  mutable CCriticalSection m_critSection;
85  std::map<std::string, std::vector<AddonUpdateRule>> m_updateRules;
86 };
87 
88 }; /* namespace ADDON */
Definition: AddonDatabase.h:61
Class - CAddonUpdateRules Manages information about the updateability of addons by defining and handl...
Definition: AddonUpdateRules.h:29
Definition: Addon.cpp:39