| 1 |
/* |
| 2 |
* Copyright (C) 2005-2021 Team Kodi (https://kodi.tv) |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
* See LICENSE.md for more information. |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#ifndef __TIMERS_H |
| 11 |
#define __TIMERS_H |
| 12 |
|
| 13 |
#include <stdlib.h> |
| 14 |
#include <string> |
| 15 |
#include "DateTime.h" |
| 16 |
#include "GenreTable.h" |
| 17 |
|
| 18 |
#include <kodi/addon-instance/pvr/Timers.h> |
| 19 |
|
| 20 |
namespace TvDatabase |
| 21 |
{ |
| 22 |
|
| 23 |
// From MediaPortal: TvDatabase.ScheduleRecordingType |
| 24 |
enum ScheduleRecordingType |
| 25 |
{ // English MediaPortal GUI description: |
| 26 |
Once = 0, // Record once |
| 27 |
Daily = 1, // Record every day at this time |
| 28 |
Weekly = 2, // Record every week at this time |
| 29 |
EveryTimeOnThisChannel = 3, // Record every time on this channel |
| 30 |
EveryTimeOnEveryChannel = 4, // Record every time on every channel |
| 31 |
Weekends = 5, // Record Weekends |
| 32 |
WorkingDays = 6, // Record Weekdays |
| 33 |
WeeklyEveryTimeOnThisChannel = 7, // Weekly on this channel |
| 34 |
KodiManual = 99 // Special type for Kodi since it distinguishes between 'Once (EPG based)' and 'manual' |
| 35 |
}; |
| 36 |
|
| 37 |
// From MediaPortal: TvDatabase.KeepMethodType |
| 38 |
enum KeepMethodType |
| 39 |
{ |
| 40 |
UntilSpaceNeeded = 0, |
| 41 |
UntilWatched = 1, |
| 42 |
TillDate = 2, |
| 43 |
Always = 3 |
| 44 |
}; |
| 45 |
|
| 46 |
}; |
| 47 |
|
| 48 |
const int cSecsInDay = 86400; ///> Amount of seconds in one day |
| 49 |
const int cKodiTimerTypeOffset = (PVR_TIMER_TYPE_NONE + 1); ///> Offset used to map the ScheduleRecordingType onto the iTimerType values |
| 50 |
const int cKodiTimerIndexOffset = (PVR_TIMER_NO_CLIENT_INDEX + 1); ///> Offset used to map the MediaPortal schedule id's to the iClientIndex values |
| 51 |
|
| 52 |
#define MPTV_REPEAT_NO_SERIES_OFFSET 0x7FFFFFF |
| 53 |
#define MPTV_NO_PARENT_SCHEDULE -1 |
| 54 |
|
| 55 |
// Kodi Keep methods : |
| 56 |
// The defines below are uses as replacement for the MediaPortal Until date version since |
| 57 |
// we cannot have both data selection and the three above keep methods at the same time |
| 58 |
#define MPTV_KEEP_ONE_WEEK 7 |
| 59 |
#define MPTV_KEEP_TWO_WEEKS 14 |
| 60 |
#define MPTV_KEEP_THREE_WEEKS 21 |
| 61 |
#define MPTV_KEEP_ONE_MONTH 31 |
| 62 |
#define MPTV_KEEP_TWO_MONTHS 61 |
| 63 |
#define MPTV_KEEP_THREE_MONTHS 92 |
| 64 |
#define MPTV_KEEP_FOUR_MONTHS 122 |
| 65 |
#define MPTV_KEEP_FIVE_MONTHS 153 |
| 66 |
#define MPTV_KEEP_SIX_MONTHS 183 |
| 67 |
#define MPTV_KEEP_SEVEN_MONTHS 214 |
| 68 |
#define MPTV_KEEP_EIGHT_MONTHS 244 |
| 69 |
#define MPTV_KEEP_NINE_MONTHS 275 |
| 70 |
#define MPTV_KEEP_TEN_MONTHS 305 |
| 71 |
#define MPTV_KEEP_ELEVEN_MONTHS 336 |
| 72 |
#define MPTV_KEEP_ONE_YEAR 365 |
| 73 |
|
| 74 |
#define MPTV_KEEP_UNTIL_SPACE_NEEDED TvDatabase::UntilSpaceNeeded |
| 75 |
#define MPTV_KEEP_UNTIL_WATCHED TvDatabase::UntilWatched |
| 76 |
#define MPTV_KEEP_ALWAYS TvDatabase::Always |
| 77 |
|
| 78 |
// Kodi timer types |
| 79 |
const int MPTV_RECORD_ONCE = |
| 80 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 81 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 82 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 83 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 84 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 85 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 86 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 87 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH; |
| 88 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 89 |
|
| 90 |
const int MPTV_RECORD_EVERY_TIME_ON_THIS_CHANNEL = |
| 91 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 92 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 93 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 94 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 95 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 96 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 97 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH; |
| 98 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 99 |
|
| 100 |
const int MPTV_RECORD_EVERY_TIME_ON_EVERY_CHANNEL = |
| 101 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 102 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 103 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 104 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 105 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 106 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 107 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 108 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH | |
| 109 |
PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL; |
| 110 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 111 |
|
| 112 |
const int MPTV_RECORD_WEEKLY = |
| 113 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 114 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 115 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 116 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 117 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 118 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 119 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 120 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 121 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH; |
| 122 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 123 |
|
| 124 |
const int MPTV_RECORD_DAILY = |
| 125 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 126 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 127 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 128 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 129 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 130 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 131 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 132 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 133 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH; |
| 134 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 135 |
|
| 136 |
const int MPTV_RECORD_WORKING_DAYS = |
| 137 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 138 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 139 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 140 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 141 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 142 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 143 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 144 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME; |
| 145 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 146 |
|
| 147 |
const int MPTV_RECORD_WEEEKENDS = |
| 148 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 149 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 150 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 151 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 152 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 153 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 154 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 155 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME; |
| 156 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 157 |
|
| 158 |
const int MPTV_RECORD_WEEKLY_EVERY_TIME_ON_THIS_CHANNEL = |
| 159 |
PVR_TIMER_TYPE_IS_REPEATING | |
| 160 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 161 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 162 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 163 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 164 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME | |
| 165 |
PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH; |
| 166 |
//PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS; |
| 167 |
|
| 168 |
const int MPTV_RECORD_MANUAL = |
| 169 |
PVR_TIMER_TYPE_IS_MANUAL | |
| 170 |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | |
| 171 |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS | |
| 172 |
PVR_TIMER_TYPE_SUPPORTS_START_TIME | |
| 173 |
PVR_TIMER_TYPE_SUPPORTS_END_TIME | |
| 174 |
PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | |
| 175 |
//PVR_TIMER_TYPE_SUPPORTS_PRIORITY | |
| 176 |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME; |
| 177 |
|
| 178 |
class cLifeTimeValues |
| 179 |
{ |
| 180 |
public: |
| 181 |
cLifeTimeValues(); |
| 182 |
void SetLifeTimeValues(kodi::addon::PVRTimerType& timertype); |
| 183 |
private: |
| 184 |
std::vector<kodi::addon::PVRTypeIntValue> m_lifetimeValues; |
| 185 |
}; |
| 186 |
|
| 187 |
class cTimer |
| 188 |
{ |
| 189 |
public: |
| 190 |
cTimer(); |
| 191 |
cTimer(const kodi::addon::PVRTimer &timerinfo); |
| 192 |
virtual ~cTimer(); |
| 193 |
|
| 194 |
void GetPVRtimerinfo(kodi::addon::PVRTimer &tag); |
| 195 |
int Index(void) const { return m_index; } |
| 196 |
unsigned int Channel(void) const { return m_channel; } |
| 197 |
int Priority(void) { return Mepo2XBMCPriority(m_priority); } |
| 198 |
const char* Title(void) const { return m_title.c_str(); } |
| 199 |
const char* Dir(void) const { return m_directory.c_str(); } |
| 200 |
time_t StartTime(void) const; |
| 201 |
time_t EndTime(void) const; |
| 202 |
bool ParseLine(const char *s); |
| 203 |
int PreRecordInterval(void) const { return m_prerecordinterval; } |
| 204 |
int PostRecordInterval(void) const { return m_postrecordinterval; } |
| 205 |
int RepeatFlags() { return SchedRecType2RepeatFlags(m_schedtype); }; |
| 206 |
bool Repeat() const { return (m_schedtype == TvDatabase::Once ? false : true); }; |
| 207 |
bool Done() const { return m_done; }; |
| 208 |
bool IsManual() const { return m_ismanual; }; |
| 209 |
bool IsActive() const { return (m_canceled==MPTV::cUndefinedDate); }; |
| 210 |
bool IsRecording() const { return m_isrecording; }; |
| 211 |
TvDatabase::ScheduleRecordingType RepeatFlags2SchedRecType(int repeatflags); |
| 212 |
std::string AddScheduleCommand(); |
| 213 |
std::string UpdateScheduleCommand(); |
| 214 |
void SetScheduleRecordingType(TvDatabase::ScheduleRecordingType schedType); |
| 215 |
void SetKeepMethod(TvDatabase::KeepMethodType keepmethod); |
| 216 |
void SetPreRecordInterval(int minutes); |
| 217 |
void SetPostRecordInterval(int minutes); |
| 218 |
|
| 219 |
void SetGenreTable(CGenreTable* genretable); |
| 220 |
|
| 221 |
private: |
| 222 |
int SchedRecType2RepeatFlags(TvDatabase::ScheduleRecordingType schedtype); |
| 223 |
|
| 224 |
/** |
| 225 |
* @brief Convert a XBMC Lifetime value to MediaPortals keepMethod+keepDate settings |
| 226 |
* @param lifetime the XBMC lifetime value (in days) (following the VDR syntax) |
| 227 |
* Should be called after setting m_starttime !! |
| 228 |
*/ |
| 229 |
void SetKeepMethod(int lifetime); |
| 230 |
int GetLifetime(void); |
| 231 |
int XBMC2MepoPriority(int xbmcprio); |
| 232 |
int Mepo2XBMCPriority(int mepoprio); |
| 233 |
|
| 234 |
// MediaPortal database fields: |
| 235 |
int m_index; ///> MediaPortal id_Schedule |
| 236 |
int m_channel; ///> MediaPortal idChannel |
| 237 |
TvDatabase::ScheduleRecordingType m_schedtype; ///> MediaPortal scheduleType |
| 238 |
std::string m_title; ///> MediaPortal programName |
| 239 |
MPTV::CDateTime m_startTime; ///> MediaPortal startTime |
| 240 |
MPTV::CDateTime m_endTime; ///> MediaPortal endTime |
| 241 |
// skipped: maxAirings field = episodes to keep |
| 242 |
int m_priority; ///> MediaPortal priority (not the XBMC one!!!) |
| 243 |
std::string m_directory; ///> MediaPortal directory |
| 244 |
// skipped: quality field |
| 245 |
TvDatabase::KeepMethodType m_keepmethod; ///> MediaPortal keepMethod |
| 246 |
MPTV::CDateTime m_keepDate; ///> MediaPortal keepDate |
| 247 |
int m_prerecordinterval; ///> MediaPortal preRecordInterval |
| 248 |
int m_postrecordinterval; ///> MediaPortal postRecordInterval |
| 249 |
MPTV::CDateTime m_canceled; ///> MediaPortal canceled (date + time) |
| 250 |
// skipped: recommendedCard |
| 251 |
bool m_series; ///> MediaPortal series |
| 252 |
int m_parentScheduleID; ///> MediaPortal idParentSchedule |
| 253 |
|
| 254 |
// XBMC asks for these fields: |
| 255 |
bool m_active; |
| 256 |
bool m_done; |
| 257 |
bool m_ismanual; |
| 258 |
bool m_isrecording; |
| 259 |
|
| 260 |
int m_progid; ///> MediaPortal Program ID |
| 261 |
std::string m_genre; ///> The genre string for the program |
| 262 |
std::string m_description; ///> Program description |
| 263 |
|
| 264 |
CGenreTable* m_genretable; |
| 265 |
}; |
| 266 |
|
| 267 |
namespace Timer |
| 268 |
{ |
| 269 |
// Life time values for the recordings |
| 270 |
extern cLifeTimeValues* lifetimeValues; |
| 271 |
}; |
| 272 |
|
| 273 |
#endif //__TIMERS_H |