예제 #1
0
파일: PVRGUIInfo.cpp 프로젝트: Kr0nZ/xbmc
void CPVRGUIInfo::UpdateNextTimer(void)
{
  CStdString strNextRecordingTitle;
  CStdString strNextRecordingChannelName;
  CStdString strNextRecordingChannelIcon;
  CStdString strNextRecordingTime;
  CStdString strNextTimerInfo;

  CPVRTimerInfoTag tag;
  if (g_PVRTimers->GetNextActiveTimer(&tag))
  {
    strNextRecordingTitle.Format("%s",       tag.m_strTitle);
    strNextRecordingChannelName.Format("%s", tag.ChannelName());
    strNextRecordingChannelIcon.Format("%s", tag.ChannelIcon());
    strNextRecordingTime.Format("%s",        tag.StartAsLocalTime().GetAsLocalizedDateTime(false, false));

    strNextTimerInfo.Format("%s %s %s %s",
        g_localizeStrings.Get(19106),
        tag.StartAsLocalTime().GetAsLocalizedDate(true),
        g_localizeStrings.Get(19107),
        tag.StartAsLocalTime().GetAsLocalizedTime("HH:mm", false));
  }

  CSingleLock lock(m_critSection);
  m_strNextRecordingTitle       = strNextRecordingTitle;
  m_strNextRecordingChannelName = strNextRecordingChannelName;
  m_strNextRecordingChannelIcon = strNextRecordingChannelIcon;
  m_strNextRecordingTime        = strNextRecordingTime;
  m_strNextTimerInfo            = strNextTimerInfo;
}
예제 #2
0
파일: PVRGUIInfo.cpp 프로젝트: A600/xbmc
void CPVRGUIInfo::UpdateNextTimer(void)
{
  CStdString strNextRecordingTitle;
  CStdString strNextRecordingChannelName;
  CStdString strNextRecordingChannelIcon;
  CStdString strNextRecordingTime;
  CStdString strNextTimerInfo;

  CFileItemPtr tag = g_PVRTimers->GetNextActiveTimer();
  if (tag && tag->HasPVRTimerInfoTag())
  {
    CPVRTimerInfoTag *timer = tag->GetPVRTimerInfoTag();
    strNextRecordingTitle.Format("%s",       timer->Title());
    strNextRecordingChannelName.Format("%s", timer->ChannelName());
    strNextRecordingChannelIcon.Format("%s", timer->ChannelIcon());
    strNextRecordingTime.Format("%s",        timer->StartAsLocalTime().GetAsLocalizedDateTime(false, false));

    strNextTimerInfo.Format("%s %s %s %s",
        g_localizeStrings.Get(19106),
        timer->StartAsLocalTime().GetAsLocalizedDate(true),
        g_localizeStrings.Get(19107),
        timer->StartAsLocalTime().GetAsLocalizedTime("HH:mm", false));
  }

  CSingleLock lock(m_critSection);
  m_strNextRecordingTitle       = strNextRecordingTitle;
  m_strNextRecordingChannelName = strNextRecordingChannelName;
  m_strNextRecordingChannelIcon = strNextRecordingChannelIcon;
  m_strNextRecordingTime        = strNextRecordingTime;
  m_strNextTimerInfo            = strNextTimerInfo;
}
예제 #3
0
CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag)
{
  /* create a new timer */
  CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag();
  if (!newTag)
  {
    CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__);
    return NULL;
  }

  /* check if a valid channel is set */
  CPVRChannel *channel = (CPVRChannel *) tag.ChannelTag();
  if (channel == NULL)
  {
    CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__);
    return NULL;
  }

  /* check if the epg end date is in the future */
  if (tag.EndAsLocalTime() < CDateTime::GetCurrentDateTime())
  {
    CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__);
    return NULL;
  }

  /* set the timer data */
  CDateTime newStart = tag.StartAsUTC();
  CDateTime newEnd = tag.EndAsUTC();
  newTag->m_iClientIndex      = -1;
  newTag->m_strTitle          = tag.Title().IsEmpty() ? channel->ChannelName() : tag.Title();
  newTag->m_iChannelNumber    = channel->ChannelNumber();
  newTag->m_iClientChannelUid = channel->UniqueID();
  newTag->m_iClientId         = channel->ClientID();
  newTag->m_bIsRadio          = channel->IsRadio();
  newTag->SetStartFromUTC(newStart);
  newTag->SetEndFromUTC(newEnd);

  if (tag.Plot().IsEmpty())
  {
    newTag->m_strSummary.Format("%s %s %s %s %s",
        newTag->StartAsLocalTime().GetAsLocalizedDate(),
        g_localizeStrings.Get(19159),
        newTag->StartAsLocalTime().GetAsLocalizedTime("", false),
        g_localizeStrings.Get(19160),
        newTag->EndAsLocalTime().GetAsLocalizedTime("", false));
  }
  else
  {
    newTag->m_strSummary = tag.Plot();
  }

  /* we might have a copy of the tag here, so get the real one from the pvrmanager */
  const CEpg *epgTable = channel->GetEPG();
  newTag->m_epgInfo = epgTable ? epgTable->GetTag(tag.UniqueBroadcastID(), tag.StartAsUTC()) : NULL;

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

  return newTag;
}
예제 #4
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;
}
예제 #5
0
CPVRTimerInfoTag *CPVRTimers::InstantTimer(const CPVRChannel &channel, bool bStartTimer /* = true */)
{
  if (!g_PVRManager.CheckParentalLock(channel))
    return NULL;

  CEpgInfoTag epgTag;
  bool bHasEpgNow = channel.GetEPGNow(epgTag);
  CPVRTimerInfoTag *newTimer = bHasEpgNow ? CPVRTimerInfoTag::CreateFromEpg(epgTag) : NULL;
  if (!newTimer)
  {
    newTimer = new CPVRTimerInfoTag;
    /* set the timer data */
    newTimer->m_iClientIndex      = -1;
    newTimer->m_strTitle          = channel.ChannelName();
    newTimer->m_strSummary        = g_localizeStrings.Get(19056);
    newTimer->m_iChannelNumber    = channel.ChannelNumber();
    newTimer->m_iClientChannelUid = channel.UniqueID();
    newTimer->m_iClientId         = channel.ClientID();
    newTimer->m_bIsRadio          = channel.IsRadio();

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

  CDateTime startTime(0);
  newTimer->SetStartFromUTC(startTime);
  newTimer->m_iMarginStart = 0; /* set the start margin to 0 for instant timers */

  int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime");
  CDateTime endTime = CDateTime::GetUTCDateTime() + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0);
  newTimer->SetEndFromUTC(endTime);

  /* 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;
}
예제 #6
0
파일: PVRGUIInfo.cpp 프로젝트: A600/xbmc
void CPVRGUIInfo::UpdateTimersToggle(void)
{
  if (!TimerInfoToggle())
    return;

  CStdString strActiveTimerTitle;
  CStdString strActiveTimerChannelName;
  CStdString strActiveTimerChannelIcon;
  CStdString strActiveTimerTime;

  /* safe to fetch these unlocked, since they're updated from the same thread as this one */
  if (m_iRecordingTimerAmount > 0)
  {
    vector<CFileItemPtr> activeTags = g_PVRTimers->GetActiveRecordings();
    if (m_iTimerInfoToggleCurrent < activeTags.size() && activeTags.at(m_iTimerInfoToggleCurrent)->HasPVRTimerInfoTag())
    {
      CPVRTimerInfoTag *tag = activeTags.at(m_iTimerInfoToggleCurrent)->GetPVRTimerInfoTag();
      strActiveTimerTitle.Format("%s",       tag->Title());
      strActiveTimerChannelName.Format("%s", tag->ChannelName());
      strActiveTimerChannelIcon.Format("%s", tag->ChannelIcon());
      strActiveTimerTime.Format("%s",        tag->StartAsLocalTime().GetAsLocalizedDateTime(false, false));
    }
  }

  CSingleLock lock(m_critSection);
  m_strActiveTimerTitle         = strActiveTimerTitle;
  m_strActiveTimerChannelName   = strActiveTimerChannelName;
  m_strActiveTimerChannelIcon   = strActiveTimerChannelIcon;
  m_strActiveTimerTime          = strActiveTimerTime;
}
예제 #7
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;
}
예제 #8
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;
}
예제 #9
0
void CPVRGUIInfo::UpdateTimersToggle(void)
{
  CSingleLock lock(m_critSection);

  if (!TimerInfoToggle())
    return;

  m_strActiveTimerTitle         = "";
  m_strActiveTimerChannelName   = "";
  m_strActiveTimerChannelIcon   = "";
  m_strActiveTimerTime          = "";

  unsigned int iBoundary = m_iRecordingTimerAmount > 0 ? m_iRecordingTimerAmount : m_iTimerAmount;
  if (m_iTimerInfoToggleCurrent < iBoundary)
  {
    CPVRTimerInfoTag tag;
    if (g_PVRTimers->GetTimerByIndex(m_iTimerInfoToggleCurrent, &tag))
    {
      m_strActiveTimerTitle.Format("%s",       tag.m_strTitle);
      m_strActiveTimerChannelName.Format("%s", tag.ChannelName());
      m_strActiveTimerChannelIcon.Format("%s", tag.ChannelIcon());
      m_strActiveTimerTime.Format("%s",        tag.StartAsLocalTime().GetAsLocalizedDateTime(false, false));
    }
  }
}
예제 #10
0
void CGUIDialogPVRTimerSettings::OnSettingAction(const CSetting *setting)
{
  if (setting == NULL)
    return;

  CGUIDialogSettingsManualBase::OnSettingAction(setting);

  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();
  if (tag == NULL)
    return;

  const std::string &settingId = setting->GetId();
  if (settingId == SETTING_TMR_BEGIN)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(m_timerStartTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestart = m_timerStartTime;
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestart.GetHour();
      int start_minute    = timestart.GetMinute();
      CDateTime newStart(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetStartFromLocalTime(newStart);

      m_timerStartTimeStr = tag->StartAsLocalTime().GetAsLocalizedTime("", false);
      setButtonLabels();
    }
  }
  else if (settingId == SETTING_TMR_END)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(m_timerEndTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestop = m_timerEndTime;
      // TODO: add separate end date control to schedule a show with more then 24 hours
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestop.GetHour();
      int start_minute    = timestop.GetMinute();
      CDateTime newEnd(start_year, start_month, start_day, start_hour, start_minute, 0);
      
      // add a day to end time if end time is before start time
      // TODO: this should be removed after separate end date control was added
      if (newEnd < tag->StartAsLocalTime())
        newEnd += CDateTimeSpan(1, 0, 0, 0);

      tag->SetEndFromLocalTime(newEnd);

      m_timerEndTimeStr = tag->EndAsLocalTime().GetAsLocalizedTime("", false);
      setButtonLabels();
    }
  }

  tag->UpdateSummary();
}
예제 #11
0
CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag)
{
  /* create a new timer */
  CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag();
  if (!newTag)
  {
    CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__);
    return NULL;
  }

  /* check if a valid channel is set */
  CPVRChannelPtr channel = tag.ChannelTag();
  if (!channel)
  {
    CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__);
    delete newTag;
    return NULL;
  }

  /* check if the epg end date is in the future */
  if (tag.EndAsLocalTime() < CDateTime::GetCurrentDateTime())
  {
    CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__);
    delete newTag;
    return NULL;
  }

  /* set the timer data */
  CDateTime newStart = tag.StartAsUTC();
  CDateTime newEnd = tag.EndAsUTC();
  newTag->m_iClientIndex      = -1;
  newTag->m_strTitle          = tag.Title().empty() ? channel->ChannelName() : tag.Title();
  newTag->m_iChannelNumber    = channel->ChannelNumber();
  newTag->m_iClientChannelUid = channel->UniqueID();
  newTag->m_iClientId         = channel->ClientID();
  newTag->m_bIsRadio          = channel->IsRadio();
  newTag->m_iGenreType        = tag.GenreType();
  newTag->m_iGenreSubType     = tag.GenreSubType();
  newTag->m_channel           = channel;
  newTag->SetStartFromUTC(newStart);
  newTag->SetEndFromUTC(newEnd);

  if (tag.Plot().empty())
  {
    newTag->m_strSummary= StringUtils::Format("%s %s %s %s %s",
                                              newTag->StartAsLocalTime().GetAsLocalizedDate().c_str(),
                                              g_localizeStrings.Get(19159).c_str(),
                                              newTag->StartAsLocalTime().GetAsLocalizedTime("", false).c_str(),
                                              g_localizeStrings.Get(19160).c_str(),
                                              newTag->EndAsLocalTime().GetAsLocalizedTime("", false).c_str());
  }
  else
  {
    newTag->m_strSummary = tag.Plot();
  }

  newTag->m_epgTag = g_EpgContainer.GetById(tag.EpgID())->GetTag(tag.StartAsUTC());

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

  return newTag;
}
예제 #12
0
void CGUIDialogPVRTimerSettings::InitializeSettings()
{
  CGUIDialogSettingsManualBase::InitializeSettings();

  CSettingCategory *category = AddCategory("pvrtimersettings", -1);
  if (category == NULL)
  {
    CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings: unable to setup settings");
    return;
  }

  CSettingGroup *group = AddGroup(category);
  if (group == NULL)
  {
    CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings: unable to setup settings");
    return;
  }

  // add a condition
  m_settingsManager->AddCondition("IsTimerDayRepeating", IsTimerDayRepeating);

  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();

  m_selectedChannelEntry = 0;
  m_channelEntries.clear();
  m_bTimerActive = tag->IsActive();

  AddToggle(group, SETTING_TMR_ACTIVE, 19074, 0, m_bTimerActive);
  AddEdit(group, SETTING_TMR_NAME, 19075, 0, tag->m_strTitle, false, false, 19097);

  if (tag->SupportsFolders())
    AddEdit(group, SETTING_TMR_DIR, 19076, 0, tag->m_strDirectory, true, false, 19104);

  AddToggle(group, SETTING_TMR_RADIO, 19077, 0, tag->m_bIsRadio);

  /// Channel names
  {
    // For TV
    AddChannelNames(group, false);

    // For Radio
    AddChannelNames(group, true);
  }

  /// Day
  {
    // get diffence of timer in days between today and timer start date
    tm time_cur; CDateTime::GetCurrentDateTime().GetAsTm(time_cur);
    tm time_tmr; tag->StartAsLocalTime().GetAsTm(time_tmr);

    m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday;
    if (time_tmr.tm_yday - time_cur.tm_yday < 0)
      m_tmp_day += 365;

    SetWeekdaySettingFromTimer(*tag);

    AddSpinner(group, SETTING_TMR_DAY, 19079, 0, m_tmp_day, DaysOptionsFiller);
  }

  AddButton(group, SETTING_TMR_BEGIN, 19080, 0);
  AddButton(group, SETTING_TMR_END, 19081, 0);
  AddSpinner(group, SETTING_TMR_PRIORITY, 19082, 0, tag->m_iPriority, 0, 1, 99);
  AddSpinner(group, SETTING_TMR_LIFETIME, 19083, 0, tag->m_iLifetime, 0, 1, 365);

  /// First day
  {
    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = tag->FirstDayAsLocalTime();

    // get diffence of timer in days between today and timer start date
    if (time < timestart)
    {
      tm time_cur; time.GetAsTm(time_cur);
      tm time_tmr; timestart.GetAsTm(time_tmr);

      m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1;
      if (time_tmr.tm_yday - time_cur.tm_yday < 0)
        m_tmp_iFirstDay += 365;
    }

    CSettingInt *settingFirstDay = AddSpinner(group, SETTING_TMR_FIRST_DAY, 19084, 0, m_tmp_iFirstDay, DaysOptionsFiller);

    // define an enable dependency with m_tmp_day <= 10
    CSettingDependency depdendencyFirstDay(SettingDependencyTypeEnable, m_settingsManager);
    depdendencyFirstDay.And()
      ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition("IsTimerDayRepeating", "true", SETTING_TMR_DAY, false, m_settingsManager)));
    SettingDependencies deps;
    deps.push_back(depdendencyFirstDay);
    settingFirstDay->SetDependencies(deps);
  }
}
예제 #13
0
void CGUIDialogPVRTimerSettings::OnSettingChanged(SettingInfo &setting)
{
  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();

  if (setting.id == CONTROL_TMR_NAME)
  {
    if (CGUIKeyboardFactory::ShowAndGetInput(tag->m_strTitle, g_localizeStrings.Get(19097), false))
    {
      UpdateSetting(CONTROL_TMR_NAME);
    }
  }
  if (setting.id == CONTROL_TMR_DIR && CGUIKeyboardFactory::ShowAndGetInput(tag->m_strDirectory, g_localizeStrings.Get(19104), false))
      UpdateSetting(CONTROL_TMR_DIR);
  else if (setting.id == CONTROL_TMR_RADIO || setting.id == CONTROL_TMR_CHNAME_TV || setting.id == CONTROL_TMR_CHNAME_RADIO)
  {
    if (setting.id == CONTROL_TMR_RADIO)
    {
      EnableSettings(CONTROL_TMR_CHNAME_TV, !tag->m_bIsRadio);
      EnableSettings(CONTROL_TMR_CHNAME_RADIO, tag->m_bIsRadio);
    }

    CFileItemPtr channel = g_PVRChannelGroups->GetGroupAll(tag->m_bIsRadio)->GetByChannelNumber(tag->m_iChannelNumber);
    if (channel && channel->HasPVRChannelInfoTag())
    {
      tag->m_iClientChannelUid = channel->GetPVRChannelInfoTag()->UniqueID();
      tag->m_iClientId         = channel->GetPVRChannelInfoTag()->ClientID();
      tag->m_bIsRadio          = channel->GetPVRChannelInfoTag()->IsRadio();
      tag->m_iChannelNumber    = channel->GetPVRChannelInfoTag()->ChannelNumber();
    }
  }
  else if (setting.id == CONTROL_TMR_DAY && m_tmp_day > 10)
  {
    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = timerStartTime;
    CDateTime timestop = timerEndTime;
    int m_tmp_diff;
    tm time_cur;
    tm time_tmr;

    /* get diffence of timer in days between today and timer start date */
    time.GetAsTm(time_cur);
    timestart.GetAsTm(time_tmr);

    m_tmp_diff = time_tmr.tm_yday - time_cur.tm_yday;
    if (time_tmr.tm_yday - time_cur.tm_yday < 0)
      m_tmp_diff = 365;

    CDateTime newStart = timestart + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
    CDateTime newEnd = timestop  + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
    tag->SetStartFromLocalTime(newStart);
    tag->SetEndFromLocalTime(newEnd);

    EnableSettings(CONTROL_TMR_FIRST_DAY, false);

    tag->m_bIsRepeating = false;
    tag->m_iWeekdays = 0;
  }
  else if (setting.id == CONTROL_TMR_DAY && m_tmp_day <= 10)
  {
    EnableSettings(CONTROL_TMR_FIRST_DAY, true);
    SetTimerFromWeekdaySetting(*tag);
  }
  else if (setting.id == CONTROL_TMR_BEGIN)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(timerStartTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestart = timerStartTime;
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestart.GetHour();
      int start_minute    = timestart.GetMinute();
      CDateTime newStart(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetStartFromLocalTime(newStart);

      timerStartTimeStr = tag->StartAsLocalTime().GetAsLocalizedTime("", false);
      UpdateSetting(CONTROL_TMR_BEGIN);
    }
  }
  else if (setting.id == CONTROL_TMR_END)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(timerEndTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestop = timerEndTime;
      int start_day       = tag->EndAsLocalTime().GetDay();
      int start_month     = tag->EndAsLocalTime().GetMonth();
      int start_year      = tag->EndAsLocalTime().GetYear();
      int start_hour      = timestop.GetHour();
      int start_minute    = timestop.GetMinute();
      CDateTime newEnd(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetEndFromLocalTime(newEnd);

      timerEndTimeStr = tag->EndAsLocalTime().GetAsLocalizedTime("", false);
      UpdateSetting(CONTROL_TMR_END);
    }
  }
  else if (setting.id == CONTROL_TMR_FIRST_DAY && m_tmp_day <= 10)
  {
    CDateTime newFirstDay;
    if (m_tmp_iFirstDay > 0)
      newFirstDay = CDateTime::GetCurrentDateTime() + CDateTimeSpan(m_tmp_iFirstDay-1, 0, 0, 0);

    tag->SetFirstDayFromLocalTime(newFirstDay);
  }

  tag->UpdateSummary();
}
예제 #14
0
void CGUIDialogPVRTimerSettings::CreateSettings()
{
  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();

  // clear out any old settings
  m_settings.clear();

  // create our settings controls
  m_bTimerActive = tag->IsActive();
  AddBool(CONTROL_TMR_ACTIVE, 19074, &m_bTimerActive);
  AddButton(CONTROL_TMR_NAME, 19075, &tag->m_strTitle, true);

  if (tag->SupportsFolders())
    AddButton(CONTROL_TMR_DIR, 19076, &tag->m_strDirectory, true);

  AddBool(CONTROL_TMR_RADIO, 19077, &tag->m_bIsRadio);

  /// Channel names
  {
    // For TV
    CFileItemList channelslist_tv;
    SETTINGSTRINGS channelstrings_tv;
    AddChannelNames(channelslist_tv, channelstrings_tv, false);

    // For Radio
    CFileItemList channelslist_radio;
    SETTINGSTRINGS channelstrings_radio;
    AddChannelNames(channelslist_radio, channelstrings_radio, true);
  }

  /// Day
  {
    SETTINGSTRINGS daystrings;
    tm time_cur;
    tm time_tmr;

    for (unsigned int iDayPtr = 19086; iDayPtr <= 19096; iDayPtr++)
      daystrings.push_back(g_localizeStrings.Get(iDayPtr));
    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = tag->StartAsLocalTime();

    /* get diffence of timer in days between today and timer start date */
    time.GetAsTm(time_cur);
    timestart.GetAsTm(time_tmr);

    m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday;
    if (time_tmr.tm_yday - time_cur.tm_yday < 0)
      m_tmp_day += 365;

    for (int i = 1; i < 365; ++i)
    {
      CStdString string = time.GetAsLocalizedDate();
      daystrings.push_back(string);
      time += CDateTimeSpan(1, 0, 0, 0);
    }

    SetWeekdaySettingFromTimer(*tag);

    AddSpin(CONTROL_TMR_DAY, 19079, &m_tmp_day, daystrings.size(), daystrings);
  }

  AddButton(CONTROL_TMR_BEGIN, 19080, &timerStartTimeStr, true);
  AddButton(CONTROL_TMR_END, 19081, &timerEndTimeStr, true);
  AddSpin(CONTROL_TMR_PRIORITY, 19082, &tag->m_iPriority, 0, 99);
  AddSpin(CONTROL_TMR_LIFETIME, 19083, &tag->m_iLifetime, 0, 365);

  /// First day
  {
    SETTINGSTRINGS daystrings;
    tm time_cur;
    tm time_tmr;

    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = tag->FirstDayAsLocalTime();

    /* get diffence of timer in days between today and timer start date */
    if (time < timestart)
    {
      time.GetAsTm(time_cur);
      timestart.GetAsTm(time_tmr);

      m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1;
      if (time_tmr.tm_yday - time_cur.tm_yday < 0)
        m_tmp_iFirstDay += 365;
    }

    daystrings.push_back(g_localizeStrings.Get(19030));

    for (int i = 1; i < 365; ++i)
    {
      CStdString string = time.GetAsLocalizedDate();
      daystrings.push_back(string);
      time += CDateTimeSpan(1, 0, 0, 0);
    }

    AddSpin(CONTROL_TMR_FIRST_DAY, 19084, &m_tmp_iFirstDay, daystrings.size(), daystrings);

    if (tag->m_bIsRepeating)
      EnableSettings(CONTROL_TMR_FIRST_DAY, true);
    else
      EnableSettings(CONTROL_TMR_FIRST_DAY, false);
  }
}
예제 #15
0
void CGUIDialogPVRTimerSettings::CreateSettings()
{
  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();

  // clear out any old settings
  m_settings.clear();

  // create our settings controls
  AddBool(CONTROL_TMR_ACTIVE, 19074, &tag->m_bIsActive);
  AddButton(CONTROL_TMR_NAME, 19075, &tag->m_strTitle, true);
  AddBool(CONTROL_TMR_RADIO, 19077, &tag->m_bIsRadio);

  /// Channel names
  {
    // For TV
    CFileItemList channelslist_tv;
    SETTINGSTRINGS channelstrings_tv;
    CPVRManager::GetChannelGroups()->GetGroupAll(false)->GetMembers(&channelslist_tv);

    channelstrings_tv.push_back("0 dummy");

    for (int i = 0; i < channelslist_tv.Size(); i++)
    {
      CStdString string;
      CFileItemPtr item = channelslist_tv[i];
      string.Format("%i %s", item->GetPVRChannelInfoTag()->ChannelNumber(), item->GetPVRChannelInfoTag()->ChannelName().c_str());
      channelstrings_tv.push_back(string);
    }

    AddSpin(CONTROL_TMR_CHNAME_TV, 19078, &tag->m_iChannelNumber, channelstrings_tv.size(), channelstrings_tv);
    EnableSettings(CONTROL_TMR_CHNAME_TV, !tag->m_bIsRadio);

    // For Radio
    CFileItemList channelslist_radio;
    SETTINGSTRINGS channelstrings_radio;
    CPVRManager::GetChannelGroups()->GetGroupAll(true)->GetMembers(&channelslist_radio);

    channelstrings_radio.push_back("0 dummy");

    for (int i = 0; i < channelslist_radio.Size(); i++)
    {
      CStdString string;
      CFileItemPtr item = channelslist_radio[i];
      string.Format("%i %s", item->GetPVRChannelInfoTag()->ChannelNumber(), item->GetPVRChannelInfoTag()->ChannelName().c_str());
      channelstrings_radio.push_back(string);
    }

    AddSpin(CONTROL_TMR_CHNAME_RADIO, 19078, &tag->m_iChannelNumber, channelstrings_radio.size(), channelstrings_radio);
    EnableSettings(CONTROL_TMR_CHNAME_RADIO, tag->m_bIsRadio);
  }

  /// Day
  {
    SETTINGSTRINGS daystrings;
    tm time_cur;
    tm time_tmr;

    daystrings.push_back(g_localizeStrings.Get(19086));
    daystrings.push_back(g_localizeStrings.Get(19087));
    daystrings.push_back(g_localizeStrings.Get(19088));
    daystrings.push_back(g_localizeStrings.Get(19089));
    daystrings.push_back(g_localizeStrings.Get(19090));
    daystrings.push_back(g_localizeStrings.Get(19091));
    daystrings.push_back(g_localizeStrings.Get(19092));
    daystrings.push_back(g_localizeStrings.Get(19093));
    daystrings.push_back(g_localizeStrings.Get(19094));
    daystrings.push_back(g_localizeStrings.Get(19095));
    daystrings.push_back(g_localizeStrings.Get(19096));
    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = tag->StartAsLocalTime();

    /* get diffence of timer in days between today and timer start date */
    time.GetAsTm(time_cur);
    timestart.GetAsTm(time_tmr);

    if (time_tmr.tm_yday - time_cur.tm_yday >= 0)
      m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday;
    else
      m_tmp_day += time_tmr.tm_yday - time_cur.tm_yday + 365;

    for (int i = 1; i < 365; ++i)
    {
      CStdString string = time.GetAsLocalizedDate();
      daystrings.push_back(string);
      time += CDateTimeSpan(1, 0, 0, 0);
    }

    if (tag->m_bIsRepeating)
    {
      if (tag->m_iWeekdays == 0x01)
        m_tmp_day = 0;
      else if (tag->m_iWeekdays == 0x02)
        m_tmp_day = 1;
      else if (tag->m_iWeekdays == 0x04)
        m_tmp_day = 2;
      else if (tag->m_iWeekdays == 0x08)
        m_tmp_day = 3;
      else if (tag->m_iWeekdays == 0x10)
        m_tmp_day = 4;
      else if (tag->m_iWeekdays == 0x20)
        m_tmp_day = 5;
      else if (tag->m_iWeekdays == 0x40)
        m_tmp_day = 6;
      else if (tag->m_iWeekdays == 0x1F)
        m_tmp_day = 7;
      else if (tag->m_iWeekdays == 0x3F)
        m_tmp_day = 8;
      else if (tag->m_iWeekdays == 0x7F)
        m_tmp_day = 9;
      else if (tag->m_iWeekdays == 0x60)
        m_tmp_day = 10;
    }

    AddSpin(CONTROL_TMR_DAY, 19079, &m_tmp_day, daystrings.size(), daystrings);
  }

  AddButton(CONTROL_TMR_BEGIN, 19080, &timerStartTimeStr, true);
  AddButton(CONTROL_TMR_END, 19081, &timerEndTimeStr, true);
  AddSpin(CONTROL_TMR_PRIORITY, 19082, &tag->m_iPriority, 0, 99);
  AddSpin(CONTROL_TMR_LIFETIME, 19083, &tag->m_iLifetime, 0, 365);

  /// First day
  {
    SETTINGSTRINGS daystrings;
    tm time_cur;
    tm time_tmr;

    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = tag->FirstDayAsLocalTime();

    /* get diffence of timer in days between today and timer start date */
    if (time < timestart)
    {
      time.GetAsTm(time_cur);
      timestart.GetAsTm(time_tmr);

      if (time_tmr.tm_yday - time_cur.tm_yday >= 0)
      {
        m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 1;
      }
      else
      {
        m_tmp_iFirstDay += time_tmr.tm_yday - time_cur.tm_yday + 365 + 1;
      }
    }

    daystrings.push_back(g_localizeStrings.Get(19030));

    for (int i = 1; i < 365; ++i)
    {
      CStdString string = time.GetAsLocalizedDate();
      daystrings.push_back(string);
      time += CDateTimeSpan(1, 0, 0, 0);
    }

    AddSpin(CONTROL_TMR_FIRST_DAY, 19084, &m_tmp_iFirstDay, daystrings.size(), daystrings);

    if (tag->m_bIsRepeating)
      EnableSettings(CONTROL_TMR_FIRST_DAY, true);
    else
      EnableSettings(CONTROL_TMR_FIRST_DAY, false);
  }
}
예제 #16
0
void CGUIDialogPVRTimerSettings::OnSettingChanged(SettingInfo &setting)
{
  CPVRTimerInfoTag* tag = m_timerItem->GetPVRTimerInfoTag();

  if (setting.id == CONTROL_TMR_NAME)
  {
    if (CGUIDialogKeyboard::ShowAndGetInput(tag->m_strTitle, g_localizeStrings.Get(19097), false))
    {
      UpdateSetting(CONTROL_TMR_NAME);
    }
  }
  else if (setting.id == CONTROL_TMR_RADIO)
  {
    const CPVRChannel* channeltag = NULL;
    if (!tag->m_bIsRadio)
    {
      EnableSettings(CONTROL_TMR_CHNAME_TV, true);
      EnableSettings(CONTROL_TMR_CHNAME_RADIO, false);
      channeltag = ((CPVRChannelGroup *) CPVRManager::GetChannelGroups()->GetGroupAll(false))->GetByChannelNumber(tag->m_iChannelNumber);
    }
    else
    {
      EnableSettings(CONTROL_TMR_CHNAME_TV, false);
      EnableSettings(CONTROL_TMR_CHNAME_RADIO, true);
      channeltag = ((CPVRChannelGroup *) CPVRManager::GetChannelGroups()->GetGroupAll(true))->GetByChannelNumber(tag->m_iChannelNumber);
    }

    if (channeltag)
    {
      tag->m_iClientChannelUid = channeltag->UniqueID();
      tag->m_iClientId         = channeltag->ClientID();
      tag->m_bIsRadio          = channeltag->IsRadio();
      tag->m_iChannelNumber    = channeltag->ChannelNumber();
    }
  }
  else if (setting.id == CONTROL_TMR_CHNAME_TV || setting.id == CONTROL_TMR_CHNAME_RADIO)
  {
    const CPVRChannel* channeltag = ((CPVRChannelGroup *) CPVRManager::GetChannelGroups()->GetGroupAll(tag->m_bIsRadio))->GetByChannelNumber(tag->m_iChannelNumber);

    if (channeltag)
    {
      tag->m_iClientChannelUid = channeltag->UniqueID();
      tag->m_iClientId         = channeltag->ClientID();
      tag->m_bIsRadio          = channeltag->IsRadio();
      tag->m_iChannelNumber    = channeltag->ChannelNumber();
    }
  }
  else if (setting.id == CONTROL_TMR_DAY && m_tmp_day > 10)
  {
    CDateTime time = CDateTime::GetCurrentDateTime();
    CDateTime timestart = timerStartTime;
    CDateTime timestop = timerEndTime;
    int m_tmp_diff;
    tm time_cur;
    tm time_tmr;

    /* get diffence of timer in days between today and timer start date */
    time.GetAsTm(time_cur);
    timestart.GetAsTm(time_tmr);

    if (time_tmr.tm_yday - time_cur.tm_yday >= 0)
      m_tmp_diff = time_tmr.tm_yday - time_cur.tm_yday;
    else
      m_tmp_diff = time_tmr.tm_yday - time_cur.tm_yday + 365;

    CDateTime newStart = timestart + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
    CDateTime newEnd = timestop  + CDateTimeSpan(m_tmp_day-11-m_tmp_diff, 0, 0, 0);
    tag->SetStartFromLocalTime(newStart);
    tag->SetEndFromLocalTime(newEnd);

    EnableSettings(CONTROL_TMR_FIRST_DAY, false);

    tag->m_bIsRepeating = false;
    tag->m_iWeekdays = 0;
  }
  else if (setting.id == CONTROL_TMR_DAY && m_tmp_day <= 10)
  {
    EnableSettings(CONTROL_TMR_FIRST_DAY, true);
    tag->m_bIsRepeating = true;

    if (m_tmp_day == 0)
      tag->m_iWeekdays = 0x01;
    else if (m_tmp_day == 1)
      tag->m_iWeekdays = 0x02;
    else if (m_tmp_day == 2)
      tag->m_iWeekdays = 0x04;
    else if (m_tmp_day == 3)
      tag->m_iWeekdays = 0x08;
    else if (m_tmp_day == 4)
      tag->m_iWeekdays = 0x10;
    else if (m_tmp_day == 5)
      tag->m_iWeekdays = 0x20;
    else if (m_tmp_day == 6)
      tag->m_iWeekdays = 0x40;
    else if (m_tmp_day == 7)
      tag->m_iWeekdays = 0x1F;
    else if (m_tmp_day == 8)
      tag->m_iWeekdays = 0x3F;
    else if (m_tmp_day == 9)
      tag->m_iWeekdays = 0x7F;
    else if (m_tmp_day == 10)
      tag->m_iWeekdays = 0x60;
    else
      tag->m_iWeekdays = 0;
  }
  else if (setting.id == CONTROL_TMR_BEGIN)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(timerStartTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestart = timerStartTime;
      int start_day       = tag->StartAsLocalTime().GetDay();
      int start_month     = tag->StartAsLocalTime().GetMonth();
      int start_year      = tag->StartAsLocalTime().GetYear();
      int start_hour      = timestart.GetHour();
      int start_minute    = timestart.GetMinute();
      CDateTime newStart(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetStartFromLocalTime(newStart);

      timerStartTimeStr = tag->StartAsLocalTime().GetAsLocalizedTime("", false);
      UpdateSetting(CONTROL_TMR_BEGIN);
    }
  }
  else if (setting.id == CONTROL_TMR_END)
  {
    if (CGUIDialogNumeric::ShowAndGetTime(timerEndTime, g_localizeStrings.Get(14066)))
    {
      CDateTime timestop = timerEndTime;
      int start_day       = tag->EndAsLocalTime().GetDay();
      int start_month     = tag->EndAsLocalTime().GetMonth();
      int start_year      = tag->EndAsLocalTime().GetYear();
      int start_hour      = timestop.GetHour();
      int start_minute    = timestop.GetMinute();
      CDateTime newEnd(start_year, start_month, start_day, start_hour, start_minute, 0);
      tag->SetEndFromLocalTime(newEnd);

      timerEndTimeStr = tag->EndAsLocalTime().GetAsLocalizedTime("", false);
      UpdateSetting(CONTROL_TMR_END);
    }
  }
  else if (setting.id == CONTROL_TMR_FIRST_DAY && m_tmp_day <= 10)
  {
    CDateTime newFirstDay;
    if (m_tmp_iFirstDay > 0)
      newFirstDay = CDateTime::GetCurrentDateTime() + CDateTimeSpan(m_tmp_iFirstDay-1, 0, 0, 0);

    tag->SetFirstDayFromLocalTime(newFirstDay);
  }

  tag->UpdateSummary();
}