kodi
PVRTimerType.h
1 /*
2  * Copyright (C) 2012-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 "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h"
12 
13 #include <memory>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 struct PVR_TIMER_TYPE;
19 
20 namespace PVR
21 {
22  class CPVRClient;
23 
24  static const int DEFAULT_RECORDING_PRIORITY = 50;
25  static const int DEFAULT_RECORDING_LIFETIME = 99; // days
26  static const unsigned int DEFAULT_RECORDING_DUPLICATEHANDLING = 0;
27 
29  {
30  public:
35  static const std::vector<std::shared_ptr<CPVRTimerType>> GetAllTypes();
36 
42  static const std::shared_ptr<CPVRTimerType> GetFirstAvailableType(
43  const std::shared_ptr<const CPVRClient>& client);
44 
51  static std::shared_ptr<CPVRTimerType> CreateFromIds(unsigned int iTypeId, int iClientId);
52 
60  static std::shared_ptr<CPVRTimerType> CreateFromAttributes(uint64_t iMustHaveAttr,
61  uint64_t iMustNotHaveAttr,
62  int iClientId);
63 
64  CPVRTimerType();
65  CPVRTimerType(const PVR_TIMER_TYPE& type, int iClientId);
66  CPVRTimerType(unsigned int iTypeId,
67  uint64_t iAttributes,
68  const std::string& strDescription = "");
69 
70  virtual ~CPVRTimerType();
71 
72  CPVRTimerType(const CPVRTimerType& type) = delete;
73  CPVRTimerType& operator=(const CPVRTimerType& orig) = delete;
74 
75  bool operator ==(const CPVRTimerType& right) const;
76  bool operator !=(const CPVRTimerType& right) const;
77 
82  void Update(const CPVRTimerType& type);
83 
88  int GetClientId() const { return m_iClientId; }
89 
94  unsigned int GetTypeId() const { return m_iTypeId; }
95 
100  const std::string& GetDescription() const { return m_strDescription; }
101 
106  uint64_t GetAttributes() const { return m_iAttributes; }
107 
112  bool IsTimerRule() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REPEATING) > 0; }
113 
118  bool IsReminder() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REMINDER) > 0; }
119 
124  bool IsOnetime() const { return !IsTimerRule(); }
125 
130  bool IsManual() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_MANUAL) > 0; }
131 
136  bool IsEpgBased() const { return !IsManual(); }
137 
142  bool IsEpgBasedTimerRule() const { return IsEpgBased() && IsTimerRule(); }
143 
148  bool IsEpgBasedOnetime() const { return IsEpgBased() && IsOnetime(); }
149 
154  bool IsManualTimerRule() const { return IsManual() && IsTimerRule(); }
155 
160  bool IsManualOnetime() const { return IsManual() && IsOnetime(); }
161 
166  bool IsReadOnly() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_READONLY) > 0; }
167 
172  bool AllowsDelete() const { return !IsReadOnly() || SupportsReadOnlyDelete(); }
173 
178  bool ForbidsNewInstances() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES) > 0; }
179 
184  bool ForbidsEpgTagOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE) > 0; }
185 
190  bool RequiresEpgTagOnCreate() const { return (m_iAttributes & (PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE |
193 
198  bool RequiresEpgSeriesOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE) > 0; }
199 
205 
210  bool SupportsEnableDisable() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE) > 0; }
211 
216  bool SupportsChannels() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_CHANNELS) > 0; }
217 
222  bool SupportsStartTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_TIME) > 0; }
223 
228  bool SupportsEndTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_TIME) > 0; }
233  bool SupportsStartAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME) > 0; }
234 
239  bool SupportsEndAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME) > 0; }
240 
246 
252  bool SupportsEpgFulltextMatch() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH) > 0; }
253 
258  bool SupportsFirstDay() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY) > 0; }
259 
264  bool SupportsWeekdays() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS) > 0; }
265 
271 
276  bool SupportsStartMargin() const
277  {
278  return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_MARGIN) > 0 ||
279  (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN) > 0;
280  }
281 
286  bool SupportsEndMargin() const
287  {
288  return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_MARGIN) > 0 ||
289  (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN) > 0;
290  }
291 
296  bool SupportsPriority() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_PRIORITY) > 0; }
297 
302  bool SupportsLifetime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_LIFETIME) > 0; }
303 
308  bool SupportsMaxRecordings() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS) > 0; }
309 
314  bool SupportsRecordingFolders() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS) > 0; }
315 
320  bool SupportsRecordingGroup() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP) > 0; }
321 
326  bool SupportsAnyChannel() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL) > 0; }
327 
332  bool SupportsReadOnlyDelete() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE) > 0; }
333 
338  void GetPriorityValues(std::vector<std::pair<std::string, int>>& list) const;
339 
344  int GetPriorityDefault() const { return m_iPriorityDefault; }
345 
350  void GetLifetimeValues(std::vector<std::pair<std::string, int>>& list) const;
351 
356  int GetLifetimeDefault() const { return m_iLifetimeDefault; }
357 
362  void GetMaxRecordingsValues(std::vector<std::pair<std::string, int>>& list) const;
363 
368  int GetMaxRecordingsDefault() const { return m_iMaxRecordingsDefault; }
369 
374  void GetPreventDuplicateEpisodesValues(std::vector<std::pair<std::string, int>>& list) const;
375 
380  int GetPreventDuplicateEpisodesDefault() const { return m_iPreventDupEpisodesDefault; }
381 
386  void GetRecordingGroupValues(std::vector<std::pair<std::string, int>>& list) const;
387 
392  int GetRecordingGroupDefault() const { return m_iRecordingGroupDefault; }
393 
394  private:
395  void InitDescription();
396  void InitAttributeValues(const PVR_TIMER_TYPE& type);
397  void InitPriorityValues(const PVR_TIMER_TYPE& type);
398  void InitLifetimeValues(const PVR_TIMER_TYPE& type);
399  void InitMaxRecordingsValues(const PVR_TIMER_TYPE& type);
400  void InitPreventDuplicateEpisodesValues(const PVR_TIMER_TYPE& type);
401  void InitRecordingGroupValues(const PVR_TIMER_TYPE& type);
402 
403  int m_iClientId = -1;
404  unsigned int m_iTypeId;
405  uint64_t m_iAttributes;
406  std::string m_strDescription;
407  std::vector< std::pair<std::string, int> > m_priorityValues;
408  int m_iPriorityDefault = DEFAULT_RECORDING_PRIORITY;
409  std::vector< std::pair<std::string, int> > m_lifetimeValues;
410  int m_iLifetimeDefault = DEFAULT_RECORDING_LIFETIME;
411  std::vector< std::pair<std::string, int> > m_maxRecordingsValues;
412  int m_iMaxRecordingsDefault = 0;
413  std::vector< std::pair<std::string, int> > m_preventDupEpisodesValues;
414  unsigned int m_iPreventDupEpisodesDefault = DEFAULT_RECORDING_DUPLICATEHANDLING;
415  std::vector< std::pair<std::string, int> > m_recordingGroupValues;
416  unsigned int m_iRecordingGroupDefault = 0;
417  };
418 }
bool IsManual() const
Check whether this type is for epg-based or manual timers.
Definition: PVRTimerType.h:130
bool IsManualOnetime() const
Check whether this type is for one time manual timers.
Definition: PVRTimerType.h:160
bool SupportsEpgTitleMatch() const
Check whether this type supports matching a search string against epg episode title.
Definition: PVRTimerType.h:245
bool SupportsChannels() const
Check whether this type supports channels.
Definition: PVRTimerType.h:216
0000 0000 0000 0000 1000 0000 0000 0000 : This type supports placing recordings in user defined fold...
Definition: pvr_timers.h:169
bool IsEpgBasedTimerRule() const
Check whether this type is for epg-based timer rules.
Definition: PVRTimerType.h:142
bool SupportsStartAnyTime() const
Check whether this type supports start any time.
Definition: PVRTimerType.h:233
bool ForbidsNewInstances() const
Check whether this type forbids creation of new timers of this type.
Definition: PVRTimerType.h:178
void GetMaxRecordingsValues(std::vector< std::pair< std::string, int >> &list) const
Obtain a list with all possible values for the MaxRecordings attribute.
Definition: PVRTimerType.cpp:370
"C" PVR add-on timer event type.
Definition: pvr_timers.h:378
bool IsEpgBasedOnetime() const
Check whether this type is for one time epg-based timers.
Definition: PVRTimerType.h:148
0000 0000 0000 0100 0000 0000 0000 0000 : Enables an &#39;Any Time&#39; over-ride option for start time (usi...
Definition: pvr_timers.h:180
bool IsTimerRule() const
Check whether this type is for timer rules or one time timers.
Definition: PVRTimerType.h:112
0000 0000 0000 0000 0000 0000 0000 0010 : Defines whether this is a type for repeating or one-shot t...
Definition: pvr_timers.h:112
void Update(const CPVRTimerType &type)
Update the data of this instance with the data given by another type instance.
Definition: PVRTimerType.cpp:218
int GetRecordingGroupDefault() const
Obtain the default value for the Recording Group attribute.
Definition: PVRTimerType.h:392
bool SupportsEndTime() const
Check whether this type supports end time.
Definition: PVRTimerType.h:228
0000 0000 0000 0000 0100 0000 0000 0000 : This type supports recording lifetime (kodi::addon::PVRTim...
Definition: pvr_timers.h:165
0000 0000 0100 0000 0000 0000 0000 0000 : This type should not appear on any create menus which prov...
Definition: pvr_timers.h:196
bool IsEpgBased() const
Check whether this type is for epg-based or manual timers.
Definition: PVRTimerType.h:136
Definition: ContextMenuManager.h:24
bool SupportsFirstDay() const
Check whether this type supports a first day the timer is active.
Definition: PVRTimerType.h:258
bool SupportsStartTime() const
Check whether this type supports start time.
Definition: PVRTimerType.h:222
int GetLifetimeDefault() const
Obtain the default value for the lifetime attribute.
Definition: PVRTimerType.h:356
static std::shared_ptr< CPVRTimerType > CreateFromAttributes(uint64_t iMustHaveAttr, uint64_t iMustNotHaveAttr, int iClientId)
Create a timer type from given timer type attributes and client id.
Definition: PVRTimerType.cpp:142
int GetPreventDuplicateEpisodesDefault() const
Obtain the default value for the duplicate episode prevention attribute.
Definition: PVRTimerType.h:380
bool SupportsRecordingGroup() const
Check whether this type supports recording groups.
Definition: PVRTimerType.h:320
static std::shared_ptr< CPVRTimerType > CreateFromIds(unsigned int iTypeId, int iClientId)
Create a timer type from given timer type id and client id.
Definition: PVRTimerType.cpp:120
bool IsReadOnly() const
Check whether this type is readonly (must not be modified after initial creation).
Definition: PVRTimerType.h:166
int GetClientId() const
Get the PVR client id for this type.
Definition: PVRTimerType.h:88
0000 0000 0000 0000 0000 0000 0010 0000 : This type supports channels (kodi::addon::PVRTimer::SetCli...
Definition: pvr_timers.h:129
uint64_t GetAttributes() const
Get the attributes of this type.
Definition: PVRTimerType.h:106
bool ForbidsEpgTagOnCreate() const
Check whether this timer type is forbidden when epg tag info is present.
Definition: PVRTimerType.h:184
0000 0000 0000 0010 0000 0000 0000 0000 : This type supports a recording end time (kodi::addon::PVRT...
Definition: pvr_timers.h:176
int GetMaxRecordingsDefault() const
Obtain the default value for the MaxRecordings attribute.
Definition: PVRTimerType.h:368
bool SupportsRecordOnlyNewEpisodes() const
Check whether this type supports the "record only new episodes" feature.
Definition: PVRTimerType.h:270
bool RequiresEpgSeriesOnCreate() const
Check whether this timer type requires epg tag info including series attributes to be present...
Definition: PVRTimerType.h:198
void GetLifetimeValues(std::vector< std::pair< std::string, int >> &list) const
Obtain a list with all possible values for the lifetime attribute.
Definition: PVRTimerType.cpp:346
bool SupportsPriority() const
Check whether this type supports recording priorities.
Definition: PVRTimerType.h:296
0000 0000 0001 0000 0000 0000 0000 0000 : This type supports specifying a maximum recordings setting...
Definition: pvr_timers.h:188
bool IsManualTimerRule() const
Check whether this type is for manual timer rules.
Definition: PVRTimerType.h:154
0000 0000 0000 0000 0000 0010 0000 0000 : This type supports a first day the timer gets active (kodi...
Definition: pvr_timers.h:147
static const std::vector< std::shared_ptr< CPVRTimerType > > GetAllTypes()
Return a list with all known timer types.
Definition: PVRTimerType.cpp:28
static const std::shared_ptr< CPVRTimerType > GetFirstAvailableType(const std::shared_ptr< const CPVRClient > &client)
Return the first available timer type from given client.
Definition: PVRTimerType.cpp:106
int GetPriorityDefault() const
Obtain the default value for the priority attribute.
Definition: PVRTimerType.h:344
bool SupportsRecordingFolders() const
Check whether this type supports user specified recording folders.
Definition: PVRTimerType.h:314
0000 0000 0000 0000 0000 0000 0001 0000 : This type supports enabling/disabling of the timer (kodi::...
Definition: pvr_timers.h:125
bool AllowsDelete() const
Check whether this type allows deletion.
Definition: PVRTimerType.h:172
void GetPriorityValues(std::vector< std::pair< std::string, int >> &list) const
Obtain a list with all possible values for the priority attribute.
Definition: PVRTimerType.cpp:306
bool SupportsEndAnyTime() const
Check whether this type supports end any time.
Definition: PVRTimerType.h:239
bool SupportsWeekdays() const
Check whether this type supports weekdays for timer schedules.
Definition: PVRTimerType.h:264
bool SupportsEndMargin() const
Check whether this type supports post record time.
Definition: PVRTimerType.h:286
0000 0000 0010 0000 0000 0000 0000 0000 : This type should not appear on any create menus which don&#39;...
Definition: pvr_timers.h:192
0000 0001 0000 0000 0000 0000 0000 0000 : This type supports &#39;any channel&#39;, for example when definin...
Definition: pvr_timers.h:213
bool SupportsMaxRecordings() const
Check whether this type supports MaxRecordings for recordings.
Definition: PVRTimerType.h:308
0000 1000 0000 0000 0000 0000 0000 0000 : Timers of this type do trigger a reminder if time is up...
Definition: pvr_timers.h:224
void GetRecordingGroupValues(std::vector< std::pair< std::string, int >> &list) const
Obtain a list with all possible values for the recording group attribute.
Definition: PVRTimerType.cpp:433
0000 0000 0000 0000 0000 0100 0000 0000 : This type supports weekdays for defining the recording sch...
Definition: pvr_timers.h:151
bool SupportsAnyChannel() const
Check whether this type supports &#39;any channel&#39;, for example for defining a timer rule that should mat...
Definition: PVRTimerType.h:326
bool SupportsStartMargin() const
Check whether this type supports pre record time.
Definition: PVRTimerType.h:276
0000 0010 0000 0000 0000 0000 0000 0000 : This type should not appear on any create menus which don&#39;...
Definition: pvr_timers.h:218
0000 0000 0000 0000 0000 1000 0000 0000 : This type supports the "record only new episodes" feature ...
Definition: pvr_timers.h:155
0001 0000 0000 0000 0000 0000 0000 0000 : This type supports pre record time (kodi::addon::PVRTimer:...
Definition: pvr_timers.h:227
bool IsReminder() const
Check whether this type is for reminder timers or recording timers.
Definition: PVRTimerType.h:118
0010 0000 0000 0000 0000 0000 0000 0000 : This type supports post record time (kodi::addon::PVRTimer...
Definition: pvr_timers.h:230
0000 0000 0000 0000 0000 0000 0100 0000 : This type supports a recording start time (kodi::addon::PV...
Definition: pvr_timers.h:133
0000 0000 1000 0000 0000 0000 0000 0000 : This type should not appear on any create menus unless ass...
Definition: pvr_timers.h:209
Definition: PVRTimerType.h:28
0000 0000 0000 0000 0001 0000 0000 0000 : This type supports pre and post record time (kodi::addon::...
Definition: pvr_timers.h:159
bool RequiresEpgSeriesLinkOnCreate() const
Check whether this timer type requires epg tag info including a series link to be present...
Definition: PVRTimerType.h:204
bool SupportsReadOnlyDelete() const
Check whether this type supports deletion of an otherwise read-only timer.
Definition: PVRTimerType.h:332
0000 0000 0000 0000 0000 0001 0000 0000 : This type supports matching "more" epg data (not just epis...
Definition: pvr_timers.h:143
0000 0000 0000 0000 0000 0000 1000 0000 : This type supports matching epg episode title usingkodi::a...
Definition: pvr_timers.h:137
0000 0000 0000 0001 0000 0000 0000 0000 : This type supports a list of recording groups (kodi::addon...
Definition: pvr_timers.h:173
bool SupportsEnableDisable() const
Check whether this type supports the "enabling/disabling" of timers of its type.
Definition: PVRTimerType.h:210
0000 0000 0000 0000 0000 0000 0000 0001 : Defines whether this is a type for manual (time-based) or ...
Definition: pvr_timers.h:108
0000 0000 0000 0000 0000 0000 0000 1000 : Timers of this type must not be created by Kodi...
Definition: pvr_timers.h:120
0000 0000 0000 0000 0010 0000 0000 0000 : This type supports recording priority (kodi::addon::PVRTim...
Definition: pvr_timers.h:162
bool IsOnetime() const
Check whether this type is for timer rules or one time timers.
Definition: PVRTimerType.h:124
const std::string & GetDescription() const
Get the plain text (UI) description of this type.
Definition: PVRTimerType.h:100
bool SupportsLifetime() const
Check whether this type supports lifetime for recordings.
Definition: PVRTimerType.h:302
void GetPreventDuplicateEpisodesValues(std::vector< std::pair< std::string, int >> &list) const
Obtain a list with all possible values for the duplicate episode prevention attribute.
Definition: PVRTimerType.cpp:406
bool RequiresEpgTagOnCreate() const
Check whether this timer type requires epg tag info to be present.
Definition: PVRTimerType.h:190
unsigned int GetTypeId() const
Get the numeric type id of this type.
Definition: PVRTimerType.h:94
0000 0000 0000 0000 0000 0000 0000 0100 : Timers of this type must not be edited by Kodi...
Definition: pvr_timers.h:116
bool SupportsEpgFulltextMatch() const
Check whether this type supports matching a search string against extended (fulltext) epg data...
Definition: PVRTimerType.h:252
0000 0000 0000 1000 0000 0000 0000 0000 : Enables a separate &#39;Any Time&#39; over-ride for end time (usin...
Definition: pvr_timers.h:184
0000 0100 0000 0000 0000 0000 0000 0000 : This type allows deletion of an otherwise read-only timer...
Definition: pvr_timers.h:221