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

Query network from QML

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

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 +0200

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
6

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

coderus gravatar image

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

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

Comments

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 +0200 )edit
2

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

Rikujolla ( 2018-12-18 06:38:02 +0200 )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 +0200 )edit

thanks @Tanghus

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

Question tools

Follow
6 followers

Stats

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

Seen: 577 times

Last updated: Dec 17 '18