bool CPVRTimers::AddTimer(const CPVRTimerInfoTag &item) { if (!g_PVRManager.GetClientProps(item.ClientID())->SupportTimers) { CGUIDialogOK::ShowAndGetInput(19033,0,19215,0); return false; } return item.AddToClient(); }
bool CPVRChannelGroupInternal::UpdateTimers(void) { /* update the timers with the new channel numbers */ CPVRTimers *timers = CPVRManager::GetTimers(); for (unsigned int ptr = 0; ptr < timers->size(); ptr++) { CPVRTimerInfoTag *timer = timers->at(ptr); const CPVRChannel *tag = GetByClient(timer->Number(), timer->ClientID()); if (tag) timer->SetNumber(tag->ChannelNumber()); } return true; }
void CPVRChannels::MoveChannel(unsigned int iOldIndex, unsigned int iNewIndex) { if (iNewIndex == iOldIndex || iNewIndex == 0) return; CPVRDatabase *database = g_PVRManager.GetTVDatabase(); database->Open(); CPVRChannels tempChannels(m_bRadio); /* move the channel */ tempChannels.push_back(at(iOldIndex - 1)); erase(begin() + iOldIndex - 1); if (iNewIndex < size()) insert(begin() + iNewIndex - 1, tempChannels[0]); else push_back(tempChannels[0]); /* update the channel numbers */ for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRChannel *channel = at(ptr); if (channel->ChannelNumber() != (int) ptr + 1) { channel->SetChannelNumber(ptr + 1, true); } } CLog::Log(LOGNOTICE, "%s - %s channel '%d' moved to '%d'", __FUNCTION__, (m_bRadio ? "radio" : "tv"), iOldIndex, iNewIndex); database->Close(); /* update the timers with the new channel numbers */ for (unsigned int ptr = 0; ptr < PVRTimers.size(); ptr++) { CPVRTimerInfoTag timer = PVRTimers[ptr]; CPVRChannel *tag = GetByClient(timer.Number(), timer.ClientID()); if (tag) timer.SetNumber(tag->ChannelNumber()); } m_bIsSorted = false; }
void CAddonHelpers_PVR::PVRTransferTimerEntry(void *addonData, const PVRHANDLE handle, const PVR_TIMERINFO *timer) { CAddonHelpers* addon = (CAddonHelpers*) addonData; if (addon == NULL || handle == NULL || timer == NULL) { CLog::Log(LOGERROR, "PVR: PVRTransferTimerEntry is called with NULL-Pointer!!!"); return; } CPVRTimers *xbmcTimers = (CPVRTimers*) handle->DATA_ADDRESS; CPVRClient* client = (CPVRClient*) handle->CALLER_ADDRESS; const CPVRChannel *channel = CPVRManager::GetChannelGroups()->GetByClientFromAll(timer->channelNum, client->GetClientID()); if (channel == NULL) { CLog::Log(LOGERROR, "PVR: PVRTransferTimerEntry is called with not present channel"); return; } CPVRTimerInfoTag tag; tag.SetClientID(client->GetClientID()); tag.SetClientIndex(timer->index); tag.SetActive(timer->active == 1); tag.SetTitle(timer->title); tag.SetDir(timer->directory); tag.SetClientNumber(timer->channelNum); tag.SetStart((time_t) (timer->starttime+client->GetTimeCorrection())); tag.SetStop((time_t) (timer->endtime+client->GetTimeCorrection())); tag.SetFirstDay((time_t) (timer->firstday+client->GetTimeCorrection())); tag.SetPriority(timer->priority); tag.SetLifetime(timer->lifetime); tag.SetRecording(timer->recording == 1); tag.SetRepeating(timer->repeat == 1); tag.SetWeekdays(timer->repeatflags); CStdString path; path.Format("pvr://client%i/timers/%i", tag.ClientID(), tag.ClientIndex()); tag.SetPath(path); xbmcTimers->Update(tag); return; }
int CPVRTimers::Update() { CSingleLock lock(m_critSection); CLog::Log(LOGDEBUG, "PVRTimers - %s - updating timers", __FUNCTION__); int iCurSize = size(); /* clear channel timers */ for (unsigned int iTimerPtr = 0; iTimerPtr < size(); iTimerPtr++) { CPVRTimerInfoTag *timerTag = &at(iTimerPtr); if (!timerTag || !timerTag->Active()) continue; CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *)timerTag->EpgInfoTag(); if (!epgTag) continue; epgTag->SetTimer(NULL); } /* clear timers */ clear(); /* get all timers from the clients */ CLIENTMAP *clients = g_PVRManager.Clients(); CLIENTMAPITR itr = clients->begin(); while (itr != clients->end()) { if (g_PVRManager.GetClientProps((*itr).second->GetID())->SupportTimers) { if ((*itr).second->GetNumTimers() > 0) { (*itr).second->GetAllTimers(this); } } itr++; } //XXX g_PVRManager.UpdateRecordingsCache(); /* set channel timers */ for (unsigned int ptr = 0; ptr < size(); ptr++) { /* get the timer tag */ CPVRTimerInfoTag *timerTag = &at(ptr); if (!timerTag || !timerTag->Active()) continue; /* try to get the channel */ CPVRChannel *channel = CPVRChannels::GetByClientFromAll(timerTag->Number(), timerTag->ClientID()); if (!channel) continue; /* try to get the EPG */ CPVREpg *epg = channel->GetEPG(); if (!epg) continue; /* try to set the timer on the epg tag that matches */ CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) epg->InfoTagBetween(timerTag->Start(), timerTag->Stop()); if (epgTag) epgTag->SetTimer(timerTag); } return size() - iCurSize; }