[Interest] QTDbus, Connman & Parameters conversion

LongChair . longchair at hotmail.com
Mon Mar 23 07:28:01 CET 2015


Hello Thiago,First of all, thanks for taking the time to answer that long message.Yes, you assumption about me making the system wifi control panel is correct.I followed then you advice to go the introspection -> xml -> qdbusxml2cpp -> cpp way.I managed to have the connman manager xml retrieved, but i would like to get some clarification about the complex type thing with a small sample of what i have.Here is a part of the xml i am having :<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
   <interface name="org.freedesktop.DBus.Introspectable">
      <method name="Introspect">
         <arg name="xml" type="s" direction="out" />
      </method>
   </interface>
   <interface name="net.connman.Manager">
      <method name="GetProperties">
         <arg name="properties" type="a{sv}" direction="out">
            <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
         </arg>
      </method> The argument type which is a{sv} is too complex for the xml2cpp converter which is fine. it's saying that i should add an annotation to define the type.As far as i know, a{sv} should convert to QVariantMap, although the converter doesn't seem happy with it.I have tried whatever type even more simpler types in the value param of the <annotation> tag, but i'm always getting the same converter error :Using : qdbusxml2cpp ./connmanManager.xml -a connmanManager.cpp  -vwill give :Got unknown type `a{sv}'You should add <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="<type>"/> to the XML descriptionI have read that for some more complex types you needed to declare them in a header an then use the -i parameter so that converter finds them, but isn't QVariantMap a known type ? if i replace QVariantMap with a simpler type like 'int', converter will still give the same error.Could you please clarify what is the right thing to do on the sample above ?Thanks,Lionel.

> From: thiago.macieira at intel.com
> To: interest at qt-project.org
> Date: Mon, 16 Mar 2015 14:51:33 -0700
> Subject: Re: [Interest] QTDbus, Connman &  Parameters conversion
> 
> 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
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150323/d6013990/attachment.html>


More information about the Interest mailing list