raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=d72a7e68009d1a1fd891619b33dae2e373165497

commit d72a7e68009d1a1fd891619b33dae2e373165497
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Tue Dec 11 17:50:25 2018 +0000

    bluez5 - fix adapter auto-power on if enabled by user
    
    the auto power-on wasn;'t working. what the module did was power the
    bt adapoter on if the user last powered it on by default hen it
    sees/detects the adapter. if the user last powered it off it will do
    the reverse (power it off too). this is kind of a workartound because
    bluez5 itself wont power the bt on.
---
 src/modules/bluez5/e_mod_popup.c | 56 ++++++++++++++++++++++++++++------------
 1 file changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/modules/bluez5/e_mod_popup.c b/src/modules/bluez5/e_mod_popup.c
index 899b4979d..d04bc4489 100644
--- a/src/modules/bluez5/e_mod_popup.c
+++ b/src/modules/bluez5/e_mod_popup.c
@@ -10,25 +10,9 @@ static Eina_List *devices = NULL;
 static void
 _adapter_add(Evas_Object *gl, Obj *o)
 {
-   Eina_List *l;
-   Config_Adapter *ad;
    Elm_Object_Item *it = evas_object_data_get(gl, "adapters_item");;
    elm_genlist_item_append(gl, adapt_itc, o, it, ELM_GENLIST_ITEM_NONE,
                             NULL, NULL);
-   if ((ebluez5_config) && (o->address))
-     {
-        EINA_LIST_FOREACH(ebluez5_config->adapters, l, ad)
-          {
-             if (!ad->addr) continue;
-             if (!strcmp(ad->addr, o->address))
-               {
-                  if (ad->powered) bz_obj_power_on(o);
-                  else bz_obj_power_off(o);
-                  if (ad->pairable) bz_obj_pairable(o);
-                  else bz_obj_unpairable(o);
-               }
-          }
-     }
 }
 
 static int
@@ -620,10 +604,40 @@ ebluze5_popup_clear(void)
      }
 }
 
+static Eina_Bool
+_cb_adapter_add_delayed_setup(void *data)
+{
+   char *path = data;
+   Obj *o;
+
+   if (!path) return EINA_FALSE;
+   o = bz_obj_find(path);
+   if ((o) && (o->address))
+     {
+        Eina_List *l;
+        Config_Adapter *ad;
+
+        EINA_LIST_FOREACH(ebluez5_config->adapters, l, ad)
+          {
+             if (!ad->addr) continue;
+             if (!strcmp(ad->addr, o->address))
+               {
+                  if (ad->powered) bz_obj_power_on(o);
+                  else bz_obj_power_off(o);
+                  if (ad->pairable) bz_obj_pairable(o);
+                  else bz_obj_unpairable(o);
+               }
+          }
+     }
+   free(path);
+   return EINA_FALSE;
+}
+
 void
 ebluez5_popup_adapter_add(Obj *o)
 {
    Eina_List *l;
+   Config_Adapter *ad;
    Evas_Object *gl;
 
    adapters = eina_list_append(adapters, o);
@@ -631,6 +645,16 @@ ebluez5_popup_adapter_add(Obj *o)
      {
         _adapter_add(gl, o);
      }
+   if ((ebluez5_config) && (o->address))
+     {
+        EINA_LIST_FOREACH(ebluez5_config->adapters, l, ad)
+          {
+             if (!ad->addr) continue;
+             if (!strcmp(ad->addr, o->address))
+               ecore_timer_add(1.0, _cb_adapter_add_delayed_setup,
+                               strdup(o->path));
+          }
+     }
    ebluez5_instances_update();
 }
 

-- 


Reply via email to