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?
int main()
{
UbuntuOneDBus *u1Dbus = new UbuntuOneDBus;
u1Dbus->init()
}
class UbuntuOneDBus : public QObject
{
Q_OBJECT
QString busName;
QString path;
QString interface;
QString method;
QString signature;
void connectReturnSignals();
private slots:
void credentialsFound();
void credentialsNotFound();
void credentialsError();
public:
UbuntuOneDBus();
void init();
};
UbuntuOneDBus::UbuntuOneDBus()
{
busName = "com.ubuntuone.Credentials";
path = "/credentials";
interface = "com.ubuntuone.CredentialsManagement";
method = "register";
signature = "a{ss}";
connectReturnSignals();
}
void 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;
}