bool CPVRChannelGroupInternal::RemoveFromGroup(CPVRChannel *channel) { if (!channel) return false; CSingleLock lock(m_critSection); /* check if this channel is currently playing if we are hiding it */ CPVRChannel currentChannel; if (g_PVRManager.GetCurrentChannel(¤tChannel) && currentChannel == *channel) { CGUIDialogOK::ShowAndGetInput(19098,19101,0,19102); return false; } /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannel *realChannel = (CPVRChannel *) GetByChannelID(channel->ChannelID()); if (!realChannel) return false; /* switch the hidden flag */ realChannel->SetHidden(true, true); ++m_iHiddenChannels; /* renumber this list */ Renumber(); /* and persist */ return Persist(); }
bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannel *realChannel = (CPVRChannel *) GetByChannelID(channel->ChannelID()); if (!realChannel) return false; /* switch the hidden flag */ if (realChannel->IsHidden()) { realChannel->SetHidden(false, true); m_iHiddenChannels--; } /* renumber this list */ Renumber(); /* move this channel and persist */ if (iChannelNumber > 0) return MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true); else return MoveChannel(realChannel->ChannelNumber(), size() - m_iHiddenChannels, true); }
bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel &channel, int iChannelNumber /* = 0 */, bool bSortAndRenumber /* = true */) { CSingleLock lock(m_critSection); bool bReturn(false); /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannel *realChannel = (CPVRChannel *) GetByChannelID(channel.ChannelID()); if (!realChannel) return bReturn; /* switch the hidden flag */ if (realChannel->IsHidden()) { realChannel->SetHidden(false, true); m_iHiddenChannels--; if (bSortAndRenumber) Renumber(); } /* move this channel and persist */ bReturn = (iChannelNumber > 0) ? MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true) : MoveChannel(realChannel->ChannelNumber(), size() - m_iHiddenChannels, true); return bReturn; }
bool CPVRChannelGroup::UpdateChannel(const CFileItem &item, bool bHidden, bool bVirtual, bool bEPGEnabled, bool bParentalLocked, int iEPGSource, int iChannelNumber, const CStdString &strChannelName, const CStdString &strIconPath, const CStdString &strStreamURL) { if (!item.HasPVRChannelInfoTag()) return false; CSingleLock lock(m_critSection); /* get the real channel from the group */ CPVRChannel *channel = GetByUniqueID(item.GetPVRChannelInfoTag()->UniqueID()); if (!channel) return false; channel->SetChannelName(strChannelName); channel->SetHidden(bHidden); channel->SetLocked(bParentalLocked); channel->SetIconPath(strIconPath); if (bVirtual) channel->SetStreamURL(strStreamURL); if (iEPGSource == 0) channel->SetEPGScraper("client"); // TODO add other scrapers channel->SetEPGEnabled(bEPGEnabled); /* set new values in the channel tag */ if (bHidden) { SortByChannelNumber(); // or previous changes will be overwritten RemoveFromGroup(*channel); } else { SetChannelNumber(*channel, iChannelNumber); } return true; }
void CGUIDialogPVRChannelManager::SaveList() // XXX investigate: renumbering doesn't work { if (!m_bContainsChanges) return; CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (!database || !database->Open()) return; CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); pDlgProgress->SetHeading(190); pDlgProgress->SetLine(0, ""); pDlgProgress->SetLine(1, 328); pDlgProgress->SetLine(2, ""); pDlgProgress->StartModal(); pDlgProgress->Progress(); pDlgProgress->SetPercentage(0); int iActiveChannels = 0; for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++) { if (m_channelItems->Get(iListPtr)->GetPropertyBOOL("ActiveChannel")) ++iActiveChannels; } // int iNextChannelNumber = 1; // int iNextHiddenChannelNumber = iActiveChannels + 1; bool bHasChangedItems = false; for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++) { bool bChanged = false; CFileItemPtr pItem = m_channelItems->Get(iListPtr); if (!pItem) continue; CPVRChannel *channel = pItem->GetPVRChannelInfoTag(); if (!channel) { //TODO add new channel continue; } /* get values from the form */ bool bHidden = !pItem->GetPropertyBOOL("ActiveChannel"); bool bVirtual = pItem->GetPropertyBOOL("Virtual"); bool bEPGEnabled = pItem->GetPropertyBOOL("UseEPG"); int iEPGSource = pItem->GetPropertyInt("EPGSource"); CStdString strChannelName = pItem->GetProperty("Name"); CStdString strIconPath = pItem->GetProperty("Icon"); CStdString strStreamURL = pItem->GetProperty("StreamURL"); /* set new values in the channel tag */ // TODO // if (bHidden) // bChanged = channel->SetChannelNumber(iNextHiddenChannelNumber++) || bChanged; // else // bChanged = channel->SetChannelNumber(iNextChannelNumber++) || bChanged; bChanged = channel->SetChannelName(strChannelName) || bChanged; bChanged = channel->SetHidden(bHidden) || bChanged; bChanged = channel->SetIconPath(strIconPath) || bChanged; if (bVirtual) bChanged = channel->SetStreamURL(strStreamURL) || bChanged; if (iEPGSource == 0) bChanged = channel->SetEPGScraper("client") || bChanged; // TODO add other scrapers bChanged = channel->SetEPGEnabled(bEPGEnabled) || bChanged; if (bChanged) { bHasChangedItems = true; channel->Persist(true); } pItem->SetProperty("Changed", false); pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size()); } if (bHasChangedItems) { database->CommitInsertQueries(); CPVRManager::Get()->Start(); // XXX not a nice way to refresh the channels, but works for now } database->Close(); m_bContainsChanges = false; pDlgProgress->Close(); }