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:

Qt Code:
  1. QT += sql
  2. QT += dbus
  3. QT -= gui
  4. TARGET = configd
  5. CONFIG += dbus
  6. CONFIG += console
  7. CONFIG -= app_bundle
  8. TEMPLATE = app
  9. SOURCES += main.cpp \
  10. configdatabase.cpp \
  11. dbusconfig.cpp \
  12. watchconfig.cpp
  13. HEADERS += configdatabase.h \
  14. dbusconfig.h \
  15. watchconfig.h
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef DBUSCONFIG_H
  2. #define DBUSCONFIG_H
  3.  
  4. #include <QDBusAbstractAdaptor>
  5. #include <QCoreApplication>
  6. #include <QDBusMessage>
  7. #include <QDBusVariant>
  8.  
  9. #include "configdatabase.h"
  10. #include "watchconfig.h"
  11.  
  12. class DBusConfig : public QDBusAbstractAdaptor
  13. {
  14. Q_OBJECT
  15. Q_CLASSINFO("D-Bus Interface", "org.myinterface")
  16.  
  17. public:
  18. //
  19. // Constructor
  20. //
  21. DBusConfig(ConfigDatabase* db, QCoreApplication *app);
  22.  
  23. signals:
  24. //
  25. // Emitted when a value has changed on the watch list.
  26. //
  27. void valueChanged(const QString&);
  28.  
  29. public slots:
  30. //
  31. // Sets a configuration value
  32. //
  33. bool setValue(const QString&, const QDBusVariant&);
  34.  
  35. //
  36. // Gets a configuration value and send a reply back through dbus
  37. //
  38. void value(const QString&, const QDBusMessage&);
  39.  
  40. //
  41. // Adds a configuration value to a watch for change list
  42. //
  43. bool addWatch(const QString&);
  44.  
  45. private slots:
  46. //
  47. // Checks the watch list for changes
  48. //
  49. void checkWatchList(void);
  50.  
  51. private:
  52. //
  53. // Configuration values to watch for change
  54. //
  55. QList<WatchConfig> _watch;
  56.  
  57. //
  58. // Configuration Database
  59. //
  60. ConfigDatabase* _database;
  61. };
  62.  
  63. #endif // DBUSCONFIG_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include <QDBusConnection>
  3.  
  4. #include "configdatabase.h"
  5. #include "dbusconfig.h"
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QCoreApplication a(argc, argv);
  10. ConfigDatabase db;
  11.  
  12. // Register configuration service
  13. if(!QDBusConnection::sessionBus().registerService("org.myservice"))
  14. {
  15. qFatal(qPrintable(QObject::tr("Could not register service on the session D-Bus.\n")));
  16. }
  17.  
  18. // Register Object
  19. DBusConfig *dbus = new DBusConfig(&db, &a);
  20. if(!QDBusConnection::sessionBus().registerObject("/Me/Config", dbus))
  21. {
  22. qFatal(qPrintable(QObject::tr("Could not register configuration object on the session D-Bus.\n")));
  23. }
  24.  
  25. return a.exec();
  26. }
To copy to clipboard, switch view to plain text mode