Initial BlueZ stub module.

Initial module written by Gustavo F. Padovan, I changed it quite a lot
to change some issues... but still many pending, see TODO at the start
of e_mod_main.c



SVN revision: 47160
This commit is contained in:
Gustavo Sverzut Barbieri 2010-03-12 13:55:11 +00:00
parent 4bafaa704d
commit abb50ef416
13 changed files with 1992 additions and 0 deletions

View File

@ -449,6 +449,14 @@ define([CHECK_MODULE_CONNMAN],
AC_SUBST(ECONNMAN_CFLAGS)
AC_SUBST(ECONNMAN_LIBS)
AM_CONDITIONAL(HAVE_EBLUEZ, false)
define([CHECK_MODULE_BLUEZ],
[
AC_E_CHECK_PKG(EBLUEZ, [edbus ebluez],
[], [EBLUEZ=false])
])
AC_SUBST(EBLUEZ_CFLAGS)
AC_SUBST(EBLUEZ_LIBS)
AC_E_OPTIONAL_MODULE([ibar], true)
AC_E_OPTIONAL_MODULE([dropshadow], true)
@ -509,6 +517,7 @@ AC_E_OPTIONAL_MODULE([conf_scale], true)
AC_E_OPTIONAL_MODULE([gadman], true)
AC_E_OPTIONAL_MODULE([mixer], true, [CHECK_MODULE_MIXER])
AC_E_OPTIONAL_MODULE([connman], true, [CHECK_MODULE_CONNMAN])
AC_E_OPTIONAL_MODULE([bluez], true, [CHECK_MODULE_BLUEZ])
AC_E_OPTIONAL_MODULE([illume], true)
AC_E_OPTIONAL_MODULE([illume2], true)
AC_E_OPTIONAL_MODULE([syscon], true)
@ -641,6 +650,8 @@ src/modules/mixer/Makefile
src/modules/mixer/module.desktop
src/modules/connman/Makefile
src/modules/connman/module.desktop
src/modules/bluez/Makefile
src/modules/bluez/module.desktop
src/modules/illume/Makefile
src/modules/illume/module.desktop
src/modules/illume/keyboards/Makefile

View File

@ -8393,6 +8393,263 @@ collections { /* begin the collection of edje groups that are in this file */
}
}
/////////////////////////////////////////////////////////////////////////////
/*** MOD: BLUEZ ***/
group { name: "e/modules/bluez/main";
images {
image: "bluetooth-powered.png" COMP;
image: "bluetooth-inactive.png" COMP;
image: "bluetooth-hidden.png" COMP;
}
//max: 128 128;
min: 16 16;
parts {
part {
name: "eventarea";
type: RECT;
mouse_events: 1;
description {
state: "default" 0.0;
color: 255 255 255 0;
}
}
part { name: "state-clipper";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
color: 255 255 255 255;
}
}
part { name: "state";
type: IMAGE;
mouse_events: 0;
clip_to: "state-clipper";
description {
state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
fixed: 1 1;
image.normal: "bluetooth-inactive.png";
}
description { state: "powered" 0.0;
inherit: "default" 0.0;
image.normal: "bluetooth-powered.png";
}
description { state: "hidden" 0.0;
inherit: "default" 0.0;
image.normal: "bluetooth-hidden.png";
}
}
programs {
program {
signal: "e,changed,off";
source: "e";
action: STATE_SET "default" 0.0;
target: "state";
}
program {
signal: "e,changed,powered";
source: "e";
action: STATE_SET "powered" 0.0;
target: "state";
}
program {
signal: "e,changed,hidden";
source: "e";
action: STATE_SET "hidden" 0.0;
target: "state";
}
}
part {
name: "e.text.name";
type: TEXT;
mouse_events: 0;
effect: SOFT_SHADOW;
description {
state: "default" 0.0;
color: 224 224 224 255;
color3: 0 0 0 64;
align: 0.5 1.0;
rel1 {
relative: 0.0 1.0;
offset: 0 -20;
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
text {
font: "Sans";
size: 8;
align: 0.5 1.0;
text: "";
min: 1 1;
}
}
description {
state: "hidden" 0.0;
inherit: "default" 0.0;
visible: 0;
}
}
programs {
program {
name: "resize";
signal: "resize";
script {
new x, y, w, h, tx, ty, tw, th;
get_geometry(PART:"eventarea", x, y, w, h);
get_geometry(PART:"e.text.name", tx, ty, tw, th);
if ((w <= 32) || (tw >= w))
set_state(PART:"e.text.name", "hidden", 0.0);
else
set_state(PART:"e.text.name", "default", 0.0);
}
}
program {
signal: "e,changed,name";
source: "e";
action: STATE_SET "default" 0.0; // show so calcs take effect!
target: "e.text.name";
after: "resize";
}
}
}
}
group { name: "e/modules/bluez/tip";
images {
image: "bluetooth-powered.png" COMP;
image: "bluetooth-inactive.png" COMP;
image: "bluetooth-hidden.png" COMP;
}
min: 200 84;
parts {
part { name: "state-clipper";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
color: 255 255 255 255;
}
}
part { name: "state";
type: IMAGE;
mouse_events: 0;
clip_to: "state-clipper";
description {
state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
fixed: 1 1;
rel1 {
relative: 0.0 0.0;
offset: 10 10;
}
rel2 {
relative: 0.0 0.0;
offset: 73 73;
}
image.normal: "bluetooth-inactive.png";
}
description { state: "powered" 0.0;
inherit: "default" 0.0;
image.normal: "bluetooth-powered.png";
}
description { state: "hidden" 0.0;
inherit: "default" 0.0;
image.normal: "bluetooth-hidden.png";
}
}
programs {
program {
signal: "e,changed,off";
source: "e";
action: STATE_SET "default" 0.0;
target: "state";
}
program {
signal: "e,changed,powered";
source: "e";
action: STATE_SET "powered" 0.0;
target: "state";
}
program {
signal: "e,changed,hidden";
source: "e";
action: STATE_SET "hidden" 0.0;
target: "state";
}
}
part { name: "e.text.name";
type: TEXT;
mouse_events: 0;
effect: SOFT_SHADOW;
description {
state: "default" 0.0;
color: 240 240 240 255;
color3: 0 0 0 64;
align: 0.0 0.0;
rel1 {
to_x: "state";
relative: 1.0 0.0;
offset: 10 20;
}
rel2 {
relative: 1.0 0.0;
offset: -10 40;
}
text {
font: "Sans:style=Bold";
size: 16;
align: 0.0 0.0;
text: "Bluetooth Manager";
min: 1 0;
}
}
}
part { name: "e.text.status";
type: TEXT;
mouse_events: 0;
clip_to: "state-clipper";
description {
state: "default" 0.0;
color: 16 16 16 255;
rel1 {
to_y: "e.text.name";
to_x: "state";
relative: 1.0 1.0;
offset: 10 10;
}
rel2 {
to_y: "e.text.name";
relative: 1.0 1.0;
offset: -10 25;
}
text {
font: "Sans";
size: 10;
align: 0.0 0.0;
text: "";
min: 1 0;
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
/*** MOD: CONF_EDGEBINDINGS ***/

View File

@ -35,6 +35,9 @@ bd_top.png \
big_arrow_down.png \
big_arrow_up.png \
bluetooth.png \
bluetooth-powered.png \
bluetooth-inactive.png \
bluetooth-hidden.png \
bnw.png \
bt_base1.png \
bt_base2.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -238,6 +238,10 @@ if USE_MODULE_CONNMAN
SUBDIRS += connman
endif
if USE_MODULE_BLUEZ
SUBDIRS += bluez
endif
if USE_MODULE_ILLUME
SUBDIRS += illume
endif
@ -323,6 +327,7 @@ conf_scale \
gadman \
mixer \
connman \
bluez \
illume \
illume2 \
illume-bluetooth \

View File

@ -0,0 +1,33 @@
MAINTAINERCLEANFILES = Makefile.in
MODULE = bluez
# data files for the module
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
files_DATA = \
e-module-$(MODULE).edj module.desktop
EXTRA_DIST = $(files_DATA)
# the module .so file
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(top_srcdir)/src/modules/$(MODULE) \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/modules \
@e_cflags@ @EBLUEZ_CFLAGS@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.h \
e_mod_main.c \
e_mod_config.c
module_la_LIBADD = @e_libs@ @dlopen_libs@ @EBLUEZ_LIBS@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

Binary file not shown.

View File

@ -0,0 +1,173 @@
#include "e_mod_main.h"
extern const char _e_bluez_Name[];
struct _E_Config_Dialog_Data
{
E_Bluez_Instance *inst;
const char *name;
Eina_Bool mode;
unsigned int timeout;
struct {
Evas_Object *label;
Evas_Object *slider;
Evas_Object *help;
} gui;
};
/* Local Function Prototypes */
static void *_create_data(E_Config_Dialog *dialog);
static void _free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create(E_Config_Dialog *dialog, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata);
E_Config_Dialog *
e_bluez_config_dialog_new(E_Container *con, E_Bluez_Instance *inst)
{
E_Config_Dialog *dialog;
E_Config_Dialog_View *view;
if (inst->conf_dialog)
return inst->conf_dialog;
view = E_NEW(E_Config_Dialog_View, 1);
if (!view)
return NULL;
view->create_cfdata = _create_data;
view->free_cfdata = _free_data;
view->basic.create_widgets = _basic_create;
view->basic.apply_cfdata = _basic_apply;
dialog = e_config_dialog_new(con, _("Bluetooth Settings"),
_e_bluez_Name, "e_bluez_config_dialog_new",
e_bluez_theme_path(), 0, view, inst);
return dialog;
}
static void *
_create_data(E_Config_Dialog *dialog)
{
E_Config_Dialog_Data *cfdata;
E_Bluez_Instance *inst;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
if (!cfdata)
return NULL;
cfdata->inst = dialog->data;
inst = cfdata->inst;
if (!e_bluez_adapter_discoverable_get(inst->adapter, &cfdata->mode))
cfdata->mode = 0;
if (!e_bluez_adapter_discoverable_timeout_get
(inst->adapter, &cfdata->timeout))
cfdata->timeout = 0;
cfdata->timeout /= 60;
if (!e_bluez_adapter_name_get(inst->adapter, &cfdata->name))
cfdata->name = NULL;
cfdata->name = strdup(cfdata->name);
return cfdata;
}
static void
_free_data(E_Config_Dialog *dialog, E_Config_Dialog_Data *cfdata)
{
E_Bluez_Instance *inst = dialog->data;
inst->conf_dialog = NULL;
E_FREE(cfdata);
}
static void
_cb_disable_timeout(void *data, Evas_Object *obj __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
Eina_Bool disable = !cfdata->mode;
e_widget_disabled_set(cfdata->gui.label, disable);
e_widget_disabled_set(cfdata->gui.slider, disable);
e_widget_disabled_set(cfdata->gui.help, disable);
}
static Evas_Object *
_basic_create(E_Config_Dialog *dialog __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *ob;
Evas_Object *check;
char buf[48];
const char *address;
o = e_widget_list_add(evas, 0, 0);
if (!e_bluez_adapter_address_get(cfdata->inst->adapter, &address))
address = NULL;
ob = e_widget_label_add(evas, _("Name"));
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_entry_add(evas, (char **)&cfdata->name, NULL, NULL, NULL);
e_widget_list_object_append(o, ob, 1, 1, 0.5);
check = e_widget_check_add
(evas, _("Discoverable mode"), (int *)&cfdata->mode);
e_widget_list_object_append(o, check, 1, 1, 0.5);
ob = e_widget_label_add(evas, _("Discovarable Timeout"));
cfdata->gui.label = ob;
e_widget_list_object_append(o, ob, 1, 1, 0.5);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 0, 30, 1, 0,
NULL, (int*)&cfdata->timeout, 100);
e_widget_slider_special_value_add(ob, 0.0, 0.0, _("Forever"));
cfdata->gui.slider = ob;
e_widget_list_object_append(o, ob, 1, 1, 0.5);
e_widget_on_change_hook_set(check, _cb_disable_timeout, cfdata);
_cb_disable_timeout(cfdata, NULL);
snprintf(buf, sizeof(buf), _("MAC Address: %s"), address);
ob = e_widget_label_add(evas, buf);
e_widget_list_object_append(o, ob, 1, 1, 0.5);
return o;
}
static void
_method_success_check(void *data, DBusMessage *msg __UNUSED__, DBusError *error)
{
const char *name = data;
if ((!error) || (!dbus_error_is_set(error)))
return;
ERR("method %s() finished with error: %s %s\n",
name, error->name, error->message);
dbus_error_free(error);
}
static int
_basic_apply(E_Config_Dialog *dialog __UNUSED__, E_Config_Dialog_Data *cfdata)
{
E_Bluez_Instance *inst = cfdata->inst;
if (!e_bluez_adapter_discoverable_set
(inst->adapter, cfdata->mode,
_method_success_check, "e_bluez_adapter_discoverable_get"))
ERR("Can't set Discoverable on adapter");
if (!e_bluez_adapter_discoverable_timeout_set
(inst->adapter, cfdata->timeout * 60,
_method_success_check, "e_bluez_adapter_discoverable_timeout_get"))
ERR("Can't set DiscoverableTimeout on adapter");
if (!e_bluez_adapter_name_set
(inst->adapter, cfdata->name,
_method_success_check, "e_bluez_adapter_name_get"))
ERR("Can't set Name on adapter");
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
#include "config.h"
#include <e.h>
#include <E_Bluez.h>
#include <eina_log.h>
#define MOD_CONF_VERSION 2
extern int _e_bluez_log_dom;
#define DBG(...) EINA_LOG_DOM_DBG(_e_bluez_log_dom, __VA_ARGS__)
#define WRN(...) EINA_LOG_DOM_WARN(_e_bluez_log_dom, __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_e_bluez_log_dom, __VA_ARGS__)
typedef struct E_Bluez_Instance E_Bluez_Instance;
typedef struct E_Bluez_Instance_Device E_Bluez_Instance_Device;
typedef struct E_Bluez_Module_Context E_Bluez_Module_Context;
struct E_Bluez_Instance
{
E_Bluez_Module_Context *ctxt;
E_Gadcon_Client *gcc;
E_Gadcon_Popup *popup;
E_Menu *menu;
/* used by popup */
int powered;
Eina_Bool first_selection;
const char *address;
const char *alias;
Eina_List *devices;
E_Bluez_Element *adapter;
double last_scan;
Eina_Bool discovering:1;
Eina_Bool powered_pending:1;
Eina_Bool discoverable:1;
struct
{
Evas_Object *gadget;
Evas_Object *list;
Evas_Object *powered;
Evas_Object *button;
Evas_Object *control;
struct
{
Ecore_X_Window win;
Ecore_Event_Handler *mouse_up;
Ecore_Event_Handler *key_down;
} input;
} ui;
E_Gadcon_Popup *tip;
Evas_Object *o_tip;
E_Config_Dialog *conf_dialog;
};
struct E_Bluez_Instance_Device
{
const char *address;
const char *alias;
// TODO (and also show list icon!): Eina_Bool paired:1;
// TODO (and also show list icon!): Eina_Bool trusted:1;
// TODO (and also show list icon!): Eina_Bool connected:1;
// TODO ... class, icon
};
struct E_Bluez_Module_Context
{
Eina_List *instances;
E_Bluez_Instance *default_instance;
const char *default_adapter;
struct {
E_DBus_Connection *conn;
E_DBus_Interface *iface;
E_DBus_Object *obj;
Eina_List *pending;
} agent;
struct
{
E_Action *toggle_powered;
} actions;
struct
{
Ecore_Event_Handler *manager_in;
Ecore_Event_Handler *manager_out;
Ecore_Event_Handler *device_found;
Ecore_Event_Handler *element_updated;
} event;
struct
{
Ecore_Poller *manager_changed;
} poller;
Eina_Bool has_manager:1;
};
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
const char *e_bluez_theme_path(void);
E_Config_Dialog *e_bluez_config_dialog_new(E_Container *con, E_Bluez_Instance *inst);
void _bluez_toggle_powered(E_Bluez_Instance *inst);
static inline void
_bluez_dbus_error_show(const char *msg, const DBusError *error)
{
const char *name;
if ((!error) || (!dbus_error_is_set(error)))
return;
name = error->name;
if (strncmp(name, "org.bluez.Error.",
sizeof("org.bluez.Error.") - 1) == 0)
name += sizeof("org.bluez.Error.") - 1;
e_util_dialog_show(_("Bluez Server Operation Failed"),
_("Could not execute remote operation:<br>"
"%s<br>"
"Server Error <hilight>%s:</hilight> %s"),
msg, name, error->message);
}
static inline void
_bluez_operation_error_show(const char *msg)
{
e_util_dialog_show(_("Bluez Operation Failed"),
_("Could not execute local operation:<br>%s"),
msg);
}
#endif

View File

@ -0,0 +1,6 @@
[Desktop Entry]
Type=Link
Name=Bluetooth Manager
Icon=e-module-bluez
Comment=<title>Bluetooth Management.</title>
X-Enlightenment-ModuleType=system