#include "vc_elm_main.h"
#include <voice_control_elm.h>
#include <voice_control_elm_private.h>
+#include <vconf.h>
#include "vc_elm.h"
#include "vc_elm_core.h"
#include "vc_elm_tooltip.h"
#include "vc_elm_widget_wrapper.h"
+//#define VC_VOICE_TOUCH_AUTOMODE VCONFKEY_VC_VOICE_TOUCH_AUTOMODE
+#define VC_VOICE_TOUCH_AUTOMODE "db/voice/vc/voice_touch/automode"
+
+#define VC_ELM_MODE_MANUAL 0
+
+#define VC_ELM_MODE_AUTO_APP 1
+
+#define VC_ELM_MODE_AUTO_APPFW 2
+
/**
* @brief Internal variable. It can check whether voice control elm is initilaized or not.
*/
return VC_ELM_ERROR_NONE;
}
+int _vc_elm_is_supported_vt_auto(bool* is_vt_automode)
+{
+ if (0 != __vc_elm_get_feature_enabled()) {
+ return VC_ELM_ERROR_NOT_SUPPORTED;
+ }
+
+ int ret = -1;
+ ret = vconf_get_bool(VC_VOICE_TOUCH_AUTOMODE, is_vt_automode);
+
+ if (0 != ret) {
+ VC_ELM_LOG_DBG("Fail to get vconfkey");
+ return VC_ELM_ERROR_OPERATION_FAILED;
+ }
+
+ VC_ELM_LOG_DBG("Success to get vconfkey(%d)", (int)(*is_vt_automode));
+
+ return ret;
+}
+
+int vc_elm_is_supported_vt_auto(bool* is_vt_automode)
+{
+ if (0 != __vc_elm_get_feature_enabled()) {
+ return VC_ELM_ERROR_NOT_SUPPORTED;
+ }
+
+ return _vc_elm_is_supported_vt_auto(is_vt_automode);
+}
+
int _vc_elm_set_auto_register_mode(int mode, int click_method)
{
g_auto_mode = mode;
g_click_method = click_method;
+ VC_ELM_LOG_DBG("g_auto_mode: %d, g_click_method: %d", g_auto_mode, g_click_method);
+
return 0;
}
+
int _vc_elm_get_auto_register_mode(int* mode, int* click_method)
{
- *mode = g_auto_mode;
- *click_method = g_click_method;
+ bool is_vt_auto;
+ if (0 != _vc_elm_is_supported_vt_auto(&is_vt_auto)) {
+ return VC_ELM_ERROR_OPERATION_FAILED;
+ } else {
+ if (false == is_vt_auto) {
+ VC_ELM_LOG_DBG("vt_automode is FALSE");
+ *mode = g_auto_mode;
+ *click_method = g_click_method;
+ } else {
+ VC_ELM_LOG_DBG("vt_automode is TRUE");
+ *mode = (int)VC_ELM_MODE_AUTO_APPFW;
+ *click_method = g_click_method;
+ }
+ }
+
+ VC_ELM_LOG_DBG("mode: %d, click_method: %d", *mode, *click_method);
return 0;
}
return VC_ELM_ERROR_NOT_SUPPORTED;
}
+ bool is_vt_auto;
+ if (0 != _vc_elm_is_supported_vt_auto(&is_vt_auto)) {
+ return VC_ELM_ERROR_OPERATION_FAILED;
+ } else {
+ if (false == is_vt_auto) {
+ VC_ELM_LOG_DBG("vt_automode is FALSE");
+ return _vc_elm_set_auto_register_mode(mode, click_method);
+ } else {
+ VC_ELM_LOG_DBG("vt_automode is TRUE");
+ return _vc_elm_set_auto_register_mode((int)VC_ELM_MODE_AUTO_APPFW, click_method);
+ }
+ }
+
return _vc_elm_set_auto_register_mode(mode, click_method);
}
return text_found;
}
+static Eina_Bool _vc_elm_click_matched_object_vt_auto(const char* cmd, int click_method)
+{
+ VC_ELM_LOG_DBG("inside _vc_elm_click_matched_object_vt_auto()");
+ VC_ELM_LOG_DBG("cmd(%s), click_method(%d)", cmd, click_method);
+
+ Eina_List *dump_iter = NULL;
+ void *data = NULL;
+ Eina_Bool text_found = EINA_FALSE;
+ EINA_LIST_FOREACH(g_dump_list, dump_iter, data) {
+ Object_Info* info = (Object_Info*)data;
+
+ if (NULL != info && NULL != info->text /*&& NULL != info->part_name*/) {
+ VC_ELM_LOG_DBG("info->text(%s)", info->text);
+// Eina_List *iter = NULL;
+// char *part_name = NULL;
+// EINA_LIST_FOREACH(g_allowed_text_part_list, iter, part_name) {
+// if (NULL != part_name && !strcmp(part_name, info->part_name)) {
+ if (!strcmp(info->text, cmd)) {
+ int x = info->geometry_info.x;
+ int y = info->geometry_info.y;
+ int w = info->geometry_info.w;
+ int h = info->geometry_info.h;
+ VC_ELM_LOG_DBG("Click event : %s x(%d) y(%d) w(%d) h(%d), address(%p) type(%s)", info->text, x, y, w, h, info->address, info->type);
+ if (0 == click_method) {
+ evas_event_feed_mouse_move(evas_object_evas_get((Evas_Object*)(info->address)), x + w/2, y + h/2, 0, NULL);
+ evas_event_feed_mouse_down(evas_object_evas_get((Evas_Object*)(info->address)), 1, EVAS_BUTTON_NONE, 1, NULL);
+ evas_event_feed_mouse_up(evas_object_evas_get((Evas_Object*)(info->address)), 1, EVAS_BUTTON_NONE, 2, NULL);
+ VC_ELM_LOG_INFO("click!!!!!");
+ } else if (1 == click_method) {
+ VC_ELM_LOG_DBG("click method - focus/key");
+ bool clicked = false;
+ if (0 != strcmp(evas_object_type_get((Evas_Object*)info->address), "text") && 0 != strcmp(evas_object_type_get((Evas_Object*)info->address), "textblock")) {
+ VC_ELM_LOG_DBG("Click event");
+ if (EINA_TRUE == elm_object_focus_get((Evas_Object*)info->address)) {
+ VC_ELM_LOG_DBG("Already focused");
+ ecore_timer_add(g_click_time, __click_event, NULL);
+ } else {
+ evas_object_smart_callback_add((Evas_Object*)(info->address), "focused", __focused_cb, "focused");
+ elm_object_focus_set((Evas_Object*)(info->address), EINA_TRUE);
+ }
+ clicked = true;
+ }
+
+ if (false == clicked) {
+ Object_Info* parent_info = ea_object_dump_parent_widget_data_get(info);
+ if (NULL != parent_info) {
+ if (EINA_TRUE == parent_info->focusable) {
+ VC_ELM_LOG_DBG("Focusable Parent");
+ VC_ELM_LOG_DBG("Click event");
+ if (EINA_TRUE == elm_object_focus_get((Evas_Object*)parent_info->address)) {
+ VC_ELM_LOG_DBG("Already focused");
+ ecore_timer_add(g_click_time, __click_event, NULL);
+ } else {
+ evas_object_smart_callback_add((Evas_Object*)(parent_info->address), "focused", __focused_cb, "focused");
+ elm_object_focus_set((Evas_Object*)(parent_info->address), EINA_TRUE);
+ }
+ clicked = true;
+ }
+ }
+
+ if (false == clicked && NULL != parent_info) {
+ parent_info = ea_object_dump_parent_widget_data_get(parent_info);
+ while (NULL != parent_info) {
+ if (EINA_TRUE == parent_info->focusable) {
+ VC_ELM_LOG_DBG("Focusable Parent");
+ const char* widget_type = elm_widget_type_get((Evas_Object*)(parent_info->address));
+ VC_ELM_LOG_DBG("type (%s)", widget_type);
+ Elm_Object_Item* item = NULL;
+ if (NULL != widget_type && !strcmp(widget_type, "Elm_Genlist")) {
+ item = elm_genlist_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, NULL);
+ if (NULL == item) {
+ item = elm_genlist_at_xy_item_get((Evas_Object*)(parent_info->address), x + w + w/2, y + h/2, NULL);
+ }
+ } else if (NULL != widget_type && !strcmp(widget_type, "Elm_List")) {
+ item = elm_list_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, NULL);
+ if (NULL == item) {
+ item = elm_list_at_xy_item_get((Evas_Object*)(parent_info->address), x + w + w/2, y + h/2, NULL);
+ }
+ } else if (NULL != widget_type && !strcmp(widget_type, "Elm_Gengrid")) {
+ int xposret, yposret;
+ item = elm_gengrid_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, &xposret, &yposret);
+ }
+ VC_ELM_LOG_DBG("item(%p)(%d)", item, elm_object_item_disabled_get(item));
+
+ if (NULL != item && EINA_FALSE == elm_object_item_disabled_get(item)) {
+ VC_ELM_LOG_DBG("Click event");
+ if (EINA_TRUE == elm_object_item_focus_get(item)) {
+ VC_ELM_LOG_DBG("Already focused");
+ ecore_timer_add(g_click_time, __click_event, NULL);
+ } else {
+ evas_object_smart_callback_add((Evas_Object*)(parent_info->address), "item,focused", __focused_cb, "item,focused");
+ elm_object_item_focus_set(item, EINA_TRUE);
+ elm_object_focus_set((Evas_Object*)(parent_info->address), EINA_TRUE);
+ }
+ text_found = EINA_TRUE;
+ break;
+ }
+ }
+ parent_info = ea_object_dump_parent_widget_data_get(parent_info);
+ }
+ }
+ }
+ } else {
+ VC_ELM_LOG_DBG("Invalid click method");
+ }
+
+ /* Propagation */
+ //return EINA_TRUE;
+ text_found = EINA_TRUE;
+ }
+ // }
+ // }
+ }
+ }
+ ea_object_dump_list_clear();
+ g_dump_list = NULL;
+
+ return text_found;
+}
+
+
+
/**
* @brief Function that matches recognition result to the registered actions
* and calls for action execution
int auto_mode = 0;
int click_method = 0;
_vc_elm_get_auto_register_mode(&auto_mode, &click_method);
+
+ Eina_Bool ret;
if (1 == auto_mode) {
- Eina_Bool ret = _vc_elm_click_matched_object(cmd, click_method);
- return ret;
+ /* for Apps */
+ VC_ELM_LOG_DBG("for App : vt_auto is FALSE");
+ ret = _vc_elm_click_matched_object(cmd, click_method);
+ } else if (2 == auto_mode) {
+ /* for App FW */
+ VC_ELM_LOG_DBG("for AppFW : vt_auto is TRUE");
+ ret = _vc_elm_click_matched_object_vt_auto(cmd, click_method);
}
+ return ret;
}
return EINA_FALSE;
static int __vc_add_commands_for_automode()
{
+ VC_ELM_LOG_DBG("inside __vc_add_commands_for_automode()");
+
if (NULL != g_dump_list) {
ea_object_dump_list_clear();
g_dump_list = NULL;
return 0;
}
+static int __vc_add_commands_for_automode_vt_auto()
+{
+ VC_ELM_LOG_DBG("inside __vc_add_commands_for_automode_vt_auto()");
+ if (NULL != g_dump_list) {
+ ea_object_dump_list_clear();
+ g_dump_list = NULL;
+ }
+ g_dump_list = ea_object_dump_full_list_get(EINA_TRUE);
+ VC_ELM_LOG_DBG("Count (%d)", eina_list_count(g_dump_list));
+
+ Eina_List *dump_iter = NULL;
+ void *data = NULL;
+ EINA_LIST_FOREACH(g_dump_list, dump_iter, data) {
+ Object_Info* info = (Object_Info*)data;
+
+ if (NULL != info && NULL != info->text /*&& NULL != info->part_name*/) {
+// Eina_List *iter = NULL;
+// char *part_name = NULL;
+// EINA_LIST_FOREACH(g_allowed_text_part_list, iter, part_name) {
+// if (NULL != part_name && !strcmp(part_name, info->part_name)) {
+ VC_ELM_LOG_DBG("Text (%s), Part(%s)", info->text, info->part_name);
+ VC_ELM_LOG_DBG("x(%d) y(%d) w(%d) h(%d)", info->geometry_info.x, info->geometry_info.y, info->geometry_info.w, info->geometry_info.h);
+ _vc_elm_widget_wrapper_add_command(info->text, NULL);
+// }
+// }
+ }
+ }
+ return 0;
+}
+
static void __vc_add_commands()
{
+ VC_ELM_LOG_DBG("inside __vc_add_commands()");
+
Eina_List *_l;
Evas_Object *obj;
size_t idx;
_vc_elm_get_auto_register_mode(&auto_mode, &click_method);
VC_ELM_LOG_DBG("Auto mode (%d) Click method (%d)", auto_mode, click_method);
if (1 == auto_mode) {
- if (0 != __vc_add_commands_for_automode()) {
- VC_ELM_LOG_ERR("Fail to add command in auto mode");
- }
+ /* for Apps */
+ VC_ELM_LOG_DBG("for App : vt_auto is FALSE");
+ __vc_add_commands_for_automode();
+ } else if (2 == auto_mode) {
+ /* for App FW */
+ VC_ELM_LOG_DBG("for AppFW : vt_auto is TRUE");
+ __vc_add_commands_for_automode_vt_auto();
}
+// if (0 != __vc_add_commands_for_automode()) {
+// VC_ELM_LOG_ERR("Fail to add command in auto mode");
+// }
_vc_elm_widget_wrapper_commit_commands(&__result_cb, NULL);
}