Kodi Development  20.0
for Binary and Script based Add-Ons
General.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/pvr_general.h"
13 
14 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15 // "C++" Definitions group 1 - General PVR
16 #ifdef __cplusplus
17 
18 namespace kodi
19 {
20 namespace addon
21 {
22 
23 //==============================================================================
34 class PVRTypeIntValue : public CStructHdl<PVRTypeIntValue, PVR_ATTRIBUTE_INT_VALUE>
35 {
36  friend class CInstancePVRClient;
37 
38 public:
40  PVRTypeIntValue(const PVRTypeIntValue& data) : CStructHdl(data) {}
53 
56 
60  PVRTypeIntValue() = default;
61 
66  PVRTypeIntValue(int value, const std::string& description)
67  {
68  SetValue(value);
69  SetDescription(description);
70  }
71 
73  void SetValue(int value) { m_cStructure->iValue = value; }
74 
76  int GetValue() const { return m_cStructure->iValue; }
77 
79  void SetDescription(const std::string& description)
80  {
81  strncpy(m_cStructure->strDescription, description.c_str(),
82  sizeof(m_cStructure->strDescription) - 1);
83  }
84 
86  std::string GetDescription() const { return m_cStructure->strDescription; }
88 
89 private:
90  PVRTypeIntValue(const PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
91  PVRTypeIntValue(PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
92 };
94 //------------------------------------------------------------------------------
95 
96 //==============================================================================
116 {
117  friend class CInstancePVRClient;
118 
119 public:
121  explicit PVRCapabilities() = delete;
157 
160 
162  void SetSupportsEPG(bool supportsEPG) { m_capabilities->bSupportsEPG = supportsEPG; }
163 
165  bool GetSupportsEPG() const { return m_capabilities->bSupportsEPG; }
166 
169  void SetSupportsEPGEdl(bool supportsEPGEdl) { m_capabilities->bSupportsEPGEdl = supportsEPGEdl; }
170 
172  bool GetSupportsEPGEdl() const { return m_capabilities->bSupportsEPGEdl; }
173 
175  void SetSupportsTV(bool supportsTV) { m_capabilities->bSupportsTV = supportsTV; }
176 
178  bool GetSupportsTV() const { return m_capabilities->bSupportsTV; }
179 
181  void SetSupportsRadio(bool supportsRadio) { m_capabilities->bSupportsRadio = supportsRadio; }
182 
184  bool GetSupportsRadio() const { return m_capabilities->bSupportsRadio; }
185 
188  void SetSupportsRecordings(bool supportsRecordings)
189  {
190  m_capabilities->bSupportsRecordings = supportsRecordings;
191  }
192 
194  bool GetSupportsRecordings() const { return m_capabilities->bSupportsRecordings; }
195 
198  void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete)
199  {
200  m_capabilities->bSupportsRecordingsUndelete = supportsRecordingsUndelete;
201  }
202 
204  bool GetSupportsRecordingsUndelete() const { return m_capabilities->bSupportsRecordingsUndelete; }
205 
208  void SetSupportsTimers(bool supportsTimers) { m_capabilities->bSupportsTimers = supportsTimers; }
209 
211  bool GetSupportsTimers() const { return m_capabilities->bSupportsTimers; }
212 
218  void SetSupportsProviders(bool supportsProviders)
219  {
220  m_capabilities->bSupportsProviders = supportsProviders;
221  }
222 
224  bool GetSupportsProviders() const { return m_capabilities->bSupportsProviders; }
225 
232  void SetSupportsChannelGroups(bool supportsChannelGroups)
233  {
234  m_capabilities->bSupportsChannelGroups = supportsChannelGroups;
235  }
236 
238  bool GetSupportsChannelGroups() const { return m_capabilities->bSupportsChannelGroups; }
239 
245  void SetSupportsChannelScan(bool supportsChannelScan)
246  {
247  m_capabilities->bSupportsChannelScan = supportsChannelScan;
248  }
249 
251  bool GetSupportsChannelScan() const { return m_capabilities->bSupportsChannelScan; }
252 
260  void SetSupportsChannelSettings(bool supportsChannelSettings)
261  {
262  m_capabilities->bSupportsChannelSettings = supportsChannelSettings;
263  }
264 
266  bool GetSupportsChannelSettings() const { return m_capabilities->bSupportsChannelSettings; }
267 
270  void SetHandlesInputStream(bool handlesInputStream)
271  {
272  m_capabilities->bHandlesInputStream = handlesInputStream;
273  }
274 
276  bool GetHandlesInputStream() const { return m_capabilities->bHandlesInputStream; }
277 
279  void SetHandlesDemuxing(bool handlesDemuxing)
280  {
281  m_capabilities->bHandlesDemuxing = handlesDemuxing;
282  }
283 
285  bool GetHandlesDemuxing() const { return m_capabilities->bHandlesDemuxing; }
286 
288  void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount)
289  {
290  m_capabilities->bSupportsRecordingPlayCount = supportsRecordingPlayCount;
291  }
292 
294  bool GetSupportsRecordingPlayCount() const { return m_capabilities->bSupportsRecordingPlayCount; }
295 
298  void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition)
299  {
300  m_capabilities->bSupportsLastPlayedPosition = supportsLastPlayedPosition;
301  }
302 
304  bool GetSupportsLastPlayedPosition() const { return m_capabilities->bSupportsLastPlayedPosition; }
305 
308  void SetSupportsRecordingEdl(bool supportsRecordingEdl)
309  {
310  m_capabilities->bSupportsRecordingEdl = supportsRecordingEdl;
311  }
312 
314  bool GetSupportsRecordingEdl() const { return m_capabilities->bSupportsRecordingEdl; }
315 
317  void SetSupportsRecordingsRename(bool supportsRecordingsRename)
318  {
319  m_capabilities->bSupportsRecordingsRename = supportsRecordingsRename;
320  }
321 
323  bool GetSupportsRecordingsRename() const { return m_capabilities->bSupportsRecordingsRename; }
324 
327  void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange)
328  {
329  m_capabilities->bSupportsRecordingsLifetimeChange = supportsRecordingsLifetimeChange;
330  }
331 
335  {
336  return m_capabilities->bSupportsRecordingsLifetimeChange;
337  }
338 
341  void SetSupportsDescrambleInfo(bool supportsDescrambleInfo)
342  {
343  m_capabilities->bSupportsDescrambleInfo = supportsDescrambleInfo;
344  }
345 
347  bool GetSupportsDescrambleInfo() const { return m_capabilities->bSupportsDescrambleInfo; }
348 
352  void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer)
353  {
354  m_capabilities->bSupportsAsyncEPGTransfer = supportsAsyncEPGTransfer;
355  }
356 
358  bool GetSupportsAsyncEPGTransfer() const { return m_capabilities->bSupportsAsyncEPGTransfer; }
359 
361  void SetSupportsRecordingSize(bool supportsRecordingSize)
362  {
363  m_capabilities->bSupportsRecordingSize = supportsRecordingSize;
364  }
365 
367  bool GetSupportsRecordingSize() const { return m_capabilities->bSupportsRecordingSize; }
368 
371  void SetSupportsRecordingsDelete(bool supportsRecordingsDelete)
372  {
373  m_capabilities->bSupportsRecordingsDelete = supportsRecordingsDelete;
374  }
375 
377  bool GetSupportsRecordingsDelete() const { return m_capabilities->bSupportsRecordingsDelete; }
378 
386  const std::vector<PVRTypeIntValue>& recordingsLifetimeValues)
387  {
388  m_capabilities->iRecordingsLifetimesSize = 0;
389  for (unsigned int i = 0; i < recordingsLifetimeValues.size() &&
390  i < sizeof(m_capabilities->recordingsLifetimeValues);
391  ++i)
392  {
393  m_capabilities->recordingsLifetimeValues[i].iValue =
394  recordingsLifetimeValues[i].GetCStructure()->iValue;
395  strncpy(m_capabilities->recordingsLifetimeValues[i].strDescription,
396  recordingsLifetimeValues[i].GetCStructure()->strDescription,
397  sizeof(m_capabilities->recordingsLifetimeValues[i].strDescription) - 1);
398  ++m_capabilities->iRecordingsLifetimesSize;
399  }
400  }
401 
403  std::vector<PVRTypeIntValue> GetRecordingsLifetimeValues() const
404  {
405  std::vector<PVRTypeIntValue> recordingsLifetimeValues;
406  for (unsigned int i = 0; i < m_capabilities->iRecordingsLifetimesSize; ++i)
407  recordingsLifetimeValues.emplace_back(
408  m_capabilities->recordingsLifetimeValues[i].iValue,
409  m_capabilities->recordingsLifetimeValues[i].strDescription);
410  return recordingsLifetimeValues;
411  }
413 
414 private:
415  PVRCapabilities(PVR_ADDON_CAPABILITIES* capabilities) : m_capabilities(capabilities) {}
416 
417  PVR_ADDON_CAPABILITIES* m_capabilities;
418 };
420 //------------------------------------------------------------------------------
421 
422 //==============================================================================
469 class PVRStreamProperty : public CStructHdl<PVRStreamProperty, PVR_NAMED_VALUE>
470 {
471  friend class CInstancePVRClient;
472 
473 public:
475  PVRStreamProperty(const PVRStreamProperty& data) : CStructHdl(data) {}
488 
491 
495  PVRStreamProperty() = default;
496 
501  PVRStreamProperty(const std::string& name, const std::string& value)
502  {
503  SetName(name);
504  SetValue(value);
505  }
506 
508  void SetName(const std::string& name)
509  {
510  strncpy(m_cStructure->strName, name.c_str(), sizeof(m_cStructure->strName) - 1);
511  }
512 
514  std::string GetName() const { return m_cStructure->strName; }
515 
517  void SetValue(const std::string& value)
518  {
519  strncpy(m_cStructure->strValue, value.c_str(), sizeof(m_cStructure->strValue) - 1);
520  }
521 
523  std::string GetValue() const { return m_cStructure->strValue; }
525 
526 private:
527  PVRStreamProperty(const PVR_NAMED_VALUE* data) : CStructHdl(data) {}
528  PVRStreamProperty(PVR_NAMED_VALUE* data) : CStructHdl(data) {}
529 };
531 //------------------------------------------------------------------------------
532 
533 } /* namespace addon */
534 } /* namespace kodi */
535 
536 #endif /* __cplusplus */
Definition: PVR.h:408
Definition: AddonBase.h:250
Definition: General.h:116
Definition: General.h:470
Definition: General.h:35
std::string GetValue() const
To get with the used property value.
Definition: General.h:523
void SetValue(const std::string &value)
To set with the used property value.
Definition: General.h:517
void SetName(const std::string &name)
To set with the identification name.
Definition: General.h:508
std::string GetName() const
To get with the identification name.
Definition: General.h:514
PVRStreamProperty()=default
Default class constructor.
PVRStreamProperty(const std::string &name, const std::string &value)
Class constructor with integrated value set.
Definition: General.h:501
void SetSupportsRecordingsDelete(bool supportsRecordingsDelete)
Set true if this add-on supports delete of recordings stored on the backend.
Definition: General.h:371
std::vector< PVRTypeIntValue > GetRecordingsLifetimeValues() const
To get with SetRecordingsLifetimeValues changed values.
Definition: General.h:403
void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete)
Set true if this add-on supports undelete of recordings stored on the backend.
Definition: General.h:198
void SetSupportsProviders(bool supportsProviders)
Set true if this add-on supports providers.
Definition: General.h:218
void SetSupportsEPGEdl(bool supportsEPGEdl)
Set true if the backend supports retrieving an edit decision list for an EPG tag.
Definition: General.h:169
bool GetSupportsRecordingsUndelete() const
To get with SetSupportsRecordings changed values.
Definition: General.h:204
bool GetSupportsRecordingsDelete() const
To get with SetSupportsRecordingsDelete changed values.
Definition: General.h:377
void SetSupportsChannelSettings(bool supportsChannelSettings)
Set true if this add-on supports channel edit.
Definition: General.h:260
void SetHandlesDemuxing(bool handlesDemuxing)
Set true if this add-on demultiplexes packets.
Definition: General.h:279
bool GetSupportsRecordingsLifetimeChange() const
To get with SetSupportsRecordingsLifetimeChange changed values.
Definition: General.h:334
void SetSupportsChannelGroups(bool supportsChannelGroups)
Set true if this add-on supports channel groups.
Definition: General.h:232
bool GetSupportsChannelSettings() const
To get with SetSupportsChannelSettings changed values.
Definition: General.h:266
bool GetSupportsRecordings() const
To get with SetSupportsRecordings changed values.
Definition: General.h:194
void SetSupportsRadio(bool supportsRadio)
Set true if this add-on provides TV channels.
Definition: General.h:181
bool GetSupportsAsyncEPGTransfer() const
To get with SetSupportsAsyncEPGTransfer changed values.
Definition: General.h:358
void SetSupportsTV(bool supportsTV)
Set true if this add-on provides TV channels.
Definition: General.h:175
void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition)
Set true if the backend supports store/retrieve of last played position for recordings.
Definition: General.h:298
void SetSupportsRecordingSize(bool supportsRecordingSize)
Set true if this addon-on supports retrieving size of recordings.
Definition: General.h:361
void SetHandlesInputStream(bool handlesInputStream)
Set true if this add-on provides an input stream. false if Kodi handles the stream.
Definition: General.h:270
bool GetSupportsProviders() const
To get with SetSupportsProviders changed values.
Definition: General.h:224
bool GetSupportsChannelScan() const
To get with SetSupportsChannelScan changed values.
Definition: General.h:251
void SetSupportsEPG(bool supportsEPG)
Set true if the add-on provides EPG information.
Definition: General.h:162
void SetSupportsRecordingEdl(bool supportsRecordingEdl)
Set true if the backend supports retrieving an edit decision list for recordings.
Definition: General.h:308
bool GetSupportsRecordingSize() const
To get with SetSupportsRecordingSize changed values.
Definition: General.h:367
void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer)
Set true if this addon-on supports asynchronous transfer of epg events to Kodi using the callback fun...
Definition: General.h:352
bool GetSupportsEPGEdl() const
To get with SetSupportsEPGEdl changed values.
Definition: General.h:172
void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange)
Set true if the backend supports changing lifetime for recordings.
Definition: General.h:327
bool GetHandlesDemuxing() const
To get with SetHandlesDemuxing changed values.
Definition: General.h:285
bool GetSupportsRadio() const
To get with SetSupportsRadio changed values.
Definition: General.h:184
void SetSupportsDescrambleInfo(bool supportsDescrambleInfo)
Set true if the backend supports descramble information for playing channels.
Definition: General.h:341
void SetSupportsTimers(bool supportsTimers)
Set true if this add-on supports the creation and editing of timers.
Definition: General.h:208
bool GetSupportsRecordingPlayCount() const
To get with SetSupportsRecordingPlayCount changed values.
Definition: General.h:294
void SetSupportsRecordingsRename(bool supportsRecordingsRename)
Set true if the backend supports renaming recordings.
Definition: General.h:317
void SetSupportsRecordings(bool supportsRecordings)
true if this add-on supports playback of recordings stored on the backend.
Definition: General.h:188
bool GetSupportsLastPlayedPosition() const
To get with SetSupportsLastPlayedPosition changed values.
Definition: General.h:304
void SetRecordingsLifetimeValues(const std::vector< PVRTypeIntValue > &recordingsLifetimeValues)
optional Set array containing the possible values for PVRRecording::SetLifetime().
Definition: General.h:385
bool GetSupportsTV() const
To get with SetSupportsTV changed values.
Definition: General.h:178
bool GetSupportsRecordingsRename() const
To get with SetSupportsRecordingsRename changed values.
Definition: General.h:323
bool GetSupportsDescrambleInfo() const
To get with SetSupportsDescrambleInfo changed values.
Definition: General.h:347
void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount)
Set true if the backend supports play count for recordings.
Definition: General.h:288
bool GetSupportsRecordingEdl() const
To get with SetSupportsRecordingEdl changed values.
Definition: General.h:314
void SetSupportsChannelScan(bool supportsChannelScan)
Set true if this add-on support scanning for new channels on the backend.
Definition: General.h:245
bool GetHandlesInputStream() const
To get with SetHandlesInputStream changed values.
Definition: General.h:276
bool GetSupportsEPG() const
To get with SetSupportsEPG changed values.
Definition: General.h:165
bool GetSupportsChannelGroups() const
To get with SetSupportsChannelGroups changed values.
Definition: General.h:238
bool GetSupportsTimers() const
To get with SetSupportsTimers changed values.
Definition: General.h:211
void SetValue(int value)
To set with the identification value.
Definition: General.h:73
std::string GetDescription() const
To get with the description text of the value.
Definition: General.h:86
void SetDescription(const std::string &description)
To set with the description text of the value.
Definition: General.h:79
int GetValue() const
To get with the identification value.
Definition: General.h:76
PVRTypeIntValue(int value, const std::string &description)
Class constructor with integrated value set.
Definition: General.h:66
PVRTypeIntValue()=default
Default class constructor.
"C" PVR add-on capabilities.
Definition: pvr_general.h:268
"C" Representation of a general attribute integer value.
Definition: pvr_defines.h:48
"C" Representation of a named value.
Definition: pvr_defines.h:57