diff options
author | WooHyun Jung <wh0705.jung@samsung.com> | 2013-07-10 11:26:25 +0900 |
---|---|---|
committer | WooHyun Jung <wh0705.jung@samsung.com> | 2013-07-10 11:28:35 +0900 |
commit | bb66989776041f381d397715c8d3e5a62f78f909 (patch) | |
tree | b4c9453e4555ad098ee7201099436ee9e7f2d26c | |
parent | e1f7237b503193170e130c7b450dd4f8fc8d6f1d (diff) | |
download | efl-assist-bb66989776041f381d397715c8d3e5a62f78f909.tar.gz efl-assist-bb66989776041f381d397715c8d3e5a62f78f909.tar.bz2 efl-assist-bb66989776041f381d397715c8d3e5a62f78f909.zip |
Refactoring for removing desktop build environment, supporting menu button event, and making ea_init and ea_shutdown do nothing.
Change-Id: I6f345f9ce9e2e3a2e695432f5398317a507d6da2
-rw-r--r-- | packaging/efl-assist.spec | 6 | ||||
-rw-r--r-- | src/include/efl_assist_editfield.h | 3 | ||||
-rw-r--r-- | src/include/efl_assist_private.h | 22 | ||||
-rw-r--r-- | src/lib/CMakeLists.txt | 28 | ||||
-rw-r--r-- | src/lib/efl_assist.c | 48 | ||||
-rw-r--r-- | src/lib/efl_assist_events.c | 70 |
6 files changed, 45 insertions, 132 deletions
diff --git a/packaging/efl-assist.spec b/packaging/efl-assist.spec index a1e1864..d1b0d19 100644 --- a/packaging/efl-assist.spec +++ b/packaging/efl-assist.spec @@ -5,13 +5,13 @@ Release: 1 Group: System/Libraries License: APLv2 Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: cmake BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(tts) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-appfw-application) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/include/efl_assist_editfield.h b/src/include/efl_assist_editfield.h index 2c96f60..c56b0bb 100644 --- a/src/include/efl_assist_editfield.h +++ b/src/include/efl_assist_editfield.h @@ -20,9 +20,6 @@ #include <Elementary.h> #include <stdbool.h> -#ifndef DESKTOP - #include <tizen.h> -#endif #ifdef __cplusplus extern "C" { diff --git a/src/include/efl_assist_private.h b/src/include/efl_assist_private.h index 61995a4..7dbdb6e 100644 --- a/src/include/efl_assist_private.h +++ b/src/include/efl_assist_private.h @@ -23,6 +23,9 @@ #include <stdlib.h> #include <string.h> #include <strings.h> +#include <tizen.h> +#include <app.h> +#include <dlog.h> #ifdef __cplusplus extern "C" { @@ -51,25 +54,6 @@ typedef unsigned int ea_magic; void _ea_magic_fail(const void *d, ea_magic m, ea_magic req_m, const char *fname); -#define CRITICAL(...) EINA_LOG_DOM_CRIT(_ea.ea_log_dom, __VA_ARGS__) -#define ERR(...) EINA_LOG_DOM_ERR(_ea.ea_log_dom, __VA_ARGS__) -#define WRN(...) EINA_LOG_DOM_WARN(_ea.ea_log_dom, __VA_ARGS__) -#define INF(...) EINA_LOG_DOM_INFO(_ea.ea_log_dom, __VA_ARGS__) -#define DBG(...) EINA_LOG_DOM_DBG(_ea.ea_log_dom, __VA_ARGS__) - -typedef struct _Ea Ea; -typedef struct _Ea_Event_Mgr Ea_Event_Mgr; - -struct _Ea -{ - Eina_List *event_mgrs; - int ea_log_dom; -}; - -extern Ea _ea; - -void ea_event_mgr_clear(Ea_Event_Mgr *event_mgr); - #ifdef __cplusplus } #endif diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index e45b392..b647f6f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,27 +1,13 @@ -option(DESKTOP "Build for i386 linux desktop" OFF) - -if (DESKTOP) - SET(LIB_SRCS - efl_assist.c - efl_assist_editfield.c - efl_assist_events.c) -else (DESKTOP) - SET(LIB_SRCS - efl_assist.c - efl_assist_editfield.c - efl_assist_events.c - efl_assist_screen_reader.c) -endif (DESKTOP) +SET(LIB_SRCS + efl_assist.c + efl_assist_editfield.c + efl_assist_events.c + efl_assist_screen_reader.c) ADD_LIBRARY(${LIB_NAME} SHARED ${LIB_SRCS}) -if (DESKTOP) - PKG_CHECK_MODULES(LIB_PKGS REQUIRED elementary) - ADD_DEFINITIONS("-DDESKTOP=1") - ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))") -else (DESKTOP) - PKG_CHECK_MODULES(LIB_PKGS REQUIRED elementary capi-base-common capi-appfw-application vconf tts) -endif (DESKTOP) +ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))") +PKG_CHECK_MODULES(LIB_PKGS REQUIRED elementary vconf tts capi-base-common capi-appfw-application dlog) FOREACH(flag ${LIB_PKGS_CFLAGS}) SET(LIB_CFLAGS "${LIB_CFLAGS} ${flag}") diff --git a/src/lib/efl_assist.c b/src/lib/efl_assist.c index b28a21d..0e3420f 100644 --- a/src/lib/efl_assist.c +++ b/src/lib/efl_assist.c @@ -22,40 +22,6 @@ * Local * *===========================================================================*/ -Ea _ea; - -static void -ea_init(void) -{ - memset(&_ea, 0x00, sizeof(_ea)); - - _ea.ea_log_dom = eina_log_domain_register("efl-assist", - EINA_COLOR_LIGHTBLUE); - if (!_ea.ea_log_dom) - { - EINA_LOG_ERR("could not register efl-assist log domain"); - _ea.ea_log_dom = EINA_LOG_DOMAIN_GLOBAL; - } -} - -static void -ea_shutdown(void) -{ - Eina_List *l; - Ea_Event_Mgr *event_mgr; - - //Remove Event Managers - EINA_LIST_FOREACH(_ea.event_mgrs, l, event_mgr) - ea_event_mgr_clear(event_mgr); - _ea.event_mgrs = eina_list_free(_ea.event_mgrs); - - if ((_ea.ea_log_dom > - 1) && (_ea.ea_log_dom != EINA_LOG_DOMAIN_GLOBAL)) - { - eina_log_domain_unregister(_ea.ea_log_dom); - _ea.ea_log_dom = -1; - } -} - static const char * _magic_string_get(ea_magic m) { @@ -74,17 +40,11 @@ _magic_string_get(ea_magic m) __CONSTRUCTOR__ static void ea_mod_init(void) { - ea_init(); - - DBG("loaded"); } __DESTRUCTOR__ static void ea_mod_shutdown(void) { - DBG("unloaded"); - - ea_shutdown(); } @@ -95,14 +55,14 @@ ea_mod_shutdown(void) void _ea_magic_fail(const void *d, ea_magic m, ea_magic req_m, const char *fname) { - ERR("\n*** MAGIC FAIL (%s) ***\n", fname); + LOGE("\n*** MAGIC FAIL (%s) ***\n", fname); if (!d) - ERR(" Input handle pointer is NULL!"); + LOGE(" Input handle pointer is NULL!"); else if (m == EA_MAGIC_NONE) - ERR(" Input handle has already been freed!"); + LOGE(" Input handle has already been freed!"); else if (m != req_m) - ERR(" Input handle is wrong type\n" + LOGE(" Input handle is wrong type\n" " Expected: %08x - %s\n" " Supplied: %08x - %s", (unsigned int)req_m, _magic_string_get(req_m), diff --git a/src/lib/efl_assist_events.c b/src/lib/efl_assist_events.c index cfb6592..85f205b 100644 --- a/src/lib/efl_assist_events.c +++ b/src/lib/efl_assist_events.c @@ -1,6 +1,8 @@ #include "efl_assist.h" #include "efl_assist_private.h" +typedef struct _Ea_Event_Mgr Ea_Event_Mgr; + struct _Ea_Event_Mgr { Eina_List *obj_events; @@ -26,9 +28,13 @@ typedef struct _Ea_Event_Callback const char *EA_OBJ_KEY_EVENT_MGR = "_ea_obj_key_event_mgr"; const char *EA_OBJ_KEY_OBJ_EVENT = "_ea_obj_key_obj_event"; -const char *EA_KEY_BACK = "XF86Stop"; -const char *EA_KEY_BACK2 = "Escape"; +const char *EA_KEY_STOP = "XF86Stop"; +const char *EA_KEY_STOP2 = "Escape"; const char *EA_KEY_SEND = "XF86Send"; +const char *EA_KEY_SEND2 = "Menu"; + + +static Eina_List *event_mgrs = NULL; static void _ea_event_mgr_del(Ea_Event_Mgr *event_mgr) @@ -37,7 +43,7 @@ _ea_event_mgr_del(Ea_Event_Mgr *event_mgr) //Redundant Event Mgr. Remove it. evas_object_del(event_mgr->key_grab_rect); - _ea.event_mgrs = eina_list_remove(_ea.event_mgrs, event_mgr); + event_mgrs = eina_list_remove(event_mgrs, event_mgr); free(event_mgr); } @@ -232,10 +238,12 @@ _ea_key_grab_rect_key_up_cb(void *data, Evas *e, Evas_Object *obj, obj_event = _ea_top_obj_event_find(event_mgr); if (!obj_event) return; - if (!strcmp(ev->keyname, EA_KEY_BACK) || !strcmp(ev->keyname, EA_KEY_BACK2)) + if (!strcmp(ev->keyname, EA_KEY_STOP) || !strcmp(ev->keyname, EA_KEY_STOP2)) type = EA_CALLBACK_BACK; - else if (!strcmp(ev->keyname, EA_KEY_SEND)) + else if (!strcmp(ev->keyname, EA_KEY_SEND) || + !strcmp(ev->keyname, EA_KEY_SEND2)) type = EA_CALLBACK_MORE; + else return; obj_event->on_callback = EINA_TRUE; EINA_LIST_FOREACH(obj_event->callbacks, l, callback) @@ -255,14 +263,18 @@ _ea_key_grab_obj_create(Ea_Event_Mgr *event_mgr) evas_object_event_callback_add(key_grab_rect, EVAS_CALLBACK_KEY_UP, _ea_key_grab_rect_key_up_cb, event_mgr); - if (!evas_object_key_grab(key_grab_rect, EA_KEY_BACK, 0, 0, EINA_FALSE)) - CRITICAL("Failed to grab END KEY\n"); + if (!evas_object_key_grab(key_grab_rect, EA_KEY_STOP, 0, 0, EINA_FALSE)) + LOGE("Failed to grab END KEY\n"); - if (!evas_object_key_grab(key_grab_rect, EA_KEY_BACK2, 0, 0, EINA_FALSE)) - CRITICAL("Failed to grab END KEY\n"); + if (!evas_object_key_grab(key_grab_rect, EA_KEY_STOP2, 0, 0, EINA_FALSE)) + LOGE("Failed to grab END KEY\n"); if (!evas_object_key_grab(key_grab_rect, EA_KEY_SEND, 0, 0, EINA_FALSE)) - CRITICAL("Failed to grab MORE KEY\n"); + LOGE("Failed to grab MORE KEY\n"); + + if (!evas_object_key_grab(key_grab_rect, EA_KEY_SEND2, 0, 0, EINA_FALSE)) + LOGE("Failed to grab MORE KEY\n"); + event_mgr->key_grab_rect = key_grab_rect; } @@ -272,7 +284,7 @@ _ea_event_mgr_new(Evas *e) Ea_Event_Mgr *event_mgr = calloc(1, sizeof(Ea_Event_Mgr)); if (!event_mgr) { - ERR("Failed to allocate event manager"); + LOGE("Failed to allocate event manager"); return NULL; } event_mgr->e = e; @@ -281,32 +293,6 @@ _ea_event_mgr_new(Evas *e) return event_mgr; } -void -ea_event_mgr_clear(Ea_Event_Mgr *event_mgr) -{ - Ea_Object_Event *obj_event; - Ea_Event_Callback *callback; - Eina_List *l, *l2; - - //Remove Object Events - EINA_LIST_FOREACH(event_mgr->obj_events, l, obj_event) - { - evas_object_event_callback_del(obj_event->obj, EVAS_CALLBACK_DEL, - _ea_object_del_cb); - //Remove Callbacks - EINA_LIST_FOREACH(obj_event->callbacks, l2, callback) - free(callback); - obj_event->callbacks = eina_list_free(obj_event->callbacks); - - free(obj_event); - } - event_mgr->obj_events = eina_list_free(event_mgr->obj_events); - - evas_object_del(event_mgr->key_grab_rect); - - free(event_mgr); -} - EAPI void * ea_object_event_callback_del(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_Cb func) { @@ -322,7 +308,7 @@ ea_object_event_callback_del(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_C if (!event_mgr || !obj_event) { - WRN("This object(%p) hasn't been registered before", obj); + LOGW("This object(%p) hasn't been registered before", obj); return NULL; } @@ -370,7 +356,7 @@ ea_object_event_callback_add(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_C //Check the registered event manager for this Evas. e = evas_object_evas_get(obj); - EINA_LIST_FOREACH(_ea.event_mgrs, l, event_mgr) + EINA_LIST_FOREACH(event_mgrs, l, event_mgr) { if (event_mgr->e == e) { @@ -383,7 +369,7 @@ ea_object_event_callback_add(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_C if (new_event_mgr) { if (!(event_mgr = _ea_event_mgr_new(e))) return; - _ea.event_mgrs = eina_list_append(_ea.event_mgrs, event_mgr); + event_mgrs = eina_list_append(event_mgrs, event_mgr); } obj_event = evas_object_data_get(obj, EA_OBJ_KEY_OBJ_EVENT); @@ -394,7 +380,7 @@ ea_object_event_callback_add(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_C obj_event = calloc(1, sizeof(Ea_Object_Event)); if (!obj_event) { - ERR("Failed to allocate object event"); + LOGE("Failed to allocate object event"); return; } evas_object_data_set(obj, EA_OBJ_KEY_OBJ_EVENT, obj_event); @@ -411,7 +397,7 @@ ea_object_event_callback_add(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_C callback = calloc(1, sizeof(Ea_Event_Callback)); if (!callback) { - ERR("Failed to allocate event callback"); + LOGE("Failed to allocate event callback"); return; } callback->type = type; |