We have moved to a new Sailfish OS Forum. Please start new discussions there.

Query network from QML

asked 2018-12-17 18:40:44 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2018-12-17 18:40:44 +0300

Tanghus gravatar image

I'm updating an app, that needs to access a web service. It should be able to run both off- and online, so the primary objective is to detect net accessibility and optionally open the network connection dialog.

I have been trying different options, which all ended with no viable result, so before reinventing sliced bread, I'd like to check if I have missed something obvious.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2018-12-17 19:59:28 +0300

coderus gravatar image

updated 2018-12-17 20:00:31 +0300

import org.freedesktop.contextkit 1.0

ContextProperty {
    id: networkOnline
    key: 'Network.Online'

// use networkOnline.value

import Nemo.DBus 2.0

DBusInterface {
     service: 'com.jolla.lipstick.ConnectionSelector'
     path: '/'
     iface: 'com.jolla.lipstick.ConnectionSelectorIf'

    function openConnection() {
        call('openConnectionNow', 'wifi')
edit flag offensive delete publish link more


I was right in guessing it would be something much easier than what I was trying to do 😃

Just to make double sure:

  • I check networkOnline.status
  • How do I call openConnection()? Can I give the DBusInterface an id and call like myDbus.openConnection()?
  • The call('openConnectionNow', 'wifi') - will it also offer to connect with mobile data?

And thanks for the swift reply @coderus

Tanghus ( 2018-12-17 22:33:08 +0300 )edit

@Tanghus You can give an id and call like you said.

Rikujolla ( 2018-12-18 06:38:02 +0300 )edit

Just curious about @coderus answer , how to get/know all possible qml import statements that i can use in building sailfish os apps ? because i found it very difficult to know what all qml modules i can import and work with!

venki ( 2018-12-18 19:44:36 +0300 )edit

thanks @Tanghus

venki ( 2018-12-19 09:39:58 +0300 )edit
Login/Signup to Answer

Question tools



Asked: 2018-12-17 18:40:44 +0300

Seen: 499 times

Last updated: Dec 17 '18