2 #include "e_mod_main.h"
4 typedef struct _Instance Instance;
13 /* local function prototypes */
14 static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
15 static void _gc_shutdown(E_Gadcon_Client *gcc);
16 static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
17 static const char *_gc_label(E_Gadcon_Client_Class *cc);
18 static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
19 static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
20 static Eina_Bool _cb_poll(void *data);
21 static int _get_interface_class(int iclass);
24 static Eina_List *instances = NULL;
25 static const char *_bt_mod_dir = NULL;
27 static const E_Gadcon_Client_Class _gc_class =
29 GADCON_CLIENT_CLASS_VERSION, "illume-bluetooth",
30 { _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new,
31 NULL, e_gadcon_site_is_not_toolbar },
32 E_GADCON_CLIENT_STYLE_PLAIN
35 /* local function prototypes */
36 static E_Gadcon_Client *
37 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
42 inst = E_NEW(Instance, 1);
44 inst->obj = edje_object_add(gc->evas);
45 if (!e_theme_edje_object_set(inst->obj, "base/theme/modules/illume-bluetooth",
46 "modules/illume-bluetooth/main"))
48 snprintf(buff, sizeof(buff), "%s/e-module-illume-bluetooth.edj",
50 edje_object_file_set(inst->obj, buff, "modules/illume-bluetooth/main");
52 evas_object_show(inst->obj);
54 inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->obj);
55 inst->gcc->data = inst;
58 inst->poller = ecore_poller_add(ECORE_POLLER_CORE, 16, _cb_poll, inst);
63 _gc_shutdown(E_Gadcon_Client *gcc)
67 if (!(inst = gcc->data)) return;
68 instances = eina_list_remove(instances, inst);
69 if (inst->poller) ecore_poller_del(inst->poller);
70 if (inst->obj) evas_object_del(inst->obj);
75 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
81 edje_object_size_min_get(inst->obj, &mw, &mh);
82 edje_object_size_max_get(inst->obj, &xw, &xh);
83 if ((mw < 1) || (mh < 1))
84 edje_object_size_min_calc(inst->obj, &mw, &mh);
87 if ((xw > 0) && (xh > 0))
88 e_gadcon_client_aspect_set(gcc, xw, xh);
89 e_gadcon_client_min_size_set(gcc, mw, mh);
93 _gc_label(E_Gadcon_Client_Class *cc __UNUSED__)
95 return _("Illume Bluetooth");
99 _gc_icon(E_Gadcon_Client_Class *cc __UNUSED__, Evas *evas)
104 snprintf(buff, sizeof(buff), "%s/e-module-illume-bluetooth.edj",
106 o = edje_object_add(evas);
107 edje_object_file_set(o, buff, "icon");
112 _gc_id_new(E_Gadcon_Client_Class *cc __UNUSED__)
114 static char buff[32];
116 snprintf(buff, sizeof(buff), "%s.%d", _gc_class.name,
117 eina_list_count(instances));
129 inst->on = _get_interface_class(0xe0);
133 edje_object_signal_emit(inst->obj, "e,state,active", "e");
135 edje_object_signal_emit(inst->obj, "e,state,passive", "e");
137 return ECORE_CALLBACK_RENEW;
141 _get_interface_class(int iclass)
146 devs = ecore_file_ls("/sys/bus/usb/devices");
147 EINA_LIST_FREE(devs, name)
152 snprintf(buf, sizeof(buf), "%s/%s/%s",
153 "/sys/bus/usb/devices", name, "bInterfaceClass");
157 if (fgets(buf, sizeof(buf), f))
161 sscanf(buf, "%x", &id);
164 EINA_LIST_FREE(devs, name)
177 EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Bluetooth" };
180 e_modapi_init(E_Module *m)
182 _bt_mod_dir = eina_stringshare_add(m->dir);
183 e_gadcon_provider_register(&_gc_class);
188 e_modapi_shutdown(E_Module *m __UNUSED__)
190 e_gadcon_provider_unregister(&_gc_class);
191 if (_bt_mod_dir) eina_stringshare_del(_bt_mod_dir);
197 e_modapi_save(E_Module *m __UNUSED__)