[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / pvr / timers / PVRTimerInfoTag.h
1 #pragma once
2 /*
3  *      Copyright (C) 2012-2013 Team XBMC
4  *      http://xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 /*
23  * DESCRIPTION:
24  *
25  * CPVRTimerInfoTag is part of the PVRManager to support sheduled recordings.
26  *
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.
31  *
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
34  * the backend server.
35  *
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!
38  */
39
40 #include "XBDateTime.h"
41 #include "addons/include/xbmc_pvr_types.h"
42
43 #include <boost/shared_ptr.hpp>
44
45 class CFileItem;
46
47 namespace EPG
48 {
49   class CEpgInfoTag;
50   typedef boost::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr;
51 }
52
53 namespace PVR
54 {
55   class CGUIDialogPVRTimerSettings;
56   class CPVRTimers;
57   class CPVRChannelGroupInternal;
58
59   class CPVRChannel;
60   typedef boost::shared_ptr<PVR::CPVRChannel> CPVRChannelPtr;
61
62   class CPVRTimerInfoTag;
63   typedef boost::shared_ptr<PVR::CPVRTimerInfoTag> CPVRTimerInfoTagPtr;
64   #define PVR_VIRTUAL_CHANNEL_UID (-1)
65
66   class CPVRTimerInfoTag
67   {
68     friend class CPVRTimers;
69     friend class CGUIDialogPVRTimerSettings;
70
71   public:
72     CPVRTimerInfoTag(void);
73     CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId);
74     virtual ~CPVRTimerInfoTag(void);
75
76     bool operator ==(const CPVRTimerInfoTag& right) const;
77     bool operator !=(const CPVRTimerInfoTag& right) const;
78     CPVRTimerInfoTag &operator=(const CPVRTimerInfoTag &orig);
79
80     int Compare(const CPVRTimerInfoTag &timer) const;
81
82     void UpdateSummary(void);
83
84     void DisplayError(PVR_ERROR err) const;
85
86     CStdString GetStatus() const;
87
88     bool SetDuration(int iDuration);
89
90     static CPVRTimerInfoTag *CreateFromEpg(const EPG::CEpgInfoTag &tag);
91     EPG::CEpgInfoTagPtr GetEpgInfoTag(void) const;
92
93     int ChannelNumber(void) const;
94     CStdString ChannelName(void) const;
95     CStdString ChannelIcon(void) const;
96     CPVRChannelPtr ChannelTag(void) const;
97
98     bool UpdateEntry(const CPVRTimerInfoTag &tag);
99
100     void UpdateEpgEvent(bool bClear = false);
101
102     bool IsActive(void) const 
103     {   
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;
109     }
110
111     bool IsRecording(void) const { return m_state == PVR_TIMER_STATE_RECORDING; }
112
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(); }
117
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(); }
122
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(); }
127
128     unsigned int MarginStart(void) const { return m_iMarginStart; }
129     void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; }
130
131     unsigned int MarginEnd(void) const { return m_iMarginEnd; }
132     void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; }
133
134     bool SupportsFolders() const;
135
136     /*!
137      * @brief Show a notification for this timer in the UI
138      */
139     void QueueNotification(void) const;
140
141     /*!
142      * @brief Get the text for the notification.
143      * @param strText The notification.
144      */
145     void GetNotificationText(CStdString &strText) const;
146
147     CStdString Title(void) const;
148     CStdString Summary(void) const;
149     CStdString Path(void) const;
150
151     /* Client control functions */
152     bool AddToClient() const;
153     bool DeleteFromClient(bool bForce = false) const;
154     bool RenameOnClient(const CStdString &strNewName);
155     bool UpdateOnClient();
156
157     void SetEpgInfoTag(EPG::CEpgInfoTagPtr tag);
158     void ClearEpgTag(void);
159
160     void UpdateChannel(void);
161
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 */
176
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 */
183
184   private:
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 */
190   };
191 }