To get all the necessary information, the command must be executed after the modem has been activated (see part 1). The produced file ofono.xml is not yet a valid XML document. You have to remove a few debug lines at the beginning and at the enf of the file to make it valid.

Create Proxy-Classes

Qt comes with a nice tool the automatically create Proxy-Classes out of the XML description of a D-Bus-API. It’s called qdbusxml2cpp. With this tool you can create proxy and adaptor classes. The latter is used to get your own Qt methods published on the D-Bus, but here we want to use existing D-Bus methods, so we use Proxy-Classes.

You see, the command has to be executed three times to separate the D-Bus-Interfaces. The parameter -p says that a proxy (not an adaptor) class shall be created, while the last parameter limits the output to only the specified Interface. The above parameters are for the Qt 4.6 version of qdbusxml2cpp. I saw the 4.7 version uses slightly different parameters.

But wait a second. You will probably get erros while executing the above commands because of an unrecognized type. That means you have to teach qdbusxml2cpp or Qt how to handle some special types. That’s done by annotations in the xml file:

The Listing shows how the unrecognized type (“a{sv}”) can be represented in Qt. The annotation is on the same level as the unrecognized type. After your XML file is adapted, the above qdbusxml2cpp commands will work.

Use Proxy-Classes

To get rid of the dbus-send command to activate the modem we want to do this in C++:

You can have a look into the above created ofono.xml file where you can see, the PropertyChanged-Signal comes with a String and a Variant. Therefore qdbusxml2cpp has automatically translated into a QDbusVairant. But a Variant can be a lot of differnt types indeed. How to get this information to convert it to an appropriate Qt-Type?

First of all, you could have a look into the Ofono project documentation which is quite good. But for other projects the documentation might not be as good as Ofono’s. How to get the information then? Well, let’s use dbus-monitor:

Very nice work. This is actually the first info I could get for using ofono from within c++. I see this post is kinda old , I hope you see this. You made my day. If possible post using ofono for accessing sms features within c++. Thanks.