I am currently using Qt Creator 1.3 to develop my project. But, I am having an issue with a QDBusAbstractAdaptor. It will build the project and run, and it will register the object with the session bus, and everything looks like it is working great.
Using the qdbusviewer I check the object that is on the session bus, it exists but my "D-Bus Interface" does not exists for the object. Only:
org.freedesktop.DBus.Properties
org.freedesktop.DBus.Interospectable
(my dbus interface) <-- MISSING
I am confused on what needs to be done for my interface to be exported on the dbus. Do I need to add something to be project file for qt creator to build the interface. Code is below:
Code:
QT += sql QT += dbus QT -= gui TARGET = configd CONFIG += dbus CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp \ configdatabase.cpp \ dbusconfig.cpp \ watchconfig.cpp HEADERS += configdatabase.h \ dbusconfig.h \ watchconfig.h
Code:
#ifndef DBUSCONFIG_H #define DBUSCONFIG_H #include <QDBusAbstractAdaptor> #include <QCoreApplication> #include <QDBusMessage> #include <QDBusVariant> #include "configdatabase.h" #include "watchconfig.h" { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.myinterface") public: // // Constructor // signals: // // Emitted when a value has changed on the watch list. // void valueChanged(const QString&); public slots: // // Sets a configuration value // bool setValue(const QString&, const QDBusVariant&); // // Gets a configuration value and send a reply back through dbus // void value(const QString&, const QDBusMessage&); // // Adds a configuration value to a watch for change list // bool addWatch(const QString&); private slots: // // Checks the watch list for changes // void checkWatchList(void); private: // // Configuration values to watch for change // QList<WatchConfig> _watch; // // Configuration Database // ConfigDatabase* _database; }; #endif // DBUSCONFIG_H
Code:
#include <QtCore/QCoreApplication> #include <QDBusConnection> #include "configdatabase.h" #include "dbusconfig.h" int main(int argc, char *argv[]) { ConfigDatabase db; // Register configuration service { } // Register Object DBusConfig *dbus = new DBusConfig(&db, &a); { } return a.exec(); }