<div>Hi Slava,<br></div><div class="protonmail_signature_block-empty"><br></div><div class="protonmail_signature_block protonmail_signature_block-empty"><div class="protonmail_signature_block-user protonmail_signature_block-empty"><div><br></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br></div></div><div class="protonmail_signature_block-empty"><br></div><div><br></div><div>Thank you for your response! With these links I can indeed figure out the current state of the network connection in Python by reading those files.<br></div><div>Now I just need to figure out how I can add it to Sailfinder without a lot of rewriting.<br></div><div><br></div><div>Kind regards,<br></div><div>Dylan Van Assche<br></div><blockquote type="cite" class="protonmail_quote"><div>-------- Original Message --------<br></div><div>Subject: Re: [SailfishDevel] Detect network state & react on it<br></div><div>Local Time: October 8, 2016 12:02 PM<br></div><div>UTC Time: October 8, 2016 10:02 AM<br></div><div>From: slava.monich@jolla.com<br></div><div>To: Dylan Van Assche <dylan.van.assche@protonmail.com>, Sailfish OS Developers <devel@lists.sailfishos.org><br></div><div><br></div><div>
    <br></div><p>Hi Dylan,<br></p><p>From QML, the easiest way is probably to monitor
      /run/state/providers/connman/Internet/NetworkState and
      /run/state/providers/connman/Internet/NetworkType with
      ContextProperty object. Google for "qml contextkit
      contextproperty" to find some examples. That way, statefs monitors
      connman state for you and you monitor statefs.<br></p><p>You can achieve the same result by directly monitoring the
      connman state over D-Bus. Then libconnman-qt is your friend. It's
      a C++ library with a QML plugin (MeeGo.Connman). That requires a
      bit more code but takes statefs out of the picture.<br></p><p>There are also Qt network configuration APIs but those are even
      more complicated and not all of those might work the way you would
      expect them to work. But this is the most platform-independent API
      in case if that is important for you (probably not). Internally it
      also talks to connman.<br></p><p>Connection selector has a D-Bus API which is easy enough to
      figure out with dbus-monitor. However it's not an official API and
      it's more or less guaranteed to change over time and break your
      app. Think twice before starting to use it.<br></p><p></p><div>Cheers,<br></div><div>
      -Slava<br></div><p></p><div><br></div><div class="moz-cite-prefix">On 08/10/16 11:59, Dylan Van Assche
      wrote:<br></div><blockquote type="cite"><div>Hi Sailors,<br></div><div><div><br></div><div>For my app Sailfinder I have received a bug report about the
        network connection. When switching between mobile data &
        WiFi the app misbehaves.<br></div></div><div><div><br></div><div>I want to detect the current network state to avoid thsi
        problem. I thought of several possibilities:<br></div></div><ul><li><div>Ping everytime to my website before doing other requests
            (expensive, better not).<br></div></li><li>Use MCE module which expose the network states in a file
          (that's what I found on the sailfishos.org website, no more
          extra information). This option is the one I want to try :)<br></li><li><div>...<br></div></li></ul><p>And if network isn't available I want to show the network
        connection dialog but I haven't find any information about it.
        Can someone help me with it? If possible, in a Harbour way since
        Sailfinder is also available in the Jolla Store.<br></p><div>Kind regards,<br></div><div>Dylan Van Assche<br></div></blockquote></blockquote><div><br></div>