[screen-reader] use configuration data
authorShinwoo Kim <cinoo.kim@samsung.com>
Tue, 16 Jul 2013 07:51:38 +0000 (16:51 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 16 Jul 2013 08:50:41 +0000 (17:50 +0900)
Change-Id: If88cd15c5bf5e195b4242904726a63c1f9299d1d

screen-reader/src/Makefile.am
screen-reader/src/e_mod_config.c
screen-reader/src/e_mod_config.h [new file with mode: 0644]
screen-reader/src/e_mod_main.c
screen-reader/src/e_mod_main.h

index 22eaf77..e766988 100644 (file)
@@ -8,7 +8,8 @@ pkgdir                 = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH
 pkg_LTLIBRARIES        = module.la
 module_la_SOURCES      = e_mod_main.c \
                          e_mod_main.h \
-                                      e_mod_config.c
+                         e_mod_config.h \
+                         e_mod_config.c
 module_la_LIBADD       =
 module_la_CFLAGS       = @ENLIGHTENMENT_CFLAGS@
 module_la_LDFLAGS      = -module -avoid-version @ENLIGHTENMENT_LIBS@
index 8f9d7d3..0a3bd47 100644 (file)
@@ -1,5 +1,6 @@
 #include "e.h"
 #include "e_mod_main.h"
+#include "e_mod_config.h"
 
 struct _E_Config_Dialog_Data
 {
@@ -77,3 +78,38 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNU
    e_config_save_queue();
    return 1;
 }
+
+EAPI void
+e_mod_screen_reader_cfdata_edd_init(E_Config_DD **conf_edd)
+{
+   *conf_edd = E_CONFIG_DD_NEW("Screen_Reader_Config", Config);
+
+#undef T
+#undef D
+#define T Config
+#define D *conf_edd
+   E_CONFIG_VAL(D, T, three_finger_swipe_timeout, INT);
+}
+
+EAPI Config *
+e_mod_screen_reader_cfdata_config_new(void)
+{
+   Config *cfg;
+
+   cfg = E_NEW(Config, 1);
+
+   cfg->three_finger_swipe_timeout = 450;
+
+   return cfg;
+}
+
+EAPI void
+e_mod_screen_reader_cfdata_config_free(Config *cfg)
+{
+   if (cfg)
+     {
+        memset(cfg, 0, sizeof(Config));
+        free(cfg);
+        cfg = NULL;
+     }
+}
diff --git a/screen-reader/src/e_mod_config.h b/screen-reader/src/e_mod_config.h
new file mode 100644 (file)
index 0000000..d9b5713
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef E_MOD_CONFIG_H
+#define E_MOD_CONFIG_H
+
+typedef struct _Config Config;
+
+struct _Config
+{
+   int three_finger_swipe_timeout;
+};
+
+EAPI void    e_mod_screen_reader_cfdata_edd_init(E_Config_DD **conf_edd);
+EAPI Config *e_mod_screen_reader_cfdata_config_new(void);
+EAPI void    e_mod_screen_reader_cfdata_config_free(Config *cfg);
+
+#endif
index 195adb1..0f9200c 100644 (file)
@@ -17,6 +17,8 @@
 #define MOUSE_MOVE 1
 #define MOUSE_BUTTON_UP 2
 
+Mod *_screen_reader_mod = NULL;
+
 typedef struct
 {
    E_Zone         *zone;
@@ -667,6 +669,7 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
    int distance = 40;
    int dx, dy;
    int angle = 0;
+   int tfs_timeout = 450;
 
    if (cov->three_finger_down)
      {
@@ -675,8 +678,10 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
         dx = ev->x - cov->dx;
         dy = ev->y - cov->dy;
 
+        if (_screen_reader_mod) tfs_timeout = _screen_reader_mod->conf->three_finger_swipe_timeout;
+
         if (((dx * dx) + (dy * dy)) > (4 * distance * distance)
-            && ((ev->timestamp - cov->dt) < (timeout * 3000)))
+            && ((ev->timestamp - cov->dt) < tfs_timeout))
           {
              /* get root window rotation */
              angle = _win_angle_get(target_win);
@@ -1370,6 +1375,22 @@ _vconf_cb_accessibility_tts_change(keynode_t *node,
    elm_config_all_flush();
    elm_config_save();
 }
+
+static void
+_e_mod_config_new(E_Module *m)
+{
+   Mod *mod = m->data;
+   mod->conf = e_mod_screen_reader_cfdata_config_new();
+}
+
+static void
+_e_mod_config_free(E_Module *m)
+{
+   Mod *mod = m->data;
+
+   e_mod_screen_reader_cfdata_config_free(mod->conf);
+   mod->conf = NULL;
+}
 /***************************************************************************/
 /* module setup */
 EAPI E_Module_Api e_modapi =
@@ -1380,6 +1401,17 @@ EAPI E_Module_Api e_modapi =
 EAPI void *
 e_modapi_init(E_Module *m)
 {
+   Mod *mod;
+
+   mod = calloc(1, sizeof(Mod));
+   m->data = mod;
+   e_mod_screen_reader_cfdata_edd_init(&(mod->conf_edd));
+   mod->conf = e_config_domain_load("module.screen-reader-tizen", mod->conf_edd);
+
+   if (!mod->conf) _e_mod_config_new(m);
+
+   _screen_reader_mod = mod;
+
    vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS,
                             _vconf_cb_accessibility_tts_change,
                             NULL);
@@ -1421,7 +1453,7 @@ e_modapi_init(E_Module *m)
 }
 
 EAPI int
-e_modapi_shutdown(E_Module *m __UNUSED__)
+e_modapi_shutdown(E_Module *m)
 {
    INF("[screen-reader module] module shutdown");
    if (property_handler) ecore_event_handler_del(property_handler);
@@ -1429,6 +1461,16 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
    _covers_shutdown();
    _events_shutdown();
 
+   Mod *mod = m->data;
+
+   if (mod == _screen_reader_mod) _screen_reader_mod = NULL;
+   _e_mod_config_free(m);
+   E_CONFIG_DD_FREE(mod->conf_edd);
+
+   memset(mod, 0, sizeof(Mod));
+   free(mod);
+   mod = NULL;
+
    return 1;
 }
 
index 91d22f1..9c38209 100644 (file)
@@ -1,12 +1,13 @@
 #ifndef E_MOD_MAIN_H
 #define E_MOD_MAIN_H
 
-typedef struct _Config       Config;
+#include "e_mod_config.h"
+typedef struct _Mod    Mod;
 
-struct _Config
+struct _Mod
 {
-   /* saved * loaded config values */
-   Eina_Bool            window;
+   E_Config_DD     *conf_edd;
+   Config          *conf;
 };
 
 EAPI extern E_Module_Api e_modapi;