void RL::Heap::on_edit_form_submitted (bool submitted, Ekiga::Form& result) { if (!submitted) return; std::string name_str = result.text ("name"); std::string root_str = result.text ("root"); std::string user_str = result.text ("user"); std::string username_str = result.text ("username"); std::string password_str = result.private_text ("password"); bool writable = result.boolean ("writable"); if (writable) xmlSetProp (node, BAD_CAST "writable", BAD_CAST "1"); else xmlSetProp (node, BAD_CAST "writable", BAD_CAST "0"); robust_xmlNodeSetContent (node, &name, "name", name_str); robust_xmlNodeSetContent (node, &root, "root", root_str); robust_xmlNodeSetContent (node, &user, "user", user_str); robust_xmlNodeSetContent (node, &username, "username", username_str); robust_xmlNodeSetContent (node, &password, "password", password_str); trigger_saving.emit (); updated.emit (); refresh (); }
bool OPENLDAP::Book::on_edit_form_submitted (bool submitted, Ekiga::Form &result, std::string &error) { if (!submitted) return false; if (OPENLDAP::BookFormInfo (result, bookinfo, error)) { return false; } robust_xmlNodeSetContent (node, &name_node, "name", bookinfo.name); robust_xmlNodeSetContent (node, &uri_node, "uri", bookinfo.uri); robust_xmlNodeSetContent (node, &authcID_node, "authcID", bookinfo.authcID); robust_xmlNodeSetContent (node, &password_node, "password", bookinfo.password); if (bookinfo.uri_host == EKIGA_NET_URI) I_am_an_ekiga_net_book = true; else I_am_an_ekiga_net_book = false; updated (this->shared_from_this ()); trigger_saving (); return true; }
void RL::Presentity::edit_presentity_form_submitted (bool submitted, Ekiga::Form &result) { if (!submitted) return; const std::string new_name = result.text ("name"); const std::string new_uri = result.text ("uri"); const std::set<std::string> new_groups = result.editable_set ("groups"); std::map<std::string, xmlNodePtr> future_group_nodes; xmlNsPtr ns = xmlSearchNsByHref (node->doc, node, BAD_CAST "http://www.ekiga.org"); bool reload = false; robust_xmlNodeSetContent (node, &name_node, "name", new_name); if (uri != new_uri) { xmlSetProp (node, (const xmlChar*)"uri", (const xmlChar*)uri.c_str ()); boost::shared_ptr<Ekiga::PresenceCore> presence_core(services.get<Ekiga::PresenceCore> ("presence-core")); presence_core->unfetch_presence (uri); reload = true; } for (std::map<std::string, xmlNodePtr>::const_iterator iter = group_nodes.begin (); iter != group_nodes.end () ; iter++) { if (new_groups.find (iter->first) == new_groups.end ()) { xmlUnlinkNode (iter->second); xmlFreeNode (iter->second); } else { future_group_nodes[iter->first] = iter->second; } } for (std::set<std::string>::const_iterator iter = new_groups.begin (); iter != new_groups.end (); iter++) { if (std::find (groups.begin (), groups.end (), *iter) == groups.end ()) future_group_nodes[*iter] = xmlNewChild (node, ns, BAD_CAST "group", BAD_CAST robust_xmlEscape (node->doc, *iter).c_str ()); } group_nodes = future_group_nodes; groups = new_groups; save (reload); }
void Local::Presentity::edit_presentity_form_submitted (bool submitted, Ekiga::Form &result) { if (!submitted) return; const std::string new_name = result.text ("name"); const std::set<std::string> groups = get_groups (); const std::set<std::string> new_groups = result.editable_set ("groups"); std::string new_uri = result.text ("uri"); const std::string uri = get_uri (); bool preferred = result.boolean ("preferred"); std::set<xmlNodePtr> nodes_to_remove; 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) { boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock (); if (pcore) { pcore->unfetch_presence (uri); pcore->fetch_presence (new_uri); } presence = "unknown"; xmlSetProp (node, (const xmlChar*)"uri", (const xmlChar*)new_uri.c_str ()); } // 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 (new_groups.find ((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 looking for groups we weren't in but are now for (std::set<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 ()); } } if (preferred) { xmlSetProp (node, BAD_CAST "preferred", BAD_CAST "true"); } else { xmlSetProp (node, BAD_CAST "preferred", BAD_CAST "false"); } updated (); trigger_saving (); }
OPENLDAP::Book::Book (Ekiga::ServiceCore &_core, boost::shared_ptr<xmlDoc> _doc, xmlNodePtr _node): saslform(NULL), core(_core), doc(_doc), node(_node), name_node(NULL), uri_node(NULL), authcID_node(NULL), password_node(NULL), ldap_context(NULL), patience(0) { xmlChar *xml_str; bool upgrade_config = false; /* for previous config */ std::string hostname="", port="", base="", scope="", call_attribute=""; xmlNodePtr hostname_node = NULL, port_node = NULL, base_node = NULL, scope_node = NULL, call_attribute_node = NULL; bookinfo.name = ""; bookinfo.uri = ""; bookinfo.authcID = ""; bookinfo.password = ""; bookinfo.saslMech = ""; bookinfo.sasl = false; bookinfo.starttls = false; 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)) { xml_str = xmlNodeGetContent (child); bookinfo.name = (const char *)xml_str; xmlFree (xml_str); name_node = child; continue; } if (xmlStrEqual (BAD_CAST ("uri"), child->name)) { xml_str = xmlNodeGetContent (child); bookinfo.uri = (const char *)xml_str; xmlFree (xml_str); uri_node = child; continue; } if (xmlStrEqual (BAD_CAST ("hostname"), child->name)) { xml_str = xmlNodeGetContent (child); hostname = (const char *)xml_str; hostname_node = child; xmlFree (xml_str); upgrade_config = true; continue; } if (xmlStrEqual (BAD_CAST ("port"), child->name)) { xml_str = xmlNodeGetContent (child); port = (const char *)xml_str; port_node = child; xmlFree (xml_str); upgrade_config = true; continue; } if (xmlStrEqual (BAD_CAST ("base"), child->name)) { xml_str = xmlNodeGetContent (child); base = (const char *)xml_str; base_node = child; xmlFree (xml_str); upgrade_config = true; continue; } if (xmlStrEqual (BAD_CAST ("scope"), child->name)) { xml_str = xmlNodeGetContent (child); scope = (const char *)xml_str; scope_node = child; xmlFree (xml_str); upgrade_config = true; continue; } if (xmlStrEqual (BAD_CAST ("call_attribute"), child->name)) { xml_str = xmlNodeGetContent (child); call_attribute = (const char *)xml_str; call_attribute_node = child; xmlFree (xml_str); upgrade_config = true; continue; } if (xmlStrEqual (BAD_CAST ("authcID"), child->name)) { xml_str = xmlNodeGetContent (child); bookinfo.authcID = (const char *)xml_str; authcID_node = child; xmlFree (xml_str); continue; } if (xmlStrEqual (BAD_CAST ("password"), child->name)) { xml_str = xmlNodeGetContent (child); bookinfo.password = (const char *)xml_str; password_node = child; xmlFree (xml_str); continue; } } } if (upgrade_config) { if (!uri_node) { LDAPURLDesc *url_tmp = NULL; char *url_str; std::string new_uri; if (hostname.empty()) hostname="localhost"; new_uri = std::string("ldap://") + hostname; if (!port.empty()) new_uri += std::string(":") + port; new_uri += "/?cn," + call_attribute + "?" + scope; ldap_url_parse (new_uri.c_str(), &url_tmp); url_tmp->lud_dn = (char *)base.c_str(); url_str = ldap_url_desc2str (url_tmp); bookinfo.uri = std::string(url_str); ldap_memfree (url_str); robust_xmlNodeSetContent (node, &uri_node, "uri", bookinfo.uri); url_tmp->lud_dn = NULL; ldap_free_urldesc (url_tmp); } if (hostname_node) { xmlUnlinkNode (hostname_node); xmlFreeNode (hostname_node); } if (port_node) { xmlUnlinkNode (port_node); xmlFreeNode (port_node); } if (base_node) { xmlUnlinkNode (base_node); xmlFreeNode (base_node); } if (scope_node) { xmlUnlinkNode (scope_node); xmlFreeNode (scope_node); } if (call_attribute_node) { xmlUnlinkNode (call_attribute_node); xmlFreeNode (call_attribute_node); } trigger_saving (); } OPENLDAP::BookInfoParse (bookinfo); if (bookinfo.uri_host == EKIGA_NET_URI) I_am_an_ekiga_net_book = true; else I_am_an_ekiga_net_book = false; /* Actor stuff */ add_action (Ekiga::ActionPtr (new Ekiga::Action ("edit-book", _("_Edit"), boost::bind (&OPENLDAP::Book::edit, this)))); add_action (Ekiga::ActionPtr (new Ekiga::Action ("remove-book", _("_Remove"), boost::bind (&OPENLDAP::Book::remove, this)))); add_action (Ekiga::ActionPtr (new Ekiga::Action ("refresh-book", _("_Refresh"), boost::bind (&OPENLDAP::Book::refresh, this)))); }
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; }