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;
65 class CPVRTimerInfoTag
67 friend class CPVRTimers;
68 friend class CGUIDialogPVRTimerSettings;
71 CPVRTimerInfoTag(void);
72 CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId);
73 virtual ~CPVRTimerInfoTag(void);
75 bool operator ==(const CPVRTimerInfoTag& right) const;
76 bool operator !=(const CPVRTimerInfoTag& right) const;
77 CPVRTimerInfoTag &operator=(const CPVRTimerInfoTag &orig);
79 int Compare(const CPVRTimerInfoTag &timer) const;
81 void UpdateSummary(void);
83 void DisplayError(PVR_ERROR err) const;
85 CStdString GetStatus() const;
87 bool SetDuration(int iDuration);
89 static CPVRTimerInfoTag *CreateFromEpg(const EPG::CEpgInfoTag &tag);
90 EPG::CEpgInfoTagPtr GetEpgInfoTag(void) const;
92 int ChannelNumber(void) const;
93 CStdString ChannelName(void) const;
94 CStdString ChannelIcon(void) const;
95 CPVRChannelPtr ChannelTag(void) const;
97 bool UpdateEntry(const CPVRTimerInfoTag &tag);
99 void UpdateEpgEvent(bool bClear = false);
101 bool IsActive(void) const
103 return m_state == PVR_TIMER_STATE_SCHEDULED
104 || m_state == PVR_TIMER_STATE_RECORDING
105 || m_state == PVR_TIMER_STATE_CONFLICT_OK
106 || m_state == PVR_TIMER_STATE_CONFLICT_NOK
107 || m_state == PVR_TIMER_STATE_ERROR;
110 bool IsRecording(void) const { return m_state == PVR_TIMER_STATE_RECORDING; }
112 CDateTime StartAsUTC(void) const;
113 CDateTime StartAsLocalTime(void) const;
114 void SetStartFromUTC(CDateTime &start) { m_StartTime = start; }
115 void SetStartFromLocalTime(CDateTime &start) { m_StartTime = start.GetAsUTCDateTime(); }
117 CDateTime EndAsUTC(void) const;
118 CDateTime EndAsLocalTime(void) const;
119 void SetEndFromUTC(CDateTime &end) { m_StopTime = end; }
120 void SetEndFromLocalTime(CDateTime &end) { m_StopTime = end.GetAsUTCDateTime(); }
122 CDateTime FirstDayAsUTC(void) const;
123 CDateTime FirstDayAsLocalTime(void) const;
124 void SetFirstDayFromUTC(CDateTime &firstDay) { m_FirstDay = firstDay; }
125 void SetFirstDayFromLocalTime(CDateTime &firstDay) { m_FirstDay = firstDay.GetAsUTCDateTime(); }
127 unsigned int MarginStart(void) const { return m_iMarginStart; }
128 void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; }
130 unsigned int MarginEnd(void) const { return m_iMarginEnd; }
131 void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; }
133 bool SupportsFolders() const;
136 * @brief Show a notification for this timer in the UI
138 void QueueNotification(void) const;
141 * @brief Get the text for the notification.
142 * @param strText The notification.
144 void GetNotificationText(CStdString &strText) const;
146 CStdString Title(void) const;
147 CStdString Summary(void) const;
148 CStdString Path(void) const;
150 /* Client control functions */
151 bool AddToClient() const;
152 bool DeleteFromClient(bool bForce = false) const;
153 bool RenameOnClient(const CStdString &strNewName);
154 bool UpdateOnClient();
156 void SetEpgInfoTag(EPG::CEpgInfoTagPtr tag);
157 void ClearEpgTag(void);
159 void UpdateChannel(void);
161 CStdString m_strTitle; /*!< @brief name of this timer */
162 CStdString m_strDirectory; /*!< @brief directory where the recording must be stored */
163 CStdString m_strSummary; /*!< @brief summary string with the time to show inside a GUI list */
164 PVR_TIMER_STATE m_state; /*!< @brief the state of this timer */
165 int m_iClientId; /*!< @brief ID of the backend */
166 int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */
167 int m_iClientChannelUid; /*!< @brief channel uid */
168 int m_iPriority; /*!< @brief priority of the timer */
169 int m_iLifetime; /*!< @brief lifetime of the timer in days */
170 bool m_bIsRepeating; /*!< @brief repeating timer if true, use the m_FirstDay and repeat flags */
171 int m_iWeekdays; /*!< @brief bit based store of weekdays to repeat */
172 CStdString m_strFileNameAndPath; /*!< @brief filename is only for reference */
173 int m_iChannelNumber; /*!< @brief integer value of the channel number */
174 bool m_bIsRadio; /*!< @brief is radio channel if set */
176 CPVRChannelPtr m_channel;
177 unsigned int m_iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */
178 unsigned int m_iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */
179 std::vector<std::string> m_genre; /*!< @brief genre of the timer */
180 int m_iGenreType; /*!< @brief genre type of the timer */
181 int m_iGenreSubType; /*!< @brief genre subtype of the timer */
184 CCriticalSection m_critSection;
185 EPG::CEpgInfoTagPtr m_epgTag;
186 CDateTime m_StartTime; /*!< start time */
187 CDateTime m_StopTime; /*!< stop time */
188 CDateTime m_FirstDay; /*!< if it is a repeating timer the first date it starts */