Ejemplo n.º 1
0
  CPVRTimerInfoTagPtr CPVRItem::GetTimerInfoTag() const
  {
    if (m_item->IsPVRTimer())
    {
      return m_item->GetPVRTimerInfoTag();
    }
    else if (m_item->IsEPG())
    {
      return m_item->GetEPGInfoTag()->Timer();
    }
    else if (m_item->IsPVRChannel())
    {
      CPVRTimerInfoTagPtr timer;
      const CEpgInfoTagPtr epgTag(m_item->GetPVRChannelInfoTag()->GetEPGNow());
      if (epgTag)
        timer = epgTag->Timer(); // cheap method, but not reliable as timers get set at epg tags asynchronously

      if (timer)
        return timer;

      return g_PVRTimers->GetActiveTimerForChannel(m_item->GetPVRChannelInfoTag()); // more expensive, but reliable and works even for channels with no epg data
    }
    else
    {
      CLog::Log(LOGERROR, "CPVRItem - %s - unsupported item type!", __FUNCTION__);
    }
    return CPVRTimerInfoTagPtr();
  }
Ejemplo n.º 2
0
JSONRPC_STATUS CPVROperations::ToggleTimer(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  if (!g_PVRManager.IsStarted())
    return FailedToExecute;

  const CEpgInfoTagPtr epgTag = g_EpgContainer.GetTagById(CPVRChannelPtr(), parameterObject["broadcastid"].asUnsignedInteger());

  if (!epgTag)
    return InvalidParams;

  bool timerrule = parameterObject["timerrule"].asBoolean(false);
  bool sentOkay = false;
  CPVRTimerInfoTagPtr timer(epgTag->Timer());
  if (timer)
  {
    if (timerrule)
      timer = g_PVRTimers->GetTimerRule(timer);

    if (timer)
      sentOkay = g_PVRTimers->DeleteTimer(timer, timer->IsRecording(), false);
  }
  else
  {
    timer = CPVRTimerInfoTag::CreateFromEpg(epgTag, timerrule);
    if (!timer)
      return InvalidParams;

    sentOkay = g_PVRTimers->AddTimer(timer);
  }

  if (sentOkay)
    return ACK;

  return FailedToExecute;
}
Ejemplo n.º 3
0
bool CGUIWindowPVRBase::AddTimer(CFileItem *item, bool bCreateRule, bool bShowTimerSettings)
{
  CEpgInfoTagPtr epgTag;
  CPVRChannelPtr channel;

  if (item->IsEPG())
  {
    epgTag  = item->GetEPGInfoTag();
    channel = epgTag->ChannelTag();
  }
  else if (item->IsPVRChannel())
  {
    channel = item->GetPVRChannelInfoTag();
    epgTag  = channel->GetEPGNow();
  }

  if (!channel)
  {
    CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no channel!", __FUNCTION__);
    return false;
  }

  if (!g_PVRManager.CheckParentalLock(channel))
    return false;

  if (!epgTag && bCreateRule)
  {
    CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no epg tag!", __FUNCTION__);
    return false;
  }

  CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : epgTag->Timer());
  CPVRTimerInfoTagPtr rule (bCreateRule ? g_PVRTimers->GetTimerRule(timer) : nullptr);
  if (timer || rule)
  {
    CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19034}); // "Information", "There is already a timer set for this event"
    return false;
  }

  CPVRTimerInfoTagPtr newTimer(epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule) : CPVRTimerInfoTag::CreateInstantTimerTag(channel));
  if (!newTimer)
  {
    CGUIDialogOK::ShowAndGetInput(CVariant{19033},
                                  bCreateRule
                                    ? CVariant{19095} // "Information", "Timer rule creation failed. The PVR add-on does not support a suitable timer rule type."
                                    : CVariant{19094}); // "Information", "Timer creation failed. The PVR add-on does not support a suitable timer type."
    return false;
  }

  if (bShowTimerSettings)
  {
    if (!ShowTimerSettings(newTimer))
      return false;
  }

  return g_PVRTimers->AddTimer(newTimer);
}
bool CGUIWindowPVRBase::DeleteTimer(CFileItem *item, bool bIsRecording, bool bDeleteRule)
{
  CPVRTimerInfoTagPtr timer;

  if (item->IsPVRTimer())
  {
    timer = item->GetPVRTimerInfoTag();
  }
  else if (item->IsEPG())
  {
    timer = item->GetEPGInfoTag()->Timer();
  }
  else if (item->IsPVRChannel())
  {
    const CEpgInfoTagPtr epgTag(item->GetPVRChannelInfoTag()->GetEPGNow());
    if (epgTag)
      timer = epgTag->Timer(); // cheap method, but not reliable as timers get set at epg tags asychrounously

    if (!timer)
      timer = g_PVRTimers->GetActiveTimerForChannel(item->GetPVRChannelInfoTag()); // more expensive, but reliable and works even for channels with no epg data
  }

  if (!timer)
  {
    CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no timer!", __FUNCTION__);
    return false;
  }

  if (bDeleteRule && !timer->IsRepeating())
    timer = g_PVRTimers->GetTimerRule(timer);

  if (!timer)
  {
    CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no timer rule!", __FUNCTION__);
    return false;
  }

  if (bIsRecording)
  {
    if (ConfirmStopRecording(timer))
      return g_PVRTimers->DeleteTimer(timer, true, false);
  }
  else if (timer->HasTimerType() && timer->GetTimerType()->IsReadOnly())
  {
    return false;
  }
  else
  {
    bool bAlsoDeleteRule(false);
    if (ConfirmDeleteTimer(timer, bAlsoDeleteRule))
      return g_PVRTimers->DeleteTimer(timer, false, bAlsoDeleteRule);
  }
  return false;
}
Ejemplo n.º 5
0
void CGUIDialogPVRGuideInfo::OnInitWindow()
{
  CGUIDialog::OnInitWindow();

  const CEpgInfoTagPtr tag(m_progItem->GetEPGInfoTag());
  if (!tag)
  {
    /* no epg event selected */
    return;
  }

  if (!tag->HasRecording())
  {
    /* not recording. hide the play recording button */
    SET_CONTROL_HIDDEN(CONTROL_BTN_PLAY_RECORDING);
  }

  bool bHideRecord(true);
  if (tag->HasTimer())
  {
    if (tag->Timer()->IsRecording())
    {
      SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19059); /* Stop recording */
      bHideRecord = false;
    }
    else if (tag->Timer()->HasTimerType() && !tag->Timer()->GetTimerType()->IsReadOnly())
    {
      SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 19060); /* Delete timer */
      bHideRecord = false;
    }
  }
  else if (tag->EndAsLocalTime() > CDateTime::GetCurrentDateTime())
  {
    SET_CONTROL_LABEL(CONTROL_BTN_RECORD, 264);     /* Record */
    bHideRecord = false;
  }

  if (bHideRecord)
    SET_CONTROL_HIDDEN(CONTROL_BTN_RECORD);
}
Ejemplo n.º 6
0
  bool CPVRGUIActions::AddTimer(const CFileItemPtr &item, bool bCreateRule, bool bShowTimerSettings) const
  {
    const CPVRChannelPtr channel(CPVRItem(item).GetChannel());
    if (!channel)
    {
      CLog::Log(LOGERROR, "CPVRGUIActions - %s - no channel!", __FUNCTION__);
      return false;
    }

    if (!g_PVRManager.CheckParentalLock(channel))
      return false;

    const CEpgInfoTagPtr epgTag(CPVRItem(item).GetEpgInfoTag());
    if (!epgTag && bCreateRule)
    {
      CLog::Log(LOGERROR, "CPVRGUIActions - %s - no epg tag!", __FUNCTION__);
      return false;
    }

    CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : epgTag->Timer());
    CPVRTimerInfoTagPtr rule (bCreateRule ? g_PVRTimers->GetTimerRule(timer) : nullptr);
    if (timer || rule)
    {
      CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19034}); // "Information", "There is already a timer set for this event"
      return false;
    }

    CPVRTimerInfoTagPtr newTimer(epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule) : CPVRTimerInfoTag::CreateInstantTimerTag(channel));
    if (!newTimer)
    {
      CGUIDialogOK::ShowAndGetInput(CVariant{19033},
                                    bCreateRule
                                      ? CVariant{19095} // "Information", "Timer rule creation failed. The PVR add-on does not support a suitable timer rule type."
                                      : CVariant{19094}); // "Information", "Timer creation failed. The PVR add-on does not support a suitable timer type."
      return false;
    }

    if (bShowTimerSettings)
    {
      if (!ShowTimerSettings(newTimer))
        return false;
    }

    return g_PVRTimers->AddTimer(newTimer);
  }
Ejemplo n.º 7
0
CPVRTimerInfoTagPtr CPVRTimers::GetTimerForEpgTag(const CEpgInfoTagPtr &epgTag) const
{
  if (epgTag)
  {
    // already a timer assigned to tag?
    CPVRTimerInfoTagPtr timer(epgTag->Timer());
    if (timer)
      return timer;

    // try to find a matching timer for the tag.
    if (epgTag->ChannelTag())
    {
      const CPVRChannelPtr channel(epgTag->ChannelTag());
      CSingleLock lock(m_critSection);

      for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it)
      {
        for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt)
        {
          timer = *timerIt;

          if (!timer->IsRepeating() &&
              (timer->GetEpgInfoTag(false) == epgTag ||
               (timer->m_iEpgUid != EPG_TAG_INVALID_UID && timer->m_iEpgUid == epgTag->UniqueBroadcastID()) ||
               (timer->m_iClientChannelUid == channel->UniqueID() &&
                timer->m_bIsRadio == channel->IsRadio() &&
                timer->StartAsUTC() <= epgTag->StartAsUTC() &&
                timer->EndAsUTC() >= epgTag->EndAsUTC())))
          {
            return timer;
          }
        }
      }
    }
  }

  return CPVRTimerInfoTagPtr();
}