Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 950  / 1 Year ago, mon, may 8, 2023, 9:17:15

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;
}

More From » ubuntu-one

 Answers
1

The signature argument to the connect method looks wrong.
Funny as it looks, it should be just "a{ss}".



That already means "array of dictionary items with string as key and string as value", so the added part "(Dict of {String, String})" may happen to be interpreted the wrong way. Similarly, the signature for the CredentialsNotFound D-Bus signal should not be "(nothing)", it should be just an empty string like "".



To familiarize yourself with the other data types that D-Bus offers try a tutorial like this:
http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#data-types


[#37272] Wednesday, May 10, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tigehanc

Total Points: 162
Total Questions: 113
Total Answers: 122

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
;