int PVRClientMythTV::GetTimersAmount(void) { if (g_bExtraDebug) XBMC->Log(LOG_DEBUG, "%s", __FUNCTION__); TimerMap timers = m_db.GetTimers(); return timers.size(); }
S32 ScriptTimerMan::stopTimer( S32 id ) { TimerMap::Iterator itr = mTimers.find( id ); if ( itr == mTimers.end() ) return -1; PlatformTimer *timer = itr->value; S32 elapsed = timer->getElapsedMs(); mTimers.erase( itr ); delete timer; return elapsed; }
S32 ScriptTimerMan::startTimer() { PlatformTimer *timer = PlatformTimer::create(); mTimers.insert( smNextId, timer ); smNextId++; return ( smNextId - 1 ); }
void AsyncOp::AddToTimerMap(TimerMap &theMap, DWORD theTimeout) { RemoveFromTimerMap(true); mTimerMap = &theMap; mTimerMapItr = theMap.insert(TimerMap::value_type(theTimeout,this)); }
PVR_ERROR PVRClientMythTV::GetTimers(ADDON_HANDLE handle) { if (g_bExtraDebug) XBMC->Log(LOG_DEBUG, "%s", __FUNCTION__); TimerMap timers = m_db.GetTimers(); m_recordingRules.clear(); for (TimerMap::iterator it = timers.begin(); it != timers.end(); it++) m_recordingRules.push_back(it->second); //Search for modifiers and add links to them for (RecordingRuleList::iterator it = m_recordingRules.begin(); it != m_recordingRules.end(); it++) if (it->Type() == MythTimer::DontRecord || it->Type() == MythTimer::OverrideRecord) for (RecordingRuleList::iterator it2 = m_recordingRules.begin(); it2 != m_recordingRules.end(); it2++) if (it2->Type() != MythTimer::DontRecord && it2->Type() != MythTimer::OverrideRecord) if (it->SameTimeslot(*it2) && !it->GetParent()) { it2->AddModifier(*it); it->SetParent(*it2); } ProgramInfoMap upcomingRecordings = m_con.GetPendingPrograms(); for (ProgramInfoMap::iterator it = upcomingRecordings.begin(); it != upcomingRecordings.end(); it++) { // When deleting a timer from mythweb, it might happen that it's removed from database // but it's still present over mythprotocol. Skip those timers, because timers.at would crash. if (timers.count(it->second.RecordID()) == 0) { XBMC->Log(LOG_DEBUG, "%s - Skipping timer that is no more in database", __FUNCTION__); continue; } PVR_TIMER tag; memset(&tag, 0, sizeof(PVR_TIMER)); tag.startTime= it->second.RecordingStartTime(); tag.endTime = it->second.RecordingEndTime(); tag.iClientChannelUid = it->second.ChannelID(); tag.iClientIndex = it->second.RecordID(); tag.iMarginEnd = timers.at(it->second.RecordID()).EndOffset(); tag.iMarginStart = timers.at(it->second.RecordID()).StartOffset(); tag.iPriority = it->second.Priority(); tag.bIsRepeating = false; tag.firstDay = 0; tag.iWeekdays = 0; int genre = m_categories.Category(it->second.Category()); tag.iGenreSubType = genre & 0x0F; tag.iGenreType = genre & 0xF0; // Title CStdString title = it->second.Title(true); if (title.IsEmpty()) { MythProgram epgProgram; title= "%"; m_db.FindProgram(tag.startTime, tag.iClientChannelUid, title, &epgProgram); title = epgProgram.title; } PVR_STRCPY(tag.strTitle, title); // Summary PVR_STRCPY(tag.strSummary, it->second.Description()); // Status if (g_bExtraDebug) XBMC->Log(LOG_DEBUG,"%s ## - State: %d - ##", __FUNCTION__, it->second.Status()); switch (it->second.Status()) { case RS_RECORDING: case RS_TUNING: tag.state = PVR_TIMER_STATE_RECORDING; break; case RS_ABORTED: tag.state = PVR_TIMER_STATE_ABORTED; break; case RS_RECORDED: tag.state = PVR_TIMER_STATE_COMPLETED; break; case RS_WILL_RECORD: tag.state = PVR_TIMER_STATE_SCHEDULED; break; case RS_UNKNOWN: case RS_DONT_RECORD: case RS_PREVIOUS_RECORDING: case RS_CURRENT_RECORDING: case RS_EARLIER_RECORDING: case RS_TOO_MANY_RECORDINGS: case RS_NOT_LISTED: case RS_CONFLICT: case RS_LATER_SHOWING: case RS_REPEAT: case RS_INACTIVE: case RS_NEVER_RECORD: case RS_OFFLINE: case RS_OTHER_SHOWING: case RS_FAILED: case RS_TUNER_BUSY: case RS_LOW_DISKSPACE: case RS_CANCELLED: case RS_MISSED: default: tag.state = PVR_TIMER_STATE_CANCELLED; break; } // Unimplemented tag.iEpgUid=0; tag.iLifetime=0; PVR_STRCPY(tag.strDirectory, ""); // Recording rules RecordingRuleList::iterator recRule = std::find(m_recordingRules.begin(), m_recordingRules.end() , it->second.RecordID()); tag.iClientIndex = ((recRule - m_recordingRules.begin()) << 16) + recRule->size(); //recRule->SaveTimerString(tag); std::pair<PVR_TIMER, MythProgramInfo> rrtmp(tag, it->second); recRule->push_back(rrtmp); PVR->TransferTimerEntry(handle,&tag); } if (g_bExtraDebug) XBMC->Log(LOG_DEBUG, "%s - Done", __FUNCTION__); return PVR_ERROR_NO_ERROR; }