当前位置: 首页>>代码示例>>C++>>正文


C++ Form::editable_list方法代码示例

本文整理汇总了C++中ekiga::Form::editable_list方法的典型用法代码示例。如果您正苦于以下问题:C++ Form::editable_list方法的具体用法?C++ Form::editable_list怎么用?C++ Form::editable_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ekiga::Form的用法示例。


在下文中一共展示了Form::editable_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bool
Opal::Presentity::edit_presentity_form_submitted (bool submitted,
                                                  Ekiga::Form &result,
                                                  std::string &error)
{
  if (!submitted)
    return false;

  const std::string new_name = result.text ("name");
  const std::list<std::string> groups = get_groups ();
  const std::list<std::string> new_groups = result.editable_list ("groups");
  std::string new_uri = result.text ("uri");
  const std::string uri = get_uri ();
  std::set<xmlNodePtr> nodes_to_remove;

  if (new_name.empty ()) {
    error = _("You did not provide a valid name");
    return false;
  }
  else if (new_uri.empty ()) {
    error = _("You did not provide a valid address");
    return false;
  }

  new_uri = canonize_uri (new_uri);

  for (xmlNodePtr child = node->children ;
       child != NULL ;
       child = child->next) {

    if (child->type == XML_ELEMENT_NODE
        && child->name != NULL)
      if (xmlStrEqual (BAD_CAST ("name"), child->name))
        robust_xmlNodeSetContent (node, &child, "name", new_name);
  }

  if (uri != new_uri) {
    xmlSetProp (node, (const xmlChar*)"uri", (const xmlChar*)new_uri.c_str ());
    account.unfetch (uri);
    account.fetch (new_uri);
    Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::presence_status_in_main, &account, new_uri, "unknown", ""));
  }

  // the first loop looks at groups we were in: are we still in?
  for (xmlNodePtr child = node->children ;
       child != NULL ;
       child = child->next) {

    if (child->type == XML_ELEMENT_NODE
        && child->name != NULL) {

      if (xmlStrEqual (BAD_CAST ("group"), child->name)) {

        xmlChar* xml_str = xmlNodeGetContent (child);

        if (xml_str != NULL) {
          if (std::find (new_groups.begin (), new_groups.end (), (const char*) xml_str) == new_groups.end ())
            nodes_to_remove.insert (child); // don't free what we loop on!
          xmlFree (xml_str);
        }
      }
    }
  }

  // ok, now we can clean up!
  for (std::set<xmlNodePtr>::iterator iter = nodes_to_remove.begin ();
       iter != nodes_to_remove.end ();
       ++iter) {

    xmlUnlinkNode (*iter);
    xmlFreeNode (*iter);
  }

  // the second loop looks for groups we weren't in but are now
  for (std::list<std::string>::const_iterator iter = new_groups.begin ();
       iter != new_groups.end ();
       iter++) {

    if (std::find (groups.begin (), groups.end (), *iter) == groups.end ())
      xmlNewChild (node, NULL,
                   BAD_CAST "group",
                   BAD_CAST robust_xmlEscape (node->doc, *iter).c_str ());
  }

  updated (this->shared_from_this ());
  trigger_saving ();

  return true;
}
开发者ID:GNOME,项目名称:ekiga,代码行数:89,代码来源:opal-presentity.cpp


注:本文中的ekiga::Form::editable_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。