bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups) { CSingleLock lock(m_critSection); // go through groups list and check for deleted groups for (int iGroupPtr = m_groups.size() - 1; iGroupPtr > 0; iGroupPtr--) { CPVRChannelGroup existingGroup(*m_groups.at(iGroupPtr)); CPVRChannelGroupPtr group = groups.GetByName(existingGroup.GroupName()); // user defined group wasn't found if (existingGroup.GroupType() == PVR_GROUP_TYPE_DEFAULT && !group) { CLog::Log(LOGDEBUG, "PVR - %s - user defined group %s with id '%u' does not exist on the client anymore; deleting it", __FUNCTION__, existingGroup.GroupName().c_str(), existingGroup.GroupID()); DeleteGroup(*m_groups.at(iGroupPtr)); } } // go through the groups list and check for new groups for (std::vector<CPVRChannelGroupPtr>::const_iterator it = groups.m_groups.begin(); it != m_groups.end(); it++) { // check if this group is present in this container CPVRChannelGroupPtr existingGroup = GetByName((*it)->GroupName()); // add it if not if (!existingGroup) m_groups.push_back(CPVRChannelGroupPtr(new CPVRChannelGroup(m_bRadio, -1, (*it)->GroupName()))); } return true; }
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; }