Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Providers.h
1/*
2 * Copyright (C) 2005-2018 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 "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr.h"
13#include "../../tools/StringUtils.h"
14
15//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
16// "C++" Definitions group 2 - PVR provider
17#ifdef __cplusplus
18
19namespace kodi
20{
21namespace addon
22{
23
24//==============================================================================
39class PVRProvider : public DynamicCStructHdl<PVRProvider, PVR_PROVIDER>
40{
41 friend class CInstancePVRClient;
42
43public:
45 PVRProvider() = default;
46 PVRProvider(const PVRProvider& provider) : DynamicCStructHdl(provider) {}
62
65
68 void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; }
69
71 unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; }
72
75 void SetName(const std::string& name)
76 {
77 ReallocAndCopyString(&m_cStructure->strName, name.c_str());
78 }
79
81 std::string GetName() const { return m_cStructure->strName ? m_cStructure->strName : ""; }
82
97 void SetType(PVR_PROVIDER_TYPE type) { m_cStructure->type = type; }
98
100 PVR_PROVIDER_TYPE GetType() const { return m_cStructure->type; }
101
104 void SetIconPath(const std::string& iconPath)
105 {
106 ReallocAndCopyString(&m_cStructure->strIconPath, iconPath.c_str());
107 }
108
110 std::string GetIconPath() const
111 {
112 return m_cStructure->strIconPath ? m_cStructure->strIconPath : "";
113 }
115
120 void SetCountries(const std::vector<std::string>& countries)
121 {
122 ReallocAndCopyString(
123 &m_cStructure->strCountries,
125 }
126
128 std::vector<std::string> GetCountries() const
129 {
130 if (m_cStructure->strCountries)
132 else
133 return {};
134 }
136
141 void SetLanguages(const std::vector<std::string>& languages)
142 {
143 ReallocAndCopyString(
144 &m_cStructure->strLanguages,
146 }
147
149 std::vector<std::string> GetLanguages() const
150 {
151 if (m_cStructure->strLanguages)
153 else
154 return {};
155 }
157
158 static void AllocResources(const PVR_PROVIDER* source, PVR_PROVIDER* target)
159 {
160 target->strName = AllocAndCopyString(source->strName);
161 target->strIconPath = AllocAndCopyString(source->strIconPath);
162 target->strCountries = AllocAndCopyString(source->strCountries);
163 target->strLanguages = AllocAndCopyString(source->strLanguages);
164 }
165
166 static void FreeResources(PVR_PROVIDER* target)
167 {
168 FreeString(target->strName);
169 FreeString(target->strIconPath);
170 FreeString(target->strCountries);
171 FreeString(target->strLanguages);
172 }
173
174private:
175 PVRProvider(const PVR_PROVIDER* provider) : DynamicCStructHdl(provider) {}
176 PVRProvider(PVR_PROVIDER* provider) : DynamicCStructHdl(provider) {}
177};
179//------------------------------------------------------------------------------
180
181//==============================================================================
189{
190public:
192 PVRProvidersResultSet() = delete;
193 PVRProvidersResultSet(const AddonInstance_PVR* instance, PVR_HANDLE handle)
194 : m_instance(instance), m_handle(handle)
195 {
196 }
201
205 void Add(const kodi::addon::PVRProvider& provider)
206 {
207 m_instance->toKodi->TransferProviderEntry(m_instance->toKodi->kodiInstance, m_handle, provider);
208 }
209
211
212private:
213 const AddonInstance_PVR* m_instance = nullptr;
214 const PVR_HANDLE m_handle;
215};
217//------------------------------------------------------------------------------
218
219} /* namespace addon */
220} /* namespace kodi */
221
222#endif /* __cplusplus */
Definition AddonBase.h:288
Definition Providers.h:40
std::vector< std::string > GetLanguages() const
To get with SetLanguages changed values.
Definition Providers.h:149
void SetLanguages(const std::vector< std::string > &languages)
optional The language codes for the provider.
Definition Providers.h:141
void SetCountries(const std::vector< std::string > &countries)
optional The country codes for the provider.
Definition Providers.h:120
std::vector< std::string > GetCountries() const
To get with SetCountries changed values.
Definition Providers.h:128
Definition Providers.h:189
PVR_PROVIDER_TYPE
Definition pvr_providers.h:47
PVR_PROVIDER_TYPE GetType() const
To get with SetType changed values.
Definition Providers.h:100
void SetIconPath(const std::string &iconPath)
optional Path to the provider icon (if present).
Definition Providers.h:104
void SetName(const std::string &name)
required Name given to this provider.
Definition Providers.h:75
std::string GetName() const
To get with SetName changed values.
Definition Providers.h:81
void SetType(PVR_PROVIDER_TYPE type)
optional Provider type.
Definition Providers.h:97
std::string GetIconPath() const
To get with SetIconPath changed values.
Definition Providers.h:110
void SetUniqueId(unsigned int uniqueId)
required Unique identifier for this provider.
Definition Providers.h:68
unsigned int GetUniqueId() const
To get with SetUniqueId changed values.
Definition Providers.h:71
void Add(const kodi::addon::PVRProvider &provider)
To add and give content from addon to Kodi on related call.
Definition Providers.h:205
#define PROVIDER_STRING_TOKEN_SEPARATOR
Separator to use in strings containing different tokens, for example country and language.
Definition pvr_providers.h:36
static std::vector< std::string > Split(const std::string &input, const std::string &delimiter, unsigned int iMaxStrings=0)
Splits the given input string using the given delimiter into separate strings.
Definition StringUtils.h:2527
static std::string Join(const CONTAINER &strings, const std::string &delimiter)
Concatenates the elements of a specified array or the members of a collection and uses the specified ...
Definition StringUtils.h:2485
Definition pvr.h:362
"C" PVR add-on provider.
Definition pvr_providers.h:80
const char * strCountries
ISO 3166 country codes, separated by PROVIDER_STRING_TOKEN_SEPARATOR (e.g 'GB,IE,FR,...
Definition pvr_providers.h:87
const char * strLanguages
RFC 5646 language codes, separated by PROVIDER_STRING_TOKEN_SEPARATOR (e.g. 'en_GB,...
Definition pvr_providers.h:90