[Interest] Question about using QtDBus

Rogers Nate nate.rogers at raymondcorp.com
Tue Sep 2 19:31:28 CEST 2014


On 08/28/2014 04:39 PM, Thiago Macieira wrote:

On Thursday 28 August 2014 20:16:56 Rogers Nate wrote:


<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection
1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"<http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd><http://www.f
reedesktop.org/standards/dbus/1.0/introspect.dtd><http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd>> <node>
  <interface name="com.GDM.ServiceData">
    <method name="serviceErrorLog">
        <arg name="serviceErrorLogData" type="a(ss)" direction="out"/>
        <annotation name="org.qtproject.QtDBus.QtTypeName.Out0"
value="ServiceErrorLogData"/> </method>
  </interface>
</node>

and I got this warning...


servicedata_adaptor.cpp:36:1: error: 'ServiceErrorLogData' does not name a
type



That should be QList<ServiceErrorLogData>.

If you're using code generation with gdbusxml2cpp, you'll need to pass the -i
ServiceData.h option to the generator so it will add the #include.

Are you using code generation with qmake? Or is it some other tool? Your use
of "qt5/" in your includes leads me to think that you're not using qmake.



It builds now with this...

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"<http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd>>
<node>
  <interface name="com.GDM.ServiceData">
    <method name="serviceErrorLog">
        <arg name="QList<ServiceErrorLogData>" type="a(ss)" direction="out"/>
        <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<ServiceErrorLogData>"/>
    </method>
  </interface>
</node>


but I get this message at runtime...


QDBusError("org.freedesktop.DBus.Error.InvalidSignature", "Unexpected reply signature: got "", expected "a(ss)"")

I am using qmake, I usually use...


qdbuscpp2xml -A ServiceData.h -o ServiceData.xml

to make my xml file from my cpp file (I had to enter in the entry for my custom type manually) and then Qt automatically makes my other cpp files when I build.  Here are the contents of my .pro files...


------------------------------------- Begin DataProcess.pro ----------------------------------------
#-------------------------------------------------
#
# Project created by QtCreator 2014-07-16T11:59:31
#
#-------------------------------------------------

QT += dbus

DBUS_ADAPTORS += ServiceData.xml

QMAKE_LFLAGS_APP += -rdynamic

QT       += core
QT       -= gui

TARGET = Data
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

INCLUDEPATH += \
    $${OUT_PWD}/../Data/

SOURCES += main.cpp \
    ServiceData.cpp \
    ServiceErrorLogData.cpp

HEADERS += \
    ServiceData.h \
    ServiceErrorLogData.h

OTHER_FILES += \
    ServiceData.xml

# Install the dbus system config file
application_interfaces.path = /etc/dbus-1/system.d/
application_interfaces.files = com.GDM.ServiceData.conf
INSTALLS += application_interfaces

# install
target.path = /opt/dbustest
INSTALLS += target
--------------------------------------------- End DataProcess.pro ----------------------------------------------


--------------------------------------------- Begin CommProcess.pro ----------------------------------------------

#-------------------------------------------------
#
# Project created by QtCreator 2014-04-18T09:19:20
#
#-------------------------------------------------

QT += dbus

DBUS_INTERFACES += ../DataProcess/ServiceData.xml

QMAKE_LFLAGS_APP += -rdynamic

QT       += core
QT       -= gui

TARGET = CanComm
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

INCLUDEPATH += \
    ../DataProcess/ \
    $${OUT_PWD}/../CanComm/ \
    $${OUT_PWD}/../Data/

SOURCES += main.cpp \
    CanData.cpp \
    ../DataProcess/ServiceErrorLogData.cpp

HEADERS += \
    CanData.h \
    ../DataProcess/ServiceErrorLogData.h

# install
target.path = /opt/dbustest
INSTALLS += target
--------------------------------------------- End CommProcess.pro ----------------------------------------------




The files it generates look like this...

----------------------------------------- Begin servicedata_adaptor.cpp --------------------------------------
/*
 * This file was generated by qdbusxml2cpp version 0.8
 * Command line was: qdbusxml2cpp -i servicedata_adaptor.h -a :servicedata_adaptor.cpp ../../../dbustest/DataProcess/ServiceData.xml
 *
 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 *
 * This is an auto-generated file.
 * Do not edit! All changes made to it will be lost.
 */

#include "servicedata_adaptor.h"
#include <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>

/*
 * Implementation of adaptor class ServiceDataAdaptor
 */

ServiceDataAdaptor::ServiceDataAdaptor(QObject *parent)
    : QDBusAbstractAdaptor(parent)
{
    // constructor
    setAutoRelaySignals(true);
}

ServiceDataAdaptor::~ServiceDataAdaptor()
{
    // destructor
}

void ServiceDataAdaptor::serviceErrorLog()
{
    // handle method call com.GDM.ServiceData.serviceErrorLog
    QMetaObject::invokeMethod(parent(), "serviceErrorLog");
}

----------------------------------------- End servicedata_adaptor.cpp --------------------------------------


----------------------------------------- Begin servicedata_adaptor.h --------------------------------------
/*
 * This file was generated by qdbusxml2cpp version 0.8
 * Command line was: qdbusxml2cpp -a servicedata_adaptor.h: ../../../dbustest/DataProcess/ServiceData.xml
 *
 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 *
 * This is an auto-generated file.
 * This file may have been hand-edited. Look for HAND-EDIT comments
 * before re-generating it.
 */

#ifndef SERVICEDATA_ADAPTOR_H_1409677747
#define SERVICEDATA_ADAPTOR_H_1409677747

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

/*
 * Adaptor class for interface com.GDM.ServiceData
 */
class ServiceDataAdaptor: public QDBusAbstractAdaptor
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.GDM.ServiceData")
    Q_CLASSINFO("D-Bus Introspection", ""
"  <interface name=\"com.GDM.ServiceData\">\n"
"    <method name=\"serviceErrorLog\"/>\n"
"  </interface>\n"
        "")
public:
    ServiceDataAdaptor(QObject *parent);
    virtual ~ServiceDataAdaptor();

public: // PROPERTIES
public Q_SLOTS: // METHODS
    void serviceErrorLog();
Q_SIGNALS: // SIGNALS
};

#endif

----------------------------------------- End servicedata_adaptor.h --------------------------------------


----------------------------------------- Begin servicedata_interface.cpp --------------------------------------
/*
 * This file was generated by qdbusxml2cpp version 0.8
 * Command line was: qdbusxml2cpp -i servicedata_interface.h -p :servicedata_interface.cpp ../../../dbustest/DataProcess/ServiceData.xml
 *
 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 *
 * This is an auto-generated file.
 * This file may have been hand-edited. Look for HAND-EDIT comments
 * before re-generating it.
 */

#include "servicedata_interface.h"
/*
 * Implementation of interface class ComGDMServiceDataInterface
 */

ComGDMServiceDataInterface::ComGDMServiceDataInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
    : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
{
}

ComGDMServiceDataInterface::~ComGDMServiceDataInterface()
{
}

----------------------------------------- End servicedata_interface.cpp --------------------------------------


----------------------------------------- Begin servicedata_interface.h --------------------------------------

/*
 * This file was generated by qdbusxml2cpp version 0.8
 * Command line was: qdbusxml2cpp -p servicedata_interface.h: ../../../dbustest/DataProcess/ServiceData.xml
 *
 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 *
 * This is an auto-generated file.
 * Do not edit! All changes made to it will be lost.
 */

#ifndef SERVICEDATA_INTERFACE_H_1409677606
#define SERVICEDATA_INTERFACE_H_1409677606

#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>

/*
 * Proxy class for interface com.GDM.ServiceData
 */
class ComGDMServiceDataInterface: public QDBusAbstractInterface
{
    Q_OBJECT
public:
    static inline const char *staticInterfaceName()
    { return "com.GDM.ServiceData"; }

public:
    ComGDMServiceDataInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);

    ~ComGDMServiceDataInterface();

public Q_SLOTS: // METHODS
    inline QDBusPendingReply<> serviceErrorLog()
    {
        QList<QVariant> argumentList;
        return asyncCallWithArgumentList(QLatin1String("serviceErrorLog"), argumentList);
    }

Q_SIGNALS: // SIGNALS
};

namespace com {
  namespace GDM {
    typedef ::ComGDMServiceDataInterface ServiceData;
  }
}
#endif
----------------------------------------- End servicedata_interface.h --------------------------------------


Thanks again for the help!


Nate


Confidentiality Notice: The preceding e-mail message (including any attachments) contains information that may be confidential, protected by applicable legal privileges, or constitute non-public information. It is intended to be conveyed only to the designated recipient(s). If you are not an intended recipient of this message, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution or reproduction of this message by unintended recipients is not authorized and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140902/67ef1e2c/attachment.html>


More information about the Interest mailing list