Is this DBus signal connection code correct?

  • This is my first time using DBus so I'm not entirely sure if I'm going about this the right way. I'm attempting to connect the the Ubuntu One DBus service and obtain login credentials for my app, however the slots I've connected to the DBus return signals detailed "here": never seem to be firing, despite a positive result being returned during the connection.

    Before I start looking for errors in the details relating to this specific service, could someone please tell me if this code would even work in the first place, or if I'm done something wrong here?

    @class UbuntuOneDBus : public QObject

    QString busName;
    QString path;
    QString interface;
    QString method;
    QString signature;

    void connectReturnSignals();

    private slots:
    void credentialsFound();
    void credentialsNotFound();
    void credentialsError();


    bool init();

    busName = "com.ubuntuone.Credentials";
    path = "/credentials";
    interface = "com.ubuntuone.CredentialsManagement";
    method = "register";
    signature = "a{ss}";


    bool UbuntuOneDBus::init()
    QDBusMessage message = QDBusMessage::createMethodCall( busName, path, interface, method );
    QDBusConnection::sessionBus().send( message );

    void UbuntuOneDBus::connectReturnSignals()
    QDBusConnection::sessionBus().connect( busName, path, interface, "CredentialsFound", this, SLOT( credentialsFound() ) );
    QDBusConnection::sessionBus().connect( busName, path, interface, "CredentialsNotFound", this, SLOT( credentialsNotFound() ) );
    QDBusConnection::sessionBus().connect( busName, path, interface, "CredentialsError", this, SLOT( credentialsError() ) );

    void UbuntuOneDBus::credentialsFound()
    qDebug() << "Credentials found";

    void UbuntuOneDBus::credentialsNotFound()
    std::cout << "Credentials not found" << std::endl;

    void UbuntuOneDBus::credentialsError()
    std::cout << "Credentials error" << std::endl;

  • Just a quick bump. Does anyone have any idea what it is I'm doing wrong?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.