[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / pvr / channels / PVRChannelGroupInternal.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2012-2013 Team XBMC
5  *      http://www.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 "PVRChannelGroup.h"
24
25 namespace PVR
26 {
27   class CPVRChannelGroups;
28   class CPVRDatabase;
29
30   /** XBMC's internal group, the group containing all channels */
31
32   class CPVRChannelGroupInternal : public CPVRChannelGroup
33   {
34     friend class CPVRChannelGroups;
35     friend class CPVRDatabase;
36
37   public:
38     /*!
39      * @brief Create a new internal channel group.
40      * @param bRadio True if this group holds radio channels.
41      */
42     CPVRChannelGroupInternal(bool bRadio);
43
44     CPVRChannelGroupInternal(const CPVRChannelGroup &group);
45
46     virtual ~CPVRChannelGroupInternal(void);
47
48     /**
49      * @brief The amount of channels in this container.
50      * @return The amount of channels in this container.
51      */
52     int GetNumHiddenChannels() const { return m_iHiddenChannels; }
53
54     /*!
55      * @brief Add or update a channel in this table.
56      * @param channel The channel to update.
57      * @return True if the channel was updated and persisted.
58      */
59     bool UpdateChannel(const CPVRChannel &channel);
60
61     /*!
62      * @brief Add a channel to this internal group.
63      * @param iChannelNumber The channel number to use for this channel or 0 to add it to the back.
64      */
65     bool InsertInGroup(CPVRChannel &channel, int iChannelNumber = 0);
66
67     /*!
68      * @brief Callback for add-ons to update a channel.
69      * @param channel The updated channel.
70      * @return True if the channel has been updated succesfully, false otherwise.
71      */
72     void UpdateFromClient(const CPVRChannel &channel, unsigned int iChannelNumber = 0);
73
74     /*!
75      * @see CPVRChannelGroup::IsGroupMember
76      */
77     bool IsGroupMember(const CPVRChannel &channel) const;
78
79     /*!
80      * @see CPVRChannelGroup::AddToGroup
81      */
82     bool AddToGroup(CPVRChannel &channel, int iChannelNumber = 0);
83
84     /*!
85      * @see CPVRChannelGroup::RemoveFromGroup
86      */
87     bool RemoveFromGroup(const CPVRChannel &channel);
88
89     /*!
90      * @see CPVRChannelGroup::MoveChannel
91      */
92     bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true);
93
94     /*!
95      * @see CPVRChannelGroup::GetMembers
96      */
97     int GetMembers(CFileItemList &results, bool bGroupMembers = true) const;
98
99     /*!
100      * @brief Check whether the group name is still correct after the language setting changed.
101      */
102     void CheckGroupName(void);
103
104     /*!
105      * @brief Create an EPG table for each channel.
106      * @brief bForce Create the tables, even if they already have been created before.
107      * @return True if all tables were created successfully, false otherwise.
108      */
109     bool CreateChannelEpgs(bool bForce = false);
110
111     bool AddNewChannel(const CPVRChannel &channel, unsigned int iChannelNumber = 0) { UpdateFromClient(channel, iChannelNumber); return true; }
112
113   protected:
114     /*!
115      * @brief Load all channels from the database.
116      * @param bCompress Compress the database after changing anything.
117      * @return The amount of channels that were loaded.
118      */
119     int LoadFromDb(bool bCompress = false);
120
121     /*!
122      * @brief Load all channels from the clients.
123      * @return True when updated succesfully, false otherwise.
124      */
125     bool LoadFromClients(void);
126
127     /*!
128      * @brief Check if this group is the internal group containing all channels.
129      * @return True if it's the internal group, false otherwise.
130      */
131     bool IsInternalGroup(void) const { return true; }
132
133     /*!
134      * @brief Update the current channel list with the given list.
135      *
136      * Update the current channel list with the given list.
137      * Only the new channels will be present in the passed list after this call.
138      *
139      * @param channels The channels to use to update this list.
140      * @return True if everything went well, false otherwise.
141      */
142     bool UpdateGroupEntries(const CPVRChannelGroup &channels);
143
144     bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers);
145
146     /*!
147      * @brief Refresh the channel list from the clients.
148      */
149     bool Update(void);
150
151     /*!
152      * @brief Remove invalid channels and updates the channel numbers.
153      */
154     bool Renumber(void);
155
156     /*!
157      * @brief Load the channels from the database.
158      *
159      * Load the channels from the database.
160      * If no channels are stored in the database, then the channels will be loaded from the clients.
161      *
162      * @return True when loaded successfully, false otherwise.
163      */
164     bool Load(void);
165
166     /*!
167      * @brief Update the vfs paths of all channels.
168      */
169     void UpdateChannelPaths(void);
170
171     void CreateChannelEpg(CPVRChannelPtr channel, bool bForce = false);
172
173     int m_iHiddenChannels; /*!< the amount of hidden channels in this container */
174   };
175 }