* Enabled the symbol visibility feature from gcc 4, reduces binary size and dynamic loading speed

* A lot of fixes to keep compatibility with older (0.6x) versions of libdbus
* Moved the xml handling code from the library to the code generator
* Rewrote the routine to generate introspection data
* Autojunk cleanup



git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@12019 30a43799-04e7-0310-8b2b-ea0d24f86d0e
This commit is contained in:
pdurante 2007-07-23 18:31:49 +00:00
parent a8f5e819bd
commit 7c420f87cd
36 changed files with 287 additions and 172 deletions

View file

@ -25,10 +25,11 @@
#include <dbus-c++/introspection.h>
#include <dbus-c++/object.h>
#include <dbus-c++/message.h>
#include <dbus-c++/xml.h>
#include <dbus/dbus.h>
#include <sstream>
using namespace DBus;
static const char* introspectable_name = "org.freedesktop.DBus.Introspectable";
@ -42,8 +43,14 @@ IntrospectableAdaptor::IntrospectableAdaptor()
Message IntrospectableAdaptor::Introspect( const CallMessage& call )
{
debug_log("requested introspection data");
Xml::Node iroot("node");
std::ostringstream xml;
xml << DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE;
const std::string path = object()->path();
xml << "<node name=\"" << path << "\">";
InterfaceAdaptorTable::const_iterator iti;
@ -54,71 +61,72 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
IntrospectedInterface* const intro = iti->second->introspect();
if(intro)
{
Xml::Node& iface = iroot.add(Xml::Node("interface"));
iface.set("name", intro->name);
xml << "<interface name=\"" << intro->name << "\">";
for(const IntrospectedProperty* p = intro->properties; p->name; ++p)
{
Xml::Node& property = iface.add(Xml::Node("property"));
property.set("name", p->name);
property.set("type", p->type);
std::string access;
if(p->read) access += "read";
if(p->write) access += "write";
property.set("access", access);
xml << "<property name=\"" << p->name << "\""
<< " type=\"" << p->type << "\""
<< " access=\"" << access << "\"/>";
}
for(const IntrospectedMethod* m = intro->methods; m->args; ++m)
{
Xml::Node& method = iface.add(Xml::Node("method"));
method.set("name", m->name);
xml << "<method name=\"" << m->name << "\">";
for(const IntrospectedArgument* a = m->args; a->type; ++a)
{
Xml::Node& arg = method.add(Xml::Node("arg"));
if(a->name) arg.set("name", a->name);
arg.set("direction", a->in ? "in" : "out");
arg.set("type", a->type);
xml << "<arg direction=\"" << (a->in ? "in" : "out") << "\""
<< " type=\"" << a->type << "\"";
if(a->name) xml << " name=\"" << a->name << "\"";
xml << "/>";
}
xml << "</method>";
}
for(const IntrospectedMethod* m = intro->signals; m->args; ++m)
{
Xml::Node& method = iface.add(Xml::Node("signal"));
method.set("name", m->name);
xml << "<signal name=\"" << m->name << "\">";
for(const IntrospectedArgument* a = m->args; a->type; ++a)
{
Xml::Node& arg = method.add(Xml::Node("arg"));
if(a->name) arg.set("name", a->name);
arg.set("type", a->type);
xml << "<arg type=\"" << a->type << "\"";
if(a->name) xml << " name=\"" << a->name << "\"";
xml << "/>";
}
xml << "</signal>";
}
xml << "</interface>";
}
}
const std::string parent = object()->path();
const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(parent + '/');
const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(path + '/');
ObjectAdaptorPList::const_iterator oci;
for(oci = children.begin(); oci != children.end(); ++oci)
{
Xml::Node& subnode = iroot.add(Xml::Node("node"));
std::string name = (*oci)->path().substr(parent.length()+1);
std::string name = (*oci)->path().substr(path.length()+1);
name.substr(name.find('/'));
subnode.set("name", name);
xml << "<node name=\"" << name << "\"/>";
}
std::string xml = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE + iroot.to_xml();
xml << "</node>";
ReturnMessage reply(call);
MessageIter wi = reply.writer();
wi.append_string(xml.c_str());
wi.append_string(xml.str().c_str());
return reply;
}