2 * Copyright (C) 2005-2021 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.
11 #include "addons/IAddonSupportList.h"
12 #include "threads/CriticalSection.h"
35 * @brief Class to manage all available and activated add-ons and
36 * to release their types to the outside for selection.
38 * @note It may also make sense in the future to expand this class and design it
39 * globally in Kodi so that other addons can also be managed with it (all which
40 * have mimetypes and file extensions, e.g. vfs, audioencoder).
42 class CExtsMimeSupportList
: public KODI::ADDONS::IAddonSupportList
45 CExtsMimeSupportList(ADDON::CAddonMgr
& addonMgr
);
46 ~CExtsMimeSupportList();
49 * @brief Filter selection values.
51 enum class FilterSelect
53 /*! To select all available */
56 /*! To select only them where support tags */
59 /*! Get only where support tracks within */
64 * @brief Structure to store information about supported part.
68 SupportValue(int description
, std::string icon
)
69 : m_description(description
), m_icon(std::move(icon
))
73 // Description text about supported part
76 // Own by addon defined icon path
81 * @brief Structure to store available data for related addon.
85 // Type of stored addon to check on scan
86 ADDON::AddonType m_addonType
{};
88 // Related addon info class
89 std::shared_ptr
<ADDON::CAddonInfo
> m_addonInfo
;
91 // Addon his own codec identification name
92 std::string m_codecName
;
94 // If as true support addons own song information tags
95 bool m_hasTags
{false};
97 // To know addon includes several tracks inside one file, if set to true
98 bool m_hasTracks
{false};
100 // List of supported file extensions by addon
101 // First: Extension name
102 // Second: With @ref SupportValue defined content
103 std::map
<std::string
, SupportValue
> m_supportedExtensions
;
105 // List of supported mimetypes by addon
106 // First: Mimetype name
107 // Second: With @ref SupportValue defined content
108 std::map
<std::string
, SupportValue
> m_supportedMimetypes
;
112 * @brief Get list of all by audiodecoder supported parts.
114 * Thought to use on planned new window about management about supported
115 * extensions and mimetypes in Kodi and to allow edit by user to enable or
116 * disable corresponding parts.
118 * This function is also used to notify Kodi supported formats and to allow
121 * @param[in] select To filter the listed information by type
122 * @return List of the available types listed for the respective add-on
124 std::vector
<SupportValues
> GetSupportedAddonInfos(FilterSelect select
);
127 * @brief To query the desired file extension is supported in it.
129 * @param[in] ext Extension name to check
130 * @return True if within supported, false if not
132 bool IsExtensionSupported(const std::string
& ext
);
135 * @brief To get a list of all compatible audio decoder add-ons for the file extension.
137 * @param[in] ext Extension name to check
138 * @param[in] select To filter the listed information by type
139 * @return List of @ref ADDON::CAddonInfo where support related extension
141 std::vector
<std::pair
<ADDON::AddonType
, std::shared_ptr
<ADDON::CAddonInfo
>>>
142 GetExtensionSupportedAddonInfos(const std::string
& ext
, FilterSelect select
);
145 * @brief To query the desired file mimetype is supported in it.
147 * @param[in] mimetype Mimetype name to check
148 * @return True if within supported, false if not
150 bool IsMimetypeSupported(const std::string
& mimetype
);
153 * @brief To get a list of all compatible audio decoder add-ons for the mimetype.
155 * @param[in] mimetype Mimetype name to check
156 * @param[in] select To filter the listed information by type
157 * @return List of @ref ADDON::CAddonInfo where support related mimetype
159 std::vector
<std::pair
<ADDON::AddonType
, std::shared_ptr
<ADDON::CAddonInfo
>>>
160 GetMimetypeSupportedAddonInfos(const std::string
& mimetype
, FilterSelect select
);
163 * @brief To give all file extensions and MIME types supported by the addon.
165 * @param[in] addonId Identifier about wanted addon
166 * @return List of all supported parts on selected addon
168 * @sa KODI::ADDONS::IAddonSupportList
170 std::vector
<KODI::ADDONS::AddonSupportEntry
> GetSupportedExtsAndMimeTypes(
171 const std::string
& addonId
) override
;
174 void Update(const std::string
& id
);
175 void OnEvent(const ADDON::AddonEvent
& event
);
177 static SupportValues
ScanAddonProperties(ADDON::AddonType type
,
178 const std::shared_ptr
<ADDON::CAddonInfo
>& addonInfo
);
180 CCriticalSection m_critSection
;
182 std::vector
<SupportValues
> m_supportedList
;
183 ADDON::CAddonMgr
& m_addonMgr
;
186 } /* namespace ADDONS */
187 } /* namespace KODI */