Ejemplo n.º 1
0
OPENLDAP::Source::Source (Ekiga::ServiceCore &_core):
    core(_core), doc(), should_add_ekiga_net_book(false)
{
    xmlNodePtr root;
    gchar *c_raw = gm_conf_get_string (KEY);

    if (c_raw != NULL && strcmp (c_raw, "")) {

        const std::string raw = c_raw;

        doc = std::tr1::shared_ptr<xmlDoc> (xmlRecoverMemory (raw.c_str (), raw.length ()), xmlFreeDoc);
        if ( !doc)
            doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc);

        root = xmlDocGetRootElement (doc.get ());

        if (root == NULL) {

            root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL);
            xmlDocSetRootElement (doc.get (), root);
        }

        migrate_from_3_0_0 ();

        for (xmlNodePtr child = root->children ;
                child != NULL ;
                child = child->next)
            if (child->type == XML_ELEMENT_NODE
                    && child->name != NULL
                    && xmlStrEqual (BAD_CAST "server", child->name))
                add (child);

        g_free (c_raw);
    } else {

        doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc);
        root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL);
        xmlDocSetRootElement (doc.get (), root);

        should_add_ekiga_net_book = true;
    }

    if (should_add_ekiga_net_book)
        new_ekiga_net_book ();
}
Ejemplo n.º 2
0
OPENLDAP::Source::Source (Ekiga::ServiceCore &_core): core(_core), doc(NULL)
{
  xmlNodePtr root;
  gchar *c_raw = gm_conf_get_string (KEY);

  if (c_raw != NULL && strcmp (c_raw, "")) {

    const std::string raw = c_raw;

    doc = xmlRecoverMemory (raw.c_str (), raw.length ());
    if (doc == NULL)
      doc = xmlNewDoc (BAD_CAST "1.0");

    root = xmlDocGetRootElement (doc);

    if (root == NULL) {

      root = xmlNewNode (NULL, BAD_CAST "list");
      xmlDocSetRootElement (doc, root);
    }

    for (xmlNodePtr child = root->children ;
	 child != NULL ;
	 child = child->next)
      if (child->type == XML_ELEMENT_NODE
	  && child->name != NULL
	  && xmlStrEqual (BAD_CAST "server", child->name))
	add (child);

    g_free (c_raw);
  } else {

    doc = xmlNewDoc (BAD_CAST "1.0");
    root = xmlNewNode (NULL, BAD_CAST "list");
    xmlDocSetRootElement (doc, root);

    new_ekiga_net_book ();
  }
}