bool CPVRChannels::GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio) { CPVRChannels * channels = bRadio ? &PVRChannelsRadio : &PVRChannelsTV; CPVRChannelGroups *channelGroups = bRadio ? &PVRChannelGroupsRadio : &PVRChannelGroupsTV; CFileItemPtr item; item.reset(new CFileItem(strBase + "/all/", true)); item->SetLabel(g_localizeStrings.Get(593)); item->SetLabelPreformated(true); results->Add(item); /* container has hidden channels */ if (channels->GetNumHiddenChannels() > 0) { item.reset(new CFileItem(strBase + "/.hidden/", true)); item->SetLabel(g_localizeStrings.Get(19022)); item->SetLabelPreformated(true); results->Add(item); } /* add all groups */ for (unsigned int ptr = 0; ptr < channelGroups->size(); ptr++) { CPVRChannelGroup group = channelGroups->at(ptr); CStdString strGroup = strBase + "/" + group.GroupName() + "/"; item.reset(new CFileItem(strGroup, true)); item->SetLabel(group.GroupName()); item->SetLabelPreformated(true); results->Add(item); } return true; }
bool CPVRDatabase::Persist(CPVRChannelGroup &group) { bool bReturn(false); CStdString strQuery; CSingleLock lock(group.m_critSection); if (group.GroupID() <= 0) { /* new group */ strQuery = FormatSQL("INSERT INTO channelgroups (" "bIsRadio, sName) " "VALUES (%i, '%s');", (group.IsRadio() ? 1 :0), group.GroupName().c_str()); } else { /* update group */ strQuery = FormatSQL("REPLACE INTO channelgroups (" "idGroup, bIsRadio, sName) " "VALUES (%i, %i, '%s');", group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupName().c_str()); } if (ExecuteQuery(strQuery)) { if (group.GroupID() <= 0) group.m_iGroupId = (int) m_pDS->lastinsertid(); lock.Leave(); bReturn = PersistGroupMembers(group); } return bReturn; }
bool CPVRChannelGroups::Update(const CPVRChannelGroup &group, bool bSaveInDb) { CSingleLock lock(m_critSection); int iIndex = -1; /* try to find the group by id */ if (group.GroupID() > 0) iIndex = GetIndexForGroupID(group.GroupID()); /* try to find the group by name if we didn't find it yet */ if (iIndex < 0) iIndex = GetIndexForGroupName(group.GroupName()); if (iIndex < 0) { CPVRChannelGroup *newGroup = new CPVRChannelGroup(m_bRadio, group.GroupID(), group.GroupName()); if (bSaveInDb) newGroup->Persist(); push_back(newGroup); } else { at(iIndex)->SetGroupID(group.GroupID()); at(iIndex)->SetGroupName(group.GroupName()); if (bSaveInDb) at(iIndex)->Persist(); } return true; }
bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups) { CSingleLock lock(m_critSection); /* go through groups list and check for deleted groups */ for (int iGroupPtr = size() - 1; iGroupPtr >= 0; iGroupPtr--) { CPVRChannelGroup existingGroup(*at(iGroupPtr)); if (!existingGroup.IsInternalGroup()) { CPVRChannelGroup *group = (CPVRChannelGroup *) groups.GetByName(existingGroup.GroupName()); if (group == NULL) { CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - user defined group %s with ID '%u' does not exist on the client anymore. deleting", __FUNCTION__, existingGroup.GroupName().c_str(), existingGroup.GroupID()); DeleteGroup(*at(iGroupPtr)); } } } /* go through the groups list and check for new groups */ for (unsigned int iGroupPtr = 0; iGroupPtr < groups.size(); iGroupPtr++) { CPVRChannelGroup *group = groups.at(iGroupPtr); /* check if this group is present in this container */ CPVRChannelGroup *existingGroup = (CPVRChannelGroup *) GetByName(group->GroupName()); if (existingGroup == NULL) { CPVRChannelGroup *newGroup = new CPVRChannelGroup(m_bRadio); newGroup->SetGroupName(group->GroupName()); push_back(newGroup); } } return true; }
bool CPVRChannelGroup::Update(const CPVRChannelGroup &group) { CSingleLock lock(m_critSection); if (!m_strGroupName.Equals(group.GroupName()) || m_iSortOrder != group.SortOrder()) { m_bChanged = true; m_strGroupName = group.GroupName(); m_iSortOrder = group.SortOrder(); } return true; }
bool CPVRChannelGroups::Update(const CPVRChannelGroup &group, bool bUpdateFromClient /* = false */) { if (group.GroupName().empty() && group.GroupID() <= 0) return true; CPVRChannelGroupPtr updateGroup; { CSingleLock lock(m_critSection); // There can be only one internal group! Make sure we never push a new one! if (group.IsInternalGroup()) updateGroup = GetGroupAll(); // try to find the group by id if (!updateGroup && group.GroupID() > 0) updateGroup = GetById(group.GroupID()); // try to find the group by name if we didn't find it yet if (!updateGroup) updateGroup = GetByName(group.GroupName()); if (!updateGroup) { // create a new group if none was found. Copy the properties immediately // so the group doesn't get flagged as "changed" further down. updateGroup = CPVRChannelGroupPtr(new CPVRChannelGroup(group.IsRadio(), group.GroupID(), group.GroupName())); m_groups.push_back(updateGroup); } updateGroup->SetRadio(group.IsRadio()); updateGroup->SetGroupID(group.GroupID()); updateGroup->SetGroupName(group.GroupName()); updateGroup->SetGroupType(group.GroupType()); updateGroup->SetPosition(group.GetPosition()); // don't override properties we only store locally in our PVR database if (!bUpdateFromClient) { updateGroup->SetLastWatched(group.LastWatched()); updateGroup->SetHidden(group.IsHidden()); } } // sort groups SortGroups(); // persist changes if (bUpdateFromClient) return updateGroup->Persist(); return true; }
/*! * @brief Copy over group info from xbmcGroup to addonGroup. * @param xbmcGroup The group on XBMC's side. * @param addonGroup The group on the addon's side. */ void CPVRClient::WriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup) { memset(&addonGroup, 0, sizeof(addonGroup)); addonGroup.bIsRadio = xbmcGroup.IsRadio(); strncpy(addonGroup.strGroupName, xbmcGroup.GroupName().c_str(), sizeof(addonGroup.strGroupName) - 1); }
bool CPVRChannelGroups::UpdateFromClient(const CPVRChannelGroup &group) { CPVRChannelGroup *newGroup = new CPVRChannelGroup(group.IsRadio(), -1, group.GroupName()); push_back(newGroup); return true; }
bool CPVRChannelGroups::UpdateFromClient(const CPVRChannelGroup &group) { CSingleLock lock(m_critSection); CPVRChannelGroup *newGroup = new CPVRChannelGroup(group.IsRadio(), 0, group.GroupName()); push_back(newGroup); return true; }
bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups) { /* go through the groups list and check for new groups */ for (unsigned int iGroupPtr = 0; iGroupPtr < groups.size(); iGroupPtr++) { CPVRChannelGroup *group = groups.at(iGroupPtr); /* check if this group is present in this container */ CPVRChannelGroup *existingGroup = (CPVRChannelGroup *) GetByName(group->GroupName()); if (existingGroup == NULL) { CPVRChannelGroup *newGroup = new CPVRChannelGroup(m_bRadio); newGroup->SetGroupName(group->GroupName()); push_back(newGroup); } } return true; }
bool CPVRDatabase::Persist(CPVRChannelGroup &group) { bool bReturn(false); if (group.GroupName().empty()) { CLog::LogF(LOGERROR, "Empty group name"); return bReturn; } std::string strQuery; bReturn = true; CSingleLock lock(m_critSection); { /* insert a new entry when this is a new group, or replace the existing one otherwise */ if (group.GroupID() <= 0) strQuery = PrepareSQL("INSERT INTO channelgroups (bIsRadio, iGroupType, sName, iLastWatched, bIsHidden, iPosition) VALUES (%i, %i, '%s', %u, %i, %i)", (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), static_cast<unsigned int>(group.LastWatched()), group.IsHidden(), group.GetPosition()); else strQuery = PrepareSQL("REPLACE INTO channelgroups (idGroup, bIsRadio, iGroupType, sName, iLastWatched, bIsHidden, iPosition) VALUES (%i, %i, %i, '%s', %u, %i, %i)", group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str(), static_cast<unsigned int>(group.LastWatched()), group.IsHidden(), group.GetPosition()); bReturn = ExecuteQuery(strQuery); /* set the group id if it was <= 0 */ if (bReturn && group.GroupID() <= 0) { CSingleLock lock(group.m_critSection); group.m_iGroupId = (int) m_pDS->lastinsertid(); } } /* only persist the channel data for the internal groups */ if (group.IsInternalGroup()) bReturn &= PersistChannels(group); /* persist the group member entries */ if (bReturn) bReturn = PersistGroupMembers(group); return bReturn; }
bool CPVRDatabase::Persist(CPVRChannelGroup &group) { bool bReturn(false); if (group.GroupName().IsEmpty()) { CLog::Log(LOGERROR, "%s - empty group name", __FUNCTION__); return bReturn; } CStdString strQuery; bReturn = true; { CSingleLock lock(group.m_critSection); /* insert a new entry when this is a new group, or replace the existing one otherwise */ if (group.GroupID() <= 0) strQuery = FormatSQL("INSERT INTO channelgroups (bIsRadio, iGroupType, sName) VALUES (%i, %i, '%s')", (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str()); else strQuery = FormatSQL("REPLACE INTO channelgroups (idGroup, bIsRadio, iGroupType, sName) VALUES (%i, %i, %i, '%s')", group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupType(), group.GroupName().c_str()); bReturn = ExecuteQuery(strQuery); /* set the group id if it was <= 0 */ if (bReturn && group.GroupID() <= 0) group.m_iGroupId = (int) m_pDS->lastinsertid(); } /* only persist the channel data for the internal groups */ if (group.IsInternalGroup()) bReturn &= PersistChannels(group); /* persist the group member entries */ if (bReturn) bReturn = PersistGroupMembers(group); return bReturn; }
bool CPVRChannelGroups::Update(const CPVRChannelGroup &group) { int iIndex = GetIndexForGroupID(group.GroupID()); if (iIndex < 0) { CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - new %s channel group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", group.GroupName().c_str()); push_back(new CPVRChannelGroup(m_bRadio, group.GroupID(), group.GroupName(), group.SortOrder())); } else { CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - updating %s channel group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", group.GroupName().c_str()); at(iIndex)->SetGroupName(group.GroupName()); at(iIndex)->SetSortOrder(group.SortOrder()); } return true; }
bool CPVRChannelGroups::Update(const CPVRChannelGroup &group, bool bSaveInDb) { if (group.GroupName().empty() && group.GroupID() <= 0) return true; CPVRChannelGroupPtr updateGroup; { CSingleLock lock(m_critSection); // try to find the group by id if (group.GroupID() > 0) updateGroup = GetById(group.GroupID()); // try to find the group by name if we didn't find it yet if (!updateGroup) updateGroup = GetByName(group.GroupName()); if (!updateGroup) { // create a new group if none was found updateGroup = CPVRChannelGroupPtr(new CPVRChannelGroup(m_bRadio, group.GroupID(), group.GroupName())); updateGroup->SetGroupType(group.GroupType()); updateGroup->SetLastWatched(group.LastWatched()); m_groups.push_back(updateGroup); } else { // update existing group updateGroup->SetGroupID(group.GroupID()); updateGroup->SetGroupName(group.GroupName()); updateGroup->SetGroupType(group.GroupType()); } } // persist changes if (bSaveInDb && updateGroup) return updateGroup->Persist(); return true; }
bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) { bool bReturn = false; if (group.IsInternalGroup()) { CLog::Log(LOG_ERROR, "CPVRChannelGroups - %s - cannot delete internal group '%s'", __FUNCTION__, group.GroupName().c_str()); return bReturn; } CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (!database || !database->Open()) { CLog::Log(LOG_ERROR, "CPVRChannelGroups - %s - unable to open the database", __FUNCTION__); return bReturn; } /* remove all channels from the group */ database->RemoveChannelsFromGroup(group.GroupID()); /* delete the group from the database */ bReturn = database->DeleteChannelGroup(group.GroupID(), m_bRadio); database->Close(); /* delete the group in this container */ for (unsigned int iGroupPtr = 0; iGroupPtr < size(); iGroupPtr++) { if (at(iGroupPtr)->GroupID() == group.GroupID()) { delete at(iGroupPtr); erase(begin() + iGroupPtr); break; } } return bReturn; }
bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) { bool bReturn = false; CSingleLock lock(m_critSection); if (group.IsInternalGroup()) { CLog::Log(LOGERROR, "CPVRChannelGroups - %s - cannot delete internal group '%s'", __FUNCTION__, group.GroupName().c_str()); return bReturn; } CPVRDatabase *database = GetPVRDatabase(); if (!database) return bReturn; /* remove all channels from the group */ database->RemoveChannelsFromGroup(group); /* delete the group from the database */ bReturn = database->Delete(group); /* delete the group in this container */ for (unsigned int iGroupPtr = 0; iGroupPtr < size(); iGroupPtr++) { if (at(iGroupPtr)->GroupID() == group.GroupID()) { CPVRChannelGroup *selectedGroup = GetSelectedGroup(); if (selectedGroup && *selectedGroup == group) g_PVRManager.SetPlayingGroup(GetGroupAll()); delete at(iGroupPtr); erase(begin() + iGroupPtr); break; } } return bReturn; }
bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) { // don't delete internal groups if (group.IsInternalGroup()) { CLog::Log(LOGERROR, "PVR - %s - cannot delete internal group '%s'", __FUNCTION__, group.GroupName().c_str()); return false; } // delete the group in this container CSingleLock lock(m_critSection); for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) { if ((*it)->GroupID() == group.GroupID()) { // update the selected group in the gui if it's deleted CPVRChannelGroupPtr selectedGroup = GetSelectedGroup(); if (selectedGroup && *selectedGroup == group) g_PVRManager.SetPlayingGroup(GetGroupAll()); m_groups.erase(it); break; } } // delete the group from the database CPVRDatabase *database = GetPVRDatabase(); return database ? database->Delete(group) : false; }
/*! * @brief Copy over group info from xbmcGroup to addonGroup. * @param xbmcGroup The group on XBMC's side. * @param addonGroup The group on the addon's side. */ inline void PVRWriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup) { addonGroup.bIsRadio = xbmcGroup.IsRadio(); addonGroup.strGroupName = xbmcGroup.GroupName(); }
bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) { // don't delete internal groups if (group.IsInternalGroup()) { CLog::Log(LOGERROR, "CPVRChannelGroups - %s - cannot delete internal group '%s'", __FUNCTION__, group.GroupName().c_str()); return false; } bool bFound(false); CPVRChannelGroupPtr playingGroup; // delete the group in this container { CSingleLock lock(m_critSection); for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); !bFound && it != m_groups.end();) { if (*(*it) == group || (group.GroupID() > 0 && (*it)->GroupID() == group.GroupID())) { // update the selected group in the gui if it's deleted CPVRChannelGroupPtr selectedGroup = GetSelectedGroup(); if (selectedGroup && *selectedGroup == group) playingGroup = GetGroupAll(); it = m_groups.erase(it); bFound = true; } else { ++it; } } } if (playingGroup) g_PVRManager.SetPlayingGroup(playingGroup); if (group.GroupID() > 0) { // delete the group from the database const CPVRDatabasePtr database(g_PVRManager.GetTVDatabase()); return database ? database->Delete(group) : false; } return bFound; }
bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { // check whether we've come back here from a window during which time we've actually // stopped playing videos if (message.GetParam1() == WINDOW_INVALID && !g_application.IsPlayingVideo()) { // why are we here if nothing is playing??? g_windowManager.PreviousWindow(); return true; } g_infoManager.SetShowInfo(false); g_infoManager.SetShowCodec(false); m_bShowCurrentTime = false; m_bGroupSelectShow = false; g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off. // switch resolution g_graphicsContext.SetFullScreenVideo(true); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif // now call the base class to load our windows CGUIWindow::OnMessage(message); m_bShowViewModeInfo = false; if (CUtil::IsUsingTTFSubtitles()) { CSingleLock lock (m_fontLock); CStdString fontPath = "special://xbmc/media/Fonts/"; fontPath += g_guiSettings.GetString("subtitles.font"); // We scale based on PAL4x3 - this at least ensures all sizing is constant across resolutions. RESOLUTION_INFO pal(720, 576, 0); CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true); CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true); if (!subFont || !borderFont) CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font"); else m_subsLayout = new CGUITextLayout(subFont, true, 0, borderFont); } else m_subsLayout = NULL; return true; } case GUI_MSG_WINDOW_DEINIT: { CGUIWindow::OnMessage(message); CGUIDialog *pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_OSD_TELETEXT); if (pDialog) pDialog->Close(true); CGUIDialogSlider *slider = (CGUIDialogSlider *)g_windowManager.GetWindow(WINDOW_DIALOG_SLIDER); if (slider) slider->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_GUIDE); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_DIRECTOR); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CUTTER); if (pDialog) pDialog->Close(true); FreeResources(true); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); lock.Leave(); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif CSingleLock lockFont(m_fontLock); if (m_subsLayout) { g_fontManager.Unload("__subtitle__"); g_fontManager.Unload("__subtitleborder__"); delete m_subsLayout; m_subsLayout = NULL; } return true; } case GUI_MSG_CLICKED: { unsigned int iControl = message.GetSenderId(); if (iControl == CONTROL_GROUP_CHOOSER && g_PVRManager.IsStarted()) { // Get the currently selected label of the Select button CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); OnMessage(msg); CStdString strLabel = msg.GetLabel(); CPVRChannel playingChannel; if (g_PVRManager.GetCurrentChannel(playingChannel)) { CPVRChannelGroup *selectedGroup = (CPVRChannelGroup *) g_PVRChannelGroups->Get(playingChannel.IsRadio())->GetByName(strLabel); if (selectedGroup) { g_PVRManager.SetPlayingGroup(selectedGroup); CLog::Log(LOGDEBUG, "%s - switched to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); if (!selectedGroup->IsGroupMember(playingChannel)) { CLog::Log(LOGDEBUG, "%s - channel '%s' is not a member of '%s', switching to channel 1 of the new group", __FUNCTION__, playingChannel.ChannelName().c_str(), selectedGroup->GroupName().c_str()); const CPVRChannel *switchChannel = selectedGroup->GetByChannelNumber(1); if (switchChannel) OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) switchChannel->ChannelNumber())); else { CLog::Log(LOGERROR, "%s - cannot find channel '1' in group %s", __FUNCTION__, selectedGroup->GroupName().c_str()); g_application.getApplicationMessenger().MediaStop(false); } } } else { CLog::Log(LOGERROR, "%s - could not switch to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); g_application.getApplicationMessenger().MediaStop(false); } } else { CLog::Log(LOGERROR, "%s - cannot find the current channel", __FUNCTION__); g_application.getApplicationMessenger().MediaStop(false); } // hide the control and reset focus m_bGroupSelectShow = false; SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER); // SET_CONTROL_FOCUS(0, 0); return true; } break; } case GUI_MSG_SETFOCUS: case GUI_MSG_LOSTFOCUS: if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true; break; } return CGUIWindow::OnMessage(message); }
void CPVRChannel::UpdatePath(unsigned int iNewChannelNumber) { CStdString strFileNameAndPath; CSingleLock lock(m_critSection); CPVRChannelGroup *group = g_PVRChannelGroups->GetGroupAll(m_bIsRadio); if (group) { strFileNameAndPath.Format("pvr://channels/%s/%s/%i.pvr", (m_bIsRadio ? "radio" : "tv"), group->GroupName().c_str(), iNewChannelNumber); if (m_strFileNameAndPath != strFileNameAndPath) { m_strFileNameAndPath = strFileNameAndPath; SetChanged(); } } }