Beispiel #1
0
 SettingList (const  SettingList&  sl):
     KKQueue<Setting> (true)
 {
   kkuint32 x;
   for  (x = 0;  x < sl.size ();  x++)
   {
     SettingPtr  setting = sl.IdxToPtr (x);
     PushOnBack (new Configuration::Setting (*setting));
   }
 }
Beispiel #2
0
SettingList CSettingGroup::GetSettings(SettingLevel level) const
{
  SettingList settings;

  for (SettingList::const_iterator it = m_settings.begin(); it != m_settings.end(); it++)
  {
    if ((*it)->GetLevel() <= level && (*it)->IsVisible())
      settings.push_back(*it);
  }

  return settings;
}
Beispiel #3
0
SettingList CSettingGroup::GetSettings(SettingLevel level) const
{
  SettingList settings;

  for (SettingList::const_iterator it = m_settings.begin(); it != m_settings.end(); ++it)
  {
    if ((*it)->GetLevel() <= level && (*it)->MeetsRequirements())
      settings.push_back(*it);
  }

  return settings;
}
Beispiel #4
0
JSONRPC_STATUS CSettingsOperations::GetCategories(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  SettingLevel level = (SettingLevel)ParseSettingLevel(parameterObject["level"].asString());
  std::string strSection = parameterObject["section"].asString();
  bool listSettings = !parameterObject["properties"].empty() && parameterObject["properties"][0].asString() == "settings";

  std::vector<SettingSectionPtr> sections;
  if (!strSection.empty())
  {
    SettingSectionPtr section = CServiceBroker::GetSettings().GetSection(strSection);
    if (section == NULL)
      return InvalidParams;

    sections.push_back(section);
  }
  else
    sections = CServiceBroker::GetSettings().GetSections();

  result["categories"] = CVariant(CVariant::VariantTypeArray);

  for (std::vector<SettingSectionPtr>::const_iterator itSection = sections.begin(); itSection != sections.end(); ++itSection)
  {
    SettingCategoryList categories = (*itSection)->GetCategories(level);
    for (SettingCategoryList::const_iterator itCategory = categories.begin(); itCategory != categories.end(); ++itCategory)
    {
      CVariant varCategory(CVariant::VariantTypeObject);
      if (!SerializeSettingCategory(*itCategory, varCategory))
        continue;

      if (listSettings)
      {
        varCategory["groups"] = CVariant(CVariant::VariantTypeArray);

        SettingGroupList groups = (*itCategory)->GetGroups(level);
        for (SettingGroupList::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)
        {
          CVariant varGroup(CVariant::VariantTypeObject);
          if (!SerializeSettingGroup(*itGroup, varGroup))
            continue;

          varGroup["settings"] = CVariant(CVariant::VariantTypeArray);
          SettingList settings = (*itGroup)->GetSettings(level);
          for (SettingList::const_iterator itSetting = settings.begin(); itSetting != settings.end(); ++itSetting)
          {
            if ((*itSetting)->IsVisible())
            {
              CVariant varSetting(CVariant::VariantTypeObject);
              if (!SerializeSetting(*itSetting, varSetting))
                continue;

              varGroup["settings"].push_back(varSetting);
            }
          }

          varCategory["groups"].push_back(varGroup);
        }
      }
      
      result["categories"].push_back(varCategory);
    }
  }

  return OK;
}
Beispiel #5
0
JSONRPC_STATUS CSettingsOperations::GetSettings(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  SettingLevel level = (SettingLevel)ParseSettingLevel(parameterObject["level"].asString());
  const CVariant &filter = parameterObject["filter"];
  bool doFilter = filter.isMember("section") && filter.isMember("category");
  std::string strSection, strCategory;
  if (doFilter)
  {
    strSection = filter["section"].asString();
    strCategory = filter["category"].asString();
  }
 
  std::vector<SettingSectionPtr> sections;

  if (doFilter)
  {
    SettingSectionPtr section = CServiceBroker::GetSettings().GetSection(strSection);
    if (section == NULL)
      return InvalidParams;

    sections.push_back(section);
  }
  else
    sections = CServiceBroker::GetSettings().GetSections();

  result["settings"] = CVariant(CVariant::VariantTypeArray);

  for (std::vector<SettingSectionPtr>::const_iterator itSection = sections.begin(); itSection != sections.end(); ++itSection)
  {
    SettingCategoryList categories = (*itSection)->GetCategories(level);
    bool found = !doFilter;
    for (SettingCategoryList::const_iterator itCategory = categories.begin(); itCategory != categories.end(); ++itCategory)
    {
      if (!doFilter || StringUtils::EqualsNoCase((*itCategory)->GetId(), strCategory))
      {
        SettingGroupList groups = (*itCategory)->GetGroups(level);
        for (SettingGroupList::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)
        {
          SettingList settings = (*itGroup)->GetSettings(level);
          for (SettingList::const_iterator itSetting = settings.begin(); itSetting != settings.end(); ++itSetting)
          {
            if ((*itSetting)->IsVisible())
            {
              CVariant varSetting(CVariant::VariantTypeObject);
              if (!SerializeSetting(*itSetting, varSetting))
                continue;

              result["settings"].push_back(varSetting);
            }
          }
        }
        found = true;

        if (doFilter)
          break;
      }
    }

    if (doFilter && !found)
      return InvalidParams;
  }

  return OK;
}
Beispiel #6
0
void CSettingGroup::AddSettings(const SettingList &settings)
{
  for (SettingList::const_iterator itSetting = settings.begin(); itSetting != settings.end(); ++itSetting)
    addISetting(NULL, *itSetting, m_settings);
}