Determine kind of internet connection we are using GSM or WLAN.
[yandex-traffic] / tests / conn / mainwindow.hpp
index c854ff0..f0c8f9b 100644 (file)
@@ -14,6 +14,7 @@ public:
         ConnectionChecker *cc = ConnectionChecker::instance ();
 
         connect (cc, SIGNAL (connected (bool)), SLOT (connected (bool)));
+        connect (cc, SIGNAL (type_changed (ConnectionChecker::network_type_t)), SLOT (type_changed (ConnectionChecker::network_type_t)));
 
         setText (cc->isConnected () ? "Connected" : "Not connected");
         connect (this, SIGNAL (clicked ()), SLOT (checkConnection ()));
@@ -29,6 +30,21 @@ protected slots:
         setText (ConnectionChecker::instance ()->isConnected () ? "Connected" : "Not connected");
     }
 
+    void type_changed (ConnectionChecker::network_type_t type)
+    {
+        switch (type) {
+            case ConnectionChecker::Net_None:
+                printf ("Type: none\n");
+                break;
+            case ConnectionChecker::Net_WLAN:
+                printf ("Type: WLAN\n");
+                break;
+            case ConnectionChecker::Net_GSM:
+                printf ("Type: GSM\n");
+                break;
+        }
+    }
+
     void checkConnection ()
     {
         ConnectionChecker::instance ()->requestState ();