Пример #1
0
CPVRTimerInfoTag *CPVRTimers::InstantTimer(CPVRChannel *channel, bool bStartTimer /* = true */)
{
  if (!channel)
  {
    if (!g_PVRManager.GetCurrentChannel(channel))
      channel = (CPVRChannel *) g_PVRChannelGroups->GetGroupAllTV()->GetFirstChannel();

    /* no channels present */
    if (!channel)
      return NULL;
  }

  const CPVREpgInfoTag *epgTag = channel->GetEPGNow();
  int iMarginEnd = g_guiSettings.GetInt("pvrrecord.marginend");
  int iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority");
  int iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime");
  int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime");

  CPVRTimerInfoTag *newTimer = epgTag ? CPVRTimerInfoTag::CreateFromEpg(*epgTag) : NULL;
  if (!newTimer)
  {
    newTimer = new CPVRTimerInfoTag;
    /* set the timer data */
    newTimer->m_iClientIndex      = -1;
    newTimer->m_bIsActive         = true;
    newTimer->m_strTitle          = channel->ChannelName();
    newTimer->m_strSummary        = g_localizeStrings.Get(19056);
    newTimer->m_iMarginEnd        = iMarginEnd ? iMarginEnd : 5; /* use 5 minutes as default */
    newTimer->m_iChannelNumber    = channel->ChannelNumber();
    newTimer->m_iClientChannelUid = channel->UniqueID();
    newTimer->m_iClientId         = channel->ClientID();
    newTimer->m_bIsRadio          = channel->IsRadio();
    newTimer->m_iPriority         = iPriority ? iPriority : 50;  /* default to 50 */
    newTimer->m_iLifetime         = iLifetime ? iLifetime : 30;  /* default to 30 days */

    /* generate summary string */
    newTimer->m_strSummary.Format("%s %s %s %s %s",
        newTimer->StartAsLocalTime().GetAsLocalizedDate(),
        g_localizeStrings.Get(19159),
        newTimer->StartAsLocalTime().GetAsLocalizedTime("", false),
        g_localizeStrings.Get(19160),
        newTimer->EndAsLocalTime().GetAsLocalizedTime("", false));
  }

  newTimer->m_iMarginStart = 0;
  newTimer->SetDuration(iDuration ? iDuration : 120); /* use 120 minutes as default */

  /* unused only for reference */
  newTimer->m_strFileNameAndPath = "pvr://timers/new";

  if (bStartTimer && !newTimer->AddToClient())
  {
    CLog::Log(LOGERROR, "PVRTimers - %s - unable to add an instant timer on the client", __FUNCTION__);
    delete newTimer;
    newTimer = NULL;
  }

  return newTimer;
}
Пример #2
0
CPVRTimerInfoTag *CPVRTimerInfoTag::InstantTimer()
{
  /* create a new timer */
  CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag();
  if (!newTag)
  {
    CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__);
    return NULL;
  }

  CFileItem *curPlayingChannel = g_PVRManager.GetCurrentPlayingItem();
  CPVRChannel *channel = (curPlayingChannel) ? curPlayingChannel->GetPVRChannelInfoTag(): NULL;
  if (!channel)
  {
    CLog::Log(LOGDEBUG, "%s - couldn't find current playing channel", __FUNCTION__);
    channel = PVRChannelsTV.GetByChannelNumber(1);

    if (!channel)
    {
      CLog::Log(LOGERROR, "%s - cannot find any channels",
          __FUNCTION__);
    }
  }

  int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime");
  if (!iDuration)
    iDuration   = 180; /* default to 180 minutes */

  int iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority");
  if (!iPriority)
    iPriority   = 50;  /* default to 50 */

  int iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime");
  if (!iLifetime)
    iLifetime   = 30;  /* default to 30 days */

  /* set the timer data */
  newTag->m_iClientIndex   = -1;
  newTag->m_bIsActive      = true;
  newTag->m_strTitle       = g_localizeStrings.Get(19056);
  newTag->m_iChannelNumber = channel->ChannelNumber();
  newTag->m_iClientNumber  = channel->ClientChannelNumber();
  newTag->m_iClientID      = channel->ClientID();
  newTag->m_bIsRadio       = channel->IsRadio();
  newTag->m_StartTime      = CDateTime::GetCurrentDateTime();
  newTag->SetDuration(iDuration);
  newTag->m_iPriority      = iPriority;
  newTag->m_iLifetime      = iLifetime;

  /* generate summary string */
  newTag->m_strSummary.Format("%s %s %s %s %s",
      newTag->m_StartTime.GetAsLocalizedDate(),
      g_localizeStrings.Get(19159),
      newTag->m_StartTime.GetAsLocalizedTime("", false),
      g_localizeStrings.Get(19160),
      newTag->m_StopTime.GetAsLocalizedTime("", false));

  /* unused only for reference */
  newTag->m_strFileNameAndPath = "pvr://timers/new";

  return newTag;
}