bool CEpg::InfoTagNow(CEpgInfoTag &tag) const { CSingleLock lock(m_critSection); if (!m_nowActive || !m_nowActive->IsActive()) { CDateTime now = CDateTime::GetCurrentDateTime().GetAsUTCDateTime(); /* one of the first items will always match if the list is sorted */ for (unsigned int iTagPtr = 0; iTagPtr < size(); iTagPtr++) { CEpgInfoTag *tag = at(iTagPtr); if (tag->StartAsUTC() <= now && tag->EndAsUTC() > now) { m_nowActive = tag; break; } } } if (m_nowActive) tag = *m_nowActive; return m_nowActive != NULL; }
CEpgInfoTagPtr CEpg::GetPreviousEvent(const CEpgInfoTag& tag) const { CSingleLock lock(m_critSection); std::map<CDateTime, CEpgInfoTagPtr>::const_iterator it = m_tags.find(tag.StartAsUTC()); if (it != m_tags.end() && it != m_tags.begin()) { --it; return it->second; } CEpgInfoTagPtr retVal; return retVal; }
bool CGUIWindowPVRCommon::ActionPlayEpg(CFileItem *item) { bool bReturn = false; CEpgInfoTag *epgTag = item->GetEPGInfoTag(); if (!epgTag) return bReturn; const CPVRChannel *channel = epgTag->ChannelTag(); if (!channel || channel->ChannelNumber() > 0) return bReturn; bReturn = g_application.PlayFile(CFileItem(*channel)); if (!bReturn) { /* cannot play file */ CGUIDialogOK::ShowAndGetInput(19033,0,19035,0); } return bReturn; }
bool CGUIWindowPVRCommon::ActionPlayEpg(CFileItem *item) { CEpgInfoTag *epgTag = item->GetEPGInfoTag(); if (!epgTag) return false; CPVRChannelPtr channel = epgTag->ChannelTag(); if (!channel || channel->ChannelNumber() > 0 || !g_PVRManager.CheckParentalLock(*channel)) return false; PlayBackRet ret = g_application.PlayFile(CFileItem(*channel)); if (ret == PLAYBACK_FAIL) { CStdString msg; msg.Format(g_localizeStrings.Get(19035).c_str(), channel->ChannelName().c_str()); // CHANNELNAME could not be played. Check the log for details. CGUIDialogOK::ShowAndGetInput(19033, 0, msg, 0); } return ret == PLAYBACK_OK; }
void CPVRTimerInfoTag::UpdateEpgEvent(bool bClear /* = false */) { CSingleLock lock(m_critSection); if (bClear) { CEpgInfoTag *epgTag = GetEpgInfoTag(); if (epgTag) epgTag->OnTimerDeleted(); } else { /* already got an epg event set */ if (m_iEpgId != -1) return; /* try to get the channel */ CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetByUniqueID(m_iClientChannelUid, m_iClientId); if (!channel) return; /* try to get the EPG table */ CEpg *epg = channel->GetEPG(); if (!epg) return; /* try to set the timer on the epg tag that matches with a 2 minute margin */ CEpgInfoTag *epgTag = (CEpgInfoTag *) epg->GetTagBetween(StartAsUTC() - CDateTimeSpan(0, 0, 2, 0), EndAsUTC() + CDateTimeSpan(0, 0, 2, 0)); if (!epgTag) epgTag = (CEpgInfoTag *) epg->GetTagAround(StartAsUTC()); if (epgTag) { m_iEpgId = epgTag->EpgID(); m_epgStart = epgTag->StartAsUTC(); m_genre = epgTag->Genre(); m_iGenreType = epgTag->GenreType(); m_iGenreSubType = epgTag->GenreSubType(); epgTag->SetTimer(this); } } }
bool EpgSearchFilter::MatchChannelNumber(const CEpgInfoTag &tag) const { bool bReturn(true); if (m_iChannelNumber != EPG_SEARCH_UNSET && g_PVRManager.IsStarted()) { const CPVRChannelGroup *group = (m_iChannelGroup != EPG_SEARCH_UNSET) ? g_PVRChannelGroups->GetByIdFromAll(m_iChannelGroup) : g_PVRChannelGroups->GetGroupAllTV(); if (!group) group = CPVRManager::Get().ChannelGroups()->GetGroupAllTV(); bReturn = (m_iChannelNumber == (int) group->GetChannelNumber(*tag.ChannelTag())); } return bReturn; }
bool CEpg::IsRemovableTag(const CEpgInfoTag &tag) const { return !tag.HasTimer(); }
CPVRTimerInfoTag::~CPVRTimerInfoTag(void) { CEpgInfoTag *tag = GetEpgInfoTag(); if (tag) tag->OnTimerDeleted(); }
int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true */, bool bLastUpdate /* = false */) { int iReturn = -1; const CEpg *epg = tag.GetTable(); if (!epg || epg->EpgID() <= 0) { CLog::Log(LOGERROR, "%s - tag '%s' does not have a valid table", __FUNCTION__, tag.Title().c_str()); return iReturn; } time_t iStartTime, iEndTime, iFirstAired; tag.StartAsUTC().GetAsTime(iStartTime); tag.EndAsUTC().GetAsTime(iEndTime); tag.FirstAiredAsUTC().GetAsTime(iFirstAired); int iEpgId = epg->EpgID(); int iBroadcastId = tag.BroadcastId(); if (iBroadcastId <= 0) { CStdString strWhereClause; if (tag.UniqueBroadcastID() > 0) { strWhereClause = FormatSQL("(iBroadcastUid = '%u' OR iStartTime = %u) AND idEpg = %u", tag.UniqueBroadcastID(), iStartTime, iEpgId); } else { strWhereClause = FormatSQL("iStartTime = %u AND idEpg = '%u'", iStartTime, iEpgId); } CStdString strValue = GetSingleValue("epgtags", "idBroadcast", strWhereClause); if (!strValue.IsEmpty()) iBroadcastId = atoi(strValue); } CStdString strQuery; if (iBroadcastId < 0) { strQuery = FormatSQL("INSERT INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid) " "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, %u, %i, %i, %i, %i, %i, %i, '%s', %i);", iEpgId, iStartTime, iEndTime, tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID()); } else { strQuery = FormatSQL("REPLACE INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, idBroadcast) " "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i);", iEpgId, iStartTime, iEndTime, tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), tag.FirstAiredAsUTC().GetAsDBDateTime().c_str(), tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), iBroadcastId); } if (bSingleUpdate) { if (ExecuteQuery(strQuery)) iReturn = (int) m_pDS->lastinsertid(); } else { QueueInsertQuery(strQuery); if (bLastUpdate) CommitInsertQueries(); iReturn = 0; } return iReturn; }
bool EpgSearchFilter::FilterEntry(const CEpgInfoTag &tag) const { if (m_iGenreType != -1) { if (tag.GenreType() != m_iGenreType && (!m_bIncludeUnknownGenres && ((tag.GenreType() < EVCONTENTMASK_USERDEFINED || tag.GenreType() >= EVCONTENTMASK_MOVIEDRAMA)))) { return false; } } if (m_iMinimumDuration != -1) { if (tag.GetDuration() < (m_iMinimumDuration*60)) return false; } if (m_iMaximumDuration != -1) { if (tag.GetDuration() > (m_iMaximumDuration*60)) return false; } int timeTag = (tag.Start().GetHour()*60 + tag.Start().GetMinute()); if (timeTag < (m_startTime.wHour*60 + m_startTime.wMinute)) return false; if (timeTag > (m_endTime.wHour*60 + m_endTime.wMinute)) return false; if (tag.Start() < m_startDate) return false; if (tag.Start() > m_endDate) return false; if (m_strSearchTerm != "") { cTextSearch search(tag.Title(), m_strSearchTerm, m_bIsCaseSensitive); if (!search.DoSearch()) { if (m_bSearchInDescription) { search.SetText(tag.PlotOutline(), m_strSearchTerm, m_bIsCaseSensitive); if (!search.DoSearch()) { search.SetText(tag.Plot(), m_strSearchTerm, m_bIsCaseSensitive); if (!search.DoSearch()) return false; } } else return false; } } return true; }
int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true */) { int iReturn(-1); if (tag.EpgID() <= 0) { CLog::Log(LOGERROR, "%s - tag '%s' does not have a valid table", __FUNCTION__, tag.Title(true).c_str()); return iReturn; } time_t iStartTime, iEndTime, iFirstAired; tag.StartAsUTC().GetAsTime(iStartTime); tag.EndAsUTC().GetAsTime(iEndTime); tag.FirstAiredAsUTC().GetAsTime(iFirstAired); int iBroadcastId = tag.BroadcastId(); std::string strQuery; /* Only store the genre string when needed */ std::string strGenre = (tag.GenreType() == EPG_GENRE_USE_STRING) ? StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator) : ""; if (iBroadcastId < 0) { strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, sIconPath, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, sRecordingId) " "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, '%s');", tag.EpgID(), iStartTime, iEndTime, tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), tag.RecordingId().c_str()); } else { strQuery = PrepareSQL("REPLACE INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, sIconPath, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, idBroadcast, sRecordingId) " "VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i, '%s');", tag.EpgID(), iStartTime, iEndTime, tag.Title(true).c_str(), tag.PlotOutline(true).c_str(), tag.Plot(true).c_str(), tag.Icon().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), iBroadcastId, tag.RecordingId().c_str()); } if (bSingleUpdate) { if (ExecuteQuery(strQuery)) iReturn = (int) m_pDS->lastinsertid(); } else { QueueInsertQuery(strQuery); iReturn = 0; } return iReturn; }
bool EpgSearchFilter::MatchStartAndEndTimes(const CEpgInfoTag &tag) const { return (tag.StartAsLocalTime() >= m_startDateTime && tag.EndAsLocalTime() <= m_endDateTime); }
bool EpgSearchFilter::MatchChannelType(const CEpgInfoTag &tag) const { return (g_PVRManager.IsStarted() && tag.ChannelTag()->IsRadio() == m_bIsRadio); }
int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true */) { int iReturn(-1); const CEpg *epg = tag.GetTable(); if (!epg || epg->EpgID() <= 0) { CLog::Log(LOGERROR, "%s - tag '%s' does not have a valid table", __FUNCTION__, tag.Title().c_str()); return iReturn; } time_t iStartTime, iEndTime, iFirstAired; tag.StartAsUTC().GetAsTime(iStartTime); tag.EndAsUTC().GetAsTime(iEndTime); tag.FirstAiredAsUTC().GetAsTime(iFirstAired); int iEpgId = epg->EpgID(); if (bSingleUpdate) { Delete(*tag.GetTable(), iStartTime, iEndTime); } int iBroadcastId = tag.BroadcastId(); CSingleLock lock(m_critSection); CStdString strQuery; /* Only store the genre string when needed */ CStdString strGenre = (tag.GenreType() == EPG_GENRE_USE_STRING) ? tag.Genre() : ""; if (iBroadcastId < 0) { strQuery = FormatSQL("INSERT INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid) " "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i);", iEpgId, iStartTime, iEndTime, tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID()); } else { strQuery = FormatSQL("REPLACE INTO epgtags (idEpg, iStartTime, " "iEndTime, sTitle, sPlotOutline, sPlot, iGenreType, iGenreSubType, sGenre, " "iFirstAired, iParentalRating, iStarRating, bNotify, iSeriesId, " "iEpisodeId, iEpisodePart, sEpisodeName, iBroadcastUid, idBroadcast) " "VALUES (%u, %u, %u, '%s', '%s', '%s', %i, %i, '%s', %u, %i, %i, %i, %i, %i, %i, '%s', %i, %i);", iEpgId, iStartTime, iEndTime, tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), strGenre.c_str(), iFirstAired, tag.ParentalRating(), tag.StarRating(), tag.Notify(), tag.SeriesNum(), tag.EpisodeNum(), tag.EpisodePart(), tag.EpisodeName().c_str(), tag.UniqueBroadcastID(), iBroadcastId); } if (bSingleUpdate) { if (ExecuteQuery(strQuery)) iReturn = (int) m_pDS->lastinsertid(); } else { QueueInsertQuery(strQuery); iReturn = 0; } return iReturn; }
bool CPVRManager::UpdateItem(CFileItem& item) { /* Don't update if a recording is played */ if (item.IsPVRRecording()) return false; if (!item.IsPVRChannel()) { CLog::Log(LOGERROR, "CPVRManager - %s - no channel tag provided", __FUNCTION__); return false; } CSingleLock lock(m_critSection); if (!m_currentFile || *m_currentFile->GetPVRChannelInfoTag() == *item.GetPVRChannelInfoTag()) return false; g_application.CurrentFileItem() = *m_currentFile; g_infoManager.SetCurrentItem(*m_currentFile); CPVRChannel* channelTag = item.GetPVRChannelInfoTag(); CEpgInfoTag epgTagNow; bool bHasTagNow = channelTag->GetEPGNow(epgTagNow); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { musictag->SetTitle(bHasTagNow ? epgTagNow.Title() : g_guiSettings.GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055)); // no information available if (bHasTagNow) musictag->SetGenre(epgTagNow.Genre()); musictag->SetDuration(bHasTagNow ? epgTagNow.GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); musictag->SetLoaded(true); musictag->SetComment(StringUtils::EmptyString); musictag->SetLyrics(StringUtils::EmptyString); } } else { CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { videotag->m_strTitle = bHasTagNow ? epgTagNow.Title() : g_guiSettings.GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available if (bHasTagNow) videotag->m_genre = epgTagNow.Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); videotag->m_strPlot = bHasTagNow ? epgTagNow.Plot() : StringUtils::EmptyString; videotag->m_strPlotOutline = bHasTagNow ? epgTagNow.PlotOutline() : StringUtils::EmptyString; videotag->m_iEpisode = bHasTagNow ? epgTagNow.EpisodeNum() : 0; } } return false; }
bool CEpgInfoTag::Update(const CEpgInfoTag &tag, bool bUpdateBroadcastId /* = true */) { bool bChanged(false); { CSingleLock lock(m_critSection); bChanged = (m_pvrChannel != tag.m_pvrChannel); } { bChanged |= ( m_strTitle != tag.m_strTitle || m_strPlotOutline != tag.m_strPlotOutline || m_strPlot != tag.m_strPlot || m_strOriginalTitle != tag.m_strOriginalTitle || m_strCast != tag.m_strCast || m_strDirector != tag.m_strDirector || m_strWriter != tag.m_strWriter || m_iYear != tag.m_iYear || m_strIMDBNumber != tag.m_strIMDBNumber || m_startTime != tag.m_startTime || m_endTime != tag.m_endTime || m_iGenreType != tag.m_iGenreType || m_iGenreSubType != tag.m_iGenreSubType || m_firstAired != tag.m_firstAired || m_iParentalRating != tag.m_iParentalRating || m_iStarRating != tag.m_iStarRating || m_bNotify != tag.m_bNotify || m_iEpisodeNumber != tag.m_iEpisodeNumber || m_iEpisodePart != tag.m_iEpisodePart || m_iSeriesNumber != tag.m_iSeriesNumber || m_strEpisodeName != tag.m_strEpisodeName || m_iUniqueBroadcastID != tag.m_iUniqueBroadcastID || EpgID() != tag.EpgID() || m_genre != tag.m_genre || m_strIconPath != tag.m_strIconPath ); if (bUpdateBroadcastId) bChanged |= (m_iBroadcastId != tag.m_iBroadcastId); if (bChanged) { if (bUpdateBroadcastId) m_iBroadcastId = tag.m_iBroadcastId; m_strTitle = tag.m_strTitle; m_strPlotOutline = tag.m_strPlotOutline; m_strPlot = tag.m_strPlot; m_strOriginalTitle = tag.m_strOriginalTitle; m_strCast = tag.m_strCast; m_strDirector = tag.m_strDirector; m_strWriter = tag.m_strWriter; m_iYear = tag.m_iYear; m_strIMDBNumber = tag.m_strIMDBNumber; m_startTime = tag.m_startTime; m_endTime = tag.m_endTime; m_iGenreType = tag.m_iGenreType; m_iGenreSubType = tag.m_iGenreSubType; m_epg = tag.m_epg; { CSingleLock lock(m_critSection); m_pvrChannel = tag.m_pvrChannel; } if (m_iGenreType == EPG_GENRE_USE_STRING) { /* No type/subtype. Use the provided description */ m_genre = tag.m_genre; } else { /* Determine genre description by type/subtype */ m_genre = StringUtils::Split(CEpg::ConvertGenreIdToString(tag.m_iGenreType, tag.m_iGenreSubType), g_advancedSettings.m_videoItemSeparator); } m_firstAired = tag.m_firstAired; m_iParentalRating = tag.m_iParentalRating; m_iStarRating = tag.m_iStarRating; m_bNotify = tag.m_bNotify; m_iEpisodeNumber = tag.m_iEpisodeNumber; m_iEpisodePart = tag.m_iEpisodePart; m_iSeriesNumber = tag.m_iSeriesNumber; m_strEpisodeName = tag.m_strEpisodeName; m_iUniqueBroadcastID = tag.m_iUniqueBroadcastID; m_strIconPath = tag.m_strIconPath; } } if (bChanged) UpdatePath(); return bChanged; }
bool CEpg::FixOverlappingEvents(bool bStore /* = true */) { bool bReturn = false; CEpgDatabase *database = NULL; if (bStore) { database = g_EpgContainer.GetDatabase(); if (!database || !database->Open()) { CLog::Log(LOGERROR, "EPG - %s - could not open the database", __FUNCTION__); return bReturn; } } bReturn = true; CEpgInfoTag *previousTag = NULL; CSingleLock lock(m_critSection); for (unsigned int ptr = 0; ptr < size(); ptr++) { /* skip the first entry or if previousTag is NULL */ if (previousTag == NULL) { previousTag = at(ptr); continue; } CEpgInfoTag *currentTag = at(ptr); /* the previous tag ends after the current tag starts. * the start time of the current tag is leading, so change the time of the previous tag */ if (previousTag->End() > currentTag->Start()) { CLog::Log(LOGDEBUG, "EPG - %s - event '%s' ends after event '%s' starts. changing the end time of '%s' to the start time of '%s': '%s'", __FUNCTION__, previousTag->Title().c_str(), currentTag->Title().c_str(), previousTag->Title().c_str(), currentTag->Title().c_str(), currentTag->Start().GetAsLocalizedDateTime(false, false).c_str()); previousTag->SetEnd(currentTag->Start()); if (bStore) bReturn = previousTag->Persist(false, false) && bReturn; } previousTag = at(ptr); } return bReturn; }
bool CPVRManager::UpdateItem(CFileItem& item) { /* Don't update if a recording is played */ if (item.IsPVRRecording()) return false; if (!item.IsPVRChannel()) { CLog::Log(LOGERROR, "CPVRManager - %s - no channel tag provided", __FUNCTION__); return false; } CSingleLock lock(m_critSection); if (!m_currentFile || *m_currentFile->GetPVRChannelInfoTag() == *item.GetPVRChannelInfoTag()) return false; g_application.CurrentFileItem() = *m_currentFile; g_infoManager.SetCurrentItem(*m_currentFile); CPVRChannel* channelTag = item.GetPVRChannelInfoTag(); CEpgInfoTag epgTagNow; bool bHasTagNow = channelTag->GetEPGNow(epgTagNow); if (channelTag->IsRadio()) { CMusicInfoTag* musictag = item.GetMusicInfoTag(); if (musictag) { musictag->SetTitle(bHasTagNow ? epgTagNow.Title() : g_localizeStrings.Get(19055)); if (bHasTagNow) musictag->SetGenre(epgTagNow.Genre()); musictag->SetDuration(bHasTagNow ? epgTagNow.GetDuration() : 3600); musictag->SetURL(channelTag->Path()); musictag->SetArtist(channelTag->ChannelName()); musictag->SetAlbumArtist(channelTag->ChannelName()); musictag->SetLoaded(true); musictag->SetComment(StringUtils::EmptyString); musictag->SetLyrics(StringUtils::EmptyString); } } else { CVideoInfoTag *videotag = item.GetVideoInfoTag(); if (videotag) { videotag->m_strTitle = bHasTagNow ? epgTagNow.Title() : g_localizeStrings.Get(19055); if (bHasTagNow) videotag->m_genre = epgTagNow.Genre(); videotag->m_strPath = channelTag->Path(); videotag->m_strFileNameAndPath = channelTag->Path(); videotag->m_strPlot = bHasTagNow ? epgTagNow.Plot() : StringUtils::EmptyString; videotag->m_strPlotOutline = bHasTagNow ? epgTagNow.PlotOutline() : StringUtils::EmptyString; videotag->m_iEpisode = bHasTagNow ? epgTagNow.EpisodeNum() : 0; } } CPVRChannel* tagPrev = item.GetPVRChannelInfoTag(); if (tagPrev && tagPrev->ChannelNumber() != m_LastChannel) { m_LastChannel = tagPrev->ChannelNumber(); m_LastChannelChanged = XbmcThreads::SystemClockMillis(); } if (XbmcThreads::SystemClockMillis() - m_LastChannelChanged >= (unsigned int) g_guiSettings.GetInt("pvrplayback.channelentrytimeout") && m_LastChannel != m_PreviousChannel[m_PreviousChannelIndex]) m_PreviousChannel[m_PreviousChannelIndex ^= 1] = m_LastChannel; else m_LastChannelChanged = XbmcThreads::SystemClockMillis(); return false; }
bool CPVRTimers::UpdateEntries(CPVRTimers *timers) { bool bChanged(false); bool bAddedOrDeleted(false); vector<CStdString> timerNotifications; CSingleLock lock(m_critSection); /* go through the timer list and check for updated or new timers */ for (unsigned int iTimerPtr = 0; iTimerPtr < timers->size(); iTimerPtr++) { const CPVRTimerInfoTag *timer = timers->at(iTimerPtr); /* check if this timer is present in this container */ CPVRTimerInfoTag *existingTimer = (CPVRTimerInfoTag *) GetByClient(timer->m_iClientId, timer->m_iClientIndex); if (existingTimer) { /* if it's present, update the current tag */ bool bStateChanged(existingTimer->m_state != timer->m_state); if (existingTimer->UpdateEntry(*timer)) { bChanged = true; if (bStateChanged && g_PVRManager.IsStarted()) { CStdString strMessage; existingTimer->GetNotificationText(strMessage); timerNotifications.push_back(strMessage); } CLog::Log(LOGDEBUG,"PVRTimers - %s - updated timer %d on client %d", __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId); } } else { /* new timer */ CPVRTimerInfoTag *newTimer = new CPVRTimerInfoTag; newTimer->UpdateEntry(*timer); push_back(newTimer); bChanged = true; bAddedOrDeleted = true; if (g_PVRManager.IsStarted()) { CStdString strMessage; newTimer->GetNotificationText(strMessage); timerNotifications.push_back(strMessage); } CLog::Log(LOGDEBUG,"PVRTimers - %s - added timer %d on client %d", __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId); } } /* check for deleted timers */ unsigned int iSize = size(); for (unsigned int iTimerPtr = 0; iTimerPtr < iSize; iTimerPtr++) { CPVRTimerInfoTag *timer = (CPVRTimerInfoTag *) at(iTimerPtr); if (!timer) continue; if (timers->GetByClient(timer->m_iClientId, timer->m_iClientIndex) == NULL) { /* timer was not found */ CLog::Log(LOGDEBUG,"PVRTimers - %s - deleted timer %d on client %d", __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId); if (g_PVRManager.IsStarted()) { CStdString strMessage; strMessage.Format("%s: '%s'", (timer->EndAsUTC() <= CDateTime::GetCurrentDateTime().GetAsUTCDateTime()) ? g_localizeStrings.Get(19227) : g_localizeStrings.Get(19228), timer->m_strTitle.c_str()); timerNotifications.push_back(strMessage); } CEpgInfoTag *epgTag = at(iTimerPtr)->GetEpgInfoTag(); if (epgTag) epgTag->SetTimer(NULL); delete at(iTimerPtr); erase(begin() + iTimerPtr); iTimerPtr--; iSize--; bChanged = true; bAddedOrDeleted = true; } } m_bIsUpdating = false; if (bChanged) { Sort(); SetChanged(); lock.Leave(); NotifyObservers(bAddedOrDeleted ? "timers-reset" : "timers", false); if (g_guiSettings.GetBool("pvrrecord.timernotifications")) { /* queue notifications */ for (unsigned int iNotificationPtr = 0; iNotificationPtr < timerNotifications.size(); iNotificationPtr++) { CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(19166), timerNotifications.at(iNotificationPtr)); } } } return bChanged; }