bool CGUIWindowPVRCommon::OnContextButtonFind(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; if (button == CONTEXT_BUTTON_FIND) { bReturn = true; if (m_parent->m_windowSearch) { CEpgInfoTag tag; m_parent->m_windowSearch->m_searchfilter.Reset(); if (item->IsEPG()) m_parent->m_windowSearch->m_searchfilter.m_strSearchTerm = "\"" + item->GetEPGInfoTag()->Title() + "\""; else if (item->IsPVRChannel() && item->GetPVRChannelInfoTag()->GetEPGNow(tag)) m_parent->m_windowSearch->m_searchfilter.m_strSearchTerm = "\"" + tag.Title() + "\""; else if (item->IsPVRRecording()) m_parent->m_windowSearch->m_searchfilter.m_strSearchTerm = "\"" + item->GetPVRRecordingInfoTag()->m_strTitle + "\""; m_parent->m_windowSearch->m_bSearchConfirmed = true; m_parent->SetLabel(m_iControlButton, 0); m_parent->SetActiveView(m_parent->m_windowSearch); m_parent->m_windowSearch->UpdateData(); m_parent->SetLabel(m_iControlList, 0); } } return bReturn; }
bool CGUIWindowPVRCommon::StartRecordFile(CFileItem *item) { if (!item->HasEPGInfoTag()) return false; CEpgInfoTag *tag = item->GetEPGInfoTag(); if (!tag || !tag->HasPVRChannel()) return false; CPVRTimerInfoTag *timer = g_PVRTimers->GetMatch(item); if (timer) { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); return false; } CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(264); pDialog->SetLine(0, tag->PVRChannelName()); pDialog->SetLine(1, ""); pDialog->SetLine(2, tag->Title()); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; CPVRTimerInfoTag *newtimer = CPVRTimerInfoTag::CreateFromEpg(*tag); CFileItem *newTimerItem = new CFileItem(*newtimer); return g_PVRTimers->AddTimer(*newTimerItem); }
bool CGUIWindowPVRSearch::OnContextButton(const CFileItem &item, CONTEXT_BUTTON button) { bool bReturn = false; switch(button) { case CONTEXT_BUTTON_FIND: { m_searchfilter.Reset(); CEpgInfoTag tag; // construct the search term if (item.IsEPG()) m_searchfilter.m_strSearchTerm = "\"" + item.GetEPGInfoTag()->Title() + "\""; else if (item.IsPVRChannel() && item.GetPVRChannelInfoTag()->GetEPGNow(tag)) m_searchfilter.m_strSearchTerm = "\"" + tag.Title() + "\""; else if (item.IsPVRRecording()) m_searchfilter.m_strSearchTerm = "\"" + item.GetPVRRecordingInfoTag()->m_strTitle + "\""; else if (item.IsPVRTimer()) m_searchfilter.m_strSearchTerm = "\"" + item.GetPVRTimerInfoTag()->m_strTitle + "\""; m_bSearchConfirmed = true; Refresh(true); bReturn = true; break; } default: bReturn = false; } return bReturn; }
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; }
bool EpgSearchFilter::MatchSearchTerm(const CEpgInfoTag &tag) const { bool bReturn(true); if (!m_strSearchTerm.IsEmpty()) { CTextSearch search(m_strSearchTerm, m_bIsCaseSensitive, SEARCH_DEFAULT_OR); bReturn = search.Search(tag.Title()) || search.Search(tag.PlotOutline()); } return bReturn; }
bool CGUIWindowPVRCommon::ActionRecord(CFileItem *item) { bool bReturn = false; CEpgInfoTag *epgTag = item->GetEPGInfoTag(); if (!epgTag) return bReturn; CPVRChannelPtr channel = epgTag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return bReturn; if (epgTag->Timer() == NULL) { /* create a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(264); pDialog->SetLine(0, ""); pDialog->SetLine(1, epgTag->Title()); pDialog->SetLine(2, ""); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*epgTag); if (newTimer) { bReturn = g_PVRTimers->AddTimer(*newTimer); delete newTimer; } else { bReturn = false; } } else { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); bReturn = true; } return bReturn; }
bool CGUIWindowPVRCommon::StartRecordFile(CFileItem *item) { if (!item->HasEPGInfoTag()) return false; CEpgInfoTag *tag = item->GetEPGInfoTag(); CPVRChannelPtr channel; if (tag) channel = tag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return false; CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(item); if (timer && timer->HasPVRTimerInfoTag()) { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); return false; } CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(264); pDialog->SetLine(0, tag->PVRChannelName()); pDialog->SetLine(1, ""); pDialog->SetLine(2, tag->Title()); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*tag); bool bReturn(false); if (newTimer) { bReturn = g_PVRTimers->AddTimer(*newTimer); delete newTimer; } 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; }
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; }
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 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; }
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; }