From 401becb78ea3581608dbb87393dfda700d31d233 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 18 May 2018 14:09:48 +0900 Subject: [PATCH] bluez5 - add support to unblock rfkill if bt adatper power is on so users will be mucho displeased and bewildered when the bt adatper is powered on but nothing happens... it ends up that with some bt adatpers it will be rfkill blocked by default. this is highly unfriendly. at least if you have bluez5 module loaded and configured the adatper to be powered on... i see no reason why it shouldn't be unblocked if the adatper is powered on. i have considerted making it an option but for now can't think of good reasons to really do that. --- src/modules/bluez5/bz_obj.c | 7 +++++++ src/modules/bluez5/e_mod_main.c | 17 +++++++++++++++++ src/modules/bluez5/e_mod_main.h | 1 + src/modules/bluez5/e_mod_popup.c | 30 ++++++++++++++++++++++++++---- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/modules/bluez5/bz_obj.c b/src/modules/bluez5/bz_obj.c index 24552bb2b..a79d2a837 100644 --- a/src/modules/bluez5/bz_obj.c +++ b/src/modules/bluez5/bz_obj.c @@ -1,4 +1,5 @@ #include "bz.h" +#include "e_mod_main.h" static Eldbus_Proxy *objman_proxy = NULL; static Eldbus_Signal_Handler *sig_ifadd = NULL; @@ -262,6 +263,12 @@ cb_obj_prop(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_ if (eldbus_message_arguments_get(msg, "a{sv}", &array)) eldbus_message_iter_dict_iterate(array, "sv", cb_obj_prop_entry, o); bz_obj_ref(o); + if ((o->powered) && (o->path)) + { + const char *s = strrchr(o->path, '/'); + + if (s) ebluez5_rfkill_unblock(s + 1); + } if (!o->add_called) { o->add_called = EINA_TRUE; diff --git a/src/modules/bluez5/e_mod_main.c b/src/modules/bluez5/e_mod_main.c index 6d779e0ea..0d6e828e2 100644 --- a/src/modules/bluez5/e_mod_main.c +++ b/src/modules/bluez5/e_mod_main.c @@ -251,6 +251,23 @@ ebluez5_popups_show(void) } } +void +ebluez5_rfkill_unblock(const char *name) +{ + Eina_Strbuf *buf; + + // XXX: need config tp enable or disable this behavior + buf = eina_strbuf_new(); + if (buf) + { + eina_strbuf_append_printf + (buf, "%s/enlightenment/utils/enlightenment_sys rfkill-unblock %s", + e_prefix_lib_get(), name); + ecore_exe_run(eina_strbuf_string_get(buf), NULL); + eina_strbuf_free(buf); + } +} + ///////////////////////////////////////////////////////////////////////////// /* Module Functions */ diff --git a/src/modules/bluez5/e_mod_main.h b/src/modules/bluez5/e_mod_main.h index 269726638..20d6a7c1e 100644 --- a/src/modules/bluez5/e_mod_main.h +++ b/src/modules/bluez5/e_mod_main.h @@ -35,6 +35,7 @@ E_API int e_modapi_shutdown(E_Module *m); E_API int e_modapi_save(E_Module *m); void ebluez5_popups_show(void); +void ebluez5_rfkill_unblock(const char *name); void ebluez5_popup_hide(Instance *inst); diff --git a/src/modules/bluez5/e_mod_popup.c b/src/modules/bluez5/e_mod_popup.c index 8152802f0..2bf714b00 100644 --- a/src/modules/bluez5/e_mod_popup.c +++ b/src/modules/bluez5/e_mod_popup.c @@ -52,7 +52,16 @@ static void _cb_power(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Obj *o = data; - if (elm_check_state_get(obj)) bz_obj_power_on(o); + if (elm_check_state_get(obj)) + { + if (o->path) + { + const char *s = strrchr(o->path, '/'); + + if (s) ebluez5_rfkill_unblock(s + 1); + } + bz_obj_power_on(o); + } else bz_obj_power_off(o); } @@ -467,7 +476,10 @@ static void _cb_settings(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Instance *inst = data; + ebluez5_popup_hide(inst); + if (e_configure_registry_exists("extensions/bluez5")) + e_configure_registry_call("extensions/bluez5", NULL, NULL); } */ @@ -537,7 +549,7 @@ ebluez5_popup_content_add(Evas_Object *base, Instance *inst) evas_object_smart_callback_add(o, "clicked", _cb_settings, inst); elm_box_pack_end(box, o); evas_object_show(o); -*/ + */ return box; } @@ -704,9 +716,19 @@ ebluez5_popup_device_change(Obj *o) { if (o == elm_object_item_data_get(it)) { - elm_genlist_item_update(it); + // if this is a change for the obj for an "initial" + // request to the user for ok/pin etc. then change it + // and do the updates if (alert) - elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + { + elm_genlist_item_update(it); + elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + } + // otherwise only do changes to items with no agent + // requests pending so we dont delete focused widgets + // or entry widgets etc. + else if (!o->agent_request) + elm_genlist_item_update(it); break; } }