4 * Copyright (C) 2012-2013 Team XBMC
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)
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.
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/>.
23 #include "PVRChannelGroups.h"
24 #include "threads/Thread.h"
25 #include "threads/CriticalSection.h"
30 class CPVRChannelsUpdateJob;
31 class CPVRChannelGroupsUpdateJob;
33 class CPVRChannelGroupsContainer
35 friend class CPVRManager;
36 friend class CPVRChannelsUpdateJob;
37 friend class CPVRChannelGroupsUpdateJob;
41 * @brief Create a new container for all channel groups
43 CPVRChannelGroupsContainer(void);
46 * @brief Destroy this container.
48 virtual ~CPVRChannelGroupsContainer(void);
51 * @brief Load all channel groups and all channels in those channel groups.
52 * @return True if all groups were loaded, false otherwise.
57 * @brief Unload and destruct all channel groups and all channels in them.
62 * @brief Get the TV channel groups.
63 * @return The TV channel groups.
65 CPVRChannelGroups *GetTV(void) const { return Get(false); }
68 * @brief Get the radio channel groups.
69 * @return The radio channel groups.
71 CPVRChannelGroups *GetRadio(void) const { return Get(true); }
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.
78 CPVRChannelGroups *Get(bool bRadio) const;
81 * @brief Get the group containing all TV channels.
82 * @return The group containing all TV channels.
84 CPVRChannelGroupPtr GetGroupAllTV(void) const{ return GetGroupAll(false); }
87 * @brief Get the group containing all radio channels.
88 * @return The group containing all radio channels.
90 CPVRChannelGroupPtr GetGroupAllRadio(void) const{ return GetGroupAll(true); }
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.
97 CPVRChannelGroupPtr GetGroupAll(bool bRadio) const;
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.
104 CPVRChannelGroupPtr GetByIdFromAll(int iGroupId) const;
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.
111 CPVRChannelPtr GetChannelById(int iChannelId) const;
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.
118 CPVRChannelPtr GetChannelByEpgId(int iEpgId) const;
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.
127 bool GetGroupsDirectory(CFileItemList *results, bool bRadio);
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.
134 CFileItemPtr GetByPath(const CStdString &strPath) const;
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.
142 bool GetDirectory(const CStdString& strPath, CFileItemList &results);
145 * @brief The total amount of unique channels in all containers.
146 * @return The total amount of unique channels in all containers.
148 int GetNumChannelsFromAll(void);
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.
155 CPVRChannelGroupPtr GetSelectedGroup(bool bRadio) const;
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.
163 CPVRChannelPtr GetByUniqueID(int iUniqueChannelId, int iClientID);
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.
170 CFileItemPtr GetByChannelIDFromAll(int iChannelID);
173 * @brief Try to find missing channel icons automatically
175 void SearchMissingChannelIcons(void);
178 * @brief The channel that was played last that has a valid client or NULL if there was none.
179 * @return The requested channel.
181 CFileItemPtr GetLastPlayedChannel(void) const;
183 bool CreateChannel(const CPVRChannel &channel);
186 * @brief Create EPG tags for channels in all internal channel groups.
187 * @return True if EPG tags were created succesfully.
189 bool CreateChannelEpgs(void);
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.
197 bool Update(bool bChannelsOnly = false);
199 CPVRChannelGroups *m_groupsRadio; /*!< all radio channel groups */
200 CPVRChannelGroups *m_groupsTV; /*!< all TV channel groups */
201 CCriticalSection m_critSection;
202 bool m_bUpdateChannelsOnly;