本文整理汇总了C++中CPVRChannelPtr::Persist方法的典型用法代码示例。如果您正苦于以下问题:C++ CPVRChannelPtr::Persist方法的具体用法?C++ CPVRChannelPtr::Persist怎么用?C++ CPVRChannelPtr::Persist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPVRChannelPtr
的用法示例。
在下文中一共展示了CPVRChannelPtr::Persist方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveFromGroup
bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannelPtr &channel)
{
if (!IsGroupMember(channel))
return false;
/* check if this channel is currently playing if we are hiding it */
CPVRChannelPtr currentChannel(CServiceBroker::GetPVRManager().GetPlayingChannel());
if (currentChannel && currentChannel == channel)
{
HELPERS::ShowOKDialogText(CVariant{19098}, CVariant{19102});
return false;
}
CSingleLock lock(m_critSection);
/* switch the hidden flag */
if (!channel->IsHidden())
{
channel->SetHidden(true);
++m_iHiddenChannels;
}
else
{
channel->SetHidden(false);
if (m_iHiddenChannels > 0)
--m_iHiddenChannels;
}
/* renumber this list */
SortAndRenumber();
/* and persist */
return channel->Persist() &&
Persist();
}
示例2: CloseStream
void CPVRManager::CloseStream(void)
{
CPVRChannelPtr channel;
bool bPersistChannel(false);
{
CSingleLock lock(m_critSection);
if (m_addons->GetPlayingChannel(channel))
{
/* store current time in iLastWatched */
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
channel->SetLastWatched(tNow);
bPersistChannel = true;
m_channelGroups->SetLastPlayedGroup(GetPlayingGroup(channel->IsRadio()));
}
m_addons->CloseStream();
SAFE_DELETE(m_currentFile);
}
if (bPersistChannel)
channel->Persist();
}
示例3: AddToGroup
bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel &channel, int iChannelNumber /* = 0 */)
{
CSingleLock lock(m_critSection);
bool bReturn(false);
/* get the actual channel since this is called from a fileitemlist copy */
CPVRChannelPtr realChannel = GetByChannelID(channel.ChannelID());
if (!realChannel)
return bReturn;
/* switch the hidden flag */
if (realChannel->IsHidden())
{
realChannel->SetHidden(false);
m_iHiddenChannels--;
SortAndRenumber();
}
/* move this channel and persist */
bReturn = (iChannelNumber > 0l) ?
MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true) :
MoveChannel(realChannel->ChannelNumber(), m_members.size() - m_iHiddenChannels, true);
if (m_bLoaded)
realChannel->Persist();
return bReturn;
}
示例4: OpenLiveStream
bool CPVRManager::OpenLiveStream(const CFileItem &channel)
{
bool bReturn(false);
if (!channel.HasPVRChannelInfoTag())
return bReturn;
CLog::Log(LOGDEBUG,"PVRManager - %s - opening live stream on channel '%s'",
__FUNCTION__, channel.GetPVRChannelInfoTag()->ChannelName().c_str());
// check if we're allowed to play this file
if (IsParentalLocked(*channel.GetPVRChannelInfoTag()))
return bReturn;
CPVRChannelPtr playingChannel;
CPVRChannelGroupPtr group;
bool bPersistChanges(false);
if ((bReturn = m_addons->OpenStream(*channel.GetPVRChannelInfoTag(), false)) != false)
{
CSingleLock lock(m_critSection);
if(m_currentFile)
delete m_currentFile;
m_currentFile = new CFileItem(channel);
if (m_addons->GetPlayingChannel(playingChannel))
{
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
/* update last watched timestamp for channel */
playingChannel->SetLastWatched(tNow);
/* update last watched timestamp for group */
group = g_PVRManager.GetPlayingGroup(playingChannel->IsRadio());
group->SetLastWatched(tNow);
/* update last played group */
m_channelGroups->SetLastPlayedGroup(group);
bPersistChanges = true;
}
}
if (bPersistChanges)
{
playingChannel->Persist();
group->Persist();
}
return bReturn;
}
示例5: CEpg
CEpg *CEpgContainer::CreateEpg(int iEpgId)
{
if (g_PVRManager.IsStarted())
{
CPVRChannelPtr channel = g_PVRChannelGroups->GetChannelByEpgId(iEpgId);
if (channel)
{
CEpg *epg = new CEpg(channel, true);
channel->Persist();
return epg;
}
}
return new CEpg(iEpgId);
}
示例6: UpdateChannel
bool CPVRChannelGroupInternal::UpdateChannel(const CPVRChannel &channel)
{
CSingleLock lock(m_critSection);
CPVRChannelPtr updateChannel = GetByUniqueID(channel.UniqueID());
if (!updateChannel)
{
updateChannel = CPVRChannelPtr(new CPVRChannel(channel.IsRadio()));
PVRChannelGroupMember newMember = { updateChannel, 0 };
m_members.push_back(newMember);
updateChannel->SetUniqueID(channel.UniqueID());
}
updateChannel->UpdateFromClient(channel);
return updateChannel->Persist(!m_bLoaded);
}
示例7: UpdateLastWatched
void CPVRManager::UpdateLastWatched(CPVRChannel &channel)
{
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
// update last watched timestamp for channel
// NOTE: method could be called with a fileitem copy as argument so we need to obtain the right channel instance
CPVRChannelPtr channelPtr = m_channelGroups->GetChannelById(channel.ChannelID());
channelPtr->SetLastWatched(tNow);
channelPtr->Persist();
// update last watched timestamp for group
CPVRChannelGroupPtr group = GetPlayingGroup(channel.IsRadio());
group->SetLastWatched(tNow);
group->Persist();
/* update last played group */
m_channelGroups->SetLastPlayedGroup(group);
}
示例8: GetLastPlayedChannel
CFileItemPtr CPVRChannelGroup::GetLastPlayedChannel(unsigned int iCurrentChannel /* = -1 */) const
{
CSingleLock lock(m_critSection);
time_t tCurrentLastWatched(0), tMaxLastWatched(0);
if (iCurrentChannel > 0)
{
CPVRChannelPtr channel = GetByChannelID(iCurrentChannel);
if (channel.get())
{
CDateTime::GetCurrentDateTime().GetAsTime(tMaxLastWatched);
channel->SetLastWatched(tMaxLastWatched);
channel->Persist();
}
}
CPVRChannelPtr returnChannel;
for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++)
{
PVRChannelGroupMember groupMember = m_members.at(iChannelPtr);
if (g_PVRClients->IsConnectedClient(groupMember.channel->ClientID()) &&
groupMember.channel->LastWatched() > 0 &&
(tMaxLastWatched == 0 || groupMember.channel->LastWatched() < tMaxLastWatched) &&
(tCurrentLastWatched == 0 || groupMember.channel->LastWatched() > tCurrentLastWatched))
{
returnChannel = groupMember.channel;
tCurrentLastWatched = returnChannel->LastWatched();
}
}
if (returnChannel)
{
CFileItemPtr retVal = CFileItemPtr(new CFileItem(*returnChannel));
return retVal;
}
CFileItemPtr retVal = CFileItemPtr(new CFileItem);
return retVal;
}
示例9: CloseStream
void CPVRManager::CloseStream(void)
{
CPVRChannelPtr channel;
CPVRChannelGroupPtr group;
bool bPersistChanges(false);
{
CSingleLock lock(m_critSection);
if (m_addons->GetPlayingChannel(channel))
{
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
/* update last watched timestamp for channel */
channel->SetLastWatched(tNow);
/* update last watched timestamp for group */
group = g_PVRManager.GetPlayingGroup(channel->IsRadio());
group->SetLastWatched(tNow);
/* update last played group */
m_channelGroups->SetLastPlayedGroup(group);
bPersistChanges = true;
// store channel settings
g_application.SaveFileState();
}
m_addons->CloseStream();
SAFE_DELETE(m_currentFile);
}
if (bPersistChanges)
{
channel->Persist();
group->Persist();
}
}
示例10: OpenLiveStream
bool CPVRManager::OpenLiveStream(const CFileItem &channel)
{
bool bReturn(false);
if (!channel.HasPVRChannelInfoTag())
return bReturn;
CLog::Log(LOGDEBUG,"PVRManager - %s - opening live stream on channel '%s'",
__FUNCTION__, channel.GetPVRChannelInfoTag()->ChannelName().c_str());
// check if we're allowed to play this file
if (IsParentalLocked(*channel.GetPVRChannelInfoTag()))
return bReturn;
CPVRChannelPtr playingChannel;
bool bPersistChannel(false);
if ((bReturn = m_addons->OpenStream(*channel.GetPVRChannelInfoTag(), false)) != false)
{
CSingleLock lock(m_critSection);
if(m_currentFile)
delete m_currentFile;
m_currentFile = new CFileItem(channel);
if (m_addons->GetPlayingChannel(playingChannel))
{
/* store current time in iLastWatched */
time_t tNow;
CDateTime::GetCurrentDateTime().GetAsTime(tNow);
playingChannel->SetLastWatched(tNow);
bPersistChannel = true;
}
}
if (bPersistChannel)
playingChannel->Persist();
return bReturn;
}
示例11: RemoveFromGroup
bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannel &channel)
{
CSingleLock lock(m_critSection);
/* check if this channel is currently playing if we are hiding it */
CPVRChannelPtr currentChannel;
if (g_PVRManager.GetCurrentChannel(currentChannel) && *currentChannel == channel)
{
CGUIDialogOK::ShowAndGetInput(19098,19101,0,19102);
return false;
}
/* get the actual channel since this is called from a fileitemlist copy */
CPVRChannelPtr realChannel = GetByChannelID(channel.ChannelID());
if (!realChannel)
return false;
/* switch the hidden flag */
if (!realChannel->IsHidden())
{
realChannel->SetHidden(true);
++m_iHiddenChannels;
}
else
{
realChannel->SetHidden(false);
--m_iHiddenChannels;
}
/* renumber this list */
SortAndRenumber();
/* and persist */
return realChannel->Persist() &&
Persist();
}
示例12: RemoveFromGroup
bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannelPtr &channel)
{
CSingleLock lock(m_critSection);
assert(channel.get());
if (!IsGroupMember(channel))
return false;
/* check if this channel is currently playing if we are hiding it */
CPVRChannelPtr currentChannel(g_PVRManager.GetCurrentChannel());
if (currentChannel && currentChannel == channel)
{
CGUIDialogOK::ShowAndGetInput(CVariant{19098}, CVariant{19102});
return false;
}
/* switch the hidden flag */
if (!channel->IsHidden())
{
channel->SetHidden(true);
++m_iHiddenChannels;
}
else
{
channel->SetHidden(false);
if (m_iHiddenChannels > 0)
--m_iHiddenChannels;
}
/* renumber this list */
SortAndRenumber();
/* and persist */
return channel->Persist() &&
Persist();
}
示例13: SearchAndSetChannelIcons
void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */)
{
std::string iconPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_PVRMENU_ICONPATH);
if (iconPath.empty())
return;
/* fetch files in icon path for fast lookup */
CFileItemList fileItemList;
XFILE::CDirectory::GetDirectory(iconPath, fileItemList, ".jpg|.png|.tbn");
if (fileItemList.IsEmpty())
return;
CGUIDialogProgressBarHandle* dlgProgressHandle = g_PVRManager.ShowProgressDialog(g_localizeStrings.Get(19286)); // Searching for channel icons
CSingleLock lock(m_critSection);
/* create a map for fast lookup of normalized file base name */
std::map<std::string, std::string> fileItemMap;
const VECFILEITEMS &items = fileItemList.GetList();
for(VECFILEITEMS::const_iterator it = items.begin(); it != items.end(); ++it)
{
std::string baseName = URIUtils::GetFileName((*it)->GetPath());
URIUtils::RemoveExtension(baseName);
StringUtils::ToLower(baseName);
fileItemMap.insert(std::make_pair(baseName, (*it)->GetPath()));
}
int channelIndex = 0;
CPVRChannelPtr channel;
for(PVR_CHANNEL_GROUP_MEMBERS::const_iterator it = m_members.begin(); it != m_members.end(); ++it)
{
channel = it->second.channel;
/* update progress dialog */
if (dlgProgressHandle)
{
dlgProgressHandle->SetProgress(channelIndex++, m_members.size());
dlgProgressHandle->SetText(channel->ChannelName());
}
/* skip if an icon is already set and exists */
if (channel->IsIconExists())
continue;
/* reset icon before searching for a new one */
channel->SetIconPath("");
std::string strChannelUid = StringUtils::Format("%08d", channel->UniqueID());
std::string strLegalClientChannelName = CUtil::MakeLegalFileName(channel->ClientChannelName());
StringUtils::ToLower(strLegalClientChannelName);
std::string strLegalChannelName = CUtil::MakeLegalFileName(channel->ChannelName());
StringUtils::ToLower(strLegalChannelName);
std::map<std::string, std::string>::iterator itItem;
if ((itItem = fileItemMap.find(strLegalClientChannelName)) != fileItemMap.end() ||
(itItem = fileItemMap.find(strLegalChannelName)) != fileItemMap.end() ||
(itItem = fileItemMap.find(strChannelUid)) != fileItemMap.end())
{
channel->SetIconPath(itItem->second, g_advancedSettings.m_bPVRAutoScanIconsUserSet);
}
if (bUpdateDb)
channel->Persist();
//! @todo start channel icon scraper here if nothing was found
}
if (dlgProgressHandle)
dlgProgressHandle->MarkFinished();
}
示例14: SearchAndSetChannelIcons
void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */)
{
std::string iconPath = CSettings::Get().GetString("pvrmenu.iconpath");
if (iconPath.empty())
return;
CPVRDatabase *database = GetPVRDatabase();
if (!database)
return;
/* fetch files in icon path for fast lookup */
CFileItemList fileItemList;
XFILE::CDirectory::GetDirectory(iconPath, fileItemList, ".jpg|.png|.tbn");
if (fileItemList.IsEmpty())
return;
CGUIDialogExtendedProgressBar* dlgProgress = (CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS);
CGUIDialogProgressBarHandle* dlgProgressHandle = dlgProgress ? dlgProgress->GetHandle(g_localizeStrings.Get(19287)) : NULL;
CSingleLock lock(m_critSection);
/* create a map for fast lookup of normalized file base name */
std::map<std::string, std::string> fileItemMap;
const VECFILEITEMS &items = fileItemList.GetList();
for(VECFILEITEMS::const_iterator it = items.begin(); it != items.end(); ++it)
{
std::string baseName = URIUtils::GetFileName((*it)->GetPath());
URIUtils::RemoveExtension(baseName);
StringUtils::ToLower(baseName);
fileItemMap.insert(std::make_pair(baseName, (*it)->GetPath()));
}
int channelIndex = 0;
for(std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); ++it)
{
CPVRChannelPtr channel = (*it).channel;
/* update progress dialog */
if (dlgProgressHandle)
{
dlgProgressHandle->SetProgress(channelIndex++, m_members.size());
dlgProgressHandle->SetText(channel->ChannelName());
}
/* skip if an icon is already set and exists */
if (channel->IsIconExists())
continue;
/* reset icon before searching for a new one */
channel->SetIconPath("");
std::string strChannelUid = StringUtils::Format("%08d", channel->UniqueID());
std::string strLegalClientChannelName = CUtil::MakeLegalFileName(channel->ClientChannelName());
StringUtils::ToLower(strLegalClientChannelName);
std::string strLegalChannelName = CUtil::MakeLegalFileName(channel->ChannelName());
StringUtils::ToLower(strLegalChannelName);
std::map<std::string, std::string>::iterator itItem;
if ((itItem = fileItemMap.find(strLegalClientChannelName)) != fileItemMap.end() ||
(itItem = fileItemMap.find(strLegalChannelName)) != fileItemMap.end() ||
(itItem = fileItemMap.find(strChannelUid)) != fileItemMap.end())
{
channel->SetIconPath(itItem->second, g_advancedSettings.m_bPVRAutoScanIconsUserSet);
}
if (bUpdateDb)
channel->Persist();
/* TODO: start channel icon scraper here if nothing was found */
}
if (dlgProgressHandle)
dlgProgressHandle->MarkFinished();
}