[SailfishDevel] libconnman-qt application examples

David Llewellyn-Jones david at flypig.co.uk
Tue Jul 23 08:20:01 UTC 2019


On 22/07/2019 23:57, David Weidenkopf wrote:
> Sorry, I forgot to mention an assumption on my part. Given the API
> design, it looks like it is usable from QML, and no C++ would be
> necessary. Is that an incorrect assumption?

Hi David,

I'm struggling a bit with your negatives, but... no, this is a *correct*
assumption! You can use libconnman-qt as a C++ library, but it also
works as a QML plugin by adding "import MeeGo.Connman 0.2" at the top of
your QML file.

> Hi, we are interested in adopting libconnman-qt as our interface to
> connman. Where can I find examples of usage? For example, I would like
> to see how the library could be used to present a list of SSIDs to a
> user. It is not clear from the API how to do this.

If you're interested in the QML side of things, then the Settings app is
a good place to start (jolla-settings-networking). It's not open source,
but you can find the relevant QML files directly on a Sailfish device
(or the emulator).

For example, this file provides the UI for the main WLAN settings page:

/usr/share/jolla-settings/pages/wlan/mainpage.qml

This lists your saved WLAN networks. It does this using the
SavedServiceModel model, which is a QAbstractListModel, and so can be
plugged straight in to a ListView (or any of the related Qt repeaters).

Look out for TechnologyModel, SavedServiceModel, NetworkTechnology and
NetworkManager around lines 225-253 of the file, which are all from
libconnman-qt.

If you want to manipulate things more specifically, the NetworkManager
provides access to NetworkService objects, and each NetworkService
object provides details of a network (e.g. its name, its domain, whether
it's connected, etc.). NetworkManager and NetworkService are basically
wrappers around their respective connman dbus interfaces:

https://git.merproject.org/mer-core/connman/blob/master/connman/doc/manager-api.txt

https://git.merproject.org/mer-core/connman/blob/master/connman/doc/service-api.txt

Another place to look would be in this file from lipstick-jolla-home,
which provides the Wifi connection selector dialogue:

/usr/share/lipstick-jolla-home-qt5/connectivity/ConnectionSelector.qml

Somewhere around line 918 you can see the TechnologyModel which is used
to populate the list shown to the user.

There may be other better or open source examples, but these are the two
that spring to mind. Getting a simple QML interface that shows saved
Wifi connections should be relatively straightforward using these models.

David
-- 
Website: http://www.flypig.co.uk


More information about the Devel mailing list