technology: Disable tethering only when no technology is tethering
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 2 Sep 2011 10:34:58 +0000 (13:34 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Sep 2011 09:40:49 +0000 (11:40 +0200)
When notifying that a technology is not tethering anymore, go
through the list of technologies and disable tethering only if
no other technology is tethering.

src/technology.c

index f8891b8..8214617 100644 (file)
@@ -154,6 +154,8 @@ static void tethering_changed(struct connman_technology *technology)
 void connman_technology_tethering_notify(struct connman_technology *technology,
                                                        connman_bool_t enabled)
 {
+       GSList *list;
+
        DBG("technology %p enabled %u", technology, enabled);
 
        if (technology->tethering == enabled)
@@ -165,8 +167,15 @@ void connman_technology_tethering_notify(struct connman_technology *technology,
 
        if (enabled == TRUE)
                __connman_tethering_set_enabled();
-       else
-               __connman_tethering_set_disabled();
+       else {
+               for (list = technology_list; list; list = list->next) {
+                       struct connman_technology *other_tech = list->data;
+                       if (other_tech->tethering == TRUE)
+                               break;
+               }
+               if (list == NULL)
+                       __connman_tethering_set_disabled();
+       }
 }
 
 static int set_tethering(struct connman_technology *technology,