xbmc
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(const std::shared_ptr<CPVRClient>& client);
43 
50  static std::shared_ptr<CPVRTimerType> CreateFromIds(unsigned int iTypeId, int iClientId);
51 
59  static std::shared_ptr<CPVRTimerType> CreateFromAttributes(uint64_t iMustHaveAttr,
60  uint64_t iMustNotHaveAttr,
61  int iClientId);
62 
63  CPVRTimerType();
64  CPVRTimerType(const PVR_TIMER_TYPE& type, int iClientId);
65  CPVRTimerType(unsigned int iTypeId,
66  uint64_t iAttributes,
67  const std::string& strDescription = "");
68 
69  virtual ~CPVRTimerType();
70 
71  CPVRTimerType(const CPVRTimerType& type) = delete;
72  CPVRTimerType& operator=(const CPVRTimerType& orig) = delete;
73 
74  bool operator ==(const CPVRTimerType& right) const;
75  bool operator !=(const CPVRTimerType& right) const;
76 
81  int GetClientId() const { return m_iClientId; }
82 
87  unsigned int GetTypeId() const { return m_iTypeId; }
88 
93  const std::string& GetDescription() const { return m_strDescription; }
94 
99  uint64_t GetAttributes() const { return m_iAttributes; }
100 
105  bool IsTimerRule() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REPEATING) > 0; }
106 
111  bool IsReminder() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REMINDER) > 0; }
112 
117  bool IsOnetime() const { return !IsTimerRule(); }
118 
123  bool IsManual() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_MANUAL) > 0; }
124 
129  bool IsEpgBased() const { return !IsManual(); }
130 
135  bool IsEpgBasedTimerRule() const { return IsEpgBased() && IsTimerRule(); }
136 
141  bool IsEpgBasedOnetime() const { return IsEpgBased() && IsOnetime(); }
142 
147  bool IsManualTimerRule() const { return IsManual() && IsTimerRule(); }
148 
153  bool IsManualOnetime() const { return IsManual() && IsOnetime(); }
154 
159  bool IsReadOnly() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_READONLY) > 0; }
160 
165  bool AllowsDelete() const { return !IsReadOnly() || SupportsReadOnlyDelete(); }
166 
171  bool ForbidsNewInstances() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES) > 0; }
172 
177  bool ForbidsEpgTagOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE) > 0; }
178 
183  bool RequiresEpgTagOnCreate() const { return (m_iAttributes & (PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE |
186 
191  bool RequiresEpgSeriesOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE) > 0; }
192 
198 
203  bool SupportsEnableDisable() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE) > 0; }
204 
209  bool SupportsChannels() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_CHANNELS) > 0; }
210 
215  bool SupportsStartTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_TIME) > 0; }
216 
221  bool SupportsEndTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_TIME) > 0; }
226  bool SupportsStartAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME) > 0; }
227 
232  bool SupportsEndAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME) > 0; }
233 
239 
245  bool SupportsEpgFulltextMatch() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH) > 0; }
246 
251  bool SupportsFirstDay() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY) > 0; }
252 
257  bool SupportsWeekdays() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS) > 0; }
258 
264 
269  bool SupportsStartMargin() const
270  {
271  return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_MARGIN) > 0 ||
272  (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN) > 0;
273  }
274 
279  bool SupportsEndMargin() const
280  {
281  return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_MARGIN) > 0 ||
282  (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN) > 0;
283  }
284 
289  bool SupportsPriority() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_PRIORITY) > 0; }
290 
295  bool SupportsLifetime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_LIFETIME) > 0; }
296 
301  bool SupportsMaxRecordings() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS) > 0; }
302 
307  bool SupportsRecordingFolders() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS) > 0; }
308 
313  bool SupportsRecordingGroup() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP) > 0; }
314 
319  bool SupportsAnyChannel() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL) > 0; }
320 
325  bool SupportsReadOnlyDelete() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE) > 0; }
326 
331  void GetPriorityValues(std::vector<std::pair<std::string, int>>& list) const;
332 
337  int GetPriorityDefault() const { return m_iPriorityDefault; }
338 
343  void GetLifetimeValues(std::vector<std::pair<std::string, int>>& list) const;
344 
349  int GetLifetimeDefault() const { return m_iLifetimeDefault; }
350 
355  void GetMaxRecordingsValues(std::vector<std::pair<std::string, int>>& list) const;
356 
361  int GetMaxRecordingsDefault() const { return m_iMaxRecordingsDefault; }
362 
367  void GetPreventDuplicateEpisodesValues(std::vector<std::pair<std::string, int>>& list) const;
368 
373  int GetPreventDuplicateEpisodesDefault() const { return m_iPreventDupEpisodesDefault; }
374 
379  void GetRecordingGroupValues(std::vector<std::pair<std::string, int>>& list) const;
380 
385  int GetRecordingGroupDefault() const { return m_iRecordingGroupDefault; }
386 
387  private:
388  void InitDescription();
389  void InitAttributeValues(const PVR_TIMER_TYPE& type);
390  void InitPriorityValues(const PVR_TIMER_TYPE& type);
391  void InitLifetimeValues(const PVR_TIMER_TYPE& type);
392  void InitMaxRecordingsValues(const PVR_TIMER_TYPE& type);
393  void InitPreventDuplicateEpisodesValues(const PVR_TIMER_TYPE& type);
394  void InitRecordingGroupValues(const PVR_TIMER_TYPE& type);
395 
396  int m_iClientId = -1;
397  unsigned int m_iTypeId;
398  uint64_t m_iAttributes;
399  std::string m_strDescription;
400  std::vector< std::pair<std::string, int> > m_priorityValues;
401  int m_iPriorityDefault = DEFAULT_RECORDING_PRIORITY;
402  std::vector< std::pair<std::string, int> > m_lifetimeValues;
403  int m_iLifetimeDefault = DEFAULT_RECORDING_LIFETIME;
404  std::vector< std::pair<std::string, int> > m_maxRecordingsValues;
405  int m_iMaxRecordingsDefault = 0;
406  std::vector< std::pair<std::string, int> > m_preventDupEpisodesValues;
407  unsigned int m_iPreventDupEpisodesDefault = DEFAULT_RECORDING_DUPLICATEHANDLING;
408  std::vector< std::pair<std::string, int> > m_recordingGroupValues;
409  unsigned int m_iRecordingGroupDefault = 0;
410  };
411 }
bool IsManual() const
Check whether this type is for epg-based or manual timers.
Definition: PVRTimerType.h:123
bool IsManualOnetime() const
Check whether this type is for one time manual timers.
Definition: PVRTimerType.h:153
bool SupportsEpgTitleMatch() const
Check whether this type supports matching a search string against epg episode title.
Definition: PVRTimerType.h:238
bool SupportsChannels() const
Check whether this type supports channels.
Definition: PVRTimerType.h:209
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:135
bool SupportsStartAnyTime() const
Check whether this type supports start any time.
Definition: PVRTimerType.h:226
bool ForbidsNewInstances() const
Check whether this type forbids creation of new timers of this type.
Definition: PVRTimerType.h:171
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:351
"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:141
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:105
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
int GetRecordingGroupDefault() const
Obtain the default value for the Recording Group attribute.
Definition: PVRTimerType.h:385
bool SupportsEndTime() const
Check whether this type supports end time.
Definition: PVRTimerType.h:221
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:129
Definition: ContextMenuManager.h:24
bool SupportsFirstDay() const
Check whether this type supports a first day the timer is active.
Definition: PVRTimerType.h:251
bool SupportsStartTime() const
Check whether this type supports start time.
Definition: PVRTimerType.h:215
int GetLifetimeDefault() const
Obtain the default value for the lifetime attribute.
Definition: PVRTimerType.h:349
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:141
int GetPreventDuplicateEpisodesDefault() const
Obtain the default value for the duplicate episode prevention attribute.
Definition: PVRTimerType.h:373
bool SupportsRecordingGroup() const
Check whether this type supports recording groups.
Definition: PVRTimerType.h:313
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:119
bool IsReadOnly() const
Check whether this type is readonly (must not be modified after initial creation).
Definition: PVRTimerType.h:159
int GetClientId() const
Get the PVR client id for this type.
Definition: PVRTimerType.h:81
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:99
bool ForbidsEpgTagOnCreate() const
Check whether this timer type is forbidden when epg tag info is present.
Definition: PVRTimerType.h:177
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:361
bool SupportsRecordOnlyNewEpisodes() const
Check whether this type supports the "record only new episodes" feature.
Definition: PVRTimerType.h:263
bool RequiresEpgSeriesOnCreate() const
Check whether this timer type requires epg tag info including series attributes to be present...
Definition: PVRTimerType.h:191
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:327
bool SupportsPriority() const
Check whether this type supports recording priorities.
Definition: PVRTimerType.h:289
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:147
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< 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:337
bool SupportsRecordingFolders() const
Check whether this type supports user specified recording folders.
Definition: PVRTimerType.h:307
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:165
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:287
bool SupportsEndAnyTime() const
Check whether this type supports end any time.
Definition: PVRTimerType.h:232
bool SupportsWeekdays() const
Check whether this type supports weekdays for timer schedules.
Definition: PVRTimerType.h:257
bool SupportsEndMargin() const
Check whether this type supports post record time.
Definition: PVRTimerType.h:279
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:301
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:414
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:319
bool SupportsStartMargin() const
Check whether this type supports pre record time.
Definition: PVRTimerType.h:269
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:111
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:197
bool SupportsReadOnlyDelete() const
Check whether this type supports deletion of an otherwise read-only timer.
Definition: PVRTimerType.h:325
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:203
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:117
const std::string & GetDescription() const
Get the plain text (UI) description of this type.
Definition: PVRTimerType.h:93
bool SupportsLifetime() const
Check whether this type supports lifetime for recordings.
Definition: PVRTimerType.h:295
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:387
bool RequiresEpgTagOnCreate() const
Check whether this timer type requires epg tag info to be present.
Definition: PVRTimerType.h:183
unsigned int GetTypeId() const
Get the numeric type id of this type.
Definition: PVRTimerType.h:87
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:245
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