[Interest] QTDbus, Connman & Parameters conversion

Thiago Macieira thiago.macieira at intel.com
Mon Mar 16 22:51:33 CET 2015


On Monday 16 March 2015 07:43:51 LongChair . wrote:
> Hello,
> I have been looking in a way to provide with my app some wifi connection
> manager which would allow the following functionality :F1 - Enable/disable
> wifi adaptersF2 - List wifi networks F3 - connect to a network specifying
> the Wifi Key to be noticed that i need this functionality on a linux which
> has connman. While doing some research about it, i found 2 possible ways :1
> - Use QtNetworkAccessManager & qtbearer API2 - Use Dbus communication with
> connman But I couldn't make it thru with either of those
> 1 - Using QNAM & QtBearer API
> That Api allows me to list networks properly (F2), but i didn't find a
> proper way to do F1 & F3. Did I overlook something ?

No, you didn't. That's not the job of random applications to turn adapters on 
and off nor change their settings. Only the system configuration application 
should do that.

Since you're trying to do exactly that, from this point on I'll consider that 
you're writing *the* system configuration application.

> 2 - Using Dbus API with connman
> Again looking at the docs, there seem to be different ways to do this :
> 2.1 -
> Using qt qdbusxml2cpp tool to make a proper cpp class that i can use in the
> project
> 2.2 - Using the raw API being helped by qtdbusviewer 

They are the same API. There's no difference between 2.1 and 2.2 from this 
description...

> I first tried 2.1 :
> but i hit very quickly the question : where do i get the xml file from.

>From connman itself. It probably provides the Introspection if you ask it 
nicely. If qdbusviewer can show anything, it's because connman had it. Just 
make the call to the Introspect function in the 
org.freedesktop.DBus.Introspectable interface.

You'll want to save the file to your project and also edit it to add support 
for the non-basic types.

> Then i moved desperately to 2.2, that
> is use dbus plain API and do that manually I use qtdbusviewer to check the
> different services and parameters types, and started to implement some code
> around it 

You should not be desperate. If you're starting on the system configuration 
application now, you're probably quite far from release...

You should not have moved to this option. This is less efficient: please go back 
to 2.1.

> Here is what i did :
> First i started with the net.connman.manager GetServices Dbus method.->
> Qtbusviewer mentions that the output parameter type is a(oa{sv}). Looking
> at the qtconnmanmanager bearer code i can see that they map that to :
> struct ConnmanMap {
> 	QDBusObjectPath objectPath;
> 	QVariantMap propertyMap;
> }; 
> typedef QList<ConnmanMap> ConnmanMapList;
> but then when i use :
>  QDBusConnection bus = QDBusConnection::systemBus();        QDBusInterface
> *interface = new QDBusInterface("net.connman",                             
>                          "/",                                              
>         "net.connman.Manager",                                             
>          bus); QDBusReply<ConnmanMapList> reply =
> interface->call("GetServices"); 

Please improve your code pasting skills into emails.

> i'm getting a SEGV which seems to be due to
> the ConnmanMapList parameter in the template (will work fine if i replace
> QDBusReply<ConnmanMapList>  with QDbusMessage I would like to avoid the
> QDbusMessage::arguments() parsing field by filed because of the hassle.

Parsing the QDBusMessage::arguments() field is exactly what QDBusReply and 
QDBusPendingReply do. So I don't see how it could be a hassle.

Also note you did not provide any more information on the SIGSEGV, so we can't 
help you with it.

> What am i doing wrong ?
> Before proceeding, i'd love to get some hints on how to
> proceed with this, that is what is the direction i should go, typically
> with that xml2cpp tool if there is any way to do this. If not, then how can
> I use a proper casting of the DBUS types into declared structs ? Thanks in
> advance for your help :)

Please get the XML file, save it to your source code, modify it to declare the 
C++ types for the non-basic payloads (such as that a(oa{sv})) and use 
qdbusxml2cpp to generate code.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list