本文整理汇总了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;
}