2013-01-04 08:11:48 -08:00
|
|
|
#include <e.h>
|
2013-04-23 08:08:29 -07:00
|
|
|
#include <Eldbus.h>
|
2013-01-04 08:11:48 -08:00
|
|
|
#include "e_mod_main.h"
|
|
|
|
#include "ebluez4.h"
|
|
|
|
|
|
|
|
/* Local Variables */
|
2013-03-17 08:07:34 -07:00
|
|
|
static Ecore_Exe *autolock_exe = NULL;
|
|
|
|
static Ecore_Poller *autolock_poller = NULL;
|
|
|
|
static Ecore_Event_Handler *autolock_die = NULL;
|
|
|
|
static Ecore_Event_Handler *autolock_out = NULL;
|
|
|
|
static Ecore_Event_Handler *autolock_desklock = NULL;
|
|
|
|
static Eina_Bool autolock_initted = EINA_FALSE;
|
|
|
|
static Eina_Bool autolock_waiting = EINA_TRUE;
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
static Eina_List *instances = NULL;
|
|
|
|
static E_Module *mod = NULL;
|
|
|
|
static char tmpbuf[1024];
|
|
|
|
|
2013-03-09 02:47:30 -08:00
|
|
|
/* Local config */
|
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
Config *ebluez4_config = NULL;
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Bluez4"};
|
|
|
|
|
|
|
|
/* Local Functions */
|
2013-03-17 08:07:34 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_ebluez_l2ping_poller(void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
const char *tmp = NULL;
|
|
|
|
|
|
|
|
autolock_poller = NULL;
|
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
if (e_desklock_state_get())
|
|
|
|
{
|
|
|
|
if (!autolock_waiting)
|
|
|
|
tmp = ebluez4_config->unlock_dev_addr;
|
|
|
|
else
|
|
|
|
tmp = ebluez4_config->lock_dev_addr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!autolock_waiting)
|
|
|
|
tmp = ebluez4_config->lock_dev_addr;
|
|
|
|
else
|
|
|
|
tmp = ebluez4_config->unlock_dev_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
eina_strbuf_append_printf(buf, "%s/enlightenment/utils/enlightenment_sys l2ping %s",
|
|
|
|
e_prefix_lib_get(), tmp);
|
|
|
|
autolock_exe = ecore_exe_run(eina_strbuf_string_get(buf), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
static void
|
2013-01-04 08:12:28 -08:00
|
|
|
_ebluez4_search_dialog_del(Instance *inst)
|
|
|
|
{
|
|
|
|
if (!inst->search_dialog) return;
|
|
|
|
e_object_del(E_OBJECT(inst->search_dialog));
|
|
|
|
inst->search_dialog = NULL;
|
2013-01-04 08:12:58 -08:00
|
|
|
inst->found_list = NULL;
|
|
|
|
|
|
|
|
if (ctxt->adap_obj)
|
|
|
|
{
|
|
|
|
ebluez4_stop_discovery();
|
|
|
|
DBG("Stopping discovery...");
|
|
|
|
}
|
2013-01-04 08:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-11-02 18:35:13 -08:00
|
|
|
_ebluez4_cb_search_dialog_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
2013-01-04 08:12:28 -08:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
E_Dialog *dialog = data;
|
2013-01-04 08:12:28 -08:00
|
|
|
_ebluez4_search_dialog_del(dialog->data);
|
2013-01-04 08:12:58 -08:00
|
|
|
}
|
2013-01-04 08:12:28 -08:00
|
|
|
|
2013-01-04 08:12:58 -08:00
|
|
|
static void
|
|
|
|
_ebluez4_cb_paired(void *data, Eina_Bool success, const char *err_msg)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
if (success)
|
|
|
|
_ebluez4_search_dialog_del(inst);
|
|
|
|
else
|
2013-04-28 13:49:16 -07:00
|
|
|
ebluez4_show_error(_("Bluez Error"), err_msg);
|
2013-01-04 08:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-04 08:12:58 -08:00
|
|
|
_ebluez4_cb_pair(void *data)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
Instance *inst = data;
|
2013-01-04 08:12:07 -08:00
|
|
|
const char *addr = e_widget_ilist_selected_value_get(inst->found_list);
|
2013-01-04 08:11:48 -08:00
|
|
|
|
|
|
|
if(!addr)
|
|
|
|
return;
|
2013-01-04 08:12:58 -08:00
|
|
|
ebluez4_pair_with_device(addr, _ebluez4_cb_paired, inst);
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 08:12:28 -08:00
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_search(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
Instance *inst = data;
|
2013-01-04 08:12:28 -08:00
|
|
|
E_Dialog *dialog;
|
|
|
|
Evas *evas;
|
|
|
|
|
|
|
|
if (inst->search_dialog)
|
2013-01-04 08:12:58 -08:00
|
|
|
_ebluez4_search_dialog_del(inst);
|
2013-01-04 08:12:28 -08:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
dialog = e_dialog_new(NULL, "Search Dialog", "search");
|
2013-04-28 13:49:16 -07:00
|
|
|
e_dialog_title_set(dialog, _("Searching for Devices..."));
|
2014-11-02 18:35:13 -08:00
|
|
|
evas_object_event_callback_add(dialog->win, EVAS_CALLBACK_DEL, _ebluez4_cb_search_dialog_del, dialog);
|
2014-12-22 06:02:05 -08:00
|
|
|
e_dialog_resizable_set(dialog, EINA_TRUE);
|
2013-01-04 08:12:28 -08:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
evas = evas_object_evas_get(dialog->win);
|
2013-01-04 08:12:28 -08:00
|
|
|
|
2013-01-04 08:13:30 -08:00
|
|
|
inst->found_list = e_widget_ilist_add(evas, 100, 0, NULL);
|
2013-01-04 08:12:28 -08:00
|
|
|
|
2013-01-04 08:13:30 -08:00
|
|
|
e_dialog_content_set(dialog, inst->found_list, 300, 200);
|
2013-01-04 08:12:28 -08:00
|
|
|
|
|
|
|
e_dialog_show(dialog);
|
|
|
|
|
|
|
|
dialog->data = inst;
|
|
|
|
inst->search_dialog = dialog;
|
|
|
|
|
|
|
|
ebluez4_start_discovery();
|
|
|
|
DBG("Starting discovery...");
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 08:13:07 -08:00
|
|
|
static void
|
2014-11-02 18:35:13 -08:00
|
|
|
_ebluez4_cb_adap_settings_dialog_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
2013-01-04 08:13:07 -08:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
E_Dialog *dialog = data;
|
2013-01-04 08:13:07 -08:00
|
|
|
ebluez4_adapter_settings_del(dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_check_changed(void *data, Evas_Object *obj, const char *prop_name)
|
|
|
|
{
|
|
|
|
Adapter *adap = data;
|
|
|
|
Eina_Bool value = e_widget_check_checked_get(obj);
|
|
|
|
ebluez4_adapter_property_set(adap, prop_name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_powered_changed(void *data, Evas_Object *obj, void *info __UNUSED__)
|
|
|
|
{
|
|
|
|
_ebluez4_check_changed(data, obj, "Powered");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_visible_changed(void *data, Evas_Object *obj, void *info __UNUSED__)
|
|
|
|
{
|
|
|
|
_ebluez4_check_changed(data, obj, "Discoverable");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_pairable_changed(void *data, Evas_Object *obj, void *info __UNUSED__)
|
|
|
|
{
|
|
|
|
_ebluez4_check_changed(data, obj, "Pairable");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_cb_adap_settings(void *data)
|
|
|
|
{
|
|
|
|
Adapter *adap = data;
|
|
|
|
E_Dialog *dialog;
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *list;
|
|
|
|
Evas_Object *ck;
|
|
|
|
int mw, mh;
|
|
|
|
Eina_List *ck_list = NULL;
|
|
|
|
|
|
|
|
if (adap->dialog)
|
|
|
|
ebluez4_adapter_settings_del(adap->dialog);
|
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
dialog = e_dialog_new(NULL, "Adapter Dialog", "adapter");
|
2013-04-28 13:49:16 -07:00
|
|
|
e_dialog_title_set(dialog, _("Adapter Settings"));
|
2014-11-02 18:35:13 -08:00
|
|
|
evas_object_event_callback_add(dialog->win, EVAS_CALLBACK_DEL, _ebluez4_cb_adap_settings_dialog_del, dialog);
|
2014-12-22 06:02:05 -08:00
|
|
|
e_dialog_resizable_set(dialog, EINA_TRUE);
|
2013-01-04 08:13:07 -08:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
evas = evas_object_evas_get(dialog->win);
|
2013-01-04 08:13:07 -08:00
|
|
|
|
|
|
|
list = e_widget_list_add(evas, 0, 0);
|
|
|
|
|
2013-04-28 13:49:16 -07:00
|
|
|
ck = e_widget_check_add(evas, _("Default"), NULL);
|
2013-01-04 08:13:07 -08:00
|
|
|
e_widget_check_checked_set(ck, adap->is_default);
|
|
|
|
e_widget_list_object_append(list, ck, 0, 0, 0);
|
|
|
|
|
2013-04-28 13:49:16 -07:00
|
|
|
ck = e_widget_check_add(evas, _("Powered"), &(adap->powered_checked));
|
2013-01-04 08:13:07 -08:00
|
|
|
e_widget_check_checked_set(ck, adap->powered);
|
|
|
|
e_widget_list_object_append(list, ck, 0, 0, 0);
|
|
|
|
evas_object_smart_callback_add(ck, "changed", _ebluez4_powered_changed,
|
|
|
|
adap);
|
|
|
|
ck_list = eina_list_append(ck_list, ck);
|
|
|
|
|
|
|
|
|
2013-04-28 13:49:16 -07:00
|
|
|
ck = e_widget_check_add(evas, _("Visible"), &(adap->visible_checked));
|
2013-01-04 08:13:07 -08:00
|
|
|
e_widget_check_checked_set(ck, adap->visible);
|
|
|
|
e_widget_list_object_append(list, ck, 0, 0, 0);
|
|
|
|
evas_object_smart_callback_add(ck, "changed",
|
|
|
|
_ebluez4_visible_changed, adap);
|
|
|
|
ck_list = eina_list_append(ck_list, ck);
|
|
|
|
|
2013-04-28 13:49:16 -07:00
|
|
|
ck = e_widget_check_add(evas, _("Pairable"), &(adap->pairable_checked));
|
2013-01-04 08:13:07 -08:00
|
|
|
e_widget_check_checked_set(ck, adap->pairable);
|
|
|
|
e_widget_list_object_append(list, ck, 0, 0, 0);
|
|
|
|
evas_object_smart_callback_add(ck, "changed",
|
|
|
|
_ebluez4_pairable_changed, adap);
|
|
|
|
ck_list = eina_list_append(ck_list, ck);
|
|
|
|
|
|
|
|
e_dialog_show(dialog);
|
|
|
|
e_widget_size_min_get(list, &mw, &mh);
|
|
|
|
if(mw < 150) mw = 150;
|
|
|
|
e_dialog_content_set(dialog, list, mw, mh);
|
|
|
|
|
|
|
|
dialog->data = adap;
|
|
|
|
adap->dialog = dialog;
|
|
|
|
e_object_data_set(E_OBJECT(dialog), ck_list);
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:13:03 -08:00
|
|
|
static void
|
|
|
|
_ebluez4_adap_list_dialog_del(Instance *inst)
|
|
|
|
{
|
2013-01-04 08:13:07 -08:00
|
|
|
if (!inst->adapters_dialog) return;
|
|
|
|
e_object_del(E_OBJECT(inst->adapters_dialog));
|
|
|
|
inst->adapters_dialog = NULL;
|
2013-01-04 08:13:03 -08:00
|
|
|
inst->adap_list = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-11-02 18:35:13 -08:00
|
|
|
_ebluez4_cb_adap_list_dialog_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
2013-01-04 08:13:03 -08:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
E_Dialog *dialog = data;
|
2013-01-04 08:13:03 -08:00
|
|
|
_ebluez4_adap_list_dialog_del(dialog->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_adap_list(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2013-01-04 08:13:03 -08:00
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
E_Dialog *dialog;
|
|
|
|
Evas *evas;
|
|
|
|
|
2013-01-04 08:13:07 -08:00
|
|
|
if (inst->adapters_dialog)
|
2013-01-04 08:13:03 -08:00
|
|
|
_ebluez4_adap_list_dialog_del(inst);
|
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
dialog = e_dialog_new(NULL, "Adapters Dialog", "adapters");
|
2013-04-28 13:49:16 -07:00
|
|
|
e_dialog_title_set(dialog, _("Adapters Available"));
|
2014-11-02 18:35:13 -08:00
|
|
|
evas_object_event_callback_add(dialog->win, EVAS_CALLBACK_DEL, _ebluez4_cb_adap_list_dialog_del, dialog);
|
2014-12-22 06:02:05 -08:00
|
|
|
e_dialog_resizable_set(dialog, EINA_TRUE);
|
2013-01-04 08:13:03 -08:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
evas = evas_object_evas_get(dialog->win);
|
2013-01-04 08:13:03 -08:00
|
|
|
|
|
|
|
inst->adap_list = e_widget_ilist_add(evas, 0, 0, NULL);
|
|
|
|
|
|
|
|
e_dialog_content_set(dialog, inst->adap_list, 250, 220);
|
|
|
|
ebluez4_update_instances(ctxt->adapters);
|
|
|
|
|
|
|
|
e_dialog_show(dialog);
|
|
|
|
|
|
|
|
dialog->data = inst;
|
2013-01-04 08:13:07 -08:00
|
|
|
inst->adapters_dialog = dialog;
|
2013-01-04 08:13:03 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_connect(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-01-04 08:12:45 -08:00
|
|
|
ebluez4_connect_to_device(data);
|
|
|
|
}
|
2013-01-04 08:12:28 -08:00
|
|
|
|
2013-01-04 08:12:50 -08:00
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_disconnect(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2013-01-04 08:12:50 -08:00
|
|
|
{
|
|
|
|
ebluez4_disconnect_device(data);
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:12:45 -08:00
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_forget(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2013-01-04 08:12:45 -08:00
|
|
|
{
|
|
|
|
Device *dev = data;
|
|
|
|
ebluez4_remove_device(dev->obj);
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
2013-03-19 01:52:27 -07:00
|
|
|
#ifdef HAVE_BLUETOOTH
|
2013-03-09 02:47:30 -08:00
|
|
|
static void
|
|
|
|
_ebluez4_cb_lock(void *data,
|
|
|
|
E_Menu *m __UNUSED__,
|
|
|
|
E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
Device *dev = data;
|
|
|
|
int tog;
|
|
|
|
|
|
|
|
tog = e_menu_item_toggle_get(mi);
|
2013-03-17 08:07:34 -07:00
|
|
|
eina_stringshare_replace(&ebluez4_config->lock_dev_addr,
|
|
|
|
tog ? dev->addr : NULL);
|
2013-03-10 07:37:05 -07:00
|
|
|
e_config_save_queue();
|
2013-03-17 08:07:34 -07:00
|
|
|
|
|
|
|
if (autolock_exe)
|
|
|
|
ecore_exe_kill(autolock_exe);
|
|
|
|
autolock_exe = NULL;
|
|
|
|
if (!autolock_poller && (ebluez4_config->lock_dev_addr || ebluez4_config->unlock_dev_addr))
|
|
|
|
autolock_poller = ecore_poller_add(ECORE_POLLER_CORE, 32, _ebluez_l2ping_poller, NULL);
|
2013-03-09 02:47:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ebluez4_cb_unlock(void *data,
|
|
|
|
E_Menu *m __UNUSED__,
|
|
|
|
E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
Device *dev = data;
|
|
|
|
int tog;
|
|
|
|
|
|
|
|
tog = e_menu_item_toggle_get(mi);
|
2013-03-17 08:07:34 -07:00
|
|
|
eina_stringshare_replace(&ebluez4_config->unlock_dev_addr,
|
|
|
|
tog ? dev->addr : NULL);
|
2013-03-10 07:37:05 -07:00
|
|
|
e_config_save_queue();
|
2013-03-17 08:07:34 -07:00
|
|
|
|
|
|
|
if (autolock_exe)
|
|
|
|
ecore_exe_kill(autolock_exe);
|
|
|
|
autolock_exe = NULL;
|
|
|
|
if (!autolock_poller && (ebluez4_config->lock_dev_addr || ebluez4_config->unlock_dev_addr))
|
|
|
|
autolock_poller = ecore_poller_add(ECORE_POLLER_CORE, 32, _ebluez_l2ping_poller, NULL);
|
2013-03-09 02:47:30 -08:00
|
|
|
}
|
2013-03-19 01:52:27 -07:00
|
|
|
#endif
|
2013-03-09 02:47:30 -08:00
|
|
|
|
2013-01-04 08:12:32 -08:00
|
|
|
static void
|
2013-01-04 08:12:45 -08:00
|
|
|
_menu_post_deactivate(void *data __UNUSED__, E_Menu *m)
|
2013-01-04 08:12:32 -08:00
|
|
|
{
|
2013-01-04 08:12:45 -08:00
|
|
|
Eina_List *iter;
|
|
|
|
E_Menu_Item *mi;
|
2013-01-04 08:13:38 -08:00
|
|
|
Instance *inst = data;
|
2013-01-04 08:12:32 -08:00
|
|
|
|
2013-01-04 08:13:38 -08:00
|
|
|
if (!(m->parent_item) || !(m->parent_item->menu))
|
|
|
|
{
|
|
|
|
e_gadcon_locked_set(inst->gcc->gadcon, 0);
|
|
|
|
inst->menu = NULL;
|
|
|
|
}
|
2013-01-04 08:12:45 -08:00
|
|
|
EINA_LIST_FOREACH(m->items, iter, mi)
|
|
|
|
if (mi->submenu) e_menu_deactivate(mi->submenu);
|
|
|
|
e_object_del(E_OBJECT(m));
|
2013-01-04 08:12:32 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 08:12:45 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ebluez4_add_devices(Instance *inst)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-01-04 08:12:45 -08:00
|
|
|
Device *dev;
|
|
|
|
Eina_List *iter;
|
|
|
|
E_Menu *m, *subm;
|
2013-01-04 08:12:54 -08:00
|
|
|
E_Menu_Item *mi, *submi;
|
2013-01-04 08:12:45 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
|
|
|
|
|
|
|
m = inst->menu;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ctxt->devices, iter, dev)
|
|
|
|
if (dev->paired)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(m);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(mi, _("Paired Devices"));
|
2013-01-04 08:12:45 -08:00
|
|
|
e_menu_item_disabled_set(mi, EINA_TRUE);
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ctxt->devices, iter, dev)
|
|
|
|
if (dev->paired)
|
|
|
|
{
|
2013-03-19 01:52:27 -07:00
|
|
|
#ifdef HAVE_BLUETOOTH
|
2013-03-09 02:47:30 -08:00
|
|
|
Eina_Bool chk;
|
2013-03-19 01:52:27 -07:00
|
|
|
#endif
|
2013-03-09 02:47:30 -08:00
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2013-01-04 08:12:45 -08:00
|
|
|
e_menu_item_label_set(mi, dev->name);
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_check_set(mi, 1);
|
2013-01-04 08:12:45 -08:00
|
|
|
subm = e_menu_new();
|
|
|
|
e_menu_post_deactivate_callback_set(subm, _menu_post_deactivate,
|
2013-01-04 08:13:38 -08:00
|
|
|
inst);
|
2013-01-04 08:12:45 -08:00
|
|
|
e_menu_item_submenu_set(mi, subm);
|
2013-01-04 08:12:54 -08:00
|
|
|
submi = e_menu_item_new(subm);
|
2013-01-04 08:12:50 -08:00
|
|
|
if (dev->connected)
|
|
|
|
{
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_toggle_set(mi, 1);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(submi, _("Disconnect"));
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_callback_set(submi, _ebluez4_cb_disconnect, dev);
|
2013-01-04 08:12:50 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_toggle_set(mi, 0);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(submi, _("Connect"));
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_callback_set(submi, _ebluez4_cb_connect, dev);
|
2013-01-04 08:12:50 -08:00
|
|
|
}
|
2013-01-04 08:12:54 -08:00
|
|
|
submi = e_menu_item_new(subm);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(submi, _("Forget"));
|
2013-01-04 08:12:54 -08:00
|
|
|
e_menu_item_callback_set(submi, _ebluez4_cb_forget, dev);
|
2013-03-09 02:47:30 -08:00
|
|
|
|
2013-03-17 08:07:34 -07:00
|
|
|
#ifdef HAVE_BLUETOOTH
|
|
|
|
if (autolock_initted)
|
|
|
|
{
|
|
|
|
/* Auto lock when away */
|
|
|
|
submi = e_menu_item_new(subm);
|
|
|
|
e_menu_item_check_set(submi, 1);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(submi, _("Lock on disconnect"));
|
2013-03-17 08:07:34 -07:00
|
|
|
e_menu_item_callback_set(submi, _ebluez4_cb_lock, dev);
|
|
|
|
chk = ebluez4_config->lock_dev_addr && dev->addr &&
|
|
|
|
!strcmp(dev->addr, ebluez4_config->lock_dev_addr);
|
|
|
|
e_menu_item_toggle_set(submi, !!chk);
|
|
|
|
|
|
|
|
submi = e_menu_item_new(subm);
|
|
|
|
e_menu_item_check_set(submi, 1);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(submi, _("Unlock on disconnect"));
|
2013-03-17 08:07:34 -07:00
|
|
|
e_menu_item_callback_set(submi, _ebluez4_cb_unlock, dev);
|
|
|
|
chk = ebluez4_config->unlock_dev_addr && dev->addr &&
|
|
|
|
!strcmp(dev->addr, ebluez4_config->unlock_dev_addr);
|
|
|
|
e_menu_item_toggle_set(submi, !!chk);
|
|
|
|
}
|
|
|
|
#endif
|
2013-01-04 08:12:45 -08:00
|
|
|
}
|
2013-01-04 08:11:48 -08:00
|
|
|
|
2013-01-04 08:12:45 -08:00
|
|
|
return ret;
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-04 08:12:45 -08:00
|
|
|
_ebluez4_menu_new(Instance *inst)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-01-04 08:12:45 -08:00
|
|
|
E_Menu *m;
|
|
|
|
E_Menu_Item *mi;
|
|
|
|
|
|
|
|
m = e_menu_new();
|
2013-01-04 08:13:17 -08:00
|
|
|
e_menu_post_deactivate_callback_set(m, _menu_post_deactivate, inst);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_title_set(m, _("Bluez4"));
|
2013-01-04 08:12:45 -08:00
|
|
|
inst->menu = m;
|
|
|
|
|
|
|
|
if (_ebluez4_add_devices(inst))
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(m);
|
|
|
|
e_menu_item_separator_set(mi, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(mi, _("Search New Devices"));
|
2013-01-04 08:12:45 -08:00
|
|
|
e_menu_item_callback_set(mi, _ebluez4_cb_search, inst);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_menu_item_label_set(mi, _("Adapter Settings"));
|
2013-01-04 08:13:03 -08:00
|
|
|
e_menu_item_callback_set(mi, _ebluez4_cb_adap_list, inst);
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez4_cb_mouse_down(void *data, Evas *evas EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED, void *event)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
2014-06-19 10:18:35 -07:00
|
|
|
int x, y;
|
2013-01-04 08:11:48 -08:00
|
|
|
|
|
|
|
if (!(inst = data)) return;
|
|
|
|
if (ev->button != 1) return;
|
2013-01-04 08:12:20 -08:00
|
|
|
if (!ctxt->adap_obj) return;
|
2013-01-04 08:11:48 -08:00
|
|
|
|
2013-01-04 08:12:45 -08:00
|
|
|
_ebluez4_menu_new(inst);
|
2014-06-19 10:18:35 -07:00
|
|
|
|
|
|
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, NULL, NULL);
|
|
|
|
e_menu_activate_mouse(inst->menu,
|
2015-03-13 14:47:36 -07:00
|
|
|
e_zone_current_get(),
|
2014-06-19 10:18:35 -07:00
|
|
|
x + ev->output.x, y + ev->output.y, 1, 1,
|
|
|
|
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
|
|
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
|
|
|
|
2013-01-04 08:13:17 -08:00
|
|
|
e_gadcon_locked_set(inst->gcc->gadcon, 1);
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 08:12:20 -08:00
|
|
|
static void
|
|
|
|
_ebluez4_set_mod_icon(Evas_Object *base)
|
|
|
|
{
|
|
|
|
char edj_path[4096];
|
|
|
|
char *group;
|
|
|
|
|
|
|
|
snprintf(edj_path, sizeof(edj_path), "%s/e-module-bluez4.edj", mod->dir);
|
|
|
|
if (ctxt->adap_obj)
|
2013-01-26 22:50:42 -08:00
|
|
|
group = "e/modules/bluez4/main";
|
2013-01-04 08:12:20 -08:00
|
|
|
else
|
2013-01-26 22:50:42 -08:00
|
|
|
group = "e/modules/bluez4/inactive";
|
2013-01-04 08:12:20 -08:00
|
|
|
|
|
|
|
if (!e_theme_edje_object_set(base, "base/theme/modules/bluez4", group))
|
|
|
|
edje_object_file_set(base, edj_path, group);
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
/* Gadcon */
|
|
|
|
static E_Gadcon_Client *
|
|
|
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
|
|
|
|
inst = E_NEW(Instance, 1);
|
|
|
|
|
|
|
|
inst->o_bluez4 = edje_object_add(gc->evas);
|
2013-01-04 08:12:20 -08:00
|
|
|
_ebluez4_set_mod_icon(inst->o_bluez4);
|
2013-01-04 08:11:48 -08:00
|
|
|
|
|
|
|
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_bluez4);
|
|
|
|
inst->gcc->data = inst;
|
|
|
|
|
2013-01-04 08:13:21 -08:00
|
|
|
e_gadcon_client_util_menu_attach(inst->gcc);
|
2013-01-04 08:11:48 -08:00
|
|
|
evas_object_event_callback_add(inst->o_bluez4, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_ebluez4_cb_mouse_down, inst);
|
|
|
|
|
|
|
|
instances = eina_list_append(instances, inst);
|
|
|
|
|
|
|
|
return inst->gcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
|
|
|
|
if (!(inst = gcc->data)) return;
|
|
|
|
instances = eina_list_remove(instances, inst);
|
|
|
|
|
|
|
|
if (inst->o_bluez4)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del(inst->o_bluez4, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_ebluez4_cb_mouse_down);
|
|
|
|
evas_object_del(inst->o_bluez4);
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:13:38 -08:00
|
|
|
if (inst->menu) e_menu_deactivate(inst->menu);
|
2013-01-04 08:12:28 -08:00
|
|
|
_ebluez4_search_dialog_del(inst);
|
2013-01-04 08:13:03 -08:00
|
|
|
_ebluez4_adap_list_dialog_del(inst);
|
2013-01-04 08:11:48 -08:00
|
|
|
|
|
|
|
E_FREE(inst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
2014-05-07 02:23:09 -07:00
|
|
|
_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
snprintf(tmpbuf, sizeof(tmpbuf), "bluez4.%d", eina_list_count(instances));
|
|
|
|
return tmpbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-07 02:23:09 -07:00
|
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
|
|
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
2014-05-07 02:23:09 -07:00
|
|
|
_gc_label(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-04-28 13:49:16 -07:00
|
|
|
return _("Bluez4");
|
2013-01-04 08:11:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2014-05-07 02:23:09 -07:00
|
|
|
_gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
|
|
|
Evas_Object *o = NULL;
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-bluez4.edj", mod->dir);
|
|
|
|
|
|
|
|
o = edje_object_add(evas);
|
|
|
|
|
|
|
|
edje_object_file_set(o, buf, "icon");
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const E_Gadcon_Client_Class _gc_class =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION, "bluez4",
|
|
|
|
{_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon,
|
|
|
|
_gc_id_new, NULL, NULL},
|
|
|
|
E_GADCON_CLIENT_STYLE_PLAIN
|
|
|
|
};
|
|
|
|
|
2013-03-17 08:07:34 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_ebluez_exe_die(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event_info)
|
|
|
|
{
|
|
|
|
Ecore_Exe_Event_Del *ev = event_info;
|
|
|
|
|
|
|
|
if (ev->exe != autolock_exe)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
|
|
|
if (!autolock_initted)
|
|
|
|
{
|
|
|
|
if (ev->exit_code == 0)
|
|
|
|
{
|
|
|
|
autolock_initted = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_desklock_state_get()) // Locked state ?
|
|
|
|
{
|
|
|
|
if (!autolock_waiting)
|
|
|
|
{
|
|
|
|
// Not waiting yet for the auto unlock device to appear before unlock
|
|
|
|
if (ev->exit_code == 0 && ebluez4_config->unlock_dev_addr)
|
|
|
|
{
|
|
|
|
e_desklock_hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ev->exit_code == 1)
|
|
|
|
{
|
|
|
|
// The device just disapeared, now we can wait for it to disapear
|
|
|
|
autolock_waiting = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!autolock_waiting)
|
|
|
|
{
|
|
|
|
// Not waiting yet for the auto lock device to disappear before locking
|
|
|
|
if (ev->exit_code == 1 && ebluez4_config->lock_dev_addr)
|
|
|
|
{
|
|
|
|
e_desklock_show(EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ev->exit_code == 0)
|
|
|
|
{
|
|
|
|
// The device just appeared, now we can wait for it to disapear
|
|
|
|
autolock_waiting = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autolock_initted)
|
|
|
|
autolock_poller = ecore_poller_add(ECORE_POLLER_CORE, 32, _ebluez_l2ping_poller, NULL);
|
|
|
|
|
|
|
|
autolock_exe = NULL;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez_exe_out(void *data EINA_UNUSED, int ev_type EINA_UNUSED,
|
|
|
|
void *ev EINA_UNUSED)
|
2013-03-17 08:07:34 -07:00
|
|
|
{
|
|
|
|
/* FIXME: Need experiment, but we should be able to use latency to somehow estimate distance, right ? */
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-05-07 02:23:09 -07:00
|
|
|
_ebluez_desklock(void *data EINA_UNUSED, int ev_type EINA_UNUSED,
|
|
|
|
void *ev EINA_UNUSED)
|
2013-03-17 08:07:34 -07:00
|
|
|
{
|
|
|
|
if (autolock_exe)
|
|
|
|
ecore_exe_kill(autolock_exe);
|
|
|
|
autolock_exe = NULL;
|
|
|
|
|
|
|
|
if (!autolock_poller && autolock_initted && (ebluez4_config->lock_dev_addr || ebluez4_config->unlock_dev_addr))
|
|
|
|
autolock_poller = ecore_poller_add(ECORE_POLLER_CORE, 32, _ebluez_l2ping_poller, NULL);
|
|
|
|
|
|
|
|
autolock_waiting = EINA_TRUE;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
/* Module Functions */
|
|
|
|
EAPI void *
|
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2013-03-17 08:07:34 -07:00
|
|
|
Eina_Strbuf *buf;
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
mod = m;
|
|
|
|
|
2013-03-09 02:47:30 -08:00
|
|
|
conf_edd = E_CONFIG_DD_NEW("Config", Config);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Config
|
|
|
|
#define D conf_edd
|
2013-03-17 08:07:34 -07:00
|
|
|
E_CONFIG_VAL(D, T, lock_dev_addr, STR);
|
|
|
|
E_CONFIG_VAL(D, T, unlock_dev_addr, STR);
|
2013-03-09 02:47:30 -08:00
|
|
|
|
|
|
|
ebluez4_config = e_config_domain_load("module.ebluez4", conf_edd);
|
|
|
|
if (!ebluez4_config)
|
|
|
|
ebluez4_config = E_NEW(Config, 1);
|
|
|
|
|
2013-04-23 08:08:29 -07:00
|
|
|
ebluez4_eldbus_init();
|
2013-01-04 08:11:48 -08:00
|
|
|
|
|
|
|
e_gadcon_provider_register(&_gc_class);
|
|
|
|
|
2013-03-17 08:07:34 -07:00
|
|
|
autolock_die = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ebluez_exe_die, NULL);
|
|
|
|
autolock_out = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _ebluez_exe_out, NULL);
|
|
|
|
autolock_desklock = ecore_event_handler_add(E_EVENT_DESKLOCK, _ebluez_desklock, NULL);
|
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
eina_strbuf_append_printf(buf, "%s/enlightenment/utils/enlightenment_sys -t l2ping",
|
|
|
|
e_prefix_lib_get());
|
|
|
|
autolock_exe = ecore_exe_run(eina_strbuf_string_get(buf), NULL);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
|
2013-01-04 08:11:48 -08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2014-05-07 02:23:09 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-03-09 02:47:30 -08:00
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
|
2013-03-17 08:07:34 -07:00
|
|
|
if (autolock_exe) ecore_exe_kill(autolock_exe);
|
|
|
|
autolock_exe = NULL;
|
2013-03-20 01:33:40 -07:00
|
|
|
E_FREE_FUNC(autolock_poller, ecore_poller_del);
|
2013-03-17 08:07:34 -07:00
|
|
|
|
|
|
|
ecore_event_handler_del(autolock_die);
|
|
|
|
ecore_event_handler_del(autolock_out);
|
|
|
|
ecore_event_handler_del(autolock_desklock);
|
|
|
|
|
|
|
|
eina_stringshare_del(ebluez4_config->lock_dev_addr);
|
|
|
|
eina_stringshare_del(ebluez4_config->unlock_dev_addr);
|
2013-03-09 02:47:30 -08:00
|
|
|
free(ebluez4_config);
|
|
|
|
ebluez4_config = NULL;
|
|
|
|
|
2013-04-23 08:08:29 -07:00
|
|
|
ebluez4_eldbus_shutdown();
|
2013-01-04 08:13:38 -08:00
|
|
|
e_gadcon_provider_unregister(&_gc_class);
|
2013-01-04 08:11:48 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2014-05-07 02:23:09 -07:00
|
|
|
e_modapi_save(E_Module *m EINA_UNUSED)
|
2013-01-04 08:11:48 -08:00
|
|
|
{
|
2013-03-10 07:37:05 -07:00
|
|
|
e_config_domain_save("module.ebluez4",
|
|
|
|
conf_edd, ebluez4_config);
|
2013-01-04 08:11:48 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Public Functions */
|
|
|
|
void
|
2013-01-04 08:12:58 -08:00
|
|
|
ebluez4_update_inst(Evas_Object *dest, Eina_List *src, Instance *inst)
|
2013-01-04 08:12:11 -08:00
|
|
|
{
|
|
|
|
Device *dev;
|
2013-01-04 08:13:30 -08:00
|
|
|
Evas_Object *o_type;
|
2013-01-04 08:13:03 -08:00
|
|
|
Adapter *adap;
|
2013-01-04 08:12:11 -08:00
|
|
|
Eina_List *iter;
|
|
|
|
|
|
|
|
e_widget_ilist_freeze(dest);
|
|
|
|
e_widget_ilist_clear(dest);
|
|
|
|
|
2013-01-04 08:13:03 -08:00
|
|
|
if (src == ctxt->found_devices)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(src, iter, dev)
|
|
|
|
if (!dev->paired)
|
2013-01-04 08:13:30 -08:00
|
|
|
{
|
|
|
|
o_type = e_widget_label_add(evas_object_evas_get(dest),
|
|
|
|
dev->type);
|
|
|
|
e_widget_ilist_append_full(dest, NULL, o_type, dev->name,
|
|
|
|
_ebluez4_cb_pair, inst, dev->addr);
|
|
|
|
|
|
|
|
}
|
2013-01-04 08:13:03 -08:00
|
|
|
}
|
|
|
|
else if (src == ctxt->adapters)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(src, iter, adap)
|
2013-01-04 08:13:07 -08:00
|
|
|
e_widget_ilist_append(dest, NULL, adap->name,
|
|
|
|
_ebluez4_cb_adap_settings, adap, NULL);
|
2013-01-04 08:13:03 -08:00
|
|
|
}
|
2013-01-04 08:12:11 -08:00
|
|
|
|
|
|
|
e_widget_ilist_go(dest);
|
2013-01-04 08:13:30 -08:00
|
|
|
e_widget_ilist_thaw(dest);
|
2013-01-04 08:12:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-04 08:12:45 -08:00
|
|
|
ebluez4_update_instances(Eina_List *src)
|
2013-01-04 08:12:11 -08:00
|
|
|
{
|
|
|
|
Eina_List *iter;
|
|
|
|
Instance *inst;
|
|
|
|
|
2013-01-04 08:13:03 -08:00
|
|
|
EINA_LIST_FOREACH(instances, iter, inst)
|
|
|
|
if (src == ctxt->found_devices && inst->found_list)
|
|
|
|
ebluez4_update_inst(inst->found_list, src, inst);
|
|
|
|
else if (src == ctxt->adapters && inst->adap_list)
|
|
|
|
ebluez4_update_inst(inst->adap_list, src, inst);
|
2013-01-04 08:12:11 -08:00
|
|
|
}
|
2013-01-04 08:12:20 -08:00
|
|
|
|
|
|
|
void
|
2013-01-04 08:13:12 -08:00
|
|
|
ebluez4_update_all_gadgets_visibility(void)
|
2013-01-04 08:12:20 -08:00
|
|
|
{
|
|
|
|
Eina_List *iter;
|
|
|
|
Instance *inst;
|
|
|
|
|
|
|
|
if (ctxt->adap_obj)
|
|
|
|
EINA_LIST_FOREACH(instances, iter, inst)
|
|
|
|
_ebluez4_set_mod_icon(inst->o_bluez4);
|
|
|
|
else
|
|
|
|
EINA_LIST_FOREACH(instances, iter, inst)
|
|
|
|
{
|
|
|
|
_ebluez4_set_mod_icon(inst->o_bluez4);
|
2013-01-04 08:13:38 -08:00
|
|
|
if (inst->menu) e_menu_deactivate(inst->menu);
|
2013-01-04 08:12:28 -08:00
|
|
|
_ebluez4_search_dialog_del(inst);
|
2013-01-04 08:13:03 -08:00
|
|
|
_ebluez4_adap_list_dialog_del(inst);
|
2013-01-04 08:12:20 -08:00
|
|
|
}
|
|
|
|
}
|
2013-01-04 08:12:37 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
ebluez4_show_error(const char *err_name, const char *err_msg)
|
|
|
|
{
|
|
|
|
snprintf(tmpbuf, sizeof(tmpbuf), "%s: %s.", err_name, err_msg);
|
2013-04-28 13:49:16 -07:00
|
|
|
e_util_dialog_internal(_("An error has ocurred"), tmpbuf);
|
2013-01-04 08:12:37 -08:00
|
|
|
}
|
2013-01-04 08:13:07 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
ebluez4_adapter_settings_del(E_Dialog *dialog)
|
|
|
|
{
|
|
|
|
Adapter *adap;
|
|
|
|
Eina_List *ck_list;
|
|
|
|
|
|
|
|
if (!dialog) return;
|
|
|
|
adap = dialog->data;
|
|
|
|
ck_list = e_object_data_get(E_OBJECT(dialog));
|
|
|
|
eina_list_free(ck_list);
|
|
|
|
e_object_del(E_OBJECT(dialog));
|
|
|
|
adap->dialog = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ebluez4_adapter_properties_update(void *data)
|
|
|
|
{
|
|
|
|
Eina_List *ck_list;
|
|
|
|
Evas_Object *ck;
|
|
|
|
Adapter *adap = data;
|
|
|
|
|
|
|
|
if (!adap->dialog) return;
|
|
|
|
ck_list = e_object_data_get(E_OBJECT(adap->dialog));
|
|
|
|
ck = eina_list_nth(ck_list, 0);
|
|
|
|
e_widget_check_checked_set(ck, adap->powered);
|
|
|
|
ck = eina_list_nth(ck_list, 1);
|
|
|
|
e_widget_check_checked_set(ck, adap->visible);
|
|
|
|
ck = eina_list_nth(ck_list, 2);
|
|
|
|
e_widget_check_checked_set(ck, adap->pairable);
|
|
|
|
}
|