Example #1
0
int CPVRChannelGroup::GetEPGAll(CFileItemList &results, bool bIncludeChannelsWithoutEPG /* = false */) const
{
  int iInitialSize = results.Size();
  CPVREpgInfoTagPtr epgTag;
  CPVRChannelPtr channel;
  CSingleLock lock(m_critSection);

  for (PVR_CHANNEL_GROUP_SORTED_MEMBERS::const_iterator it = m_sortedMembers.begin(); it != m_sortedMembers.end(); ++it)
  {
    channel = (*it).channel;
    if (!channel->IsHidden())
    {
      int iAdded = 0;

      CPVREpgPtr epg = channel->GetEPG();
      if (epg)
      {
        // XXX channel pointers aren't set in some occasions. this works around the issue, but is not very nice
        epg->SetChannel(channel);
        iAdded = epg->Get(results);
      }

      if (bIncludeChannelsWithoutEPG && iAdded == 0)
      {
        // Add dummy EPG tag associated with this channel
        epgTag = CPVREpgInfoTag::CreateDefaultTag();
        epgTag->SetChannel(channel);
        results.Add(CFileItemPtr(new CFileItem(epgTag)));
      }
    }
  }

  return results.Size() - iInitialSize;
}