3 * Copyright (C) 2012-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
25 * CPVRTimerInfoTag is part of the PVRManager to support sheduled recordings.
27 * The timer information tag holds data about current programmed timers for
28 * the PVRManager. It is possible to create timers directly based upon
29 * a EPG entry by giving the EPG information tag or as instant timer
30 * on currently tuned channel, or give a blank tag to modify later.
32 * With exception of the blank one, the tag can easily and unmodified added
33 * by the PVRManager function "bool AddTimer(const CFileItem &item)" to
36 * The filename inside the tag is for reference only and gives the index
37 * number of the tag reported by the PVR backend and can not be played!
40 #include "XBDateTime.h"
41 #include "addons/include/xbmc_pvr_types.h"
43 #include <boost/shared_ptr.hpp>
50 typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr;
55 class CGUIDialogPVRTimerSettings;
57 class CPVRChannelGroupInternal;
60 typedef boost::shared_ptr<PVR::CPVRChannel> CPVRChannelPtr;
62 class CPVRTimerInfoTag;
63 typedef boost::shared_ptr<PVR::CPVRTimerInfoTag> CPVRTimerInfoTagPtr;
64 #define PVR_VIRTUAL_CHANNEL_UID (-1)
66 class CPVRTimerInfoTag
68 friend class CPVRTimers;
69 friend class CGUIDialogPVRTimerSettings;
72 CPVRTimerInfoTag(void);
73 CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId);
74 virtual ~CPVRTimerInfoTag(void);
76 bool operator ==(const CPVRTimerInfoTag& right) const;
77 bool operator !=(const CPVRTimerInfoTag& right) const;
78 CPVRTimerInfoTag &operator=(const CPVRTimerInfoTag &orig);
80 int Compare(const CPVRTimerInfoTag &timer) const;
82 void UpdateSummary(void);
84 void DisplayError(PVR_ERROR err) const;
86 CStdString GetStatus() const;
88 bool SetDuration(int iDuration);
90 static CPVRTimerInfoTag *CreateFromEpg(const EPG::CEpgInfoTag &tag);
91 EPG::CEpgInfoTagPtr GetEpgInfoTag(void) const;
93 int ChannelNumber(void) const;
94 CStdString ChannelName(void) const;
95 CStdString ChannelIcon(void) const;
96 CPVRChannelPtr ChannelTag(void) const;
98 bool UpdateEntry(const CPVRTimerInfoTag &tag);
100 void UpdateEpgEvent(bool bClear = false);
102 bool IsActive(void) const
104 return m_state == PVR_TIMER_STATE_SCHEDULED
105 || m_state == PVR_TIMER_STATE_RECORDING
106 || m_state == PVR_TIMER_STATE_CONFLICT_OK
107 || m_state == PVR_TIMER_STATE_CONFLICT_NOK
108 || m_state == PVR_TIMER_STATE_ERROR;
111 bool IsRecording(void) const { return m_state == PVR_TIMER_STATE_RECORDING; }
113 CDateTime StartAsUTC(void) const;
114 CDateTime StartAsLocalTime(void) const;
115 void SetStartFromUTC(CDateTime &start) { m_StartTime = start; }
116 void SetStartFromLocalTime(CDateTime &start) { m_StartTime = start.GetAsUTCDateTime(); }
118 CDateTime EndAsUTC(void) const;
119 CDateTime EndAsLocalTime(void) const;
120 void SetEndFromUTC(CDateTime &end) { m_StopTime = end; }
121 void SetEndFromLocalTime(CDateTime &end) { m_StopTime = end.GetAsUTCDateTime(); }
123 CDateTime FirstDayAsUTC(void) const;
124 CDateTime FirstDayAsLocalTime(void) const;
125 void SetFirstDayFromUTC(CDateTime &firstDay) { m_FirstDay = firstDay; }
126 void SetFirstDayFromLocalTime(CDateTime &firstDay) { m_FirstDay = firstDay.GetAsUTCDateTime(); }
128 unsigned int MarginStart(void) const { return m_iMarginStart; }
129 void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; }
131 unsigned int MarginEnd(void) const { return m_iMarginEnd; }
132 void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; }
134 bool SupportsFolders() const;
137 * @brief Show a notification for this timer in the UI
139 void QueueNotification(void) const;
142 * @brief Get the text for the notification.
143 * @param strText The notification.
145 void GetNotificationText(CStdString &strText) const;
147 CStdString Title(void) const;
148 CStdString Summary(void) const;
149 CStdString Path(void) const;
151 /* Client control functions */
152 bool AddToClient() const;
153 bool DeleteFromClient(bool bForce = false) const;
154 bool RenameOnClient(const CStdString &strNewName);
155 bool UpdateOnClient();
157 void SetEpgInfoTag(EPG::CEpgInfoTagPtr tag);
158 void ClearEpgTag(void);
160 void UpdateChannel(void);
162 CStdString m_strTitle; /*!< @brief name of this timer */
163 CStdString m_strDirectory; /*!< @brief directory where the recording must be stored */
164 CStdString m_strSummary; /*!< @brief summary string with the time to show inside a GUI list */
165 PVR_TIMER_STATE m_state; /*!< @brief the state of this timer */
166 int m_iClientId; /*!< @brief ID of the backend */
167 int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */
168 int m_iClientChannelUid; /*!< @brief channel uid */
169 int m_iPriority; /*!< @brief priority of the timer */
170 int m_iLifetime; /*!< @brief lifetime of the timer in days */
171 bool m_bIsRepeating; /*!< @brief repeating timer if true, use the m_FirstDay and repeat flags */
172 int m_iWeekdays; /*!< @brief bit based store of weekdays to repeat */
173 CStdString m_strFileNameAndPath; /*!< @brief filename is only for reference */
174 int m_iChannelNumber; /*!< @brief integer value of the channel number */
175 bool m_bIsRadio; /*!< @brief is radio channel if set */
177 CPVRChannelPtr m_channel;
178 unsigned int m_iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */
179 unsigned int m_iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */
180 std::vector<std::string> m_genre; /*!< @brief genre of the timer */
181 int m_iGenreType; /*!< @brief genre type of the timer */
182 int m_iGenreSubType; /*!< @brief genre subtype of the timer */
185 CCriticalSection m_critSection;
186 EPG::CEpgInfoTagPtr m_epgTag;
187 CDateTime m_StartTime; /*!< start time */
188 CDateTime m_StopTime; /*!< stop time */
189 CDateTime m_FirstDay; /*!< if it is a repeating timer the first date it starts */