P2P is not tight to any devices, thus the need of automatically
triggering the proper enabling/disabling function which will in turn
send the signal about Powered being changed accordingly.
---
 src/technology.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/technology.c b/src/technology.c
index bc8557c..dc38f93 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -56,6 +56,7 @@ struct connman_technology {
        char *path;
        GSList *device_list;
        bool enabled;
+       bool p2p_enabled;
        char *regdom;
        bool connected;
 
@@ -688,6 +689,14 @@ static int technology_enabled(struct connman_technology 
*technology)
 
        technology->enabled = true;
 
+       if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+               struct connman_technology *p2p;
+
+               p2p = technology_find(CONNMAN_SERVICE_TYPE_P2P);
+               if (p2p && !p2p->enabled && p2p->p2p_enabled)
+                       technology_enabled(p2p);
+       }
+
        if (technology->tethering_persistent)
                enable_tethering(technology);
 
@@ -704,6 +713,16 @@ static int technology_enable(struct connman_technology 
*technology)
        DBG("technology %p enable", technology);
 
        __sync_synchronize();
+
+       if (technology->type == CONNMAN_SERVICE_TYPE_P2P) {
+               struct connman_technology *wifi;
+
+               wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI);
+               if (wifi->enabled)
+                       return technology_enabled(technology);
+               return 0;
+       }
+
        if (technology->enabled)
                return -EALREADY;
 
@@ -745,6 +764,20 @@ static int technology_disable(struct connman_technology 
*technology)
        DBG("technology %p disable", technology);
 
        __sync_synchronize();
+
+       if (technology->type == CONNMAN_SERVICE_TYPE_P2P) {
+               technology->p2p_enabled = false;
+               return technology_disabled(technology);
+       } else if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+               struct connman_technology *p2p;
+
+               p2p = technology_find(CONNMAN_SERVICE_TYPE_P2P);
+               if (p2p && p2p->enabled) {
+                       p2p->p2p_enabled = true;
+                       technology_disabled(p2p);
+               }
+       }
+
        if (!technology->enabled)
                return -EALREADY;
 
-- 
1.8.3.2

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to