xbmc
ExtsMimeSupportList.h
1 /*
2  * Copyright (C) 2005-2021 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 "addons/IAddonSupportList.h"
12 #include "threads/CriticalSection.h"
13 
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <utility>
18 #include <vector>
19 
20 namespace ADDON
21 {
22 enum class AddonType;
23 class CAddonMgr;
24 class CAddonInfo;
25 
26 struct AddonEvent;
27 }
28 
29 namespace KODI
30 {
31 namespace ADDONS
32 {
33 
43 {
44 public:
47 
51  enum class FilterSelect
52  {
54  all,
55 
57  hasTags,
58 
60  hasTracks
61  };
62 
66  struct SupportValue
67  {
68  SupportValue(int description, std::string icon)
69  : m_description(description), m_icon(std::move(icon))
70  {
71  }
72 
73  // Description text about supported part
74  int m_description;
75 
76  // Own by addon defined icon path
77  std::string m_icon;
78  };
79 
84  {
85  // Type of stored addon to check on scan
86  ADDON::AddonType m_addonType{};
87 
88  // Related addon info class
89  std::shared_ptr<ADDON::CAddonInfo> m_addonInfo;
90 
91  // Addon his own codec identification name
92  std::string m_codecName;
93 
94  // If as true support addons own song information tags
95  bool m_hasTags{false};
96 
97  // To know addon includes several tracks inside one file, if set to true
98  bool m_hasTracks{false};
99 
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;
104 
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;
109  };
110 
124  std::vector<SupportValues> GetSupportedAddonInfos(FilterSelect select);
125 
132  bool IsExtensionSupported(const std::string& ext);
133 
141  std::vector<std::pair<ADDON::AddonType, std::shared_ptr<ADDON::CAddonInfo>>>
142  GetExtensionSupportedAddonInfos(const std::string& ext, FilterSelect select);
143 
150  bool IsMimetypeSupported(const std::string& mimetype);
151 
159  std::vector<std::pair<ADDON::AddonType, std::shared_ptr<ADDON::CAddonInfo>>>
160  GetMimetypeSupportedAddonInfos(const std::string& mimetype, FilterSelect select);
161 
170  std::vector<KODI::ADDONS::AddonSupportEntry> GetSupportedExtsAndMimeTypes(
171  const std::string& addonId) override;
172 
173 protected:
174  void Update(const std::string& id);
175  void OnEvent(const ADDON::AddonEvent& event);
176 
177  static SupportValues ScanAddonProperties(ADDON::AddonType type,
178  const std::shared_ptr<ADDON::CAddonInfo>& addonInfo);
179 
180  CCriticalSection m_critSection;
181 
182  std::vector<SupportValues> m_supportedList;
183  ADDON::CAddonMgr& m_addonMgr;
184 };
185 
186 } /* namespace ADDONS */
187 } /* namespace KODI */
Class - CAddonMgr Holds references to all addons, enabled or otherwise.
Definition: AddonManager.h:79
Structure to store available data for related addon.
Definition: ExtsMimeSupportList.h:83
Class to manage all available and activated add-ons and to release their types to the outside for sel...
Definition: ExtsMimeSupportList.h:42
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: AddonEvents.h:18
Structure to store information about supported part.
Definition: ExtsMimeSupportList.h:66
FilterSelect
Filter selection values.
Definition: ExtsMimeSupportList.h:51
Definition: Addon.cpp:39
Parent class to manage all available mimetypes and file extensions of the respective add-on and its t...
Definition: IAddonSupportList.h:61