Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pvr: CFileItemPtr return values in CPVRChannelGroup. removed unneeded…

… methods, some dupe code and virtual keywords. some methods still need to be done.
  • Loading branch information...
commit 4e72ffee1177838765917cca1c663121e9319f9c 1 parent baf9292
@opdenkamp opdenkamp authored
View
18 xbmc/filesystem/PVRFile.cpp
@@ -54,15 +54,11 @@ bool CPVRFile::Open(const CURL& url)
if (strURL.Left(18) == "pvr://channels/tv/" || strURL.Left(21) == "pvr://channels/radio/")
{
- const CPVRChannel *tag = g_PVRChannelGroups->GetByPath(strURL);
- if (tag)
+ CFileItemPtr tag = g_PVRChannelGroups->GetByPath(strURL);
+ if (tag && tag->HasPVRChannelInfoTag())
{
- CPVRChannel *newTag = new CPVRChannel(*tag);
- if (!g_PVRManager.OpenLiveStream(*newTag))
- {
- delete newTag;
+ if (!g_PVRManager.OpenLiveStream(*tag))
return false;
- }
m_isPlayRecording = false;
CLog::Log(LOGDEBUG, "PVRFile - %s - playback has started on filename %s", __FUNCTION__, strURL.c_str());
@@ -219,10 +215,10 @@ CStdString CPVRFile::TranslatePVRFilename(const CStdString& pathFile)
CStdString FileName = pathFile;
if (FileName.substr(0, 14) == "pvr://channels")
{
- const CPVRChannel *tag = g_PVRChannelGroups->GetByPath(FileName);
- if (tag)
+ CFileItemPtr channel = g_PVRChannelGroups->GetByPath(FileName);
+ if (channel && channel->HasPVRChannelInfoTag())
{
- CStdString stream = tag->StreamURL();
+ CStdString stream = channel->GetPVRChannelInfoTag()->StreamURL();
if(!stream.IsEmpty())
{
if (stream.compare(6, 7, "stream/") == 0)
@@ -231,7 +227,7 @@ CStdString CPVRFile::TranslatePVRFilename(const CStdString& pathFile)
// This function was added to retrieve the stream URL for this item
// Is is used for the MediaPortal (ffmpeg) PVR addon
// see PVRManager.cpp
- return g_PVRClients->GetStreamURL(*tag);
+ return g_PVRClients->GetStreamURL(*channel->GetPVRChannelInfoTag());
}
else
{
View
10 xbmc/interfaces/json-rpc/PVROperations.cpp
@@ -49,15 +49,15 @@ JSONRPC_STATUS CPVROperations::ChannelSwitch(const CStdString &method, ITranspor
CLog::Log(LOGDEBUG, "JSONRPC: switch to channel '%d'", iChannelId);
- const CPVRChannel *channel = g_PVRChannelGroups->GetByChannelIDFromAll(iChannelId);
- if (channel == NULL)
+ CFileItemPtr channel = g_PVRChannelGroups->GetByChannelIDFromAll(iChannelId);
+ if (!channel || !channel->HasPVRChannelInfoTag())
return InternalError;
CPVRChannel currentChannel;
- if (g_PVRManager.GetCurrentChannel(currentChannel) && currentChannel.IsRadio() == channel->IsRadio())
- CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)channel->ChannelNumber()));
+ if (g_PVRManager.GetCurrentChannel(currentChannel) && currentChannel.IsRadio() == channel->GetPVRChannelInfoTag()->IsRadio())
+ CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)channel->GetPVRChannelInfoTag()->ChannelNumber()));
else
- CApplicationMessenger::Get().MediaPlay(CFileItem(*channel));
+ CApplicationMessenger::Get().MediaPlay(*channel);
return ACK;
}
View
16 xbmc/pvr/PVRDatabase.cpp
@@ -370,7 +370,7 @@ int CPVRDatabase::Get(CPVRChannelGroupInternal &results)
CLog::Log(LOGDEBUG, "PVR - %s - channel '%s' loaded from the database", __FUNCTION__, channel->m_strChannelName.c_str());
PVRChannelGroupMember newMember = { channel, m_pDS->fv("iChannelNumber").get_asInt() };
- results.push_back(newMember);
+ results.m_members.push_back(newMember);
m_pDS->next();
++iReturn;
@@ -608,7 +608,7 @@ bool CPVRDatabase::RemoveStaleChannelsFromGroup(const CPVRChannelGroup &group)
bDelete = DeleteValues("map_channelgroups_channels", strWhereClause);
}
- if (group.size() > 0)
+ if (group.m_members.size() > 0)
{
vector<int> currentMembers;
if (GetCurrentGroupMembers(group, currentMembers))
@@ -710,7 +710,7 @@ int CPVRDatabase::Get(CPVRChannelGroup &group)
{
int iChannelId = m_pDS->fv("idChannel").get_asInt();
int iChannelNumber = m_pDS->fv("iChannelNumber").get_asInt();
- CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetByChannelIDFromAll(iChannelId);
+ CPVRChannel *channel = g_PVRChannelGroups->GetGroupAll(group.IsRadio())->GetByChannelID(iChannelId);
if (channel && group.AddToGroup(*channel, iChannelNumber))
++iReturn;
@@ -737,9 +737,9 @@ bool CPVRDatabase::PersistChannels(CPVRChannelGroup &group)
if (m_sqlite)
iLastChannel = GetLastChannelId();
- for (unsigned int iChannelPtr = 0; iChannelPtr < group.size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < group.m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember member = group.at(iChannelPtr);
+ PVRChannelGroupMember member = group.m_members.at(iChannelPtr);
if (member.channel->IsChanged() || member.channel->IsNew())
{
if (m_sqlite && member.channel->IsNew())
@@ -757,11 +757,11 @@ bool CPVRDatabase::PersistGroupMembers(CPVRChannelGroup &group)
CStdString strQuery;
CSingleLock lock(group.m_critSection);
- if (group.size() > 0)
+ if (group.m_members.size() > 0)
{
- for (unsigned int iChannelPtr = 0; iChannelPtr < group.size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < group.m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember member = group.at(iChannelPtr);
+ PVRChannelGroupMember member = group.m_members.at(iChannelPtr);
CStdString strWhereClause = FormatSQL("idChannel = %u AND idGroup = %u AND iChannelNumber = %u",
member.channel->ChannelID(), group.GroupID(), member.iChannelNumber);
View
49 xbmc/pvr/PVRManager.cpp
@@ -366,14 +366,14 @@ bool CPVRManager::ChannelSwitch(unsigned int iChannelNumber)
return false;
}
- const CPVRChannel *channel = playingGroup->GetByChannelNumber(iChannelNumber);
- if (channel == NULL)
+ CFileItemPtr channel = playingGroup->GetByChannelNumber(iChannelNumber);
+ if (!channel || !channel->HasPVRChannelInfoTag())
{
CLog::Log(LOGERROR, "PVRManager - %s - cannot find channel %d", __FUNCTION__, iChannelNumber);
return false;
}
- return PerformChannelSwitch(*channel, false);
+ return PerformChannelSwitch(*channel->GetPVRChannelInfoTag(), false);
}
bool CPVRManager::ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview, bool bUp)
@@ -386,10 +386,14 @@ bool CPVRManager::ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview,
const CPVRChannelGroup *group = GetPlayingGroup(currentChannel->IsRadio());
if (group)
{
- const CPVRChannel *newChannel = bUp ? group->GetByChannelUp(*currentChannel) : group->GetByChannelDown(*currentChannel);
- if (newChannel && PerformChannelSwitch(*newChannel, bPreview))
+ CFileItemPtr newChannel = bUp ?
+ group->GetByChannelUp(*currentChannel) :
+ group->GetByChannelDown(*currentChannel);
+
+ if (newChannel && newChannel->HasPVRChannelInfoTag() &&
+ PerformChannelSwitch(*newChannel->GetPVRChannelInfoTag(), bPreview))
{
- *iNewChannelNumber = newChannel->ChannelNumber();
+ *iNewChannelNumber = newChannel->GetPVRChannelInfoTag()->ChannelNumber();
bReturn = true;
}
}
@@ -400,19 +404,19 @@ bool CPVRManager::ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview,
bool CPVRManager::ContinueLastChannel(void)
{
- CSingleLock lock(m_critSection);
- if (!m_bFirstStart)
- return true;
- m_bFirstStart = false;
- lock.Leave();
+ {
+ CSingleLock lock(m_critSection);
+ if (!m_bFirstStart)
+ return true;
+ m_bFirstStart = false;
+ }
bool bReturn(false);
- const CPVRChannel *channel = m_channelGroups->GetLastPlayedChannel();
- if (channel != NULL)
+ CFileItemPtr channel = m_channelGroups->GetLastPlayedChannel();
+ if (channel && channel->HasPVRChannelInfoTag())
{
- CLog::Log(LOGNOTICE, "PVRManager - %s - continue playback on channel '%s'",
- __FUNCTION__, channel->ChannelName().c_str());
- bReturn = StartPlayback(channel, (g_guiSettings.GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN));
+ CLog::Log(LOGNOTICE, "PVRManager - %s - continue playback on channel '%s'", __FUNCTION__, channel->GetPVRChannelInfoTag()->ChannelName().c_str());
+ bReturn = StartPlayback(channel->GetPVRChannelInfoTag(), (g_guiSettings.GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN));
}
return bReturn;
@@ -750,22 +754,25 @@ bool CPVRChannelSettingsSaveJob::DoWork(void)
return true;
}
-bool CPVRManager::OpenLiveStream(const CPVRChannel &tag)
+bool CPVRManager::OpenLiveStream(const CFileItem &channel)
{
bool bReturn(false);
+ if (!channel.HasPVRChannelInfoTag())
+ return bReturn;
+
CLog::Log(LOGDEBUG,"PVRManager - %s - opening live stream on channel '%s'",
- __FUNCTION__, tag.ChannelName().c_str());
+ __FUNCTION__, channel.GetPVRChannelInfoTag()->ChannelName().c_str());
// check if we're allowed to play this file
- if (!CheckParentalLock(tag))
+ if (!CheckParentalLock(*channel.GetPVRChannelInfoTag()))
return bReturn;
- if ((bReturn = m_addons->OpenLiveStream(tag)) != false)
+ if ((bReturn = m_addons->OpenLiveStream(*channel.GetPVRChannelInfoTag())) != false)
{
CSingleLock lock(m_critSection);
if(m_currentFile)
delete m_currentFile;
- m_currentFile = new CFileItem(tag);
+ m_currentFile = new CFileItem(channel);
}
return bReturn;
View
4 xbmc/pvr/PVRManager.h
@@ -225,10 +225,10 @@ namespace PVR
/*!
* @brief Open a stream from the given channel.
- * @param tag The channel to open.
+ * @param channel The channel to open.
* @return True if the stream was opened, false otherwise.
*/
- bool OpenLiveStream(const CPVRChannel &tag);
+ bool OpenLiveStream(const CFileItem &channel);
/*!
* @brief Open a stream from the given recording.
View
362 xbmc/pvr/channels/PVRChannelGroup.cpp
@@ -106,7 +106,7 @@ CPVRChannelGroup::CPVRChannelGroup(const CPVRChannelGroup &group)
m_bUsingBackendChannelNumbers = group.m_bUsingBackendChannelNumbers;
for (int iPtr = 0; iPtr < group.Size(); iPtr++)
- push_back(group.at(iPtr));
+ m_members.push_back(group.m_members.at(iPtr));
}
int CPVRChannelGroup::Load(void)
@@ -122,10 +122,10 @@ int CPVRChannelGroup::Load(void)
__FUNCTION__, iChannelCount, m_strGroupName.c_str());
Update();
- if (size() - iChannelCount > 0)
+ if (Size() - iChannelCount > 0)
{
CLog::Log(LOGDEBUG, "PVRChannelGroup - %s - %d channels added from clients to group '%s'",
- __FUNCTION__, (int) size() - iChannelCount, m_strGroupName.c_str());
+ __FUNCTION__, Size() - iChannelCount, m_strGroupName.c_str());
}
SortByChannelNumber();
@@ -134,13 +134,14 @@ int CPVRChannelGroup::Load(void)
g_guiSettings.RegisterObserver(this);
m_bLoaded = true;
- return size();
+ return Size();
}
void CPVRChannelGroup::Unload(void)
{
g_guiSettings.UnregisterObserver(this);
- clear();
+ CSingleLock lock(m_critSection);
+ m_members.clear();
}
bool CPVRChannelGroup::Update(void)
@@ -159,15 +160,15 @@ bool CPVRChannelGroup::SetChannelNumber(const CPVRChannel &channel, unsigned int
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (*at(iChannelPtr).channel == channel)
+ if (*m_members.at(iChannelPtr).channel == channel)
{
- if (at(iChannelPtr).iChannelNumber != iChannelNumber)
+ if (m_members.at(iChannelPtr).iChannelNumber != iChannelNumber)
{
m_bChanged = true;
bReturn = true;
- at(iChannelPtr).iChannelNumber = iChannelNumber;
+ m_members.at(iChannelPtr).iChannelNumber = iChannelNumber;
}
break;
}
@@ -188,17 +189,17 @@ bool CPVRChannelGroup::MoveChannel(unsigned int iOldChannelNumber, unsigned int
SortByChannelNumber();
/* old channel number out of range */
- if (iOldChannelNumber > size())
+ if (iOldChannelNumber > m_members.size())
return bReturn;
/* new channel number out of range */
- if (iNewChannelNumber > size())
- iNewChannelNumber = size();
+ if (iNewChannelNumber > m_members.size())
+ iNewChannelNumber = m_members.size();
/* move the channel in the list */
- PVRChannelGroupMember entry = at(iOldChannelNumber - 1);
- erase(begin() + iOldChannelNumber - 1);
- insert(begin() + iNewChannelNumber - 1, entry);
+ PVRChannelGroupMember entry = m_members.at(iOldChannelNumber - 1);
+ m_members.erase(m_members.begin() + iOldChannelNumber - 1);
+ m_members.insert(m_members.begin() + iNewChannelNumber - 1, entry);
/* renumber the list */
Renumber();
@@ -227,9 +228,9 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */)
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
/* skip if an icon is already set */
if (!groupMember.channel->IconPath().IsEmpty())
@@ -280,13 +281,13 @@ struct sortByChannelNumber
void CPVRChannelGroup::SortByClientChannelNumber(void)
{
CSingleLock lock(m_critSection);
- sort(begin(), end(), sortByClientChannelNumber());
+ sort(m_members.begin(), m_members.end(), sortByClientChannelNumber());
}
void CPVRChannelGroup::SortByChannelNumber(void)
{
CSingleLock lock(m_critSection);
- sort(begin(), end(), sortByChannelNumber());
+ sort(m_members.begin(), m_members.end(), sortByChannelNumber());
}
/********** getters **********/
@@ -296,9 +297,9 @@ CPVRChannel *CPVRChannelGroup::GetByClient(int iUniqueChannelId, int iClientID)
CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
if (groupMember.channel->UniqueID() == iUniqueChannelId &&
groupMember.channel->ClientID() == iClientID)
{
@@ -315,9 +316,9 @@ CPVRChannel *CPVRChannelGroup::GetByChannelID(int iChannelID) const
CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
if (groupMember.channel->ChannelID() == iChannelID)
{
channel = groupMember.channel;
@@ -333,9 +334,9 @@ CPVRChannel *CPVRChannelGroup::GetByChannelEpgID(int iEpgID) const
CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
if (groupMember.channel->EpgID() == iEpgID)
{
channel = groupMember.channel;
@@ -351,9 +352,9 @@ CPVRChannel *CPVRChannelGroup::GetByUniqueID(int iUniqueID) const
CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
if (groupMember.channel->UniqueID() == iUniqueID)
{
channel = groupMember.channel;
@@ -364,14 +365,14 @@ CPVRChannel *CPVRChannelGroup::GetByUniqueID(int iUniqueID) const
return channel;
}
-CPVRChannel *CPVRChannelGroup::GetLastPlayedChannel(void) const
+CFileItemPtr CPVRChannelGroup::GetLastPlayedChannel(void) const
{
CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember groupMember = at(iChannelPtr);
+ PVRChannelGroupMember groupMember = m_members.at(iChannelPtr);
/* check whether the client is loaded */
if (!g_PVRClients->IsConnectedClient(groupMember.channel->ClientID()))
@@ -389,7 +390,14 @@ CPVRChannel *CPVRChannelGroup::GetLastPlayedChannel(void) const
channel = groupMember.channel;
}
- return channel;
+ if (channel)
+ {
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem(*channel));
+ return retVal;
+ }
+
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem);
+ return retVal;
}
@@ -397,11 +405,11 @@ unsigned int CPVRChannelGroup::GetChannelNumber(const CPVRChannel &channel) cons
{
unsigned int iReturn = 0;
CSingleLock lock(m_critSection);
- unsigned int iSize = size();
+ unsigned int iSize = m_members.size();
for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++)
{
- PVRChannelGroupMember member = at(iChannelPtr);
+ PVRChannelGroupMember member = m_members.at(iChannelPtr);
if (member.channel->ChannelID() == channel.ChannelID())
{
iReturn = member.iChannelNumber;
@@ -412,71 +420,68 @@ unsigned int CPVRChannelGroup::GetChannelNumber(const CPVRChannel &channel) cons
return iReturn;
}
-CPVRChannel *CPVRChannelGroup::GetByChannelNumber(unsigned int iChannelNumber) const
+CFileItemPtr CPVRChannelGroup::GetByChannelNumber(unsigned int iChannelNumber) const
{
- CPVRChannel *channel = NULL;
CSingleLock lock(m_critSection);
- for (unsigned int ptr = 0; ptr < size(); ptr++)
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr++)
{
- PVRChannelGroupMember groupMember = at(ptr);
+ PVRChannelGroupMember groupMember = m_members.at(ptr);
if (groupMember.iChannelNumber == iChannelNumber)
{
- channel = groupMember.channel;
- break;
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem(*groupMember.channel));
+ return retVal;
}
}
- return channel;
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem);
+ return retVal;
}
-CPVRChannel *CPVRChannelGroup::GetByChannelUpDown(const CPVRChannel &channel, bool bChannelUp) const
+CFileItemPtr CPVRChannelGroup::GetByChannelUpDown(const CFileItem &channel, bool bChannelUp) const
{
- CPVRChannel *retVal(NULL);
- bool bGotChannel(false);
- CSingleLock lock(m_critSection);
- int iChannelIndex = GetIndex(channel);
-
- while (!bGotChannel && !(retVal && *retVal == channel))
+ if (channel.HasPVRChannelInfoTag())
{
- if (bChannelUp)
- iChannelIndex++;
- else
- iChannelIndex--;
+ CSingleLock lock(m_critSection);
+ int iChannelIndex = GetIndex(*channel.GetPVRChannelInfoTag());
- if (iChannelIndex >= (int)size())
- iChannelIndex = 0;
- else if (iChannelIndex < 0)
- iChannelIndex = size() - 1;
+ bool bGotChannel(false);
+ while (!bGotChannel)
+ {
+ if (bChannelUp)
+ iChannelIndex++;
+ else
+ iChannelIndex--;
- retVal = GetByIndex(iChannelIndex);
- if (!retVal->IsHidden())
- bGotChannel = true;
- }
+ if (iChannelIndex >= (int)m_members.size())
+ iChannelIndex = 0;
+ else if (iChannelIndex < 0)
+ iChannelIndex = m_members.size() - 1;
- return retVal;
-}
+ CFileItemPtr current = GetByIndex(iChannelIndex);
+ if (!current || *current->GetPVRChannelInfoTag() == *channel.GetPVRChannelInfoTag())
+ break;
-CPVRChannel *CPVRChannelGroup::GetByChannelUp(const CPVRChannel &channel) const
-{
- CPVRChannel *retVal(NULL);
- retVal = GetByChannelUpDown(channel, true);
- return retVal;
-}
+ if (!current->GetPVRChannelInfoTag()->IsHidden())
+ return current;
+ }
+ }
-CPVRChannel *CPVRChannelGroup::GetByChannelDown(const CPVRChannel &channel) const
-{
- CPVRChannel *retVal(NULL);
- retVal = GetByChannelUpDown(channel, false);
+ CFileItemPtr retVal(new CFileItem);
return retVal;
}
-CPVRChannel *CPVRChannelGroup::GetByIndex(unsigned int iIndex) const
+CFileItemPtr CPVRChannelGroup::GetByIndex(unsigned int iIndex) const
{
CSingleLock lock(m_critSection);
- return iIndex < size() ?
- at(iIndex).channel :
- NULL;
+ if (iIndex < m_members.size())
+ {
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem(*m_members.at(iIndex).channel));
+ return retVal;
+ }
+
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem);
+ return retVal;
}
int CPVRChannelGroup::GetIndex(const CPVRChannel &channel) const
@@ -484,9 +489,9 @@ int CPVRChannelGroup::GetIndex(const CPVRChannel &channel) const
int iIndex(-1);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (*at(iChannelPtr).channel == channel)
+ if (*m_members.at(iChannelPtr).channel == channel)
{
iIndex = iChannelPtr;
break;
@@ -502,9 +507,9 @@ int CPVRChannelGroup::GetMembers(CFileItemList &results, bool bGroupMembers /* =
CSingleLock lock(m_critSection);
const CPVRChannelGroup *channels = bGroupMembers ? this : g_PVRChannelGroups->GetGroupAll(m_bRadio);
- for (unsigned int iChannelPtr = 0; iChannelPtr < channels->size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < channels->m_members.size(); iChannelPtr++)
{
- CPVRChannel *channel = channels->at(iChannelPtr).channel;
+ CPVRChannel *channel = channels->m_members.at(iChannelPtr).channel;
if (!channel)
continue;
@@ -536,16 +541,16 @@ int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */)
if (!database)
return -1;
- int iChannelCount = size();
+ int iChannelCount = Size();
database->Get(*this);
- return size() - iChannelCount;
+ return Size() - iChannelCount;
}
int CPVRChannelGroup::LoadFromClients(void)
{
- int iCurSize = size();
+ int iCurSize = Size();
/* get the channels from the backends */
PVR_ERROR error;
@@ -553,7 +558,7 @@ int CPVRChannelGroup::LoadFromClients(void)
if (error != PVR_ERROR_NO_ERROR)
CLog::Log(LOGWARNING, "PVRChannelGroup - %s - got bad error (%d) on call to GetChannelGroupMembers", __FUNCTION__, error);
- return size() - iCurSize;
+ return Size() - iCurSize;
}
bool CPVRChannelGroup::AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers)
@@ -563,9 +568,9 @@ bool CPVRChannelGroup::AddAndUpdateChannels(const CPVRChannelGroup &channels, bo
/* go through the channel list and check for new channels.
channels will only by updated in CPVRChannelGroupInternal to prevent dupe updates */
- for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember member = channels.at(iChannelPtr);
+ PVRChannelGroupMember member = channels.m_members.at(iChannelPtr);
if (!member.channel)
continue;
@@ -595,9 +600,9 @@ bool CPVRChannelGroup::RemoveDeletedChannels(const CPVRChannelGroup &channels)
CSingleLock lock(m_critSection);
/* check for deleted channels */
- for (int iChannelPtr = size() - 1; iChannelPtr >= 0; iChannelPtr--)
+ for (int iChannelPtr = m_members.size() - 1; iChannelPtr >= 0; iChannelPtr--)
{
- CPVRChannel *channel = at(iChannelPtr).channel;
+ CPVRChannel *channel = m_members.at(iChannelPtr).channel;
if (!channel)
continue;
@@ -616,7 +621,7 @@ bool CPVRChannelGroup::RemoveDeletedChannels(const CPVRChannelGroup &channels)
channel->Delete();
}
- erase(begin() + iChannelPtr);
+ m_members.erase(m_members.begin() + iChannelPtr);
m_bChanged = true;
bReturn = true;
}
@@ -633,7 +638,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels)
CSingleLock lock(m_critSection);
/* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */
- bool bUseBackendChannelNumbers(size() == 0 || m_bUsingBackendChannelOrder);
+ bool bUseBackendChannelNumbers(m_members.size() == 0 || m_bUsingBackendChannelOrder);
CPVRDatabase *database = GetPVRDatabase();
if (!database)
@@ -669,14 +674,15 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels)
void CPVRChannelGroup::RemoveInvalidChannels(void)
{
bool bDelete(false);
- for (unsigned int ptr = 0; ptr < size(); ptr--)
+ CSingleLock lock(m_critSection);
+ for (unsigned int ptr = 0; ptr < m_members.size(); ptr--)
{
bDelete = false;
- CPVRChannel *channel = at(ptr).channel;
+ CPVRChannel *channel = m_members.at(ptr).channel;
if (channel->IsVirtual())
continue;
- if (at(ptr).channel->ClientChannelNumber() <= 0)
+ if (m_members.at(ptr).channel->ClientChannelNumber() <= 0)
{
CLog::Log(LOGERROR, "PVRChannelGroup - %s - removing invalid channel '%s' from client '%i': no valid client channel number",
__FUNCTION__, channel->ChannelName().c_str(), channel->ClientID());
@@ -700,7 +706,7 @@ void CPVRChannelGroup::RemoveInvalidChannels(void)
}
else
{
- erase(begin() + ptr);
+ m_members.erase(m_members.begin() + ptr);
}
m_bChanged = true;
}
@@ -712,12 +718,12 @@ bool CPVRChannelGroup::RemoveFromGroup(const CPVRChannel &channel)
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (channel == *at(iChannelPtr).channel)
+ if (channel == *m_members.at(iChannelPtr).channel)
{
// TODO notify observers
- erase(begin() + iChannelPtr);
+ m_members.erase(m_members.begin() + iChannelPtr);
bReturn = true;
m_bChanged = true;
break;
@@ -737,8 +743,8 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel &channel, int iChannelNumber /* =
if (!CPVRChannelGroup::IsGroupMember(channel))
{
- if (iChannelNumber <= 0 || iChannelNumber > (int) size() + 1)
- iChannelNumber = size() + 1;
+ if (iChannelNumber <= 0 || iChannelNumber > (int) m_members.size() + 1)
+ iChannelNumber = m_members.size() + 1;
CPVRChannel *realChannel = (IsInternalGroup()) ?
&channel :
@@ -747,7 +753,7 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel &channel, int iChannelNumber /* =
if (realChannel)
{
PVRChannelGroupMember newMember = { realChannel, iChannelNumber };
- push_back(newMember);
+ m_members.push_back(newMember);
m_bChanged = true;
if (bSortAndRenumber)
@@ -772,9 +778,9 @@ bool CPVRChannelGroup::IsGroupMember(const CPVRChannel &channel) const
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (channel == *at(iChannelPtr).channel)
+ if (channel == *m_members.at(iChannelPtr).channel)
{
bReturn = true;
break;
@@ -789,9 +795,9 @@ bool CPVRChannelGroup::IsGroupMember(int iChannelId) const
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (iChannelId == at(iChannelPtr).channel->ChannelID())
+ if (iChannelId == m_members.at(iChannelPtr).channel->ChannelID())
{
bReturn = true;
break;
@@ -801,17 +807,6 @@ bool CPVRChannelGroup::IsGroupMember(int iChannelId) const
return bReturn;
}
-CPVRChannel *CPVRChannelGroup::GetFirstChannel(void) const
-{
- CPVRChannel *channel = NULL;
- CSingleLock lock(m_critSection);
-
- if (size() > 0)
- channel = at(0).channel;
-
- return channel;
-}
-
bool CPVRChannelGroup::SetGroupName(const CStdString &strGroupName, bool bSaveInDb /* = false */)
{
bool bReturn(false);
@@ -845,7 +840,7 @@ bool CPVRChannelGroup::Persist(void)
if (CPVRDatabase *database = GetPVRDatabase())
{
CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - persisting channel group '%s' with %d channels",
- __FUNCTION__, GroupName().c_str(), (int) size());
+ __FUNCTION__, GroupName().c_str(), (int) m_members.size());
m_bChanged = false;
lock.Leave();
@@ -866,23 +861,23 @@ bool CPVRChannelGroup::Renumber(void)
bool bUseBackendChannelNumbers(g_guiSettings.GetBool("pvrmanager.usebackendchannelnumbers") && g_PVRClients->EnabledClientAmount() == 1);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
unsigned int iCurrentChannelNumber;
- if (at(iChannelPtr).channel->IsHidden())
+ if (m_members.at(iChannelPtr).channel->IsHidden())
iCurrentChannelNumber = 0;
else if (bUseBackendChannelNumbers)
- iCurrentChannelNumber = at(iChannelPtr).channel->ClientChannelNumber();
+ iCurrentChannelNumber = m_members.at(iChannelPtr).channel->ClientChannelNumber();
else
iCurrentChannelNumber = ++iChannelNumber;
- if (at(iChannelPtr).iChannelNumber != iCurrentChannelNumber)
+ if (m_members.at(iChannelPtr).iChannelNumber != iCurrentChannelNumber)
{
bReturn = true;
m_bChanged = true;
}
- at(iChannelPtr).iChannelNumber = iCurrentChannelNumber;
+ m_members.at(iChannelPtr).iChannelNumber = iCurrentChannelNumber;
}
SortByChannelNumber();
@@ -906,8 +901,8 @@ void CPVRChannelGroup::ResetChannelNumberCache(void)
g_PVRChannelGroups->GetGroupAll(m_bRadio)->ResetChannelNumbers();
/* set all channel numbers on members of this group */
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
- at(iChannelPtr).channel->SetCachedChannelNumber(at(iChannelPtr).iChannelNumber);
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
+ m_members.at(iChannelPtr).channel->SetCachedChannelNumber(m_members.at(iChannelPtr).iChannelNumber);
}
bool CPVRChannelGroup::HasChangedChannels(void) const
@@ -915,9 +910,9 @@ bool CPVRChannelGroup::HasChangedChannels(void) const
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (at(iChannelPtr).channel->IsChanged())
+ if (m_members.at(iChannelPtr).channel->IsChanged())
{
bReturn = true;
break;
@@ -932,9 +927,9 @@ bool CPVRChannelGroup::HasNewChannels(void) const
bool bReturn(false);
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (at(iChannelPtr).channel->ChannelID() <= 0)
+ if (m_members.at(iChannelPtr).channel->ChannelID() <= 0)
{
bReturn = true;
break;
@@ -953,8 +948,8 @@ bool CPVRChannelGroup::HasChanges(void) const
void CPVRChannelGroup::ResetChannelNumbers(void)
{
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
- at(iChannelPtr).channel->SetCachedChannelNumber(0);
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
+ m_members.at(iChannelPtr).channel->SetCachedChannelNumber(0);
}
void CPVRChannelGroup::Notify(const Observable &obs, const CStdString& msg)
@@ -1014,11 +1009,11 @@ int CPVRChannelGroup::GetEPGNow(CFileItemList &results)
int iInitialSize = results.Size();
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- CPVRChannel *channel = at(iChannelPtr).channel;
+ CPVRChannel *channel = m_members.at(iChannelPtr).channel;
CEpg *epg = channel->GetEPG();
- if (!epg || !epg->HasValidEntries() || at(iChannelPtr).channel->IsHidden())
+ if (!epg || !epg->HasValidEntries() || m_members.at(iChannelPtr).channel->IsHidden())
continue;
CEpgInfoTag epgNow;
@@ -1040,11 +1035,11 @@ int CPVRChannelGroup::GetEPGNext(CFileItemList &results)
int iInitialSize = results.Size();
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- CPVRChannel *channel = at(iChannelPtr).channel;
+ CPVRChannel *channel = m_members.at(iChannelPtr).channel;
CEpg *epg = channel->GetEPG();
- if (!epg || !epg->HasValidEntries() || at(iChannelPtr).channel->IsHidden())
+ if (!epg || !epg->HasValidEntries() || m_members.at(iChannelPtr).channel->IsHidden())
continue;
CEpgInfoTag epgNow;
@@ -1066,13 +1061,106 @@ int CPVRChannelGroup::GetEPGAll(CFileItemList &results)
int iInitialSize = results.Size();
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (!at(iChannelPtr).channel || at(iChannelPtr).channel->IsHidden())
+ if (!m_members.at(iChannelPtr).channel || m_members.at(iChannelPtr).channel->IsHidden())
continue;
- at(iChannelPtr).channel->GetEPG(results);
+ m_members.at(iChannelPtr).channel->GetEPG(results);
}
return results.Size() - iInitialSize;
}
+
+int CPVRChannelGroup::Size(void) const
+{
+ CSingleLock lock(m_critSection);
+ return m_members.size();
+}
+
+int CPVRChannelGroup::GroupID(void) const
+{
+ CSingleLock lock(m_critSection);
+ return m_iGroupId;
+}
+
+void CPVRChannelGroup::SetGroupID(int iGroupId)
+{
+ CSingleLock lock(m_critSection);
+ m_iGroupId = iGroupId;
+}
+
+void CPVRChannelGroup::SetGroupType(int iGroupType)
+{
+ CSingleLock lock(m_critSection);
+ m_iGroupType = iGroupType;
+}
+
+int CPVRChannelGroup::GroupType(void) const
+{
+ CSingleLock lock(m_critSection);
+ return m_iGroupType;
+}
+
+CStdString CPVRChannelGroup::GroupName(void) const
+{
+ CSingleLock lock(m_critSection);
+ CStdString strReturn(m_strGroupName);
+ return strReturn;
+}
+
+bool CPVRChannelGroup::UpdateChannel(const CFileItem &item, bool bHidden, bool bVirtual, bool bEPGEnabled, bool bParentalLocked, int iEPGSource, int iChannelNumber, const CStdString &strChannelName, const CStdString &strIconPath, const CStdString &strStreamURL)
+{
+ if (!item.HasPVRChannelInfoTag())
+ return false;
+
+ CSingleLock lock(m_critSection);
+
+ /* get the real channel from the group */
+ CPVRChannel *channel = GetByUniqueID(item.GetPVRChannelInfoTag()->UniqueID());
+ if (!channel)
+ return false;
+
+ channel->SetChannelName(strChannelName);
+ channel->SetHidden(bHidden);
+ channel->SetLocked(bParentalLocked);
+ channel->SetIconPath(strIconPath);
+
+ if (bVirtual)
+ channel->SetStreamURL(strStreamURL);
+ if (iEPGSource == 0)
+ channel->SetEPGScraper("client");
+
+ // TODO add other scrapers
+ channel->SetEPGEnabled(bEPGEnabled);
+
+ /* set new values in the channel tag */
+ if (bHidden)
+ {
+ SortByChannelNumber(); // or previous changes will be overwritten
+ RemoveFromGroup(*channel);
+ }
+ else
+ {
+ SetChannelNumber(*channel, iChannelNumber);
+ }
+
+ return true;
+}
+
+bool CPVRChannelGroup::ToggleChannelLocked(const CFileItem &item)
+{
+ if (!item.HasPVRChannelInfoTag())
+ return false;
+
+ CSingleLock lock(m_critSection);
+
+ /* get the real channel from the group */
+ CPVRChannel *channel = GetByUniqueID(item.GetPVRChannelInfoTag()->UniqueID());
+ if (!channel)
+ return false;
+
+ channel->SetLocked(!channel->IsLocked());
+
+ return true;
+}
View
159 xbmc/pvr/channels/PVRChannelGroup.h
@@ -41,6 +41,7 @@ namespace PVR
class CPVRChannelGroups;
class CPVRChannelGroupInternal;
+ class CPVRChannelGroupsContainer;
typedef struct
{
@@ -49,14 +50,14 @@ namespace PVR
} PVRChannelGroupMember;
/** A group of channels */
- class CPVRChannelGroup : private std::vector<PVRChannelGroupMember>,
- private Observer,
+ class CPVRChannelGroup : private Observer,
public Observable,
public IJobCallback
{
friend class CPVRChannelGroups;
friend class CPVRChannelGroupInternal;
+ friend class CPVRChannelGroupsContainer;
friend class CPVRDatabase;
public:
@@ -80,17 +81,21 @@ namespace PVR
*/
CPVRChannelGroup(const PVR_CHANNEL_GROUP &group);
- CPVRChannelGroup(const CPVRChannelGroup &group);
-
/*!
- * @brief Destruct this channel group.
+ * @brief Copy constructor
+ * @param group Source group
*/
+ CPVRChannelGroup(const CPVRChannelGroup &group);
+
virtual ~CPVRChannelGroup(void);
- virtual bool operator ==(const CPVRChannelGroup &right) const;
- virtual bool operator !=(const CPVRChannelGroup &right) const;
+ bool operator ==(const CPVRChannelGroup &right) const;
+ bool operator !=(const CPVRChannelGroup &right) const;
- virtual int Size(void) const { return size(); }
+ /*!
+ * @return The amount of group members
+ */
+ int Size(void) const;
/*!
* @brief Refresh the channel list from the clients.
@@ -102,7 +107,7 @@ namespace PVR
* @param channel The channel to change the channel number for.
* @param iChannelNumber The new channel number.
*/
- virtual bool SetChannelNumber(const CPVRChannel &channel, unsigned int iChannelNumber);
+ bool SetChannelNumber(const CPVRChannel &channel, unsigned int iChannelNumber);
/*!
* @brief Move a channel from position iOldIndex to iNewIndex.
@@ -117,7 +122,7 @@ namespace PVR
* @brief Search missing channel icons for all known channels.
* @param bUpdateDb If true, update the changed values in the database.
*/
- virtual void SearchAndSetChannelIcons(bool bUpdateDb = false);
+ void SearchAndSetChannelIcons(bool bUpdateDb = false);
/*!
* @brief Remove a channel from this container.
@@ -141,13 +146,13 @@ namespace PVR
* @param bSaveInDb Save in the database or not.
* @return True if the something changed, false otherwise.
*/
- virtual bool SetGroupName(const CStdString &strGroupName, bool bSaveInDb = false);
+ bool SetGroupName(const CStdString &strGroupName, bool bSaveInDb = false);
/*!
* @brief Persist changed or new data.
* @return True if the channel was persisted, false otherwise.
*/
- virtual bool Persist(void);
+ bool Persist(void);
/*!
* @brief Check whether a channel is in this container.
@@ -170,45 +175,39 @@ namespace PVR
virtual bool IsInternalGroup(void) const { return false; }
/*!
- * @brief Get the first channel in this group.
- * @return The first channel.
- */
- virtual CPVRChannel *GetFirstChannel(void) const;
-
- /*!
* @brief True if this group holds radio channels, false if it holds TV channels.
* @return True if this group holds radio channels, false if it holds TV channels.
*/
- virtual bool IsRadio(void) const { return m_bRadio; }
+ bool IsRadio(void) const { return m_bRadio; }
/*!
* @brief The database ID of this group.
* @return The database ID of this group.
*/
- virtual int GroupID(void) const { return m_iGroupId; }
+ int GroupID(void) const;
/*!
* @brief Set the database ID of this group.
* @param iGroupId The new database ID.
*/
- virtual void SetGroupID(int iGroupId) { m_iGroupId = iGroupId; }
+ void SetGroupID(int iGroupId);
/*!
* @brief Set the type of this group.
* @param the new type for this group.
*/
- virtual void SetGroupType(int iGroupType) { m_iGroupType = iGroupType; }
+ void SetGroupType(int iGroupType);
/*!
* @brief Return the type of this group.
*/
- virtual int GroupType(void) const { return m_iGroupType; }
+ int GroupType(void) const;
/*!
* @brief The name of this group.
* @return The name of this group.
*/
- virtual const CStdString &GroupName(void) const { return m_strGroupName; }
+ CStdString GroupName(void) const;
/*! @name Sort methods
*/
@@ -217,99 +216,71 @@ namespace PVR
/*!
* @brief Sort the current channel list by client channel number.
*/
- virtual void SortByClientChannelNumber(void);
+ void SortByClientChannelNumber(void);
/*!
* @brief Sort the current channel list by channel number.
*/
- virtual void SortByChannelNumber(void);
+ void SortByChannelNumber(void);
//@}
- virtual void ResetChannelNumbers(void);
-
- virtual void Notify(const Observable &obs, const CStdString& msg);
-
- /*! @name getters
- */
- //@{
-
- /*!
- * @brief Get a channel given the channel number on the client.
- * @param iUniqueChannelId The unique channel id on the client.
- * @param iClientID The ID of the client.
- * @return The channel or NULL if it wasn't found.
- */
- virtual CPVRChannel *GetByClient(int iUniqueChannelId, int iClientID) const;
-
- /*!
- * @brief Get a channel given it's channel ID.
- * @param iChannelID The channel ID.
- * @return The channel or NULL if it wasn't found.
- */
- virtual CPVRChannel *GetByChannelID(int iChannelID) const;
+ void Notify(const Observable &obs, const CStdString& msg);
/*!
* @brief Get a channel given it's EPG ID.
* @param iEpgID The channel EPG ID.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByChannelEpgID(int iEpgID) const;
-
- /*!
- * @brief Get a channel given it's unique ID.
- * @param iUniqueID The unique ID.
- * @return The channel or NULL if it wasn't found.
- */
- virtual CPVRChannel *GetByUniqueID(int iUniqueID) const;
+ CPVRChannel *GetByChannelEpgID(int iEpgID) const;
/*!
* @brief The channel that was played last that has a valid client or NULL if there was none.
* @return The requested channel.
*/
- virtual CPVRChannel *GetLastPlayedChannel(void) const;
+ CFileItemPtr GetLastPlayedChannel(void) const;
/*!
* @brief Get a channel given it's channel number.
* @param iChannelNumber The channel number.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByChannelNumber(unsigned int iChannelNumber) const;
+ CFileItemPtr GetByChannelNumber(unsigned int iChannelNumber) const;
/*!
* @brief Get the channel number in this group of the given channel.
* @param channel The channel to get the channel number for.
* @return The channel number in this group or 0 if the channel isn't a member of this group.
*/
- virtual unsigned int GetChannelNumber(const CPVRChannel &channel) const;
+ unsigned int GetChannelNumber(const CPVRChannel &channel) const;
/*!
* @brief Get the next channel in this group.
* @param channel The current channel.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByChannelUp(const CPVRChannel &channel) const;
+ CFileItemPtr GetByChannelUp(const CFileItem &channel) const { return GetByChannelUpDown(channel, true); }
/*!
* @brief Get the previous channel in this group.
* @param channel The current channel.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByChannelDown(const CPVRChannel &channel) const;
+ CFileItemPtr GetByChannelDown(const CFileItem &channel) const { return GetByChannelUpDown(channel, true); }
/*!
* @brief Get a channel given it's index in this container.
* @param index The index in this container.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByIndex(unsigned int index) const;
+ CFileItemPtr GetByIndex(unsigned int index) const;
/*!
* @brief Get the current index in this group of a channel.
* @param channel The channel to get the index for.
* @return The index or -1 if it wasn't found.
*/
- virtual int GetIndex(const CPVRChannel &channel) const;
+ int GetIndex(const CPVRChannel &channel) const;
/*!
* @brief Get the list of channels in a group.
@@ -322,12 +293,12 @@ namespace PVR
/*!
* @return The next channel group.
*/
- virtual CPVRChannelGroup *GetNextGroup(void) const;
+ CPVRChannelGroup *GetNextGroup(void) const;
/*!
* @return The previous channel group.
*/
- virtual CPVRChannelGroup *GetPreviousGroup(void) const;
+ CPVRChannelGroup *GetPreviousGroup(void) const;
/*!
* @brief The amount of hidden channels in this container.
@@ -338,26 +309,24 @@ namespace PVR
/*!
* @return True if there is at least one channel in this group with changes that haven't been persisted, false otherwise.
*/
- virtual bool HasChangedChannels(void) const;
+ bool HasChangedChannels(void) const;
/*!
* @return True if there is at least one new channel in this group that hasn't been persisted, false otherwise.
*/
- virtual bool HasNewChannels(void) const;
+ bool HasNewChannels(void) const;
/*!
* @return True if anything changed in this group that hasn't been persisted, false otherwise.
*/
- virtual bool HasChanges(void) const;
-
- //@}
+ bool HasChanges(void) const;
/*!
* @brief Reset the channel number cache if this is the selected group in the UI.
*/
- virtual void ResetChannelNumberCache(void);
+ void ResetChannelNumberCache(void);
- virtual void OnJobComplete(unsigned int jobID, bool success, CJob* job) {}
+ void OnJobComplete(unsigned int jobID, bool success, CJob* job) {}
/*!
* @brief Get all EPG tables and apply a filter.
@@ -365,28 +334,32 @@ namespace PVR
* @param filter The filter to apply.
* @return The amount of entries that were added.
*/
- virtual int GetEPGSearch(CFileItemList &results, const EPG::EpgSearchFilter &filter);
+ int GetEPGSearch(CFileItemList &results, const EPG::EpgSearchFilter &filter);
/*!
* @brief Get all EPG tables.
* @param results The fileitem list to store the results in.
* @return The amount of entries that were added.
*/
- virtual int GetEPGAll(CFileItemList &results);
+ int GetEPGAll(CFileItemList &results);
/*!
* @brief Get all entries that are active now.
* @param results The fileitem list to store the results in.
* @return The amount of entries that were added.
*/
- virtual int GetEPGNow(CFileItemList &results);
+ int GetEPGNow(CFileItemList &results);
/*!
* @brief Get all entries that will be active next.
* @param results The fileitem list to store the results in.
* @return The amount of entries that were added.
*/
- virtual int GetEPGNext(CFileItemList &results);
+ int GetEPGNext(CFileItemList &results);
+
+ bool UpdateChannel(const CFileItem &channel, bool bHidden, bool bVirtual, bool bEPGEnabled, bool bParentalLocked, int iEPGSource, int iChannelNumber, const CStdString &strChannelName, const CStdString &strIconPath, const CStdString &strStreamURL);
+
+ bool ToggleChannelLocked(const CFileItem &channel);
protected:
/*!
@@ -408,12 +381,13 @@ namespace PVR
virtual bool UpdateGroupEntries(const CPVRChannelGroup &channels);
virtual bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers);
- virtual bool RemoveDeletedChannels(const CPVRChannelGroup &channels);
+
+ bool RemoveDeletedChannels(const CPVRChannelGroup &channels);
/*!
* @brief Remove invalid channels from this container.
*/
- virtual void RemoveInvalidChannels(void);
+ void RemoveInvalidChannels(void);
/*!
* @brief Load the channels from the database.
@@ -444,7 +418,31 @@ namespace PVR
* @param bChannelUp True to get the next channel, false to get the previous one.
* @return The requested channel or NULL if there is none.
*/
- virtual CPVRChannel *GetByChannelUpDown(const CPVRChannel &channel, bool bChannelUp) const;
+ CFileItemPtr GetByChannelUpDown(const CFileItem &channel, bool bChannelUp) const;
+
+ void ResetChannelNumbers(void);
+
+ /*!
+ * @brief Get a channel given it's unique ID.
+ * @param iUniqueID The unique ID.
+ * @return The channel or NULL if it wasn't found.
+ */
+ CPVRChannel *GetByUniqueID(int iUniqueID) const;
+
+ /*!
+ * @brief Get a channel given it's channel ID.
+ * @param iChannelID The channel ID.
+ * @return The channel or NULL if it wasn't found.
+ */
+ CPVRChannel *GetByChannelID(int iChannelID) const;
+
+ /*!
+ * @brief Get a channel given the channel number on the client.
+ * @param iUniqueChannelId The unique channel id on the client.
+ * @param iClientID The ID of the client.
+ * @return The channel or NULL if it wasn't found.
+ */
+ CPVRChannel *GetByClient(int iUniqueChannelId, int iClientID) const;
bool m_bRadio; /*!< true if this container holds radio channels, false if it holds TV channels */
int m_iGroupType; /*!< The type of this group */
@@ -454,6 +452,7 @@ namespace PVR
bool m_bChanged; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */
bool m_bUsingBackendChannelOrder; /*!< true to use the channel order from backends, false otherwise */
bool m_bUsingBackendChannelNumbers; /*!< true to use the channel numbers from 1 backend, false otherwise */
+ std::vector<PVRChannelGroupMember> m_members;
CCriticalSection m_critSection;
};
@@ -462,7 +461,7 @@ namespace PVR
public:
CPVRPersistGroupJob(CPVRChannelGroup *group) { m_group = group; }
virtual ~CPVRPersistGroupJob() {}
- virtual const char *GetType() const { return "pvr-channelgroup-persist"; }
+ const char *GetType() const { return "pvr-channelgroup-persist"; }
virtual bool DoWork();
View
42 xbmc/pvr/channels/PVRChannelGroupInternal.cpp
@@ -80,18 +80,18 @@ void CPVRChannelGroupInternal::CheckGroupName(void)
void CPVRChannelGroupInternal::UpdateChannelPaths(void)
{
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember member = at(iChannelPtr);
+ PVRChannelGroupMember member = m_members.at(iChannelPtr);
member.channel->UpdatePath(iChannelPtr);
}
}
void CPVRChannelGroupInternal::Unload()
{
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- delete at(iChannelPtr).channel;
+ delete m_members.at(iChannelPtr).channel;
}
CPVRChannelGroup::Unload();
@@ -171,7 +171,7 @@ bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel &channel, int iChannelNumb
/* move this channel and persist */
bReturn = (iChannelNumber > 0) ?
MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true) :
- MoveChannel(realChannel->ChannelNumber(), size() - m_iHiddenChannels, true);
+ MoveChannel(realChannel->ChannelNumber(), m_members.size() - m_iHiddenChannels, true);
return bReturn;
}
@@ -216,8 +216,8 @@ bool CPVRChannelGroupInternal::MoveChannel(unsigned int iOldChannelNumber, unsig
{
CSingleLock lock(m_critSection);
/* new channel number out of range */
- if (iNewChannelNumber > size() - m_iHiddenChannels)
- iNewChannelNumber = size() - m_iHiddenChannels;
+ if (iNewChannelNumber > m_members.size() - m_iHiddenChannels)
+ iNewChannelNumber = m_members.size() - m_iHiddenChannels;
return CPVRChannelGroup::MoveChannel(iOldChannelNumber, iNewChannelNumber, bSaveInDb);
}
@@ -227,9 +227,9 @@ int CPVRChannelGroupInternal::GetMembers(CFileItemList &results, bool bGroupMemb
int iOrigSize = results.Size();
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- CPVRChannel *channel = at(iChannelPtr).channel;
+ CPVRChannel *channel = m_members.at(iChannelPtr).channel;
if (!channel)
continue;
@@ -249,7 +249,7 @@ int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */)
if (!database)
return -1;
- int iChannelCount = size();
+ int iChannelCount = Size();
if (database->Get(*this) > 0)
{
@@ -264,12 +264,12 @@ int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */)
SortByChannelNumber();
- return size() - iChannelCount;
+ return Size() - iChannelCount;
}
int CPVRChannelGroupInternal::LoadFromClients(void)
{
- int iCurSize = size();
+ int iCurSize = Size();
/* get the channels from the backends */
PVR_ERROR error;
@@ -277,7 +277,7 @@ int CPVRChannelGroupInternal::LoadFromClients(void)
if (error != PVR_ERROR_NO_ERROR)
CLog::Log(LOGWARNING, "CPVRChannelGroupInternal - %s - got bad error (%d) on call to GetChannels", __FUNCTION__, error);
- return size() - iCurSize;
+ return Size() - iCurSize;
}
bool CPVRChannelGroupInternal::Renumber(void)
@@ -286,12 +286,12 @@ bool CPVRChannelGroupInternal::Renumber(void)
bool bReturn(CPVRChannelGroup::Renumber());
m_iHiddenChannels = 0;
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- if (at(iChannelPtr).channel->IsHidden())
+ if (m_members.at(iChannelPtr).channel->IsHidden())
m_iHiddenChannels++;
else
- at(iChannelPtr).channel->UpdatePath(iChannelPtr);
+ m_members.at(iChannelPtr).channel->UpdatePath(iChannelPtr);
}
return bReturn;
@@ -311,7 +311,7 @@ bool CPVRChannelGroupInternal::UpdateChannel(const CPVRChannel &channel)
{
updateChannel = new CPVRChannel(channel.IsRadio());
PVRChannelGroupMember newMember = { updateChannel, 0 };
- push_back(newMember);
+ m_members.push_back(newMember);
updateChannel->SetUniqueID(channel.UniqueID());
}
updateChannel->UpdateFromClient(channel);
@@ -325,9 +325,9 @@ bool CPVRChannelGroupInternal::AddAndUpdateChannels(const CPVRChannelGroup &chan
CSingleLock lock(m_critSection);
/* go through the channel list and check for updated or new channels */
- for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.m_members.size(); iChannelPtr++)
{
- PVRChannelGroupMember member = channels.at(iChannelPtr);
+ PVRChannelGroupMember member = channels.m_members.at(iChannelPtr);
if (!member.channel)
continue;
@@ -383,9 +383,9 @@ bool CPVRChannelGroupInternal::CreateChannelEpgs(bool bForce /* = false */)
{
{
CSingleLock lock(m_critSection);
- for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
+ for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
- CPVRChannel *channel = at(iChannelPtr).channel;
+ CPVRChannel *channel = m_members.at(iChannelPtr).channel;
if (!channel)
continue;
View
44 xbmc/pvr/channels/PVRChannelGroupInternal.h
@@ -50,71 +50,71 @@ namespace PVR
* @brief The amount of channels in this container.
* @return The amount of channels in this container.
*/
- virtual int GetNumHiddenChannels() const { return m_iHiddenChannels; }
+ int GetNumHiddenChannels() const { return m_iHiddenChannels; }
/*!
* @brief Update all channel numbers on timers.
* @return True if the channel number were updated, false otherwise.
*/
- virtual bool UpdateTimers(void);
+ bool UpdateTimers(void);
/*!
* @brief Add or update a channel in this table.
* @param channel The channel to update.
* @return True if the channel was updated and persisted.
*/
- virtual bool UpdateChannel(const CPVRChannel &channel);
+ bool UpdateChannel(const CPVRChannel &channel);
/*!
* @brief Add a channel to this internal group.
* @param iChannelNumber The channel number to use for this channel or 0 to add it to the back.
* @param bSortAndRenumber Set to false to not to sort the group after adding a channel
*/
- virtual bool InsertInGroup(CPVRChannel &channel, int iChannelNumber = 0, bool bSortAndRenumber = true);
+ bool InsertInGroup(CPVRChannel &channel, int iChannelNumber = 0, bool bSortAndRenumber = true);
/*!
* @brief Callback for add-ons to update a channel.
* @param channel The updated channel.
* @return True if the channel has been updated succesfully, false otherwise.
*/
- virtual bool UpdateFromClient(const CPVRChannel &channel);
+ bool UpdateFromClient(const CPVRChannel &channel);
/*!
* @see CPVRChannelGroup::IsGroupMember
*/
- virtual bool IsGroupMember(const CPVRChannel &channel) const;
+ bool IsGroupMember(const CPVRChannel &channel) const;
/*!
* @see CPVRChannelGroup::AddToGroup
*/
- virtual bool AddToGroup(CPVRChannel &channel, int iChannelNumber = 0, bool bSortAndRenumber = true);
+ bool AddToGroup(CPVRChannel &channel, int iChannelNumber = 0, bool bSortAndRenumber = true);
/*!
* @see CPVRChannelGroup::RemoveFromGroup
*/
- virtual bool RemoveFromGroup(const CPVRChannel &channel);
+ bool RemoveFromGroup(const CPVRChannel &channel);
/*!
* @see CPVRChannelGroup::MoveChannel
*/
- virtual bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true);
+ bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true);
/*!
* @see CPVRChannelGroup::GetMembers
*/
- virtual int GetMembers(CFileItemList &results, bool bGroupMembers = true) const;
+ int GetMembers(CFileItemList &results, bool bGroupMembers = true) const;
/*!
* @brief Check whether the group name is still correct after the language setting changed.
*/
- virtual void CheckGroupName(void);
+ void CheckGroupName(void);
/*!
* @brief Create an EPG table for each channel.
* @brief bForce Create the tables, even if they already have been created before.
* @return True if all tables were created successfully, false otherwise.
*/
- virtual bool CreateChannelEpgs(bool bForce = false);
+ bool CreateChannelEpgs(bool bForce = false);
protected:
/*!
@@ -122,19 +122,19 @@ namespace PVR
* @param bCompress Compress the database after changing anything.
* @return The amount of channels that were loaded.
*/
- virtual int LoadFromDb(bool bCompress = false);
+ int LoadFromDb(bool bCompress = false);
/*!
* @brief Load all channels from the clients.
* @return The amount of channels that were loaded.
*/
- virtual int LoadFromClients(void);
+ int LoadFromClients(void);
/*!
* @brief Check if this group is the internal group containing all channels.
* @return True if it's the internal group, false otherwise.
*/
- virtual bool IsInternalGroup(void) const { return true; }
+ bool IsInternalGroup(void) const { return true; }
/*!
* @brief Update the current channel list with the given list.
@@ -145,19 +145,19 @@ namespace PVR
* @param channels The channels to use to update this list.
* @return True if everything went well, false otherwise.
*/
- virtual bool UpdateGroupEntries(const CPVRChannelGroup &channels);
+ bool UpdateGroupEntries(const CPVRChannelGroup &channels);
- virtual bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers);
+ bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers);
/*!
* @brief Refresh the channel list from the clients.
*/
- virtual bool Update(void);
+ bool Update(void);
/*!
* @brief Remove invalid channels and updates the channel numbers.
*/
- virtual bool Renumber(void);
+ bool Renumber(void);
/*!
* @brief Load the channels from the database.
@@ -167,17 +167,17 @@ namespace PVR
*
* @return The amount of channels that were added.
*/
- virtual int Load(void);
+ int Load(void);
/*!
* @brief Update the vfs paths of all channels.
*/
- virtual void UpdateChannelPaths(void);
+ void UpdateChannelPaths(void);
/*!
* @brief Clear this channel list and destroy all channel instances in it.
*/
- virtual void Unload(void);
+ void Unload(void);
int m_iHiddenChannels; /*!< the amount of hidden channels in this container */
};
View
11 xbmc/pvr/channels/PVRChannelGroups.cpp
@@ -472,16 +472,21 @@ bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group)
return bReturn;
}
-const CStdString &CPVRChannelGroups::GetGroupName(int iGroupId) const
+CStdString CPVRChannelGroups::GetGroupName(int iGroupId) const
{
+ CStdString strReturn(g_localizeStrings.Get(13205));
+
CSingleLock lock(m_critSection);
for (unsigned int iGroupPtr = 0; iGroupPtr < size(); iGroupPtr++)
{
if (iGroupId == at(iGroupPtr)->GroupID())
- return at(iGroupPtr)->GroupName();
+ {
+ strReturn = at(iGroupPtr)->GroupName();
+ break;
+ }
}
- return g_localizeStrings.Get(13205);
+ return strReturn;
}
int CPVRChannelGroups::GetGroupId(CStdString strGroupName) const
View
2  xbmc/pvr/channels/PVRChannelGroups.h
@@ -160,7 +160,7 @@ namespace PVR
* @param iGroupId The ID of the group.
* @return The name of the group or localized string 953 if it wasn't found.
*/
- const CStdString &GetGroupName(int iGroupId) const;
+ CStdString GetGroupName(int iGroupId) const;
/*!
* @brief Get the ID of a group given it's name.
View
56 xbmc/pvr/channels/PVRChannelGroupsContainer.cpp
@@ -148,7 +148,7 @@ bool CPVRChannelGroupsContainer::GetGroupsDirectory(const CStdString &strBase, C
return true;
}
-CPVRChannel *CPVRChannelGroupsContainer::GetByPath(const CStdString &strPath)
+CFileItemPtr CPVRChannelGroupsContainer::GetByPath(const CStdString &strPath)
{
const CPVRChannelGroup *channels = NULL;
int iChannelIndex(-1);
@@ -177,7 +177,11 @@ CPVRChannel *CPVRChannelGroupsContainer::GetByPath(const CStdString &strPath)
}
}
- return channels ? channels->GetByIndex(iChannelIndex) : NULL;
+ if (channels)
+ return channels->GetByIndex(iChannelIndex);
+
+ CFileItemPtr retVal(new CFileItem);
+ return retVal;
}
bool CPVRChannelGroupsContainer::GetDirectory(const CStdString& strPath, CFileItemList &results)
@@ -265,7 +269,7 @@ CPVRChannel *CPVRChannelGroupsContainer::GetByUniqueID(int iClientChannelNumber,
return channel;
}
-CPVRChannel *CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID)
+CFileItemPtr CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID)
{
CPVRChannel *channel = NULL;
const CPVRChannelGroup* channelgroup = GetGroupAllTV();
@@ -279,33 +283,14 @@ CPVRChannel *CPVRChannelGroupsContainer::GetByChannelIDFromAll(int iChannelID)
channel = channelgroup->GetByChannelID(iChannelID);
}
- return channel;
-}
-
-CPVRChannel *CPVRChannelGroupsContainer::GetByClientFromAll(unsigned int iClientId, unsigned int iChannelUid)
-{
- CPVRChannel *channel = NULL;
-
- channel = GetGroupAllTV()->GetByClient(iChannelUid, iClientId);
-
- if (channel == NULL)
- channel = GetGroupAllRadio()->GetByClient(iChannelUid, iClientId);
-
- return channel;
-}
-
-CPVRChannel *CPVRChannelGroupsContainer::GetByUniqueIDFromAll(int iUniqueID)
-{
- CPVRChannel *channel;
- const CPVRChannelGroup* channelgroup = GetGroupAllTV();
-
- if (channelgroup == NULL)
- channelgroup = GetGroupAllRadio();
-
- if (channelgroup != NULL)
- channel = channelgroup->GetByUniqueID(iUniqueID);
+ if (channel)
+ {
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem(*channel));
+ return retVal;
+ }
- return NULL;
+ CFileItemPtr retVal = CFileItemPtr(new CFileItem);
+ return retVal;
}
void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void)
@@ -324,13 +309,16 @@ void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void)
CGUIDialogOK::ShowAndGetInput(19103,0,20177,0);
}
-CPVRChannel *CPVRChannelGroupsContainer::GetLastPlayedChannel(void) const
+CFileItemPtr CPVRChannelGroupsContainer::GetLastPlayedChannel(void) const
{
- CPVRChannel *lastChannel = GetGroupAllTV()->GetLastPlayedChannel();
+ CFileItemPtr lastChannel = GetGroupAllTV()->GetLastPlayedChannel();
+ bool bHasTVChannel(lastChannel && lastChannel->HasPVRChannelInfoTag());
+
+ CFileItemPtr lastRadioChannel = GetGroupAllRadio()->GetLastPlayedChannel();
+ bool bHasRadioChannel(lastRadioChannel && lastRadioChannel->HasPVRChannelInfoTag());
- CPVRChannel *lastRadioChannel = GetGroupAllRadio()->GetLastPlayedChannel();
- if (!lastChannel || (lastRadioChannel && lastChannel->LastWatched() < lastRadioChannel->LastWatched()))
- lastChannel = lastRadioChannel;
+ if (!bHasTVChannel || (bHasRadioChannel && lastChannel->GetPVRChannelInfoTag()->LastWatched() < lastRadioChannel->GetPVRChannelInfoTag()->LastWatched()))
+ return lastRadioChannel;
return lastChannel;
}
View
53 xbmc/pvr/channels/PVRChannelGroupsContainer.h
@@ -52,50 +52,50 @@ namespace PVR
* @brief Load all channel groups and all channels in those channel groups.
* @return True if all groups were loaded, false otherwise.
*/
- virtual bool Load(void);
+ bool Load(void);
/*!
* @brief Unload and destruct all channel groups and all channels in them.
*/
- virtual void Unload(void);
+ void Unload(void);
/*!
* @brief Get the TV channel groups.
* @return The TV channel groups.
*/
- virtual CPVRChannelGroups *GetTV(void) const { return Get(false); }
+ CPVRChannelGroups *GetTV(void) const { return Get(false); }
/*!
* @brief Get the radio channel groups.
* @return The radio channel groups.
*/
- virtual CPVRChannelGroups *GetRadio(void) const { return Get(true); }
+ CPVRChannelGroups *GetRadio(void) const { return Get(true); }
/*!
* @brief Get the radio or TV channel groups.
* @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise.
* @return The requested groups.
*/
- virtual CPVRChannelGroups *Get(bool bRadio) const;
+ CPVRChannelGroups *Get(bool bRadio) const;
/*!
* @brief Get the group containing all TV channels.
* @return The group containing all TV channels.
*/
- virtual CPVRChannelGroupInternal *GetGroupAllTV(void) const{ return GetGroupAll(false); }
+ CPVRChannelGroupInternal *GetGroupAllTV(void) const{ return GetGroupAll(false); }
/*!
* @brief Get the group containing all radio channels.
* @return The group containing all radio channels.
*/
- virtual CPVRChannelGroupInternal *GetGroupAllRadio(void) const{ return GetGroupAll(true); }
+ CPVRChannelGroupInternal *GetGroupAllRadio(void) const{ return GetGroupAll(true); }
/*!
* @brief Get the group containing all TV or radio channels.
* @param bRadio If true, get the group containing all radio channels. Get the group containing all TV channels otherwise.
* @return The requested group.
*/
- virtual CPVRChannelGroupInternal *GetGroupAll(bool bRadio) const;
+ CPVRChannelGroupInternal *GetGroupAll(bool bRadio) const;
/*!
* @brief Get a group given it's ID.
@@ -103,28 +103,28 @@ namespace PVR
* @param iGroupId The ID of the group.
* @return The requested group or NULL if it wasn't found.
*/
- virtual CPVRChannelGroup *GetById(bool bRadio, int iGroupId) const;
+ CPVRChannelGroup *GetById(bool bRadio, int iGroupId) const;
/*!
* @brief Get a group given it's ID.
* @param iGroupId The ID of the group.
* @return The requested group or NULL if it wasn't found.
*/
- virtual CPVRChannelGroup *GetByIdFromAll(int iGroupId) const;
+ CPVRChannelGroup *GetByIdFromAll(int iGroupId) const;
/*!
* @brief Get a channel given it's database ID.
* @param iChannelId The ID of the channel.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetChannelById(int iChannelId) const;
+ CPVRChannel *GetChannelById(int iChannelId) const;
/*!
* @brief Get a channel given it's EPG ID.
* @param iEpgId The EPG ID of the channel.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetChannelByEpgId(int iEpgId) const;
+ CPVRChannel *GetChannelByEpgId(int iEpgId) const;
/*!
* @brief Get the groups list for a directory.
@@ -133,14 +133,14 @@ namespace PVR
* @param bRadio Get radio channels or tv channels.
* @return True if the list was filled succesfully.
*/
- virtual bool GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio);
+ bool GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio);
/*!
* @brief Get a channel given it's path.
* @param strPath The path.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByPath(const CStdString &strPath);
+ CFileItemPtr GetByPath(const CStdString &strPath);
/*!
* @brief Get the directory for a path.
@@ -148,20 +148,20 @@ namespace PVR
* @param results The file list to store the results in.
* @return True if the directory was found, false if not.
*/
- virtual bool GetDirectory(const CStdString& strPath, CFileItemList &results);
+ bool GetDirectory(const CStdString& strPath, CFileItemList &results);
/*!
* @brief The total amount of unique channels in all containers.
* @return The total amount of unique channels in all containers.
*/
- virtual int GetNumChannelsFromAll(void);
+ int GetNumChannelsFromAll(void);
/*!
* @brief Get the group that is currently selected in the UI.
* @param bRadio True to get the selected radio group, false to get the selected TV group.
* @return The selected group.
*/
- virtual CPVRChannelGroup *GetSelectedGroup(bool bRadio) const;
+ CPVRChannelGroup *GetSelectedGroup(bool bRadio) const;
/*!
* @brief Get a channel given it's channel ID from all containers.
@@ -169,34 +169,25 @@ namespace PVR
* @param iClientID The ID of the client.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByUniqueID(int iClientChannelNumber, int iClientID);
+ CPVRChannel *GetByUniqueID(int iClientChannelNumber, int iClientID);
/*!
* @brief Get a channel given it's channel ID from all containers.
* @param iChannelID The channel ID.
* @return The channel or NULL if it wasn't found.
*/
- virtual CPVRChannel *GetByChannelIDFromAll(int iChannelID);
-
- virtual CPVRChannel *GetByClientFromAll(unsigned int iClientId, unsigned int iChannelUid);
-
- /*!
- * @brief Get a channel given it's unique ID.
- * @param iUniqueID The unique ID of the channel.
- * @return The channel or NULL if it wasn't found.
- */
- virtual CPVRChannel *GetByUniqueIDFromAll(int iUniqueID);
+ CFileItemPtr GetByChannelIDFromAll(int iChannelID);
/*!
* @brief Try to find missing channel icons automatically
*/
- virtual void SearchMissingChannelIcons(void);
+ void SearchMissingChannelIcons(void);
/*!
* @brief The channel that was played last that has a valid client or NULL if there was none.
* @return The requested channel.
*/
- virtual CPVRChannel *GetLastPlayedChannel(void) const;
+ CFileItemPtr GetLastPlayedChannel(void) const;
protected:
/*!
@@ -204,7 +195,7 @@ namespace PVR
* @param bChannelsOnly Set to true to only update channels, not the groups themselves.
* @return True if the update was successful, false otherwise.
*/
- virtual bool Update(bool bChannelsOnly = false);
+ bool Update(bool bChannelsOnly = false);
CPVRChannelGroups *m_groupsRadio; /*!< all radio channel groups */
CPVRChannelGroups *m_groupsTV; /*!< all TV channel groups */
View
36 xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
@@ -720,8 +720,11 @@ void CGUIDialogPVRChannelManager::Update()
for (int iChannelPtr = 0; iChannelPtr < channels->Size(); iChannelPtr++)
{
- const CPVRChannel *channel = channels->GetByIndex(iChannelPtr);
- CFileItemPtr channelFile(new CFileItem(*channel));
+ CFileItemPtr channelFile = channels->GetByIndex(iChannelPtr);
+ if (!channelFile || !channelFile->HasPVRChannelInfoTag())
+ continue;
+ const CPVRChannel *channel = channelFile->GetPVRChannelInfoTag();
+
channelFile->SetProperty("ActiveChannel", !channel->IsHidden());
channelFile->SetProperty("Name", channel->ChannelName());
channelFile->SetProperty("UseEPG", channel->EPGEnabled());
@@ -770,12 +773,7 @@ void CGUIDialogPVRChannelManager::Clear(void)
bool CGUIDialogPVRChannelManager::PersistChannel(CFileItemPtr pItem, CPVRChannelGroup *group, unsigned int *iChannelNumber)
{
- if (!pItem || !pItem->HasPVRChannelInfoTag())
- return false;
-
- /* get the real channel from the group */
- CPVRChannel *channel = (CPVRChannel *) group->GetByUniqueID(pItem->GetPVRChannelInfoTag()->UniqueID());
- if (!channel)
+ if (!pItem || !pItem->HasPVRChannelInfoTag() || !group)
return false;
/* get values from the form */
@@ -788,27 +786,7 @@ bool CGUIDialogPVRChannelManager::PersistChannel(CFileItemPtr pItem, CPVRChannel
CStdString strIconPath = pItem->GetProperty("Icon").asString();
CStdString strStreamURL = pItem->GetProperty("StreamURL").asString();
- channel->SetChannelName(strChannelName);
- channel->SetHidden(bHidden);
- channel->SetLocked(bParentalLocked);
- channel->SetIconPath(strIconPath);
- if (bVirtual)
- channel->SetStreamURL(strStreamURL);
- if (iEPGSource == 0)
- channel->SetEPGScraper("client");
- // TODO add other scrapers
- channel->SetEPGEnabled(bEPGEnabled);
-
- /* set new values in the channel tag */
- if (bHidden)
- {
- group->SortByChannelNumber(); // or previous changes will be overwritten
- group->RemoveFromGroup(*channel);
- }
- else
- group->SetChannelNumber(*channel, ++(*iChannelNumber));
-
- return true;
+ return group->UpdateChannel(*pItem, bHidden, bVirtual, bEPGEnabled, bParentalLocked, iEPGSource, ++(*iChannelNumber), strChannelName, strIconPath, strStreamURL);
}
void CGUIDialogPVRChannelManager::SaveList(void)
View
8 xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp
@@ -85,12 +85,12 @@ void CGUIDialogPVRGuideSearch::UpdateChannelSpin(void)
for (int iChannelPtr = 0; iChannelPtr < group->Size(); iChannelPtr++)
{
- const CPVRChannel *channel = group->GetByIndex(iChannelPtr);
- if (!channel)
+ CFileItemPtr channel = group->GetByIndex(iChannelPtr);
+ if (!channel || !channel->HasPVRChannelInfoTag())
continue;
- int iChannelNumber = group->GetChannelNumber(*channel);
- pSpin->AddLabel(channel->ChannelName().c_str(), iChannelNumber);