[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / pvr / timers / PVRTimerInfoTag.h
1 #pragma once
2 /*
3  *      Copyright (C) 2012-2013 Team XBMC
4  *      http://www.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
65   class CPVRTimerInfoTag
66   {
67     friend class CPVRTimers;
68     friend class CGUIDialogPVRTimerSettings;
69
70   public:
71     CPVRTimerInfoTag(void);
72     CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId);
73     virtual ~CPVRTimerInfoTag(void);
74
75     bool operator ==(const CPVRTimerInfoTag& right) const;
76     bool operator !=(const CPVRTimerInfoTag& right) const;
77     CPVRTimerInfoTag &operator=(const CPVRTimerInfoTag &orig);
78
79     int Compare(const CPVRTimerInfoTag &timer) const;
80
81     void UpdateSummary(void);
82
83     void DisplayError(PVR_ERROR err) const;
84
85     CStdString GetStatus() const;
86
87     bool SetDuration(int iDuration);
88
89     static CPVRTimerInfoTag *CreateFromEpg(const EPG::CEpgInfoTag &tag);
90     EPG::CEpgInfoTagPtr GetEpgInfoTag(void) const;
91
92     int ChannelNumber(void) const;
93     CStdString ChannelName(void) const;
94     CStdString ChannelIcon(void) const;
95     CPVRChannelPtr ChannelTag(void) const;
96
97     bool UpdateEntry(const CPVRTimerInfoTag &tag);
98
99     void UpdateEpgEvent(bool bClear = false);
100
101     bool IsActive(void) const 
102     {   
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;
108     }
109
110     bool IsRecording(void) const { return m_state == PVR_TIMER_STATE_RECORDING; }
111
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(); }
116
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(); }
121
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(); }
126
127     unsigned int MarginStart(void) const { return m_iMarginStart; }
128     void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; }
129
130     unsigned int MarginEnd(void) const { return m_iMarginEnd; }
131     void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; }
132
133     bool SupportsFolders() const;
134
135     /*!
136      * @brief Show a notification for this timer in the UI
137      */
138     void QueueNotification(void) const;
139
140     /*!
141      * @brief Get the text for the notification.
142      * @param strText The notification.
143      */
144     void GetNotificationText(CStdString &strText) const;
145
146     CStdString Title(void) const;
147     CStdString Summary(void) const;
148     CStdString Path(void) const;
149
150     /* Client control functions */
151     bool AddToClient() const;
152     bool DeleteFromClient(bool bForce = false) const;
153     bool RenameOnClient(const CStdString &strNewName);
154     bool UpdateOnClient();
155
156     void SetEpgInfoTag(EPG::CEpgInfoTagPtr tag);
157     void ClearEpgTag(void);
158
159     void UpdateChannel(void);
160
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 */
175
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 */
182
183   private:
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 */
189   };
190 }