Пример #1
0
bool CPVRChannelGroups::Update(const CPVRChannelGroup &group, bool bSaveInDb)
{
  CSingleLock lock(m_critSection);

  int iIndex = -1;
  /* try to find the group by id */
  if (group.GroupID() > 0)
    iIndex = GetIndexForGroupID(group.GroupID());
  /* try to find the group by name if we didn't find it yet */
  if (iIndex < 0)
    iIndex = GetIndexForGroupName(group.GroupName());

  if (iIndex < 0)
  {
    CPVRChannelGroup *newGroup = new CPVRChannelGroup(m_bRadio, group.GroupID(), group.GroupName());
    if (bSaveInDb)
      newGroup->Persist();

    push_back(newGroup);
  }
  else
  {
    at(iIndex)->SetGroupID(group.GroupID());
    at(iIndex)->SetGroupName(group.GroupName());

    if (bSaveInDb)
      at(iIndex)->Persist();
  }

  return true;
}
Пример #2
0
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;
}