bool CPVRDatabase::GetChannelGroupList(CPVRChannelGroups &results, bool bRadio /* = false */) { bool bReturn = false; CStdString strQuery = FormatSQL("SELECT * from ChannelGroup WHERE IsRadio = %u ORDER BY sortOrder\n", bRadio); int iNumRows = ResultQuery(strQuery); if (iNumRows > 0) { try { while (!m_pDS->eof()) { CPVRChannelGroup data; data.SetGroupID(m_pDS->fv("GroupId").get_asInt()); data.SetGroupName(m_pDS->fv("Name").get_asString()); data.SetSortOrder(m_pDS->fv("SortOrder").get_asInt()); results.push_back(data); m_pDS->next(); } bReturn = true; } catch (...) { CLog::Log(LOGERROR, "%s - couldn't load channels from the database", __FUNCTION__); } } m_pDS->close(); return bReturn; }
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 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 CPVRChannelGroups::AddGroup(const CStdString &strName) { bool bReturn = false; CPVRChannelGroup *group = (CPVRChannelGroup *) GetByName(strName); if (!group) { group = new CPVRChannelGroup(m_bRadio); group->SetGroupName(strName); push_back(group); bReturn = group->Persist(); } else { bReturn = true; } return bReturn; }