本文整理汇总了C++中CPVRDatabase::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ CPVRDatabase::Open方法的具体用法?C++ CPVRDatabase::Open怎么用?C++ CPVRDatabase::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPVRDatabase
的用法示例。
在下文中一共展示了CPVRDatabase::Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveOldEntries
bool CPVREpgs::RemoveOldEntries()
{
bool bReturn = false;
CLog::Log(LOGINFO, "PVREpgs - %s - removing old EPG entries",
__FUNCTION__);
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
CDateTime now = CDateTime::GetCurrentDateTime();
if (!database->Open())
{
CLog::Log(LOGERROR, "PVREpgs - %s - cannot open the database",
__FUNCTION__);
return bReturn;
}
/* call Cleanup() on all known EPG tables */
for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
{
at(iEpgPtr)->Cleanup(now);
}
/* remove the old entries from the database */
bReturn = database->EraseOldEpgEntries();
if (bReturn)
CDateTime::GetCurrentDateTime().GetAsTime(m_iLastEpgCleanup);
return bReturn;
}
示例2: Clear
void CPVREpgs::Clear(bool bClearDb /* = false */)
{
/* remove all pointers to epg tables on timers */
for (unsigned int iTimerPtr = 0; iTimerPtr < PVRTimers.size(); iTimerPtr++)
PVRTimers[iTimerPtr].SetEpgInfoTag(NULL);
/* clear all epg tables and remove pointers to epg tables on channels */
for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
{
CPVREpg *epg = at(iEpgPtr);
epg->Clear();
CPVRChannel *channel = (CPVRChannel *) epg->Channel();
if (channel)
channel->m_EPG = NULL;
}
/* remove all EPG tables */
clear();
/* clear the database entries */
if (bClearDb)
{
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
database->Open();
database->EraseEpg();
database->Close();
}
m_iLastEpgUpdate = 0;
m_bDatabaseLoaded = false;
}
示例3: LoadFromClients
int CPVRChannels::LoadFromClients(bool bAddToDb /* = true */)
{
CPVRDatabase *database = NULL;
int iCurSize = size();
if (bAddToDb)
{
database = g_PVRManager.GetTVDatabase();
if (!database || !database->Open())
return -1;
}
if (GetFromClients() == -1)
return -1;
SortByClientChannelNumber();
ReNumberAndCheck();
SearchAndSetChannelIcons();
if (bAddToDb)
{
/* add all channels to the database */
for (unsigned int ptr = 0; ptr < size(); ptr++)
database->UpdateChannel(*at(ptr));
database->Close();
clear();
return LoadFromDb(true);
}
return size() - iCurSize;
}
示例4: LoadFromDb
int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */)
{
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
if (!database || !database->Open())
return -1;
int iChannelCount = size();
if (database->GetChannels(this, m_bRadio) > 0)
{
if (bCompress)
database->Compress(true);
}
else
{
CLog::Log(LOGINFO, "PVRChannelGroupInternal - %s - no channels in the database",
__FUNCTION__);
}
database->Close();
SortByChannelNumber();
return size() - iChannelCount;
}
示例5: Load
bool CPVRChannelGroups::Load(void)
{
CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - loading all %s channel groups",
__FUNCTION__, m_bRadio ? "radio" : "TV");
Clear();
/* create internal channel group */
CPVRChannelGroupInternal *internalChannels = new CPVRChannelGroupInternal(m_bRadio);
push_back(internalChannels);
internalChannels->Load();
/* load the other groups from the database */
CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
if (database->Open())
{
database->GetChannelGroupList(*this, m_bRadio);
/* load group members */
for (unsigned int iGroupPtr = 1; iGroupPtr < size(); iGroupPtr++)
at(iGroupPtr)->Load();
database->Close();
}
CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d %s channel groups loaded",
__FUNCTION__, size(), m_bRadio ? "radio" : "TV");
return true;
}
示例6: LoadFromDb
bool CPVREpgs::LoadFromDb(bool bShowProgress /* = false */)
{
if (m_bDatabaseLoaded)
return m_bDatabaseLoaded;
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
/* show the progress bar */
CGUIDialogPVRUpdateProgressBar *scanner = NULL;
if (bShowProgress)
{
scanner = (CGUIDialogPVRUpdateProgressBar *)g_windowManager.GetWindow(WINDOW_DIALOG_EPG_SCAN);
scanner->Show();
scanner->SetHeader(g_localizeStrings.Get(19004));
}
/* open the database */
database->Open();
/* load all EPG tables */
bool bLoaded = false;
unsigned int iSize = size();
for (unsigned int iEpgPtr = 0; iEpgPtr < iSize; iEpgPtr++)
{
CPVREpg *epg = at(iEpgPtr);
CPVRChannel *channel = epg->Channel();
if (epg->LoadFromDb())
{
if (channel)
channel->UpdateEPGPointers();
bLoaded = true;
}
if (bShowProgress)
{
/* update the progress bar */
if (channel)
scanner->SetTitle(channel->ChannelName());
scanner->SetProgress(iEpgPtr, iSize);
scanner->UpdateState();
}
}
/* close the database */
database->Close();
if (bShowProgress)
scanner->Close();
m_bDatabaseLoaded = bLoaded;
return bLoaded;
}
示例7: Persist
bool CPVRChannelGroupInternal::Persist(void)
{
bool bReturn(true);
CSingleLock lock(m_critSection);
bool bHasNewChannels = HasNewChannels();
bool bHasChangedChannels = HasChangedChannels();
if (bHasNewChannels || bHasChangedChannels)
CLog::Log(LOGDEBUG, "CPVRChannelGroupInternal - %s - persisting %d channels",
__FUNCTION__, (int) size());
if (bHasNewChannels)
{
CLog::Log(LOGDEBUG, "CPVRChannelGroupInternal - %s - group '%s' has new channels. writing changes directly",
__FUNCTION__, GroupName().c_str());
/* write directly to get channel ids */
for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
{
if (!at(iChannelPtr).channel->Persist())
{
CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channel '%s'",
__FUNCTION__, at(iChannelPtr).channel->ChannelName().c_str());
bReturn = false;
}
}
}
else if (bHasChangedChannels)
{
/* open the database */
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
if (!database || !database->Open())
{
CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to open the database", __FUNCTION__);
return false;
}
/* queue queries */
for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
at(iChannelPtr).channel->Persist(true);
/* and commit them */
bReturn = database->CommitInsertQueries();
if (!bReturn)
CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channels", __FUNCTION__);
database->Close();
}
if (bReturn)
bReturn = CPVRChannelGroup::Persist();
return bReturn;
}
示例8: Update
bool CPVRChannelGroupInternal::Update()
{
bool bReturn = false;
CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
if (database && database->Open())
{
CPVRChannelGroupInternal PVRChannels_tmp(m_bRadio);
PVRChannels_tmp.LoadFromClients(false);
bReturn = UpdateGroupEntries(&PVRChannels_tmp);
database->Close();
}
return bReturn;
}
示例9: Update
bool CPVRChannels::Update()
{
bool bReturn = false;
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
if (database && database->Open())
{
CPVRChannels PVRChannels_tmp(m_bRadio);
PVRChannels_tmp.LoadFromClients(false);
bReturn = Update(&PVRChannels_tmp);
database->Close();
}
return bReturn;
}
示例10: MoveChannel
void CPVRChannels::MoveChannel(unsigned int iOldIndex, unsigned int iNewIndex)
{
if (iNewIndex == iOldIndex || iNewIndex == 0)
return;
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
database->Open();
CPVRChannels tempChannels(m_bRadio);
/* move the channel */
tempChannels.push_back(at(iOldIndex - 1));
erase(begin() + iOldIndex - 1);
if (iNewIndex < size())
insert(begin() + iNewIndex - 1, tempChannels[0]);
else
push_back(tempChannels[0]);
/* update the channel numbers */
for (unsigned int ptr = 0; ptr < size(); ptr++)
{
CPVRChannel *channel = at(ptr);
if (channel->ChannelNumber() != (int) ptr + 1)
{
channel->SetChannelNumber(ptr + 1, true);
}
}
CLog::Log(LOGNOTICE, "%s - %s channel '%d' moved to '%d'",
__FUNCTION__, (m_bRadio ? "radio" : "tv"), iOldIndex, iNewIndex);
database->Close();
/* update the timers with the new channel numbers */
for (unsigned int ptr = 0; ptr < PVRTimers.size(); ptr++)
{
CPVRTimerInfoTag timer = PVRTimers[ptr];
CPVRChannel *tag = GetByClient(timer.Number(), timer.ClientID());
if (tag)
timer.SetNumber(tag->ChannelNumber());
}
m_bIsSorted = false;
}
示例11: Process
void CPVREpgs::Process()
{
time_t iNow = 0;
m_iLastPointerUpdate = 0;
m_iLastTimerUpdate = 0;
m_iLastEpgCleanup = 0;
m_iLastEpgUpdate = 0;
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
if (!database->Open())
{
CLog::Log(LOGERROR, "PVREpgs - %s - cannot open the database",
__FUNCTION__);
return;
}
/* get the last EPG update time from the database */
database->GetLastEpgScanTime().GetAsTime(m_iLastEpgUpdate);
database->Close();
LoadSettings();
while (!m_bStop)
{
CDateTime::GetCurrentDateTime().GetAsTime(iNow);
/* update the EPG */
if (!m_bStop && (iNow > m_iLastEpgUpdate + m_iUpdateTime || !m_bDatabaseLoaded))
UpdateEPG(!m_bDatabaseLoaded);
/* update the "now playing" pointers every 60 seconds */
if (!m_bStop && iNow > m_iLastPointerUpdate + 60)
UpdateAllChannelEPGPointers();
/* update the timers every 60 seconds */
if (!m_bStop && iNow > m_iLastTimerUpdate + 60)
UpdateTimers();
/* remove old entries every 30 minutes */
if (!m_bStop && iNow > m_iLastEpgCleanup + 1800)
RemoveOldEntries();
Sleep(1000);
}
}
示例12: SearchAndSetChannelIcons
void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */)
{
if (g_guiSettings.GetString("pvrmenu.iconpath") == "")
return;
CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
database->Open();
CSingleLock lock(m_critSection);
for (unsigned int ptr = 0; ptr < size(); ptr++)
{
PVRChannelGroupMember groupMember = at(ptr);
/* skip if an icon is already set */
if (groupMember.channel->IconPath() != "")
continue;
CStdString strBasePath = g_guiSettings.GetString("pvrmenu.iconpath");
CStdString strChannelName = groupMember.channel->ClientChannelName();
CStdString strIconPath = strBasePath + groupMember.channel->ClientChannelName();
CStdString strIconPathLower = strBasePath + strChannelName.ToLower();
CStdString strIconPathUid;
strIconPathUid.Format("%s/%08d", strBasePath, groupMember.channel->UniqueID());
groupMember.channel->SetIconPath(strIconPath + ".tbn", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPath + ".jpg", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPath + ".png", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathLower + ".tbn", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathLower + ".jpg", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathLower + ".png", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathUid + ".tbn", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathUid + ".jpg", bUpdateDb) ||
groupMember.channel->SetIconPath(strIconPathUid + ".png", bUpdateDb);
/* TODO: start channel icon scraper here if nothing was found */
}
database->Close();
}
示例13: LoadFromDb
int CPVRChannels::LoadFromDb(bool bCompress /* = false */)
{
CPVRDatabase *database = g_PVRManager.GetTVDatabase();
if (!database || !database->Open())
return -1;
int iChannelCount = size();
if (database->GetChannels(*this, m_bRadio) > 0)
{
if (bCompress)
database->Compress(true);
Update();
}
database->Close();
return size() - iChannelCount;
}
示例14: Delete
bool CPVRChannel::Delete(void)
{
bool bReturn = false;
CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
if (!database || !database->Open())
return bReturn;
/* delete the EPG table */
if (m_EPG)
{
CPVRManager::GetEpg()->DeleteEpg(*m_EPG, true);
m_EPG = NULL;
}
bReturn = database->Delete(*this);
database->Close();
return bReturn;
}
示例15: Persist
bool CPVRChannel::Persist(bool bQueueWrite /* = false */)
{
CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
if (database)
{
if (!bQueueWrite)
{
database->Open();
m_iChannelId = database->Persist(*this, false);
database->Close();
return m_iChannelId > 0;
}
else
{
database->Persist(*this, true);
return true;
}
}
return false;
}