Add illume-bluetooth module (based on original module from illume)

SVN revision: 45273
This commit is contained in:
Christopher Michael 2010-01-18 02:02:09 +00:00
parent 8d1f4a54af
commit 0121ec9afc
7 changed files with 248 additions and 1 deletions

View File

@ -637,6 +637,8 @@ src/modules/illume-kbd-toggle/Makefile
src/modules/illume-kbd-toggle/module.desktop
src/modules/illume-mode-toggle/Makefile
src/modules/illume-mode-toggle/module.desktop
src/modules/illume-bluetooth/Makefile
src/modules/illume-bluetooth/module.desktop
src/modules/illume2/Makefile
src/modules/illume2/module.desktop
src/modules/illume2/keyboards/Makefile

View File

@ -243,7 +243,7 @@ SUBDIRS += illume
endif
if USE_MODULE_ILLUME2
SUBDIRS += illume2 illume-home illume-softkey illume-keyboard illume-indicator illume-kbd-toggle illume-mode-toggle
SUBDIRS += illume2 illume-home illume-softkey illume-keyboard illume-indicator illume-kbd-toggle illume-mode-toggle illume-bluetooth
endif
if USE_MODULE_SYSCON

View File

@ -0,0 +1,29 @@
MAINTAINERCLEANFILES = Makefile.in
MODULE = illume-bluetooth
# 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@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

View File

@ -0,0 +1,200 @@
#include "e.h"
#include "e_mod_main.h"
typedef struct _Instance Instance;
struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *obj;
Ecore_Poller *poller;
int on;
};
/* local function prototypes */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static char *_gc_label(E_Gadcon_Client_Class *cc);
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
static int _cb_poll(void *data);
static int _get_interface_class(int iclass);
/* local variables */
static Eina_List *instances = NULL;
static const char *_bt_mod_dir = NULL;
static const E_Gadcon_Client_Class _gc_class =
{
GADCON_CLIENT_CLASS_VERSION, "illume-bluetooth",
{ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new,
NULL, e_gadcon_site_is_not_toolbar },
E_GADCON_CLIENT_STYLE_PLAIN
};
/* local function prototypes */
static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
Instance *inst;
char buff[PATH_MAX];
inst = E_NEW(Instance, 1);
inst->obj = edje_object_add(gc->evas);
if (!e_theme_edje_object_set(inst->obj, "base/theme/modules/illume-bluetooth",
"modules/illume-bluetooth/main"))
{
snprintf(buff, sizeof(buff), "%s/e-module-illume-bluetooth.edj",
_bt_mod_dir);
edje_object_file_set(inst->obj, buff, "modules/illume-bluetooth/main");
}
evas_object_show(inst->obj);
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->obj);
inst->gcc->data = inst;
inst->on = -1;
inst->poller = ecore_poller_add(ECORE_POLLER_CORE, 16, _cb_poll, inst);
return inst->gcc;
}
static void
_gc_shutdown(E_Gadcon_Client *gcc)
{
Instance *inst;
if (!(inst = gcc->data)) return;
instances = eina_list_remove(instances, inst);
if (inst->poller) ecore_poller_del(inst->poller);
if (inst->obj) evas_object_del(inst->obj);
E_FREE(inst);
}
static void
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
{
Instance *inst;
int mw, mh, xw, xh;
inst = gcc->data;
edje_object_size_min_get(inst->obj, &mw, &mh);
edje_object_size_max_get(inst->obj, &xw, &xh);
if ((mw < 1) || (mh < 1))
edje_object_size_min_calc(inst->obj, &mw, &mh);
if (mw < 4) mw = 4;
if (mh < 4) mh = 4;
if ((xw > 0) && (xh > 0))
e_gadcon_client_aspect_set(gcc, xw, xh);
e_gadcon_client_min_size_set(gcc, mw, mh);
}
static char *
_gc_label(E_Gadcon_Client_Class *cc)
{
return _("Illume Bluetooth");
}
static Evas_Object *
_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas)
{
Evas_Object *o;
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s/e-module-illume-bluetooth.edj",
_bt_mod_dir);
o = edje_object_add(evas);
edje_object_file_set(o, buff, "icon");
return o;
}
static const char *
_gc_id_new(E_Gadcon_Client_Class *cc)
{
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s.%d", _gc_class.name,
eina_list_count(instances));
return strdup(buff);
}
static int
_cb_poll(void *data)
{
Instance *inst;
int pon;
inst = data;
pon = inst->on;
inst->on = _get_interface_class(0xe0);
if (inst->on != pon)
{
if (inst->on)
edje_object_signal_emit(inst->obj, "e,state,active", "e");
else
edje_object_signal_emit(inst->obj, "e,state,passive", "e");
}
return 1;
}
static int
_get_interface_class(int iclass)
{
Eina_List *devs;
char *name;
devs = ecore_file_ls("/sys/bus/usb/devices");
EINA_LIST_FREE(devs, name)
{
char buf[PATH_MAX];
FILE *f;
snprintf(buf, sizeof(buf), "%s/%s/%s",
"/sys/bus/usb/devices", name, "bInterfaceClass");
f = fopen(buf, "r");
if (f)
{
if (fgets(buf, sizeof(buf), f))
{
int id = -1;
sscanf(buf, "%x", &id);
if (iclass == id)
{
EINA_LIST_FREE(devs, name)
free(name);
fclose(f);
return 1;
}
}
fclose(f);
}
free(name);
}
return 0;
}
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Bluetooth" };
EAPI void *
e_modapi_init(E_Module *m)
{
_bt_mod_dir = eina_stringshare_add(m->dir);
e_gadcon_provider_register(&_gc_class);
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m)
{
e_gadcon_provider_unregister(&_gc_class);
if (_bt_mod_dir) eina_stringshare_del(_bt_mod_dir);
_bt_mod_dir = NULL;
return 1;
}
EAPI int
e_modapi_save(E_Module *M)
{
return 1;
}

View File

@ -0,0 +1,10 @@
#ifndef E_MOD_MAIN_H
# define E_MOD_MAIN_H
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);
#endif

View File

@ -0,0 +1,6 @@
[Desktop Entry]
Type=Link
Name=Illume-Bluetooth
Icon=e-module-illume-bluetooth
X-Enlightenment-ModuleType=system
Comment=<title>Illume Bluetooth for Embedded</title>