Example #1
0
void CPVREpg::AddEntry(const CPVREpgInfoTag &tag)
{
  CPVREpgInfoTagPtr newTag;
  CPVRChannelPtr channel;
  {
    CSingleLock lock(m_critSection);
    std::map<CDateTime, CPVREpgInfoTagPtr>::iterator itr = m_tags.find(tag.StartAsUTC());
    if (itr != m_tags.end())
      newTag = itr->second;
    else
    {
      newTag.reset(new CPVREpgInfoTag(this, m_pvrChannel, m_strName, m_pvrChannel ? m_pvrChannel->IconPath() : ""));
      m_tags.insert(make_pair(tag.StartAsUTC(), newTag));
    }

    channel = m_pvrChannel;
  }

  if (newTag)
  {
    newTag->Update(tag);
    newTag->SetChannel(channel);
    newTag->SetEpg(this);
    newTag->SetTimer(CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(newTag));
    newTag->SetRecording(CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(newTag));
  }
}
Example #2
0
bool CPVREpgDatabase::Delete(const CPVREpgInfoTag &tag)
{
  /* tag without a database ID was not persisted */
  if (tag.BroadcastId() <= 0)
    return false;

  Filter filter;
  filter.AppendWhere(PrepareSQL("idBroadcast = %u", tag.BroadcastId()));

  return DeleteValues("epgtags", filter);
}
Example #3
0
void CPVREpg::Cleanup(const CDateTime &Time)
{
  CSingleLock lock(m_critSection);

  for (unsigned int i = 0; i < size(); i++)
  {
    CPVREpgInfoTag *tag = (CPVREpgInfoTag *) at(i);
    if ( tag && /* valid tag */
        !tag->HasTimer() && /* no timer set */
        (tag->End() + CDateTimeSpan(0, g_advancedSettings.m_iEpgLingerTime / 60, g_advancedSettings.m_iEpgLingerTime % 60, 0) < Time))
    {
      DeleteInfoTag(tag);
    }
  }
}
Example #4
0
bool CGUIWindowPVRCommon::ActionRecord(CFileItem *item)
{
  bool bReturn = false;

  CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) item->GetEPGInfoTag();
  if (!epgTag)
    return bReturn;

  const CPVRChannel *channel = epgTag->ChannelTag();
  if (!channel || channel->ChannelNumber() > 0)
    return bReturn;

  if (epgTag->Timer() == NULL)
  {
    /* create a confirmation dialog */
    CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
    if (!pDialog)
      return bReturn;

    pDialog->SetHeading(264);
    pDialog->SetLine(0, "");
    pDialog->SetLine(1, epgTag->Title());
    pDialog->SetLine(2, "");
    pDialog->DoModal();

    /* prompt for the user's confirmation */
    if (!pDialog->IsConfirmed())
      return bReturn;

    CPVRTimerInfoTag *newtimer = CPVRTimerInfoTag::CreateFromEpg(*epgTag);
    CFileItem *item = new CFileItem(*newtimer);

    if (CPVRManager::GetTimers()->AddTimer(*item))
      CPVRManager::GetTimers()->Update();

    bReturn = true;
  }
  else
  {
    CGUIDialogOK::ShowAndGetInput(19033,19034,0,0);
    bReturn = true;
  }

  return bReturn;
}
Example #5
0
bool CPVRDatabase::RemoveEpgEntry(const CPVREpgInfoTag &tag)
{
  /* invalid tag */
  if (tag.BroadcastId() <= 0 && tag.UniqueBroadcastID() <= 0)
  {
    CLog::Log(LOGERROR, "PVRDB - %s - invalid EPG tag", __FUNCTION__);
    return false;
  }

  CStdString strWhereClause;

  if (tag.BroadcastId() > 0)
    strWhereClause = FormatSQL("BroadcastId = %u", tag.BroadcastId());
  else
    strWhereClause = FormatSQL("BroadcastUid = %u", tag.UniqueBroadcastID());

  return DeleteValues("EpgData", strWhereClause);
}
Example #6
0
CPVREpgInfoTagPtr CPVREpg::GetNextEvent(const CPVREpgInfoTag& tag) const
{
  CSingleLock lock(m_critSection);
  std::map<CDateTime, CPVREpgInfoTagPtr>::const_iterator it = m_tags.find(tag.StartAsUTC());
  if (it != m_tags.end() && ++it != m_tags.end())
    return it->second;

  CPVREpgInfoTagPtr retVal;
  return retVal;
}
Example #7
0
void PVR::CPVREpg::Cleanup(const CDateTime &Time)
{
  CSingleLock lock(m_critSection);

  CDateTime firstDate = Time.GetAsUTCDateTime() - CDateTimeSpan(0, g_advancedSettings.m_iEpgLingerTime / 60, g_advancedSettings.m_iEpgLingerTime % 60, 0);

  unsigned int iSize = size();
  for (unsigned int iTagPtr = 0; iTagPtr < iSize; iTagPtr++)
  {
    CPVREpgInfoTag *tag = (CPVREpgInfoTag *) at(iTagPtr);
    if ( tag && /* valid tag */
        !tag->HasTimer() && /* no timer set */
        tag->EndAsLocalTime() < firstDate)
    {
      DeleteInfoTag(tag);
      iTagPtr--;
      iSize--;
    }
  }
}
Example #8
0
bool CGUIWindowPVRCommon::StartRecordFile(CFileItem *item)
{
  bool bReturn = false;

  if (!item->HasEPGInfoTag())
    return bReturn;

  CPVREpgInfoTag *tag = (CPVREpgInfoTag *) item->GetEPGInfoTag();
  if (!tag || !tag->ChannelTag() || tag->ChannelTag()->ChannelNumber() <= 0)
    return bReturn;

  CPVRTimerInfoTag *timer = CPVRManager::GetTimers()->GetMatch(item);
  if (timer)
  {
    CGUIDialogOK::ShowAndGetInput(19033,19034,0,0);
    return bReturn;
  }

  CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
  if (!pDialog)
    return bReturn;
  pDialog->SetHeading(264);
  pDialog->SetLine(0, tag->ChannelTag()->ChannelName());
  pDialog->SetLine(1, "");
  pDialog->SetLine(2, tag->Title());
  pDialog->DoModal();

  if (!pDialog->IsConfirmed())
    return bReturn;

  CPVRTimerInfoTag *newtimer = CPVRTimerInfoTag::CreateFromEpg(*tag);
  CFileItem *newTimerItem = new CFileItem(*newtimer);
  if (CPVRManager::GetTimers()->AddTimer(*newTimerItem))
  {
    CPVRManager::GetTimers()->Update();
    bReturn = true;
  }

  return bReturn;
}
Example #9
0
bool PVREpgSearchFilter::FilterEntry(const CPVREpgInfoTag &tag) const
{
  bool bReturn = EpgSearchFilter::FilterEntry(tag);

  if (bReturn)
  {
    if (m_iChannelNumber != -1)
    {
      if (m_iChannelNumber == -2)
      {
        if (tag.ChannelTag()->IsRadio())
          bReturn = false;
      }
      else if (m_iChannelNumber == -3)
      {
        if (!tag.ChannelTag()->IsRadio())
          bReturn = false;
      }
      else if (tag.ChannelTag()->ChannelNumber() != m_iChannelNumber)
        bReturn = false;
    }
    if (m_bFTAOnly && tag.ChannelTag()->IsEncrypted())
    {
      bReturn = false;
    }
    if (m_iChannelGroup != -1)
    {
      const CPVRChannelGroup *group = CPVRManager::GetChannelGroups()->GetById(tag.ChannelTag()->IsRadio(), m_iChannelGroup);
      if (!group || !group->IsGroupMember(tag.ChannelTag()))
        bReturn = false;
    }
  }

  return bReturn;
}
Example #10
0
bool CGUIWindowPVRCommon::ActionPlayEpg(CFileItem *item)
{
  bool bReturn = false;

  CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) item->GetEPGInfoTag();
  if (!epgTag)
    return bReturn;

  const CPVRChannel *channel = epgTag->ChannelTag();
  if (!channel || channel->ChannelNumber() > 0)
    return bReturn;

  bReturn = g_application.PlayFile(CFileItem(*channel));

  if (!bReturn)
  {
    /* cannot play file */
    CGUIDialogOK::ShowAndGetInput(19033,0,19035,0);
  }

  return bReturn;
}
Example #11
0
void CPVREpgs::UpdateFirstAndLastEPGDates(const CPVREpgInfoTag &tag)
{
  if (!tag.ChannelTag())
    return;

  if (tag.ChannelTag()->IsRadio())
  {
    if (tag.Start() < m_RadioFirst)
      m_RadioFirst = tag.Start();

    if (tag.End() > m_RadioLast)
      m_RadioLast = tag.End();
  }
  else
  {
    if (tag.Start() < m_TVFirst)
      m_TVFirst = tag.Start();

    if (tag.End() > m_TVLast)
      m_TVLast = tag.End();
  }
}
Example #12
0
bool CGUIWindowPVRCommon::StopRecordFile(CFileItem *item)
{
  bool bReturn = false;

  if (!item->HasEPGInfoTag())
    return bReturn;

  CPVREpgInfoTag *tag = (CPVREpgInfoTag *) item->GetEPGInfoTag();
  if (!tag || !tag->ChannelTag() || tag->ChannelTag()->ChannelNumber() <= 0)
    return bReturn;

  CPVRTimerInfoTag *timer = CPVRManager::GetTimers()->GetMatch(item);
  if (!timer || timer->IsRepeating())
    return bReturn;

  if (CPVRManager::GetTimers()->DeleteTimer(*timer))
  {
    CPVRManager::GetTimers()->Update();
    bReturn = true;
  }

  return bReturn;
}
Example #13
0
void CGUIDialogPVRGuideInfo::Update()
{
  // set recording button label
  CPVREpgInfoTag* tag = (CPVREpgInfoTag *) m_progItem->GetEPGInfoTag();
  if (tag->End() > CDateTime::GetCurrentDateTime())
  {
    if (tag->Timer() == NULL)
    {
      if (tag->Start() < CDateTime::GetCurrentDateTime())
        SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 264);
      else
        SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19061);
    }
    else
    {
      if (tag->Start() < CDateTime::GetCurrentDateTime())
        SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19059);
      else
        SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19060);
    }
  }
  else
    SET_CONTROL_HIDDEN(CONTROL_BTN_RECORD);
}
Example #14
0
int CPVREpgDatabase::Persist(const CPVREpgInfoTag &tag, bool bSingleUpdate /* = true */)
{
  int iReturn(-1);

  if (tag.EpgID() <= 0)
  {
    CLog::Log(LOGERROR, "%s - tag '%s' does not have a valid table", __FUNCTION__, tag.Title(true).c_str());
    return iReturn;
  }

  time_t iStartTime, iEndTime, iFirstAired;
  tag.StartAsUTC().GetAsTime(iStartTime);
  tag.EndAsUTC().GetAsTime(iEndTime);
  tag.FirstAiredAsUTC().GetAsTime(iFirstAired);

  int iBroadcastId = tag.BroadcastId();
  std::string strQuery;

  /* Only store the genre string when needed */
  std::string strGenre = (tag.GenreType() == EPG_GENRE_USE_STRING) ? StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator) : "";

  if (iBroadcastId < 0)
  {
    strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, "
        "iEndTime, sTitle, sPlotOutline, sPlot, sOriginalTitle, sCast, sDirector, sWriter, iYear, sIMDBNumber, "
        "sIconPath, iGenreType, iGenreSubType, sGenre, iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, "
        "iEpisodeId, iEpisodePart, sEpisodeName, iFlags, iBroadcastUid) "
        "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i);",
        tag.EpgID(), static_cast<unsigned int>(iStartTime), static_cast<unsigned int>(iEndTime),
        tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(),
        tag.OriginalTitle(true).c_str(), tag.Cast().c_str(), tag.Director().c_str(), tag.Writer().c_str(), tag.Year(), tag.IMDBNumber().c_str(),
        tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(),
        static_cast<unsigned int>(iFirstAired), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNumber(), tag.EpisodeNumber(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.Flags(),
        tag.UniqueBroadcastID());
  }
  else
  {
    strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, "
        "iEndTime, sTitle, sPlotOutline, sPlot, sOriginalTitle, sCast, sDirector, sWriter, iYear, sIMDBNumber, "
        "sIconPath, iGenreType, iGenreSubType, sGenre, iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, "
        "iEpisodeId, iEpisodePart, sEpisodeName, iFlags, iBroadcastUid, idBroadcast) "
        "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i, %i);",
        tag.EpgID(), static_cast<unsigned int>(iStartTime), static_cast<unsigned int>(iEndTime),
        tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(),
        tag.OriginalTitle(true).c_str(), tag.Cast().c_str(), tag.Director().c_str(), tag.Writer().c_str(), tag.Year(), tag.IMDBNumber().c_str(),
        tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(),
        static_cast<unsigned int>(iFirstAired), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNumber(), tag.EpisodeNumber(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.Flags(),
        tag.UniqueBroadcastID(), iBroadcastId);
  }

  if (bSingleUpdate)
  {
    if (ExecuteQuery(strQuery))
      iReturn = (int) m_pDS->lastinsertid();
  }
  else
  {
    QueueInsertQuery(strQuery);
    iReturn = 0;
  }

  return iReturn;
}
Example #15
0
bool CPVRTimers::UpdateEntries(CPVRTimers *timers)
{
  bool bChanged(false);
  bool bAddedOrDeleted(false);

  CSingleLock lock(m_critSection);

  /* go through the timer list and check for updated or new timers */
  for (unsigned int iTimerPtr = 0; iTimerPtr < timers->size(); iTimerPtr++)
  {
    const CPVRTimerInfoTag *timer = timers->at(iTimerPtr);

    /* check if this timer is present in this container */
    CPVRTimerInfoTag *existingTimer = (CPVRTimerInfoTag *) GetByClient(timer->m_iClientId, timer->m_iClientIndex);
    if (existingTimer)
    {
      /* if it's present, update the current tag */
      if (existingTimer->UpdateEntry(*timer))
      {
        bChanged = true;

        CLog::Log(LOGINFO,"PVRTimers - %s - updated timer %d on client %d",
            __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);
      }
    }
    else
    {
      /* new timer */
      CPVRTimerInfoTag *newTimer = new CPVRTimerInfoTag;
      newTimer->UpdateEntry(*timer);
      push_back(newTimer);
      bChanged = true;
      bAddedOrDeleted = true;

      CLog::Log(LOGINFO,"PVRTimers - %s - added timer %d on client %d",
          __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);
    }
  }

  /* check for deleted timers */
  unsigned int iSize = size();
  for (unsigned int iTimerPtr = 0; iTimerPtr < iSize; iTimerPtr++)
  {
    CPVRTimerInfoTag *timer = (CPVRTimerInfoTag *) at(iTimerPtr);
    if (!timer)
      continue;
    if (timers->GetByClient(timer->m_iClientId, timer->m_iClientIndex) == NULL)
    {
      /* timer was not found */
      CLog::Log(LOGINFO,"PVRTimers - %s - deleted timer %d on client %d",
          __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);

      CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) at(iTimerPtr)->m_epgInfo;
      if (epgTag)
        epgTag->SetTimer(NULL);

      delete at(iTimerPtr);
      erase(begin() + iTimerPtr);
      iTimerPtr--;
      iSize--;
      bChanged = true;
      bAddedOrDeleted = true;
    }
  }

  m_bIsUpdating = false;
  if (bChanged)
  {
    Sort();
    SetChanged();
    lock.Leave();

    NotifyObservers("timers", false);

    g_PVRManager.UpdateWindow(PVR_WINDOW_TIMERS, bAddedOrDeleted);
    g_PVRManager.UpdateWindow(PVR_WINDOW_EPG, false);
    g_PVRManager.UpdateWindow(PVR_WINDOW_RECORDINGS, bAddedOrDeleted);
    g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_TV, false);
    g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_RADIO, false);
  }

  return bChanged;
}
Example #16
0
int CPVRTimers::Update()
{
  CSingleLock lock(m_critSection);

  CLog::Log(LOGDEBUG, "PVRTimers - %s - updating timers",
      __FUNCTION__);

  int iCurSize = size();

  /* clear channel timers */
  for (unsigned int iTimerPtr = 0; iTimerPtr < size(); iTimerPtr++)
  {
    CPVRTimerInfoTag *timerTag = &at(iTimerPtr);
    if (!timerTag || !timerTag->Active())
      continue;

    CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *)timerTag->EpgInfoTag();
    if (!epgTag)
      continue;

    epgTag->SetTimer(NULL);
  }

  /* clear timers */
  clear();

  /* get all timers from the clients */
  CLIENTMAP *clients = g_PVRManager.Clients();
  CLIENTMAPITR itr = clients->begin();
  while (itr != clients->end())
  {
    if (g_PVRManager.GetClientProps((*itr).second->GetID())->SupportTimers)
    {
      if ((*itr).second->GetNumTimers() > 0)
      {
        (*itr).second->GetAllTimers(this);
      }
    }
    itr++;
  }

  //XXX
  g_PVRManager.UpdateRecordingsCache();

  /* set channel timers */
  for (unsigned int ptr = 0; ptr < size(); ptr++)
  {
    /* get the timer tag */
    CPVRTimerInfoTag *timerTag = &at(ptr);
    if (!timerTag || !timerTag->Active())
      continue;

    /* try to get the channel */
    CPVRChannel *channel = CPVRChannels::GetByClientFromAll(timerTag->Number(), timerTag->ClientID());
    if (!channel)
      continue;

    /* try to get the EPG */
    CPVREpg *epg = channel->GetEPG();
    if (!epg)
      continue;

    /* try to set the timer on the epg tag that matches */
    CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) epg->InfoTagBetween(timerTag->Start(), timerTag->Stop());
    if (epgTag)
      epgTag->SetTimer(timerTag);
  }

  return size() - iCurSize;
}
Example #17
0
bool CPVRTimers::UpdateEntries(CPVRTimers *timers)
{
  bool bChanged(false);
  bool bAddedOrDeleted(false);

  CSingleLock lock(m_critSection);

  /* go through the timer list and check for updated or new timers */
  for (unsigned int iTimerPtr = 0; iTimerPtr < timers->size(); iTimerPtr++)
  {
    const CPVRTimerInfoTag *timer = timers->at(iTimerPtr);

    /* check if this timer is present in this container */
    CPVRTimerInfoTag *existingTimer = (CPVRTimerInfoTag *) GetByClient(timer->m_iClientId, timer->m_iClientIndex);
    if (existingTimer)
    {
      /* if it's present, update the current tag */
      bool bStateChanged(existingTimer->m_state != timer->m_state);
      if (existingTimer->UpdateEntry(*timer))
      {
        bChanged = true;

        if (bStateChanged && g_PVRManager.IsStarted())
          existingTimer->QueueNotification();

        CLog::Log(LOGINFO,"PVRTimers - %s - updated timer %d on client %d",
            __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);
      }
    }
    else
    {
      /* new timer */
      CPVRTimerInfoTag *newTimer = new CPVRTimerInfoTag;
      newTimer->UpdateEntry(*timer);
      push_back(newTimer);
      bChanged = true;
      bAddedOrDeleted = true;

      if (g_PVRManager.IsStarted())
        newTimer->QueueNotification();

      CLog::Log(LOGINFO,"PVRTimers - %s - added timer %d on client %d",
          __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);
    }
  }

  /* check for deleted timers */
  unsigned int iSize = size();
  for (unsigned int iTimerPtr = 0; iTimerPtr < iSize; iTimerPtr++)
  {
    CPVRTimerInfoTag *timer = (CPVRTimerInfoTag *) at(iTimerPtr);
    if (!timer)
      continue;
    if (timers->GetByClient(timer->m_iClientId, timer->m_iClientIndex) == NULL)
    {
      /* timer was not found */
      CLog::Log(LOGINFO,"PVRTimers - %s - deleted timer %d on client %d",
          __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);

      if (g_PVRManager.IsStarted() && g_guiSettings.GetBool("pvrrecord.timernotifications"))
      {
        CStdString strMessage;
        strMessage.Format("%s: '%s'", g_localizeStrings.Get(19228), timer->m_strTitle.c_str());
        g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(19166), strMessage);
      }

      CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) at(iTimerPtr)->m_epgInfo;
      if (epgTag)
        epgTag->SetTimer(NULL);

      delete at(iTimerPtr);
      erase(begin() + iTimerPtr);
      iTimerPtr--;
      iSize--;
      bChanged = true;
      bAddedOrDeleted = true;
    }
  }

  m_bIsUpdating = false;
  if (bChanged)
  {
    Sort();
    SetChanged();
    lock.Leave();

    NotifyObservers(bAddedOrDeleted ? "timers-reset" : "timers", false);
  }

  return bChanged;
}
Example #18
0
bool CPVRDatabase::UpdateEpgEntry(const CPVREpgInfoTag &tag, bool bSingleUpdate /* = true */, bool bLastUpdate /* = false */)
{
  int bReturn = false;

  /* invalid tag */
  if (tag.UniqueBroadcastID() <= 0)
  {
    CLog::Log(LOGERROR, "PVRDB - %s - invalid EPG tag", __FUNCTION__);
    return bReturn;
  }

  int iBroadcastId = tag.BroadcastId();
  if (iBroadcastId)
  {
    CStdString strWhereClause = FormatSQL("(BroadcastUid = '%u' OR StartTime = '%s') AND ChannelId = '%u'",
        tag.UniqueBroadcastID(), tag.Start().GetAsDBDateTime().c_str(), tag.ChannelTag()->ChannelID());
    CStdString strValue = GetSingleValue("EpgData", "BroadcastId", strWhereClause);

    if (!strValue.IsEmpty())
      iBroadcastId = atoi(strValue);
  }

  CStdString strQuery;

  if (iBroadcastId < 0)
  {
    strQuery = FormatSQL("INSERT INTO EpgData (ChannelId, StartTime, "
        "EndTime, Title, PlotOutline, Plot, GenreType, GenreSubType, Genre, "
        "FirstAired, ParentalRating, StarRating, Notify, SeriesId, "
        "EpisodeId, EpisodePart, EpisodeName, BroadcastUid) "
        "VALUES (%i, '%s', '%s', '%s', '%s', '%s', %i, %i, '%s', '%s', %i, %i, %i, '%s', '%s', '%s', '%s', %i)\n",
        tag.ChannelTag()->ChannelID(), tag.Start().GetAsDBDateTime().c_str(), tag.End().GetAsDBDateTime().c_str(),
        tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), tag.Genre(),
        tag.FirstAired().GetAsDBDateTime().c_str(), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNum().c_str(), tag.EpisodeNum().c_str(), tag.EpisodePart().c_str(), tag.EpisodeName().c_str(),
        tag.UniqueBroadcastID());
  }
  else
  {
    strQuery = FormatSQL("REPLACE INTO EpgData (ChannelId, StartTime, "
        "EndTime, Title, PlotOutline, Plot, GenreType, GenreSubType, Genre, "
        "FirstAired, ParentalRating, StarRating, Notify, SeriesId, "
        "EpisodeId, EpisodePart, EpisodeName, BroadcastUid, BroadcastId) "
        "VALUES (%i, '%s', '%s', '%s', '%s', '%s', %i, %i, '%s', '%s', %i, %i, %i, '%s', '%s', '%s', '%s', %i, %i)\n",
        tag.ChannelTag()->ChannelID(), tag.Start().GetAsDBDateTime().c_str(), tag.End().GetAsDBDateTime().c_str(),
        tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), tag.Genre(),
        tag.FirstAired().GetAsDBDateTime().c_str(), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNum().c_str(), tag.EpisodeNum().c_str(), tag.EpisodePart().c_str(), tag.EpisodeName().c_str(),
        tag.UniqueBroadcastID(), iBroadcastId);
  }

  if (bSingleUpdate)
  {
    bReturn = ExecuteQuery(strQuery);
  }
  else
  {
    bReturn = QueueInsertQuery(strQuery);

    if (bLastUpdate)
      CommitInsertQueries();
  }

  if ((bSingleUpdate || bLastUpdate) && GetEpgDataEnd(tag.ChannelTag()->ChannelID()) > tag.End())
    EraseEpgForChannel(*tag.ChannelTag(), NULL, tag.End());

  return bReturn;
}
Example #19
0
void CPVREpgInfoTag::Update(const CPVREpgInfoTag &tag)
{
  SetBroadcastId(tag.BroadcastId());
  SetTitle(tag.Title());
  SetPlotOutline(tag.PlotOutline());
  SetPlot(tag.Plot());
  SetStart(tag.Start());
  SetEnd(tag.End());
  SetGenre(tag.GenreType(), tag.GenreSubType(), tag.Genre());
  SetFirstAired(tag.FirstAired());
  SetParentalRating(tag.ParentalRating());
  SetStarRating(tag.StarRating());
  SetNotify(tag.Notify());
  SetEpisodeNum(tag.EpisodeNum());
  SetEpisodePart(tag.EpisodePart());
  SetEpisodeName(tag.EpisodeName());
}