PVR_ERROR PVRClientMythTV::AddTimer(const PVR_TIMER &timer) { if(g_bExtraDebug) XBMC->Log(LOG_DEBUG,"%s - title: %s, start: %i, end: %i, chanID: %i",__FUNCTION__,timer.strTitle,timer.startTime,timer.iClientChannelUid); MythTimer mt; m_con.DefaultTimer(mt); CStdString category=Genre(timer.iGenreType); mt.Category(category); mt.ChanID(timer.iClientChannelUid); mt.Callsign(m_channels.at(timer.iClientChannelUid).Callsign()); mt.Description(timer.strSummary); mt.EndOffset(timer.iMarginEnd); mt.EndTime(timer.endTime); mt.Inactive(timer.state == PVR_TIMER_STATE_ABORTED ||timer.state == PVR_TIMER_STATE_CANCELLED); mt.Priority(timer.iPriority); mt.StartOffset(timer.iMarginStart); mt.StartTime(timer.startTime); mt.Title(timer.strTitle,true); CStdString title=mt.Title(false); mt.SearchType(m_db.FindProgram(timer.startTime,timer.iClientChannelUid,title,NULL)?MythTimer::NoSearch:MythTimer::ManualSearch); mt.Type(timer.bIsRepeating? (timer.iWeekdays==127? MythTimer::TimeslotRecord : MythTimer::WeekslotRecord) : MythTimer::SingleRecord); int id=m_db.AddTimer(mt); if(id<0) return PVR_ERROR_NOT_POSSIBLE; if(!m_con.UpdateSchedules(id)) return PVR_ERROR_NOT_POSSIBLE; if(g_bExtraDebug) XBMC->Log(LOG_DEBUG,"%s - Done - %i",__FUNCTION__,id); //PVR->TriggerTimerUpdate(); return PVR_ERROR_NO_ERROR; }
void PVRClientMythTV::PVRtoMythTimer(const PVR_TIMER timer, MythTimer& mt) { CStdString category=Genre(timer.iGenreType); mt.Category(category); mt.ChanID(timer.iClientChannelUid); mt.Callsign(m_channels.at(timer.iClientChannelUid).Callsign()); mt.Description(timer.strSummary); mt.EndOffset(timer.iMarginEnd); mt.EndTime(timer.endTime); mt.Inactive(timer.state == PVR_TIMER_STATE_ABORTED ||timer.state == PVR_TIMER_STATE_CANCELLED); mt.Priority(timer.iPriority); mt.StartOffset(timer.iMarginStart); mt.StartTime(timer.startTime); mt.Title(timer.strTitle,true); CStdString title=mt.Title(false); mt.SearchType(m_db.FindProgram(timer.startTime,timer.iClientChannelUid,title,NULL)?MythTimer::NoSearch:MythTimer::ManualSearch); mt.Type(timer.bIsRepeating? (timer.iWeekdays==127? MythTimer::TimeslotRecord : MythTimer::WeekslotRecord) : MythTimer::SingleRecord); mt.RecordID(timer.iClientIndex); }
bool MythDatabase::UpdateTimer(MythTimer &timer) { m_database_t->Lock(); bool retval = CMYTH->MysqlUpdateTimer(*m_database_t,timer.RecordID(),timer.ChanID(),timer.m_callsign.Buffer(),timer.m_description.Buffer(),timer.StartTime(), timer.EndTime(),timer.m_title.Buffer(), timer.m_category.Buffer(),timer.Type(),timer.m_subtitle.Buffer(),timer.Priority(),timer.StartOffset(),timer.EndOffset(),timer.SearchType(),timer.Inactive()?1:0,timer.DupMethod(),timer.CheckDupIn(),timer.RecGroup().Buffer(), timer.StoreGroup().Buffer(),timer.PlayGroup().Buffer(),timer.AutoTranscode(),timer.Userjobs(),timer.AutoCommFlag(),timer.AutoExpire(),timer.MaxEpisodes(),timer.NewExpireOldRecord(),timer.Transcoder())==0; m_database_t->Unlock(); return retval; }
PVR_ERROR PVRClientMythTV::UpdateTimer(const PVR_TIMER &timer) { if(g_bExtraDebug) XBMC->Log(LOG_DEBUG,"%s - title: %s, start: %i, end: %i, chanID: %i, ID: %i",__FUNCTION__,timer.strTitle,timer.startTime,timer.iClientChannelUid,timer.iClientIndex); RecordingRule r = m_recordingRules[(timer.iClientIndex)>>16]; PVR_TIMER oldPvrTimer = r[(timer.iClientIndex)&0xffff].first; { bool createNewRule = false; bool createNewOverrideRule = false; MythTimer mt; PVRtoMythTimer(timer,mt); mt.Description(oldPvrTimer.strSummary);//Fix broken description mt.Inactive(false); mt.RecordID(r.RecordID()); //These should trigger a manual search or a new rule if(oldPvrTimer.iClientChannelUid != timer.iClientChannelUid || oldPvrTimer.endTime != timer.endTime || oldPvrTimer.startTime != timer.startTime || oldPvrTimer.startTime != timer.startTime || strcmp(oldPvrTimer.strTitle, timer.strTitle) || //strcmp(oldPvrTimer.strSummary, timer.strSummary) || timer.bIsRepeating ) createNewRule = true; //Change type if(oldPvrTimer.state != timer.state) { if( r.Type() != MythTimer::SingleRecord && !createNewRule) { if(timer.state == PVR_TIMER_STATE_ABORTED ||timer.state == PVR_TIMER_STATE_CANCELLED) mt.Type( MythTimer::DontRecord ); else mt.Type( MythTimer::OverrideRecord ); createNewOverrideRule = true; } else mt.Inactive( timer.state == PVR_TIMER_STATE_ABORTED ||timer.state == PVR_TIMER_STATE_CANCELLED); } //These can be updated without triggering a new rule if(oldPvrTimer.iMarginEnd != timer.iMarginEnd || oldPvrTimer.iPriority != timer.iPriority || oldPvrTimer.iMarginStart != timer.iMarginStart ) createNewOverrideRule = true; CStdString title = timer.strTitle; if(createNewRule) mt.SearchType(m_db.FindProgram(timer.startTime,timer.iClientChannelUid,title,NULL)?MythTimer::NoSearch:MythTimer::ManualSearch); if(createNewOverrideRule && r.SearchType() == MythTimer::ManualSearch) mt.SearchType( MythTimer::ManualSearch); if(r.Type() == MythTimer::DontRecord || r.Type() == MythTimer::OverrideRecord) createNewOverrideRule = false; if(createNewRule && r.Type() != MythTimer::SingleRecord ) { if(!m_db.AddTimer(mt)) return PVR_ERROR_NOT_POSSIBLE; MythTimer mtold; PVRtoMythTimer(oldPvrTimer,mtold); mtold.Type(MythTimer::DontRecord); mtold.Inactive(false); mtold.RecordID(r.RecordID()); int id=r.RecordID(); if(r.Type() == MythTimer::DontRecord || r.Type() == MythTimer::OverrideRecord) m_db.UpdateTimer(mtold); else id=m_db.AddTimer(mtold);//Blocks old record rule m_con.UpdateSchedules(id); } else if(createNewOverrideRule && r.Type() != MythTimer::SingleRecord ) { if(mt.Type() != MythTimer::DontRecord && mt.Type() != MythTimer::OverrideRecord) mt.Type(MythTimer::OverrideRecord); if(!m_db.AddTimer(mt)) return PVR_ERROR_NOT_POSSIBLE; } else { if(!m_db.UpdateTimer(mt)) return PVR_ERROR_NOT_POSSIBLE; } m_con.UpdateSchedules(mt.RecordID()); } if(g_bExtraDebug) XBMC->Log(LOG_DEBUG,"%s - Done",__FUNCTION__); return PVR_ERROR_NO_ERROR; }