[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / pvr / channels / PVRChannelGroupsContainer.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2012-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "PVRChannelGroups.h"
24 #include "threads/Thread.h"
25 #include "threads/CriticalSection.h"
26
27 namespace PVR
28 {
29   class CPVRManager;
30   class CPVRChannelsUpdateJob;
31   class CPVRChannelGroupsUpdateJob;
32
33   class CPVRChannelGroupsContainer
34   {
35     friend class CPVRManager;
36     friend class CPVRChannelsUpdateJob;
37     friend class CPVRChannelGroupsUpdateJob;
38
39   public:
40     /*!
41      * @brief Create a new container for all channel groups
42      */
43     CPVRChannelGroupsContainer(void);
44
45     /*!
46      * @brief Destroy this container.
47      */
48     virtual ~CPVRChannelGroupsContainer(void);
49
50     /*!
51      * @brief Load all channel groups and all channels in those channel groups.
52      * @return True if all groups were loaded, false otherwise.
53      */
54     bool Load(void);
55
56     /*!
57      * @brief Unload and destruct all channel groups and all channels in them.
58      */
59     void Unload(void);
60
61     /*!
62      * @brief Get the TV channel groups.
63      * @return The TV channel groups.
64      */
65     CPVRChannelGroups *GetTV(void) const { return Get(false); }
66
67     /*!
68      * @brief Get the radio channel groups.
69      * @return The radio channel groups.
70      */
71     CPVRChannelGroups *GetRadio(void) const { return Get(true); }
72
73     /*!
74      * @brief Get the radio or TV channel groups.
75      * @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise.
76      * @return The requested groups.
77      */
78     CPVRChannelGroups *Get(bool bRadio) const;
79
80     /*!
81      * @brief Get the group containing all TV channels.
82      * @return The group containing all TV channels.
83      */
84     CPVRChannelGroupPtr GetGroupAllTV(void)  const{ return GetGroupAll(false); }
85
86     /*!
87      * @brief Get the group containing all radio channels.
88      * @return The group containing all radio channels.
89      */
90     CPVRChannelGroupPtr GetGroupAllRadio(void)  const{ return GetGroupAll(true); }
91
92     /*!
93      * @brief Get the group containing all TV or radio channels.
94      * @param bRadio If true, get the group containing all radio channels. Get the group containing all TV channels otherwise.
95      * @return The requested group.
96      */
97     CPVRChannelGroupPtr GetGroupAll(bool bRadio) const;
98
99     /*!
100      * @brief Get a group given it's ID.
101      * @param iGroupId The ID of the group.
102      * @return The requested group or NULL if it wasn't found.
103      */
104     CPVRChannelGroupPtr GetByIdFromAll(int iGroupId) const;
105
106     /*!
107      * @brief Get a channel given it's database ID.
108      * @param iChannelId The ID of the channel.
109      * @return The channel or NULL if it wasn't found.
110      */
111     CPVRChannelPtr GetChannelById(int iChannelId) const;
112
113     /*!
114      * @brief Get a channel given it's EPG ID.
115      * @param iEpgId The EPG ID of the channel.
116      * @return The channel or NULL if it wasn't found.
117      */
118     CPVRChannelPtr GetChannelByEpgId(int iEpgId) const;
119
120     /*!
121      * @brief Get the groups list for a directory.
122      * @param strBase The directory path.
123      * @param results The file list to store the results in.
124      * @param bRadio Get radio channels or tv channels.
125      * @return True if the list was filled succesfully.
126      */
127     bool GetGroupsDirectory(CFileItemList *results, bool bRadio);
128
129     /*!
130      * @brief Get a channel given it's path.
131      * @param strPath The path.
132      * @return The channel or NULL if it wasn't found.
133      */
134     CFileItemPtr GetByPath(const CStdString &strPath) const;
135
136     /*!
137      * @brief Get the directory for a path.
138      * @param strPath The path.
139      * @param results The file list to store the results in.
140      * @return True if the directory was found, false if not.
141      */
142     bool GetDirectory(const CStdString& strPath, CFileItemList &results);
143
144     /*!
145      * @brief The total amount of unique channels in all containers.
146      * @return The total amount of unique channels in all containers.
147      */
148     int GetNumChannelsFromAll(void);
149
150     /*!
151      * @brief Get the group that is currently selected in the UI.
152      * @param bRadio True to get the selected radio group, false to get the selected TV group.
153      * @return The selected group.
154      */
155     CPVRChannelGroupPtr GetSelectedGroup(bool bRadio) const;
156
157     /*!
158      * @brief Get a channel given it's channel ID from all containers.
159      * @param iUniqueChannelId The unique channel id on the client.
160      * @param iClientID The ID of the client.
161      * @return The channel or NULL if it wasn't found.
162      */
163     CPVRChannelPtr GetByUniqueID(int iUniqueChannelId, int iClientID);
164
165     /*!
166      * @brief Get a channel given it's channel ID from all containers.
167      * @param iChannelID The channel ID.
168      * @return The channel or NULL if it wasn't found.
169      */
170     CFileItemPtr GetByChannelIDFromAll(int iChannelID);
171
172     /*!
173      * @brief Try to find missing channel icons automatically
174      */
175     void SearchMissingChannelIcons(void);
176
177     /*!
178      * @brief The channel that was played last that has a valid client or NULL if there was none.
179      * @return The requested channel.
180      */
181     CFileItemPtr GetLastPlayedChannel(void) const;
182
183     bool CreateChannel(const CPVRChannel &channel);
184
185     /*!
186      * @brief Create EPG tags for channels in all internal channel groups.
187      * @return True if EPG tags were created succesfully.
188      */
189     bool CreateChannelEpgs(void);
190
191   protected:
192     /*!
193      * @brief Update the contents of all the groups in this container.
194      * @param bChannelsOnly Set to true to only update channels, not the groups themselves.
195      * @return True if the update was successful, false otherwise.
196      */
197     bool Update(bool bChannelsOnly = false);
198
199     CPVRChannelGroups *m_groupsRadio; /*!< all radio channel groups */
200     CPVRChannelGroups *m_groupsTV;    /*!< all TV channel groups */
201     CCriticalSection   m_critSection;
202     bool               m_bUpdateChannelsOnly;
203     bool               m_bIsUpdating;
204   };
205 }