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; }
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; }
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; }
bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return false; bool bSyncWithBackends = g_guiSettings.GetBool("pvrmanager.syncchannelgroups"); CSingleLock lock(m_critSection); // load the other groups from the database int iSize = m_groups.size(); database->Get(*this); CLog::Log(LOGDEBUG, "PVR - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV"); // load groups from the backends if the option is enabled iSize = m_groups.size(); if (bSyncWithBackends) { GetGroupsFromClients(); CLog::Log(LOGDEBUG, "PVR - %s - %d new user defined %s channel groups fetched from clients", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV"); } else CLog::Log(LOGDEBUG, "PVR - %s - 'synchannelgroups' is disabled; skipping groups from clients", __FUNCTION__); // load group members for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) (*it)->Load(); // persist changes if we fetched groups from the backends return bSyncWithBackends ? PersistAll() : true; }
bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return false; CSingleLock lock(m_critSection); /* load the other groups from the database */ int iSize = size(); database->Get(*this); CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (size() - iSize), m_bRadio ? "radio" : "TV"); iSize = size(); GetGroupsFromClients(); CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d new user defined %s channel groups fetched from clients", __FUNCTION__, (int) (size() - iSize), m_bRadio ? "radio" : "TV"); /* load group members */ for (unsigned int iGroupPtr = 1; iGroupPtr < size(); iGroupPtr++) at(iGroupPtr)->Load(); return PersistAll(); }
int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */) { CPVRDatabase *database = OpenPVRDatabase(); if (!database) return -1; int iChannelCount = size(); if (database->Get(*this) > 0) { if (bCompress) database->Compress(true); } else { CLog::Log(LOGINFO, "PVRChannelGroupInternal - %s - no channels in the database", __FUNCTION__); } database->Close(); SortByChannelNumber(); return size() - iChannelCount; }
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; }
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; }
void CPVRClients::SaveCurrentChannelSettings(void) { CPVRChannelPtr channel; { CSingleLock lock(m_critSection); if (!GetPlayingChannel(channel) || !m_bIsValidChannelSettings) return; } CPVRDatabase *database = GetPVRDatabase(); if (!database) return; if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings) { CLog::Log(LOGDEBUG, "PVR - %s - persisting custom channel settings for channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); database->PersistChannelSettings(*channel, g_settings.m_currentVideoSettings); } else { CLog::Log(LOGDEBUG, "PVR - %s - no custom channel settings for channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); database->DeleteChannelSettings(*channel); } }
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; }
bool CPVRChannelGroupInternal::Persist(void) { bool bReturn(true); CSingleLock lock(m_critSection); bool bHasNewChannels = HasNewChannels(); bool bHasChangedChannels = HasChangedChannels(); /* open the database */ CPVRDatabase *database = OpenPVRDatabase(); if (!database) return false; 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++) { CPVRChannel *channel = at(iChannelPtr).channel; if (!channel->Persist()) { CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); bReturn = false; } } lock.Leave(); } else if (bHasChangedChannels) { /* queue queries */ for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) at(iChannelPtr).channel->Persist(true); lock.Leave(); /* and commit them */ bReturn = database->CommitInsertQueries(); if (!bReturn) CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channels", __FUNCTION__); } if (bReturn) bReturn = CPVRChannelGroup::Persist(); database->Close(); return bReturn; }
bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return false; bool bSyncWithBackends = CSettings::Get().GetBool("pvrmanager.syncchannelgroups"); CSingleLock lock(m_critSection); // load the other groups from the database int iSize = m_groups.size(); database->Get(*this); CLog::Log(LOGDEBUG, "PVR - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV"); // load groups from the backends if the option is enabled iSize = m_groups.size(); if (bSyncWithBackends) { GetGroupsFromClients(); CLog::Log(LOGDEBUG, "PVR - %s - %d new user defined %s channel groups fetched from clients", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV"); } else CLog::Log(LOGDEBUG, "PVR - %s - 'synchannelgroups' is disabled; skipping groups from clients", __FUNCTION__); std::vector<CPVRChannelGroupPtr> emptyGroups; // load group members for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++) { // load only user defined groups, as internal group is already loaded if (!(*it)->IsInternalGroup()) { if (!(*it)->Load()) { CLog::Log(LOGDEBUG, "PVR - %s - failed to load channel group '%s'", __FUNCTION__, (*it)->GroupName().c_str()); return false; } // remove empty groups when sync with backend is enabled if (bSyncWithBackends && (*it)->Size() == 0) emptyGroups.push_back(*it); } } for (std::vector<CPVRChannelGroupPtr>::iterator it = emptyGroups.begin(); it != emptyGroups.end(); it++) { CLog::Log(LOGDEBUG, "PVR - %s - deleting empty group '%s'", __FUNCTION__, (*it)->GroupName().c_str()); DeleteGroup(*(*it)); } // persist changes if we fetched groups from the backends return bSyncWithBackends ? PersistAll() : true; }
int CPVRClients::RegisterClient(AddonPtr client, bool* newRegistration/*=NULL*/) { int iClientId(-1); if (newRegistration) *newRegistration = false; if (!client->Enabled()) return -1; CLog::Log(LOGDEBUG, "%s - registering add-on '%s'", __FUNCTION__, client->Name().c_str()); CPVRDatabase *database = GetPVRDatabase(); if (!database) return -1; // check whether we already know this client iClientId = database->GetClientId(client->ID()); // try to register the new client in the db if (iClientId < 0) { if ((iClientId = database->Persist(client)) < 0) { CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, client->Name().c_str()); return -1; } else if (newRegistration) *newRegistration = true; } PVR_CLIENT addon; // load and initialise the client libraries { CSingleLock lock(m_critSection); PVR_CLIENTMAP_CITR existingClient = m_clientMap.find(iClientId); if (existingClient != m_clientMap.end()) { // return existing client addon = existingClient->second; } else { // create a new client instance addon = boost::dynamic_pointer_cast<CPVRClient>(client); m_clientMap.insert(std::make_pair(iClientId, addon)); } } if (iClientId < 0) CLog::Log(LOGERROR, "PVR - %s - can't register add-on '%s'", __FUNCTION__, client->Name().c_str()); return iClientId; }
int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return -1; int iChannelCount = Size(); database->Get(*this); return Size() - iChannelCount; }
int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */) { CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (!database || !database->Open()) return -1; int iChannelCount = size(); database->GetChannelsInGroup(this); database->Close(); return size() - iChannelCount; }
int CPVRClients::AddClientToDb(const CStdString &strClientId, const CStdString &strName) { /* add this client to the database if it's not in there yet */ CPVRDatabase *database = OpenPVRDatabase(); int iClientDbId = database ? database->AddClient(strName, strClientId) : -1; if (iClientDbId == -1) { CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, strName.c_str()); } return iClientDbId; }
int CPVRClients::AddClientToDb(const AddonPtr client) { /* add this client to the database if it's not in there yet */ CPVRDatabase *database = GetPVRDatabase(); int iClientDbId = database ? database->Persist(client) : -1; if (iClientDbId == -1) { CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, client->Name().c_str()); } return iClientDbId; }
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; }
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; }
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; }
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); } }
bool CPVRChannelGroups::Load(void) { CPVRDatabase *database = GetPVRDatabase(); if (!database) return false; CSingleLock lock(m_critSection); // remove previous contents Clear(); CLog::Log(LOGDEBUG, "CPVRChannelGroups - %s - loading all %s channel groups", __FUNCTION__, m_bRadio ? "radio" : "TV"); // create the internal channel group CPVRChannelGroupPtr internalGroup = CPVRChannelGroupPtr(new CPVRChannelGroupInternal(m_bRadio)); m_groups.push_back(internalGroup); // load groups from the database database->Get(*this); CLog::Log(LOGDEBUG, "CPVRChannelGroups - %s - %" PRIuS" %s groups fetched from the database", __FUNCTION__, m_groups.size(), m_bRadio ? "radio" : "TV"); // load channels of internal group if (!internalGroup->Load()) { CLog::Log(LOGERROR, "CPVRChannelGroups - %s - failed to load channels", __FUNCTION__); return false; } // load the other groups from the database if (!LoadUserDefinedChannelGroups()) { CLog::Log(LOGERROR, "CPVRChannelGroups - %s - failed to load channel groups", __FUNCTION__); return false; } // set the last played group as selected group at startup CPVRChannelGroupPtr lastPlayedGroup = GetLastPlayedGroup(); SetSelectedGroup(lastPlayedGroup ? lastPlayedGroup : internalGroup); CLog::Log(LOGDEBUG, "CPVRChannelGroups - %s - %" PRIuS" %s channel groups loaded", __FUNCTION__, m_groups.size(), m_bRadio ? "radio" : "TV"); // need at least 1 group return m_groups.size() > 0; }
bool CPVRChannel::Delete(void) { bool bReturn = false; CPVRDatabase *database = GetPVRDatabase(); if (!database) return bReturn; /* delete the EPG table */ CEpg *epg = GetEPG(); if (epg) { g_EpgContainer.DeleteEpg(*epg, true); CSingleLock lock(m_critSection); m_bEPGCreated = false; } bReturn = database->Delete(*this); return bReturn; }
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(); }
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; }
bool CPVRChannelGroup::Persist(void) { CSingleLock lock(m_critSection); if (!HasChanges()) return true; CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (database && database->Open()) { CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - persisting channel group '%s' with %d channels", __FUNCTION__, GroupName().c_str(), (int) size()); database->Persist(this); database->Close(); m_bChanged = false; return true; } return false; }
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; }
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; }
void CPVRChannels::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) { if (g_guiSettings.GetString("pvrmenu.iconpath") == "") return; CPVRDatabase *database = g_PVRManager.GetTVDatabase(); database->Open(); for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRChannel *channel = at(ptr); /* skip if an icon is already set */ if (channel->IconPath() != "") continue; CStdString strBasePath = g_guiSettings.GetString("pvrmenu.iconpath"); CStdString strIconPath = strBasePath + channel->ClientChannelName(); CStdString strIconPathLower = strBasePath + channel->ClientChannelName().ToLower(); CStdString strIconPathUid; strIconPathUid.Format("%s/%08d", strBasePath, channel->UniqueID()); channel->SetIconPath(strIconPath + ".tbn", bUpdateDb) || channel->SetIconPath(strIconPath + ".jpg", bUpdateDb) || channel->SetIconPath(strIconPath + ".png", bUpdateDb) || channel->SetIconPath(strIconPathLower + ".tbn", bUpdateDb) || channel->SetIconPath(strIconPathLower + ".jpg", bUpdateDb) || channel->SetIconPath(strIconPathLower + ".png", bUpdateDb) || channel->SetIconPath(strIconPathUid + ".tbn", bUpdateDb) || channel->SetIconPath(strIconPathUid + ".jpg", bUpdateDb) || channel->SetIconPath(strIconPathUid + ".png", bUpdateDb); /* TODO: start channel icon scraper here if nothing was found */ } database->Close(); }
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; }