[Qt-interest] Problems compiling code generated from Avahi Introspection using qdbusxml2cpp

Lassi Väätämöinen lassi.vaatamoinen at ixonos.com
Thu Mar 4 10:11:08 CET 2010


I have problems compiling a proxy class generated from Avahi servers DBus 
Introspection, org.freedesktop.Avahi.Server

The problem is coused by the following method described in the XML file:

<method name="ResolveService">
    <arg name="interface" type="i" direction="in"/>
    <arg name="protocol" type="i" direction="in"/>
    <arg name="name" type="s" direction="in"/>
    <arg name="type" type="s" direction="in"/>
    <arg name="domain" type="s" direction="in"/>
    <arg name="aprotocol" type="i" direction="in"/>
    <arg name="flags" type="u" direction="in"/>
    <arg name="interface" type="i" direction="out"/>
    <arg name="protocol" type="i" direction="out"/>
    <arg name="name" type="s" direction="out"/>
    <arg name="type" type="s" direction="out"/>
    <arg name="domain" type="s" direction="out"/>
    <arg name="host" type="s" direction="out"/>
    <arg name="aprotocol" type="i" direction="out"/>
    <arg name="address" type="s" direction="out"/>
    <arg name="port" type="q" direction="out"/>
    <arg name="txt" type="aay" direction="out"/>
    <arg name="flags" type="u" direction="out"/>
    <annotation name="com.trolltech.QtDBus.QtTypeName.Out9"
      value="QList&lt;QByteArray&gt;"/>
</method>


Code generation is successfull, and following the generation two generated 
methods are produced:


inline QDBusPendingReply<int, int, QString, QString, QString, QString, int, 
QString, ushort, QList<QByteArray> , uint> ResolveService(int interface, int 
protocol, const QString &name, const QString &type, const QString &domain, int 
aprotocol, uint flags)
{
    QList<QVariant> argumentList;
    argumentList  << qVariantFromValue(interface)
      << qVariantFromValue(protocol) << qVariantFromValue(name)
      << qVariantFromValue(type) << qVariantFromValue(domain) 
      << qVariantFromValue(aprotocol) << qVariantFromValue(flags);

      return asyncCallWithArgumentList(QLatin1String("ResolveService"),
        argumentList);
}

inline QDBusReply<int> ResolveService(int interface, int protocol, const 
QString &name, const QString &type, const QString &domain, int aprotocol, uint 
flags, int &protocol_, QString &name_, QString &type_, QString &domain_, 
QString &host, int &aprotocol_, QString &address, ushort &port, 
QList<QByteArray> &txt, uint &flags_)
{
  QList<QVariant> argumentList;
  argumentList << qVariantFromValue(interface) << qVariantFromValue(protocol)
  << qVariantFromValue(name) << qVariantFromValue(type) 
  << qVariantFromValue(domain) << qVariantFromValue(aprotocol) 
  << qVariantFromValue(flags);
 
  QDBusMessage reply
    = callWithArgumentList(QDBus::Block,
                                     QLatin1String("ResolveService"),
                                    argumentList);

  if (reply.type() == QDBusMessage::ReplyMessage 
     && reply.arguments().count() == 11) {
            protocol_ = qdbus_cast<int>(reply.arguments().at(1));
            name_ = qdbus_cast<QString>(reply.arguments().at(2));
            type_ = qdbus_cast<QString>(reply.arguments().at(3));
            domain_ = qdbus_cast<QString>(reply.arguments().at(4));
            host = qdbus_cast<QString>(reply.arguments().at(5));
            aprotocol_ = qdbus_cast<int>(reply.arguments().at(6));
            address = qdbus_cast<QString>(reply.arguments().at(7));
            port = qdbus_cast<ushort>(reply.arguments().at(8));
            txt = qdbus_cast<QList<QByteArray> >(reply.arguments().at(9));
            flags_ = qdbus_cast<uint>(reply.arguments().at(10));
        }
  return reply;
}


The problem is that compilation of the generated proxy class stops at the first 
function above, due to "invalid" number of template parameters in the 
QDBusPendingReply return value, 11 instead of 8 required by Qt:


/AvahiServerProxy.h:191: error: wrong number of template arguments (11, should 
be 8) /usr/include/qt4/QtDBus/qdbuspendingreply.h:113: error: provided for 
‘template<class T1, class T2, class T3, class T4, class T5, class T6, class 
T7, class T8> class QDBusPendingReply


Is there any way to overcome this problem by using qdbusxml2cpp, or do I have 
to circumvent this problem manually? By little Googling I found out some KDE 
project that used dbusxml2cpp, which had  different output, generating only 
functions returning QDBusReply return value template param. in the  (that 
would correspond with latter function above). The dbusxml2cpp version used for 
that was 0.6, and the current version of qdbusxml2cpp seems to be 0.7

Thanks in advance!






More information about the Qt-interest-old mailing list