On 09/12/2013 05:21 PM, Jamie Strandboge wrote: > On 08/01/2013 08:23 AM, Jamie Strandboge wrote: >> On 08/01/2013 05:23 AM, Iain Lane wrote: >>> On Wed, Jul 31, 2013 at 05:42:43PM +0100, Iain Lane wrote: >>>> On Wed, Jul 31, 2013 at 03:18:27PM +0400, Alberto Mardegan wrote: >>>>> On 07/30/2013 07:50 PM, Iain Lane wrote: >>>>>> Admittedly I didn't know about it ;-) But looking at that API reference >>>>>> it seems to be more about mobile stuff whereas my question is a bit more >>>>>> generic than that — I want to know if there's an internet connection of >>>>>> any type available. >>>>>> >>>>>> Maybe I can't see it on this API or maybe Qt has something else for that >>>>>> in which case I'd be happy to switch over. >>>>> >>>>> QNetworkAccessManager::networkAccessible(): >>>>> >>>>> https://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html#networkAccessible-prop >>>> >>>> Thanks for the tip. It looks like it should work, however I always get >>>> QNetworkAccessManager::UnknownAccessibility returned. Is there a trick? >>> >>> I found [0] and followed that. Then I get Accessible back. I was happy, >>> until I tried disconnecting from the network (on my desktop) and still >>> got Accessible. >>> >>> All the while NM has known the correct state, so if I could use that >>> we'd be in happy land. >>> >>> Ho hum? >>> >>> [0] >>> http://www.qtcentre.org/threads/37514-use-of-QNetworkAccessManager-networkAccessible?p=188372#post188372 >>> >> Along these lines-- we really need to define and document the canonical way >> for >> determining network accessibility. My team is tasked with defining apparmor >> policy for this, and SDK app developers should ideally do this one way and >> then >> my team can write tests to make sure that it works for that use case. >> Everyone >> coming up with their own method won't work with application confinement. >> > I looked into this a bit today. We should *not* rely on anything that uses > network-manager to obtain this information. Its DBus API does not currently > provide the answer to "Can I use the internet?" without granting a whole bunch > of other accesses. > > Instead, apps should use qtdeclarative5-systeminfo-plugin, specifically > NetworkInfo[1]. I played with this today and rather than talking to > network-manager, it just reads various files in /sys, /proc and needs 'inet > stream' and 'inet dgram'. I'll be updating the apparmor policy group for > 'connectivity' to allow these accesses so it works with > qtdeclarative5-systeminfo-plugin. I also tested (a bit) with C++ using > QHostAddress and QNetworkInterface. >
Of course, things are never so simple as they seem. The above works fine on desktop and the Nexus 7, but as soon as ofono is involved (eg, on a Nexus 4), ofono DBus apparmor denials appear and cause qtdeclarative5-systeminfo-plugin to report an error. I filed LP: #1226844 to track this. In the short term there is probably an easy workaround for the bug, bug ideally we would provide a simple dbus service (I think 'uconnectd' would be a great name-- feel free to use it ;) with methods like OnlineWired, OnlineWireless and OnlineCostlyNetwork. Apps would connect to this service (via a small, blessed QML extension/Qt library) to see if online and this dbus service would in turn consult network manager and ofono to do the heavy lifting. I imagine it would take a couple days to design and implement the service, then a couple days for the qt/qml plugin. CC'ing potentially interested parties. [1]https://launchpad.net/bugs/1226844 -- Jamie Strandboge http://www.ubuntu.com/
signature.asc
Description: OpenPGP digital signature
-- Mailing list: https://launchpad.net/~ubuntu-phone Post to : ubuntu-phone@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntu-phone More help : https://help.launchpad.net/ListHelp