Example #1
0
CPVRTimerInfoTag *CPVRTimers::GetMatch(const CEpgInfoTag *Epg)
{
  CPVRTimerInfoTag *returnTag = NULL;
  CSingleLock lock(m_critSection);

  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    CPVRTimerInfoTag *timer = at(ptr);

    if (!Epg || !Epg->GetTable() || !Epg->GetTable()->Channel())
      continue;

    const CPVRChannel *channel = Epg->GetTable()->Channel();
    if (timer->ChannelNumber() != channel->ChannelNumber()
        || timer->m_bIsRadio != channel->IsRadio())
      continue;

    if (timer->StartAsUTC() > Epg->StartAsUTC() || timer->EndAsUTC() < Epg->EndAsUTC())
      continue;

    returnTag = timer;
    break;
  }
  return returnTag;
}
Example #2
0
bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannel &channel, bool bDeleteRepeating /* = true */, bool bCurrentlyActiveOnly /* = false */)
{
  bool bReturn = false;
  CSingleLock lock(m_critSection);

  for (map<CDateTime, vector<CPVRTimerInfoTag *>* >::reverse_iterator it = m_tags.rbegin(); it != m_tags.rend(); it++)
  {
    for (int iTimerPtr = it->second->size() - 1; iTimerPtr >= 0; iTimerPtr--)
    {
      CPVRTimerInfoTag *timer = it->second->at(iTimerPtr);

      if (bCurrentlyActiveOnly &&
          (CDateTime::GetCurrentDateTime() < timer->StartAsLocalTime() ||
           CDateTime::GetCurrentDateTime() > timer->EndAsLocalTime()))
        continue;

      if (!bDeleteRepeating && timer->m_bIsRepeating)
        continue;

      if (timer->ChannelNumber() == channel.ChannelNumber() && timer->m_bIsRadio == channel.IsRadio())
      {
        bReturn = timer->DeleteFromClient(true) || bReturn;
        it->second->erase(it->second->begin() + iTimerPtr);
      }
    }
  }

  return bReturn;
}
Example #3
0
bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannel &channel, bool bDeleteRepeating /* = true */, bool bCurrentlyActiveOnly /* = false */)
{
  bool bReturn = false;
  CSingleLock lock(m_critSection);

  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    CPVRTimerInfoTag *timer = at(ptr);

    if (bCurrentlyActiveOnly &&
        (CDateTime::GetCurrentDateTime() < timer->StartAsLocalTime() ||
         CDateTime::GetCurrentDateTime() > timer->EndAsLocalTime()))
      continue;

    if (!bDeleteRepeating && timer->m_bIsRepeating)
      continue;

    if (timer->ChannelNumber() == channel.ChannelNumber() && timer->m_bIsRadio == channel.IsRadio())
    {
      bReturn = timer->DeleteFromClient(true) || bReturn;
      erase(begin() + ptr);
      ptr--;
    }
  }

  return bReturn;
}
Example #4
0
CFileItemPtr CPVRTimers::GetMatch(const CEpgInfoTag *Epg)
{
  CSingleLock lock(m_critSection);

  for (map<CDateTime, vector<CPVRTimerInfoTag *>* >::iterator it = m_tags.begin(); it != m_tags.end(); it++)
  {
    for (unsigned int iTimerPtr = 0; iTimerPtr < it->second->size(); iTimerPtr++)
    {
      CPVRTimerInfoTag *timer = it->second->at(iTimerPtr);

      CPVRChannelPtr channel;
      if (Epg)
        channel = Epg->ChannelTag();
      if (!channel)
        continue;

      if (timer->ChannelNumber() != channel->ChannelNumber()
          || timer->m_bIsRadio != channel->IsRadio())
        continue;

      if (timer->StartAsUTC() > Epg->StartAsUTC() || timer->EndAsUTC() < Epg->EndAsUTC())
        continue;

      CFileItemPtr fileItem(new CFileItem(*timer));
      return fileItem;
    }
  }
  CFileItemPtr fileItem;
  return fileItem;
}
Example #5
0
bool CPVRTimers::ChannelHasTimers(const CPVRChannel &channel)
{
  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    CPVRTimerInfoTag timer = at(ptr);

    if (timer.ChannelNumber() == channel.ChannelNumber() && timer.IsRadio() == channel.IsRadio())
      return true;
  }

  return false;
}
Example #6
0
int CPVREpgContainer::GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter)
{
  CEpgContainer::GetEPGSearch(results, filter);

  /* filter recordings */
  if (filter.m_bIgnorePresentRecordings && CPVRManager::GetRecordings()->size() > 0)
  {
    for (unsigned int iRecordingPtr = 0; iRecordingPtr < CPVRManager::GetRecordings()->size(); iRecordingPtr++)
    {
      for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++)
      {
        const CPVREpgInfoTag *epgentry  = (CPVREpgInfoTag *) results->Get(iResultPtr)->GetEPGInfoTag();
        CPVRRecording *recording = CPVRManager::GetRecordings()->at(iRecordingPtr);
        if (epgentry)
        {
          if (epgentry->Title()       != recording->m_strTitle ||
              epgentry->PlotOutline() != recording->m_strPlotOutline ||
              epgentry->Plot()        != recording->m_strPlot)
            continue;

          results->Remove(iResultPtr);
          iResultPtr--;
        }
      }
    }
  }

  /* filter timers */
  if (filter.m_bIgnorePresentTimers)
  {
    CPVRTimers *timers = CPVRManager::GetTimers();
    for (unsigned int iTimerPtr = 0; iTimerPtr < timers->size(); iTimerPtr++)
    {
      for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++)
      {
        const CPVREpgInfoTag *epgentry = (CPVREpgInfoTag *) results->Get(iResultPtr)->GetEPGInfoTag();
        CPVRTimerInfoTag *timer        = timers->at(iTimerPtr);
        if (epgentry)
        {
          if (epgentry->ChannelTag()->ChannelNumber() != timer->ChannelNumber() ||
              epgentry->Start()                       <  timer->m_StartTime ||
              epgentry->End()                         >  timer->m_StopTime)
            continue;

          results->Remove(iResultPtr);
          iResultPtr--;
        }
      }
    }
  }

  return results->Size();
}
Example #7
0
bool CPVRTimers::ChannelHasTimers(const CPVRChannel &channel)
{
  CSingleLock lock(m_critSection);
  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    CPVRTimerInfoTag *timer = at(ptr);

    if (timer->ChannelNumber() == channel.ChannelNumber() && timer->m_bIsRadio == channel.IsRadio())
      return true;
  }

  return false;
}
Example #8
0
bool CPVRTimers::ChannelHasTimers(const CPVRChannel &channel)
{
  CSingleLock lock(m_critSection);
  for (map<CDateTime, vector<CPVRTimerInfoTag *>* >::iterator it = m_tags.begin(); it != m_tags.end(); it++)
  {
    for (unsigned int iTimerPtr = 0; iTimerPtr < it->second->size(); iTimerPtr++)
    {
      CPVRTimerInfoTag *timer = it->second->at(iTimerPtr);

      if (timer->ChannelNumber() == channel.ChannelNumber() && timer->m_bIsRadio == channel.IsRadio())
        return true;
    }
  }

  return false;
}
Example #9
0
bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannel &channel, bool bForce /* = false */)
{
  bool bReturn = true;

  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    CPVRTimerInfoTag timer = at(ptr);

    if (timer.ChannelNumber() == channel.ChannelNumber() && timer.IsRadio() == channel.IsRadio())
    {
      bReturn = timer.DeleteFromClient(bForce) && bReturn;
      erase(begin() + ptr);
      ptr--;
    }
  }

  return bReturn;
}
Example #10
0
int CPVREpgs::GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter)
{
  for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
  {
    CPVREpg *epg = at(iEpgPtr);
    epg->Get(results, filter);
  }

  /* filter recordings */
  if (filter.m_bIgnorePresentRecordings && PVRRecordings.size() > 0)
  {
    for (unsigned int iRecordingPtr = 0; iRecordingPtr < PVRRecordings.size(); iRecordingPtr++)
    {
      for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++)
      {
        const CPVREpgInfoTag *epgentry  = results->Get(iResultPtr)->GetEPGInfoTag();
        CPVRRecordingInfoTag *recording = &PVRRecordings[iRecordingPtr];
        if (epgentry)
        {
          if (epgentry->Title()       != recording->Title() ||
              epgentry->PlotOutline() != recording->PlotOutline() ||
              epgentry->Plot()        != recording->Plot())
            continue;

          results->Remove(iResultPtr);
          iResultPtr--;
        }
      }
    }
  }

  /* filter timers */
  if (filter.m_bIgnorePresentTimers && PVRTimers.size() > 0)
  {
    for (unsigned int iTimerPtr = 0; iTimerPtr < PVRTimers.size(); iTimerPtr++)
    {
      for (int iResultPtr = 0; iResultPtr < results->Size(); iResultPtr++)
      {
        const CPVREpgInfoTag *epgentry = results->Get(iResultPtr)->GetEPGInfoTag();
        CPVRTimerInfoTag *timer        = &PVRTimers[iTimerPtr];
        if (epgentry)
        {
          if (epgentry->ChannelTag()->ChannelNumber() != timer->ChannelNumber() ||
              epgentry->Start()                       <  timer->Start() ||
              epgentry->End()                         >  timer->Stop())
            continue;

          results->Remove(iResultPtr);
          iResultPtr--;
        }
      }
    }
  }

  /* remove duplicate entries */
  if (filter.m_bPreventRepeats)
  {
    unsigned int iSize = results->Size();
    for (unsigned int iResultPtr = 0; iResultPtr < iSize; iResultPtr++)
    {
      const CPVREpgInfoTag *epgentry_1 = results->Get(iResultPtr)->GetEPGInfoTag();
      for (unsigned int iTagPtr = 0; iTagPtr < iSize; iTagPtr++)
      {
        const CPVREpgInfoTag *epgentry_2 = results->Get(iTagPtr)->GetEPGInfoTag();
        if (iResultPtr == iTagPtr)
          continue;

        if (epgentry_1->Title()       != epgentry_2->Title() ||
            epgentry_1->Plot()        != epgentry_2->Plot() ||
            epgentry_1->PlotOutline() != epgentry_2->PlotOutline())
          continue;

        results->Remove(iTagPtr);
        iSize = results->Size();
        iResultPtr--;
        iTagPtr--;
      }
    }
  }

  return results->Size();
}