forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PVRTimerType.h
393 lines (329 loc) · 16.2 KB
/
PVRTimerType.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
struct PVR_TIMER_TYPE;
namespace PVR
{
class CPVRClient;
static const int DEFAULT_RECORDING_PRIORITY = 50;
static const int DEFAULT_RECORDING_LIFETIME = 99; // days
static const unsigned int DEFAULT_RECORDING_DUPLICATEHANDLING = 0;
class CPVRTimerType
{
public:
/*!
* @brief Return a list with all known timer types.
* @return A list of timer types or an empty list if no types available.
*/
static const std::vector<std::shared_ptr<CPVRTimerType>> GetAllTypes();
/*!
* @brief Return the first available timer type from given client.
* @param client the PVR client.
* @return A timer type or NULL if none available.
*/
static const std::shared_ptr<CPVRTimerType> GetFirstAvailableType(const std::shared_ptr<CPVRClient>& client);
/*!
* @brief Create a timer type from given timer type id and client id.
* @param iTimerType the timer type id.
* @param iClientId the PVR client id.
* @return A timer type instance.
*/
static std::shared_ptr<CPVRTimerType> CreateFromIds(unsigned int iTypeId, int iClientId);
/*!
* @brief Create a timer type from given timer type attributes and client id.
* @param iMustHaveAttr a combination of PVR_TIMER_TYPE_* attributes the type to create must have.
* @param iMustNotHaveAttr a combination of PVR_TIMER_TYPE_* attributes the type to create must not have.
* @param iClientId the PVR client id.
* @return A timer type instance.
*/
static std::shared_ptr<CPVRTimerType> CreateFromAttributes(unsigned int iMustHaveAttr, unsigned int iMustNotHaveAttr, int iClientId);
CPVRTimerType();
CPVRTimerType(const PVR_TIMER_TYPE& type, int iClientId);
CPVRTimerType(unsigned int iTypeId, unsigned int iAttributes, const std::string& strDescription = "");
virtual ~CPVRTimerType();
CPVRTimerType(const CPVRTimerType& type) = delete;
CPVRTimerType& operator=(const CPVRTimerType& orig) = delete;
bool operator ==(const CPVRTimerType& right) const;
bool operator !=(const CPVRTimerType& right) const;
/*!
* @brief Get the PVR client id for this type.
* @return The PVR client id.
*/
int GetClientId() const { return m_iClientId; }
/*!
* @brief Get the numeric type id of this type.
* @return The type id.
*/
unsigned int GetTypeId() const { return m_iTypeId; }
/*!
* @brief Get the plain text (UI) description of this type.
* @return The description.
*/
const std::string& GetDescription() const { return m_strDescription; }
/*!
* @brief Get the attributes of this type.
* @return The attributes.
*/
unsigned int GetAttributes() const { return m_iAttributes; }
/*!
* @brief Check whether this type is for timer rules or one time timers.
* @return True if type represents a timer rule, false otherwise.
*/
bool IsTimerRule() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REPEATING) > 0; }
/*!
* @brief Check whether this type is for reminder timers or recording timers.
* @return True if type represents a reminder timer, false otherwise.
*/
bool IsReminder() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_REMINDER) > 0; }
/*!
* @brief Check whether this type is for timer rules or one time timers.
* @return True if type represents a one time timer, false otherwise.
*/
bool IsOnetime() const { return !IsTimerRule(); }
/*!
* @brief Check whether this type is for epg-based or manual timers.
* @return True if manual, false otherwise.
*/
bool IsManual() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_MANUAL) > 0; }
/*!
* @brief Check whether this type is for epg-based or manual timers.
* @return True if epg-based, false otherwise.
*/
bool IsEpgBased() const { return !IsManual(); }
/*!
* @brief Check whether this type is for epg-based timer rules.
* @return True if epg-based timer rule, false otherwise.
*/
bool IsEpgBasedTimerRule() const { return IsEpgBased() && IsTimerRule(); }
/*!
* @brief Check whether this type is for one time epg-based timers.
* @return True if one time epg-based, false otherwise.
*/
bool IsEpgBasedOnetime() const { return IsEpgBased() && IsOnetime(); }
/*!
* @brief Check whether this type is for manual timer rules.
* @return True if manual timer rule, false otherwise.
*/
bool IsManualTimerRule() const { return IsManual() && IsTimerRule(); }
/*!
* @brief Check whether this type is for one time manual timers.
* @return True if one time manual, false otherwise.
*/
bool IsManualOnetime() const { return IsManual() && IsOnetime(); }
/*!
* @brief Check whether this type is readonly (must not be modified after initial creation).
* @return True if readonly, false otherwise.
*/
bool IsReadOnly() const { return (m_iAttributes & PVR_TIMER_TYPE_IS_READONLY) > 0; }
/*!
* @brief Check whether this type allows deletion.
* @return True if type allows deletion, false otherwise.
*/
bool AllowsDelete() const { return !IsReadOnly() || SupportsReadOnlyDelete(); }
/*!
* @brief Check whether this type forbids creation of new timers of this type.
* @return True if new instances are forbidden, false otherwise.
*/
bool ForbidsNewInstances() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES) > 0; }
/*!
* @brief Check whether this timer type is forbidden when epg tag info is present.
* @return True if new instances are forbidden when epg info is present, false otherwise.
*/
bool ForbidsEpgTagOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE) > 0; }
/*!
* @brief Check whether this timer type requires epg tag info to be present.
* @return True if new instances require EPG info, false otherwise.
*/
bool RequiresEpgTagOnCreate() const { return (m_iAttributes & (PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE |
PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE |
PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE)) > 0; }
/*!
* @brief Check whether this timer type requires epg tag info including series attributes to be present.
* @return True if new instances require an EPG tag with series attributes, false otherwise.
*/
bool RequiresEpgSeriesOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE) > 0; }
/*!
* @brief Check whether this timer type requires epg tag info including a series link to be present.
* @return True if new instances require an EPG tag with a series link, false otherwise.
*/
bool RequiresEpgSeriesLinkOnCreate() const { return (m_iAttributes & PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE) > 0; }
/*!
* @brief Check whether this type supports the "enabling/disabling" of timers of its type.
* @return True if "enabling/disabling" feature is supported, false otherwise.
*/
bool SupportsEnableDisable() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE) > 0; }
/*!
* @brief Check whether this type supports channels.
* @return True if channels are supported, false otherwise.
*/
bool SupportsChannels() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_CHANNELS) > 0; }
/*!
* @brief Check whether this type supports start time.
* @return True if start time values are supported, false otherwise.
*/
bool SupportsStartTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_TIME) > 0; }
/*!
* @brief Check whether this type supports end time.
* @return True if end time values are supported, false otherwise.
*/
bool SupportsEndTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_TIME) > 0; }
/*!
* @brief Check whether this type supports start any time.
* @return True if start any time is supported, false otherwise.
*/
bool SupportsStartAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME) > 0; }
/*!
* @brief Check whether this type supports end any time.
* @return True if end any time is supported, false otherwise.
*/
bool SupportsEndAnyTime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME) > 0; }
/*!
* @brief Check whether this type supports matching a search string against epg episode title.
* @return True if title matching is supported, false otherwise.
*/
bool SupportsEpgTitleMatch() const { return (m_iAttributes & (PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH | PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH)) > 0; }
/*!
* @brief Check whether this type supports matching a search string against extended (fulltext) epg data. This
includes title matching.
* @return True if fulltext matching is supported, false otherwise.
*/
bool SupportsEpgFulltextMatch() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH) > 0; }
/*!
* @brief Check whether this type supports a first day the timer is active.
* @return True if first day is supported, false otherwise.
*/
bool SupportsFirstDay() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY) > 0; }
/*!
* @brief Check whether this type supports weekdays for timer schedules.
* @return True if weekdays are supported, false otherwise.
*/
bool SupportsWeekdays() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS) > 0; }
/*!
* @brief Check whether this type supports the "record only new episodes" feature.
* @return True if the "record only new episodes" feature is supported, false otherwise.
*/
bool SupportsRecordOnlyNewEpisodes() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES) > 0; }
/*!
* @brief Check whether this type supports pre and post record time.
* @return True if pre and post record time is supported, false otherwise.
*/
bool SupportsStartEndMargin() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN) > 0; }
/*!
* @brief Check whether this type supports recording priorities.
* @return True if recording priority is supported, false otherwise.
*/
bool SupportsPriority() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_PRIORITY) > 0; }
/*!
* @brief Check whether this type supports lifetime for recordings.
* @return True if recording lifetime is supported, false otherwise.
*/
bool SupportsLifetime() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_LIFETIME) > 0; }
/*!
* @brief Check whether this type supports MaxRecordings for recordings.
* @return True if MaxRecordings is supported, false otherwise.
*/
bool SupportsMaxRecordings() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS) > 0; }
/*!
* @brief Check whether this type supports user specified recording folders.
* @return True if recording folders are supported, false otherwise.
*/
bool SupportsRecordingFolders() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS) > 0; }
/*!
* @brief Check whether this type supports recording groups.
* @return True if recording groups are supported, false otherwise.
*/
bool SupportsRecordingGroup() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP) > 0; }
/*!
* @brief Check whether this type supports 'any channel', for example for defining a timer rule that should match any channel instead of a particular channel.
* @return True if any channel is supported, false otherwise.
*/
bool SupportsAnyChannel() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL) > 0; }
/*!
* @brief Check whether this type supports deletion of an otherwise read-only timer.
* @return True if read-only deletion is supported, false otherwise.
*/
bool SupportsReadOnlyDelete() const { return (m_iAttributes & PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE) > 0; }
/*!
* @brief Obtain a list with all possible values for the priority attribute.
* @param list out, the list with the values or an empty list, if priority is not supported by this type.
*/
void GetPriorityValues(std::vector<std::pair<std::string, int>>& list) const;
/*!
* @brief Obtain the default value for the priority attribute.
* @return the default value.
*/
int GetPriorityDefault() const { return m_iPriorityDefault; }
/*!
* @brief Obtain a list with all possible values for the lifetime attribute.
* @param list out, the list with the values or an empty list, if lifetime is not supported by this type.
*/
void GetLifetimeValues(std::vector<std::pair<std::string, int>>& list) const;
/*!
* @brief Obtain the default value for the lifetime attribute.
* @return the default value.
*/
int GetLifetimeDefault() const { return m_iLifetimeDefault; }
/*!
* @brief Obtain a list with all possible values for the MaxRecordings attribute.
* @param list out, the list with the values or an empty list, if MaxRecordings is not supported by this type.
*/
void GetMaxRecordingsValues(std::vector<std::pair<std::string, int>>& list) const;
/*!
* @brief Obtain the default value for the MaxRecordings attribute.
* @return the default value.
*/
int GetMaxRecordingsDefault() const { return m_iMaxRecordingsDefault; }
/*!
* @brief Obtain a list with all possible values for the duplicate episode prevention attribute.
* @param list out, the list with the values or an empty list, if duplicate episode prevention is not supported by this type.
*/
void GetPreventDuplicateEpisodesValues(std::vector<std::pair<std::string, int>>& list) const;
/*!
* @brief Obtain the default value for the duplicate episode prevention attribute.
* @return the default value.
*/
int GetPreventDuplicateEpisodesDefault() const { return m_iPreventDupEpisodesDefault; }
/*!
* @brief Obtain a list with all possible values for the recording group attribute.
* @param list out, the list with the values or an empty list, if recording group is not supported by this type.
*/
void GetRecordingGroupValues(std::vector<std::pair<std::string, int>>& list) const;
/*!
* @brief Obtain the default value for the Recording Group attribute.
* @return the default value.
*/
int GetRecordingGroupDefault() const { return m_iRecordingGroupDefault; }
private:
void InitDescription();
void InitAttributeValues(const PVR_TIMER_TYPE& type);
void InitPriorityValues(const PVR_TIMER_TYPE& type);
void InitLifetimeValues(const PVR_TIMER_TYPE& type);
void InitMaxRecordingsValues(const PVR_TIMER_TYPE& type);
void InitPreventDuplicateEpisodesValues(const PVR_TIMER_TYPE& type);
void InitRecordingGroupValues(const PVR_TIMER_TYPE& type);
int m_iClientId = -1;
unsigned int m_iTypeId;
unsigned int m_iAttributes;
std::string m_strDescription;
std::vector< std::pair<std::string, int> > m_priorityValues;
int m_iPriorityDefault = DEFAULT_RECORDING_PRIORITY;
std::vector< std::pair<std::string, int> > m_lifetimeValues;
int m_iLifetimeDefault = DEFAULT_RECORDING_LIFETIME;
std::vector< std::pair<std::string, int> > m_maxRecordingsValues;
int m_iMaxRecordingsDefault = 0;
std::vector< std::pair<std::string, int> > m_preventDupEpisodesValues;
unsigned int m_iPreventDupEpisodesDefault = DEFAULT_RECORDING_DUPLICATEHANDLING;
std::vector< std::pair<std::string, int> > m_recordingGroupValues;
unsigned int m_iRecordingGroupDefault = 0;
};
}