2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <cynara-client.h>
18 #include <cynara-error.h>
19 #include <cynara-session.h>
20 #include <system_info.h>
21 #include "vc_elm_main.h"
22 #include <voice_control_elm.h>
23 #include <voice_control_elm_private.h>
27 #include "vc_elm_core.h"
28 #include "vc_elm_tools.h"
29 #include "vc_elm_tooltip.h"
30 #include "vc_elm_widget_wrapper.h"
32 //#define VC_VOICE_TOUCH_AUTOMODE VCONFKEY_VC_VOICE_TOUCH_AUTOMODE
33 #define VC_VOICE_TOUCH_AUTOMODE "db/voice/vc/voice_touch/automode"
35 #define VC_ELM_MODE_MANUAL 0
37 #define VC_ELM_MODE_AUTO_APP 1
39 #define VC_ELM_MODE_AUTO_APPFW 2
42 * @brief Internal variable. It can check whether voice control elm is initialized or not.
44 static unsigned is_vc_elm_initialized = false;
47 * @brief An internal variable for checking whether voice touch's auto mode is ON or not.
49 static int g_is_vt_automode = 0;
52 * @brief App domain name of the current app.
54 static char *g_app_domain = NULL;
55 static Eina_List *g_handlers_list = NULL;
58 VC_ELM_TYPE_EVAS_OBJECT = 0, VC_ELM_TYPE_ITEM = 1
66 typedef struct __vc_elm_s vc_elm_s;
68 struct __vc_elm_widget_cb_data_s {
69 vc_elm_widget_cb callback;
73 typedef struct __vc_elm_widget_cb_data_s vc_elm_widget_cb_data_s;
75 static int g_feature_enabled = -1;
77 static int g_privilege_allowed = -1;
78 static cynara *p_cynara = NULL;
80 static int g_auto_mode = 0;
81 static int g_click_method = 0;
83 static int __vc_elm_get_feature_enabled()
85 if (0 == g_feature_enabled) {
86 VC_ELM_LOG_DBG("[ERROR] Voice control feature NOT supported"); //LCOV_EXCL_LINE
87 return VC_ELM_ERROR_NOT_SUPPORTED;
88 } else if (-1 == g_feature_enabled) {
89 bool vc_supported = false;
90 bool mic_supported = false;
91 if (0 == system_info_get_platform_bool(VC_ELM_FEATURE_PATH, &vc_supported)) {
92 if (0 == system_info_get_platform_bool(VC_ELM_MIC_FEATURE_PATH, &mic_supported)) {
93 if (false == vc_supported || false == mic_supported) {
94 VC_ELM_LOG_DBG("[ERROR] Voice control feature NOT supported"); //LCOV_EXCL_LINE
95 g_feature_enabled = 0;
96 return VC_ELM_ERROR_NOT_SUPPORTED;
99 g_feature_enabled = 1;
101 VC_ELM_LOG_DBG("[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE
102 return VC_ELM_ERROR_NOT_SUPPORTED;
105 VC_ELM_LOG_DBG("[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE
106 return VC_ELM_ERROR_NOT_SUPPORTED;
112 static int __check_privilege_initialize()
114 int ret = cynara_initialize(&p_cynara, NULL);
115 if (CYNARA_API_SUCCESS != ret)
116 VC_ELM_LOG_ERR("[ERROR] fail to initialize"); //LCOV_EXCL_LINE
118 return ret == CYNARA_API_SUCCESS;
121 static int __check_privilege(const char* uid, const char * privilege)
124 char label_path[1024] = "/proc/self/attr/current";
125 char smack_label[1024] = {'\0',};
131 fp = fopen(label_path, "r");
133 if (0 >= fread(smack_label, 1, sizeof(smack_label), fp))
134 VC_ELM_LOG_ERR("[ERROR] fail to fread"); //LCOV_EXCL_LINE
139 pid_t pid = getpid();
140 char *session = cynara_session_from_pid(pid);
141 int ret = cynara_check(p_cynara, smack_label, session, uid, privilege);
142 VC_ELM_LOG_DBG("[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied");
146 if (ret != CYNARA_API_ACCESS_ALLOWED)
151 static void __check_privilege_deinitialize()
154 cynara_finish(p_cynara);
158 static int __vc_elm_check_privilege()
162 if (0 == g_privilege_allowed) {
163 VC_ELM_LOG_ERR("[ERROR] Permission is denied"); //LCOV_EXCL_LINE
164 return VC_ELM_ERROR_PERMISSION_DENIED;
165 } else if (-1 == g_privilege_allowed) {
166 if (false == __check_privilege_initialize()) {
167 VC_ELM_LOG_ERR("[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE
168 return VC_ELM_ERROR_PERMISSION_DENIED;
170 snprintf(uid, 16, "%d", getuid());
171 if (false == __check_privilege(uid, VC_ELM_PRIVILEGE)) {
172 VC_ELM_LOG_ERR("[ERROR] Permission is denied"); //LCOV_EXCL_LINE
173 g_privilege_allowed = 0;
174 __check_privilege_deinitialize();
175 return VC_ELM_ERROR_PERMISSION_DENIED;
177 __check_privilege_deinitialize();
180 g_privilege_allowed = 1;
181 return VC_ELM_ERROR_NONE;
184 void __vc_config_vtauto_changed_cb(keynode_t *key, void *data)
186 (void)data; //unused parameter
187 int ret = vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &g_is_vt_automode);
189 VC_ELM_LOG_ERR("Fail to get vconfkey(%s), current voice touch mode(%d)", key, g_is_vt_automode); //LCOV_EXCL_LINE
195 int vc_elm_initialize()
197 if (0 != __vc_elm_get_feature_enabled()) {
198 return VC_ELM_ERROR_NOT_SUPPORTED;
201 if (true == is_vc_elm_initialized) {
202 VC_ELM_LOG_DBG("vc elm is already initialized"); //LCOV_EXCL_LINE
203 return VC_ELM_ERROR_INVALID_STATE;
206 eina_log_level_set(EINA_LOG_LEVEL_DBG);
208 _vc_elm_core_enable_name_autogen(EINA_FALSE);
211 g_handlers_list = NULL;
214 is_vc_elm_initialized = true;
216 /* Initialize voice touch's automode and Register to detect voice touch automode change */
217 vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &g_is_vt_automode);
219 vconf_notify_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, __vc_config_vtauto_changed_cb, NULL);
221 VC_ELM_LOG_DBG("vc elm is initialized");
222 return VC_ELM_ERROR_NONE;
225 int vc_elm_deinitialize()
228 vc_elm_h handler = NULL;
230 if (0 != __vc_elm_get_feature_enabled()) {
231 return VC_ELM_ERROR_NOT_SUPPORTED;
234 if (false == is_vc_elm_initialized) {
235 VC_ELM_LOG_DBG("vc elm is already deinitialized"); //LCOV_EXCL_LINE
236 return VC_ELM_ERROR_INVALID_STATE;
239 if (NULL != g_handlers_list) {
240 EINA_LIST_FOREACH(g_handlers_list, l, handler) {
241 vc_elm_unset_command(handler);
242 vc_elm_unset_command_hint(handler);
243 vc_elm_destroy(handler);
245 eina_list_free(g_handlers_list);
248 vconf_ignore_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, __vc_config_vtauto_changed_cb);
252 if (NULL != g_app_domain) {
257 is_vc_elm_initialized = false;
258 VC_ELM_LOG_DBG("shutting down vc_elm");
259 return VC_ELM_ERROR_NONE;
262 int vc_elm_foreach_supported_languages(vc_elm_supported_language_cb callback, void *user_data)
265 if (0 != __vc_elm_get_feature_enabled()) {
266 return VC_ELM_ERROR_NOT_SUPPORTED;
268 if (0 != __vc_elm_check_privilege()) {
269 return VC_ELM_ERROR_PERMISSION_DENIED;
272 ret = _vc_elm_widget_wrapper_foreach_supported_languages(callback, user_data);
276 int vc_elm_get_current_language(char **language)
279 if (0 != __vc_elm_get_feature_enabled()) {
280 return VC_ELM_ERROR_NOT_SUPPORTED;
282 if (0 != __vc_elm_check_privilege()) {
283 return VC_ELM_ERROR_PERMISSION_DENIED;
286 ret = _vc_elm_widget_wrapper_get_current_language(language);
290 static Eina_Bool __hash_fn(const Eina_Hash *hash, const void *key, void *kdata, void *fdata)
292 vc_elm_widget_cb_data_s *data;
293 vc_elm_widget_cb callback;
296 data = (vc_elm_widget_cb_data_s *)fdata;
297 callback = data->callback;
298 callback(key, data->data);
302 int vc_elm_foreach_supported_widgets(vc_elm_widget_cb callback, void *user_data)
304 vc_elm_widget_cb_data_s data;
305 const Eina_Hash *hash = NULL;
307 if (0 != __vc_elm_get_feature_enabled()) {
308 return VC_ELM_ERROR_NOT_SUPPORTED;
310 if (0 != __vc_elm_check_privilege()) {
311 return VC_ELM_ERROR_PERMISSION_DENIED;
314 if (NULL == callback) {
315 VC_ELM_LOG_ERR("Invalid parameters detected!"); //LCOV_EXCL_LINE
316 return VC_ELM_ERROR_INVALID_PARAMETER;
318 if (false == is_vc_elm_initialized) {
319 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
320 return VC_ELM_ERROR_INVALID_STATE;
322 data.callback = callback;
323 data.data = user_data;
324 hash = _vc_elm_core_get_config_widget_map();
326 VC_ELM_LOG_ERR("Config widget map is NULL!"); //LCOV_EXCL_LINE
327 return VC_ELM_ERROR_OPERATION_FAILED;
329 eina_hash_foreach(hash, __hash_fn, &data);
330 return VC_ELM_ERROR_NONE;
333 int vc_elm_foreach_supported_actions(const char *widget, vc_elm_action_cb callback, void *user_data)
335 const Eina_Hash *hash = NULL;
336 Eina_List *actions_list = NULL;
338 const char *action_tag = NULL;
340 if (0 != __vc_elm_get_feature_enabled()) {
341 return VC_ELM_ERROR_NOT_SUPPORTED;
343 if (0 != __vc_elm_check_privilege()) {
344 return VC_ELM_ERROR_PERMISSION_DENIED;
347 if ((NULL == widget) || (NULL == callback)) {
348 VC_ELM_LOG_ERR("Invalid parameters detected!"); //LCOV_EXCL_LINE
349 return VC_ELM_ERROR_INVALID_PARAMETER;
351 if (false == is_vc_elm_initialized) {
352 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
353 return VC_ELM_ERROR_INVALID_STATE;
355 hash = _vc_elm_core_get_config_widget_map();
357 VC_ELM_LOG_ERR("Config widget map is NULL!"); //LCOV_EXCL_LINE
358 return VC_ELM_ERROR_OPERATION_FAILED;
360 actions_list = (Eina_List *)eina_hash_find(hash, widget);
361 if (NULL == actions_list) {
362 VC_ELM_LOG_ERR("Action list is NULL!"); //LCOV_EXCL_LINE
363 return VC_ELM_ERROR_OPERATION_FAILED;
365 EINA_LIST_FOREACH(actions_list, l, action_tag) {
366 if (NULL != action_tag) {
367 callback(action_tag, user_data);
370 return VC_ELM_ERROR_NONE;
373 int vc_elm_get_action_command(const char *action, char **command)
375 const Eina_Hash *hash = NULL;
376 const char *command_name = NULL;
379 if (0 != __vc_elm_get_feature_enabled()) {
380 return VC_ELM_ERROR_NOT_SUPPORTED;
382 if (0 != __vc_elm_check_privilege()) {
383 return VC_ELM_ERROR_PERMISSION_DENIED;
386 if ((NULL == action) || (NULL == command)) {
387 VC_ELM_LOG_ERR("Invalid parameters detected!"); //LCOV_EXCL_LINE
388 return VC_ELM_ERROR_INVALID_PARAMETER;
390 if (false == is_vc_elm_initialized) {
391 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
392 return VC_ELM_ERROR_INVALID_STATE;
394 hash = _vc_elm_core_get_config_action_map();
396 VC_ELM_LOG_ERR("Config action map is NULL!"); //LCOV_EXCL_LINE
397 return VC_ELM_ERROR_OPERATION_FAILED;
399 command_name = eina_hash_find(_vc_elm_core_get_config_action_map(), action);
400 if (NULL == command_name) {
401 VC_ELM_LOG_ERR("No command for given action name!"); //LCOV_EXCL_LINE
402 return VC_ELM_ERROR_OPERATION_FAILED;
404 len = strlen(command_name) + 1;
405 *command = (char *)calloc(len, sizeof(char));
406 if (NULL == *command) {
407 VC_ELM_LOG_ERR("Can not allocate memory!"); //LCOV_EXCL_LINE
408 return VC_ELM_ERROR_OPERATION_FAILED;
410 memcpy(*command, command_name, len);
412 VC_ELM_LOG_INFO("[SUCCESS] get action command, action(%s), command(%s)", action, *command);
413 return VC_ELM_ERROR_NONE;
416 int vc_elm_create_object(Evas_Object *object, vc_elm_h *vc_elm)
418 vc_elm_s *handler = NULL;
419 if (0 != __vc_elm_get_feature_enabled()) {
420 return VC_ELM_ERROR_NOT_SUPPORTED;
422 if (0 != __vc_elm_check_privilege()) {
423 return VC_ELM_ERROR_PERMISSION_DENIED;
426 if (NULL == vc_elm) {
427 VC_ELM_LOG_ERR("Invalid parameters detected! (vc_elm_h *) pointer is NULL"); //LCOV_EXCL_LINE
428 return VC_ELM_ERROR_INVALID_PARAMETER;
430 if ((NULL == object) || (!elm_object_widget_check(object))) {
431 VC_ELM_LOG_ERR("Invalid parameters detected! Incorrect (Evas_Object *)"); //LCOV_EXCL_LINE
433 return VC_ELM_ERROR_INVALID_PARAMETER;
435 if (false == is_vc_elm_initialized) {
436 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
437 return VC_ELM_ERROR_INVALID_STATE;
439 if (!_vc_elm_core_register_default_widget(_get_ui_object_name(object), EINA_FALSE, NULL) || (NULL == eina_hash_find(_vc_elm_core_get_config_widget_map(), elm_widget_type_get(object)))) {
440 VC_ELM_LOG_ERR("Not supported widget"); //LCOV_EXCL_LINE
442 return VC_ELM_ERROR_NOT_SUPPORTED;
444 handler = (vc_elm_s *)calloc(1, sizeof(vc_elm_s));
445 if (NULL == handler) {
446 VC_ELM_LOG_ERR("Calloc function returned NULL"); //LCOV_EXCL_LINE
447 return VC_ELM_ERROR_OUT_OF_MEMORY;
449 handler->type = VC_ELM_TYPE_EVAS_OBJECT;
450 handler->data = (void *)object;
451 g_handlers_list = eina_list_append(g_handlers_list, handler);
452 *vc_elm = (vc_elm_h)handler;
454 VC_ELM_LOG_INFO("[SUCCESS] create object(%s)", _get_ui_object_name(object));
455 _vc_elm_core_set_view_changed();
456 return VC_ELM_ERROR_NONE;
459 int vc_elm_create_item(Elm_Object_Item *item, vc_elm_h *vc_elm)
461 vc_elm_s *handler = NULL;
462 if (0 != __vc_elm_get_feature_enabled()) {
463 return VC_ELM_ERROR_NOT_SUPPORTED;
465 if (0 != __vc_elm_check_privilege()) {
466 return VC_ELM_ERROR_PERMISSION_DENIED;
469 if (NULL == vc_elm) {
470 VC_ELM_LOG_ERR("Invalid parameters detected! (vc_elm_h *) pointer is NULL"); //LCOV_EXCL_LINE
471 return VC_ELM_ERROR_INVALID_PARAMETER;
474 VC_ELM_LOG_ERR("Invalid parameters detected! (Elm_Object_Item *) pointer is NULL"); //LCOV_EXCL_LINE
476 return VC_ELM_ERROR_INVALID_PARAMETER;
478 if (false == is_vc_elm_initialized) {
479 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
480 return VC_ELM_ERROR_INVALID_STATE;
482 handler = (vc_elm_s *)calloc(1, sizeof(vc_elm_s));
483 if (NULL == handler) {
484 VC_ELM_LOG_ERR("Calloc function returned NULL"); //LCOV_EXCL_LINE
486 return VC_ELM_ERROR_OUT_OF_MEMORY;
488 handler->type = VC_ELM_TYPE_ITEM;
489 handler->data = (void *)item;
490 g_handlers_list = eina_list_append(g_handlers_list, handler);
491 *vc_elm = (vc_elm_h)handler;
493 VC_ELM_LOG_INFO("[SUCCESS] create item object)");
494 _vc_elm_core_set_view_changed();
495 return VC_ELM_ERROR_NONE;
498 int vc_elm_destroy(vc_elm_h vc_elm)
500 vc_elm_s *handler = NULL;
501 Eina_List *list = NULL;
502 if (0 != __vc_elm_get_feature_enabled()) {
503 return VC_ELM_ERROR_NOT_SUPPORTED;
505 if (0 != __vc_elm_check_privilege()) {
506 return VC_ELM_ERROR_PERMISSION_DENIED;
509 if (NULL == vc_elm) {
510 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
511 return VC_ELM_ERROR_INVALID_PARAMETER;
513 handler = (vc_elm_s *)vc_elm;
514 list = eina_list_data_find_list(g_handlers_list, handler);
516 VC_ELM_LOG_ERR("Bad handler pointer detected!"); //LCOV_EXCL_LINE
517 return VC_ELM_ERROR_INVALID_PARAMETER;
519 g_handlers_list = eina_list_remove_list(g_handlers_list, list);
523 VC_ELM_LOG_INFO("[SUCCESS] destroy");
524 _vc_elm_core_set_view_changed();
525 return VC_ELM_ERROR_NONE;
528 int vc_elm_set_command(vc_elm_h vc_elm, const char *command)
530 vc_elm_s *handler = (vc_elm_s *)vc_elm;
532 if (0 != __vc_elm_get_feature_enabled()) {
533 return VC_ELM_ERROR_NOT_SUPPORTED;
535 if (0 != __vc_elm_check_privilege()) {
536 return VC_ELM_ERROR_PERMISSION_DENIED;
539 if (NULL == vc_elm) {
540 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
541 return VC_ELM_ERROR_INVALID_PARAMETER;
543 type = handler->type;
544 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
545 Evas_Object *obj = (Evas_Object *)handler->data;
546 return _vc_elm_set_object_command(obj, command);
547 } else if (VC_ELM_TYPE_ITEM == type) {
548 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
549 return _vc_elm_set_item_object_command(it, command);
552 VC_ELM_LOG_INFO("[SUCCESS] set command(%s)", command);
553 _vc_elm_core_set_view_changed();
554 return VC_ELM_ERROR_INVALID_PARAMETER;
557 int vc_elm_unset_command(vc_elm_h vc_elm)
559 vc_elm_s *handler = (vc_elm_s *)vc_elm;
561 if (0 != __vc_elm_get_feature_enabled()) {
562 return VC_ELM_ERROR_NOT_SUPPORTED;
564 if (0 != __vc_elm_check_privilege()) {
565 return VC_ELM_ERROR_PERMISSION_DENIED;
568 if (NULL == vc_elm) {
569 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
570 return VC_ELM_ERROR_INVALID_PARAMETER;
572 type = handler->type;
573 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
574 Evas_Object *obj = (Evas_Object *)handler->data;
575 return _vc_elm_unset_object_command(obj);
576 } else if (VC_ELM_TYPE_ITEM == type) {
577 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
578 return _vc_elm_unset_item_object_command(it);
581 VC_ELM_LOG_INFO("[SUCCESS] unset command");
582 _vc_elm_core_set_view_changed();
583 return VC_ELM_ERROR_INVALID_PARAMETER;
586 int vc_elm_set_command_hint(vc_elm_h vc_elm, const char* hint)
588 vc_elm_s *handler = (vc_elm_s *)vc_elm;
590 if (0 != __vc_elm_get_feature_enabled()) {
591 return VC_ELM_ERROR_NOT_SUPPORTED;
593 if (0 != __vc_elm_check_privilege()) {
594 return VC_ELM_ERROR_PERMISSION_DENIED;
597 if (NULL == vc_elm) {
598 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
599 return VC_ELM_ERROR_INVALID_PARAMETER;
601 type = handler->type;
602 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
603 Evas_Object *obj = (Evas_Object *)handler->data;
604 return _vc_elm_set_object_hint(obj, hint);
605 } else if (VC_ELM_TYPE_ITEM == type) {
606 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
607 return _vc_elm_set_item_object_hint(it, hint);
610 VC_ELM_LOG_INFO("[SUCCESS] set hint(%s)", hint);
611 _vc_elm_core_set_view_changed();
612 return VC_ELM_ERROR_INVALID_PARAMETER;
615 int vc_elm_unset_command_hint(vc_elm_h vc_elm)
617 vc_elm_s *handler = (vc_elm_s *)vc_elm;
619 if (0 != __vc_elm_get_feature_enabled()) {
620 return VC_ELM_ERROR_NOT_SUPPORTED;
622 if (0 != __vc_elm_check_privilege()) {
623 return VC_ELM_ERROR_PERMISSION_DENIED;
626 if (NULL == vc_elm) {
627 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
628 return VC_ELM_ERROR_INVALID_PARAMETER;
630 type = handler->type;
631 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
632 Evas_Object *obj = (Evas_Object *)handler->data;
633 return _vc_elm_unset_object_hint(obj);
634 } else if (VC_ELM_TYPE_ITEM == type) {
635 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
636 return _vc_elm_unset_item_object_hint(it);
639 VC_ELM_LOG_INFO("[SUCCESS] unset hint");
640 _vc_elm_core_set_view_changed();
641 return VC_ELM_ERROR_INVALID_PARAMETER;
644 int vc_elm_set_command_hint_direction(vc_elm_h vc_elm, vc_elm_direction_e direction)
646 vc_elm_s *handler = (vc_elm_s *)vc_elm;
648 if (0 != __vc_elm_get_feature_enabled()) {
649 return VC_ELM_ERROR_NOT_SUPPORTED;
651 if (0 != __vc_elm_check_privilege()) {
652 return VC_ELM_ERROR_PERMISSION_DENIED;
655 if (NULL == vc_elm) {
656 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
657 return VC_ELM_ERROR_INVALID_PARAMETER;
659 type = handler->type;
660 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
661 Evas_Object *obj = (Evas_Object *)handler->data;
662 return _vc_elm_set_object_hint_direction(obj, direction);
663 } else if (VC_ELM_TYPE_ITEM == type) {
664 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
665 Evas_Object *parent = elm_object_item_widget_get(it);
666 return _vc_elm_set_sub_item_hint_direction(parent, direction);
669 VC_ELM_LOG_INFO("[SUCCESS] set hint direction(%d)", direction);
670 _vc_elm_core_set_view_changed();
671 return VC_ELM_ERROR_INVALID_PARAMETER;
674 int vc_elm_get_command_hint_direction(vc_elm_h vc_elm, vc_elm_direction_e *direction)
676 vc_elm_s *handler = (vc_elm_s *)vc_elm;
678 if (0 != __vc_elm_get_feature_enabled()) {
679 return VC_ELM_ERROR_NOT_SUPPORTED;
681 if (0 != __vc_elm_check_privilege()) {
682 return VC_ELM_ERROR_PERMISSION_DENIED;
685 if (NULL == vc_elm) {
686 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
687 return VC_ELM_ERROR_INVALID_PARAMETER;
689 type = handler->type;
690 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
691 Evas_Object *obj = (Evas_Object *)handler->data;
692 return _vc_elm_get_object_hint_direction(obj, direction);
693 } else if (VC_ELM_TYPE_ITEM == type) {
694 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
695 Evas_Object *parent = elm_object_item_widget_get(it);
696 return _vc_elm_get_sub_item_hint_direction(parent, direction);
699 VC_ELM_LOG_INFO("[SUCCESS] get hint direction(%d)", *direction);
700 return VC_ELM_ERROR_INVALID_PARAMETER;
703 int vc_elm_set_command_hint_offset(vc_elm_h vc_elm, int pos_x, int pos_y)
705 vc_elm_s *handler = (vc_elm_s *)vc_elm;
707 if (0 != __vc_elm_get_feature_enabled()) {
708 return VC_ELM_ERROR_NOT_SUPPORTED;
710 if (0 != __vc_elm_check_privilege()) {
711 return VC_ELM_ERROR_PERMISSION_DENIED;
714 if (NULL == vc_elm) {
715 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
716 return VC_ELM_ERROR_INVALID_PARAMETER;
718 type = handler->type;
719 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
720 Evas_Object *obj = (Evas_Object *)handler->data;
721 return _vc_elm_set_object_custom_hint(obj, NULL, pos_x, pos_y);
722 } else if (VC_ELM_TYPE_ITEM == type) {
723 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
724 return _vc_elm_set_item_object_custom_hint(it, NULL, pos_x, pos_y);
727 VC_ELM_LOG_INFO("[SUCCESS] set hint offset, x(%d), y(%d)", pos_x, pos_y);
728 _vc_elm_core_set_view_changed();
729 return VC_ELM_ERROR_INVALID_PARAMETER;
732 int vc_elm_get_command_hint_offset(vc_elm_h vc_elm, int *pos_x, int *pos_y)
734 vc_elm_s *handler = (vc_elm_s *)vc_elm;
735 const char *path = NULL;
737 if (0 != __vc_elm_get_feature_enabled()) {
738 return VC_ELM_ERROR_NOT_SUPPORTED;
740 if (0 != __vc_elm_check_privilege()) {
741 return VC_ELM_ERROR_PERMISSION_DENIED;
744 if (NULL == vc_elm) {
745 VC_ELM_LOG_ERR("Invalid vc_elm parameter detected!"); //LCOV_EXCL_LINE
746 return VC_ELM_ERROR_INVALID_PARAMETER;
748 if ((NULL == pos_x) || (NULL == pos_y)) {
749 VC_ELM_LOG_ERR("Invalid position pointers detected!"); //LCOV_EXCL_LINE
750 return VC_ELM_ERROR_INVALID_PARAMETER;
752 type = handler->type;
753 if (VC_ELM_TYPE_EVAS_OBJECT == type) {
754 Evas_Object *obj = (Evas_Object *)handler->data;
755 return _vc_elm_get_object_custom_hint(obj, &path, pos_x, pos_y);
756 } else if (VC_ELM_TYPE_ITEM == type) {
757 Elm_Object_Item *it = (Elm_Object_Item *)handler->data;
758 return _vc_elm_get_item_object_custom_hint(it, &path, pos_x, pos_y);
760 return VC_ELM_ERROR_INVALID_PARAMETER;
763 int vc_elm_set_current_language_changed_cb(vc_elm_current_language_changed_cb callback, void *user_data)
765 int ret = VC_ELM_ERROR_NONE;
767 if (0 != __vc_elm_get_feature_enabled()) {
768 return VC_ELM_ERROR_NOT_SUPPORTED;
770 if (0 != __vc_elm_check_privilege()) {
771 return VC_ELM_ERROR_PERMISSION_DENIED;
774 if (false == is_vc_elm_initialized) {
775 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
776 return VC_ELM_ERROR_INVALID_STATE;
779 ret = _vc_elm_widget_wrapper_set_current_language_changed_callback(callback, user_data);
781 return VC_ELM_ERROR_OPERATION_FAILED;
783 return VC_ELM_ERROR_NONE;
786 int vc_elm_unset_current_language_changed_cb(void)
788 int ret = VC_ELM_ERROR_NONE;
790 if (0 != __vc_elm_get_feature_enabled()) {
791 return VC_ELM_ERROR_NOT_SUPPORTED;
793 if (0 != __vc_elm_check_privilege()) {
794 return VC_ELM_ERROR_PERMISSION_DENIED;
797 if (false == is_vc_elm_initialized) {
798 VC_ELM_LOG_ERR("Invalid state detected! Library not initialized!"); //LCOV_EXCL_LINE
799 return VC_ELM_ERROR_INVALID_STATE;
802 ret = _vc_elm_widget_wrapper_unset_current_language_changed_callback();
804 return VC_ELM_ERROR_OPERATION_FAILED;
806 return VC_ELM_ERROR_NONE;
809 int _vc_elm_set_object_command(Evas_Object *obj, const char *command)
811 if (_vc_elm_core_set_object_command(obj, command))
812 return VC_ELM_ERROR_NONE;
814 return VC_ELM_ERROR_OPERATION_FAILED;
817 int _vc_elm_unset_object_command(Evas_Object *obj)
819 if (_vc_elm_core_unset_object_command(obj))
820 return VC_ELM_ERROR_NONE;
822 return VC_ELM_ERROR_OPERATION_FAILED;
825 int _vc_elm_set_object_hint(Evas_Object *obj, const char *hint)
827 if (_vc_elm_core_set_object_hint(obj, hint))
828 return VC_ELM_ERROR_NONE;
830 return VC_ELM_ERROR_OPERATION_FAILED;
833 int _vc_elm_unset_object_hint(Evas_Object *obj)
835 if (_vc_elm_core_unset_object_hint(obj))
836 return VC_ELM_ERROR_NONE;
838 return VC_ELM_ERROR_OPERATION_FAILED;
841 int _vc_elm_set_object_custom_hint(Evas_Object *obj, const char *image_path, int pos_x, int pos_y)
843 if (_vc_elm_core_set_object_custom_hint(obj, image_path, pos_x, pos_y))
844 return VC_ELM_ERROR_NONE;
846 return VC_ELM_ERROR_OPERATION_FAILED;
849 int _vc_elm_get_object_custom_hint(Evas_Object *obj, const char **image_path, int *pos_x, int *pos_y)
851 if (_vc_elm_core_get_object_custom_hint(obj, image_path, pos_x, pos_y))
852 return VC_ELM_ERROR_NONE;
854 return VC_ELM_ERROR_OPERATION_FAILED;
857 int _vc_elm_set_item_object_custom_hint(Elm_Object_Item *obj, const char *image_path, int pos_x, int pos_y)
859 if (_vc_elm_core_set_item_object_custom_hint(obj, image_path, pos_x, pos_y))
860 return VC_ELM_ERROR_NONE;
862 return VC_ELM_ERROR_OPERATION_FAILED;
865 int _vc_elm_get_item_object_custom_hint(Elm_Object_Item *obj, const char **image_path, int *pos_x, int *pos_y)
867 if (_vc_elm_core_get_item_object_custom_hint(obj, image_path, pos_x, pos_y))
868 return VC_ELM_ERROR_NONE;
870 return VC_ELM_ERROR_OPERATION_FAILED;
873 int _vc_elm_set_item_object_command(Elm_Object_Item *obj, const char *command)
875 if (_vc_elm_core_set_item_object_command(obj, command))
876 return VC_ELM_ERROR_NONE;
878 return VC_ELM_ERROR_OPERATION_FAILED;
881 int _vc_elm_unset_item_object_command(Elm_Object_Item *obj)
883 if (_vc_elm_core_unset_item_object_command(obj))
884 return VC_ELM_ERROR_NONE;
886 return VC_ELM_ERROR_OPERATION_FAILED;
889 int _vc_elm_set_item_object_hint(Elm_Object_Item *obj, const char *hint)
891 if (_vc_elm_core_set_item_object_hint(obj, hint))
892 return VC_ELM_ERROR_NONE;
894 return VC_ELM_ERROR_OPERATION_FAILED;
897 int _vc_elm_unset_item_object_hint(Elm_Object_Item *obj)
899 if (_vc_elm_core_unset_item_object_hint(obj))
900 return VC_ELM_ERROR_NONE;
902 return VC_ELM_ERROR_OPERATION_FAILED;
905 int _vc_elm_enable_name_autogen_enable(Eina_Bool autogen)
907 if (_vc_elm_core_enable_name_autogen(autogen))
908 return VC_ELM_ERROR_NONE;
910 return VC_ELM_ERROR_OPERATION_FAILED;
914 _vc_elm_register_widget(const char *widget_name, vc_elm_get_subobjects_cb get_subobjects_func, vc_elm_command_filter_cb is_feltered_func, void *user_data)
916 return _vc_elm_core_register_widget(widget_name, get_subobjects_func, is_feltered_func, user_data);
919 void _vc_elm_register_action(vc_elm_widget_info *info, const char *action_name, void *data, vc_elm_action_activator_cb func)
921 _vc_elm_core_register_action(info, action_name, data, func);
924 int _vc_elm_set_object_hint_direction(Evas_Object *obj, vc_elm_direction_e direction)
926 if (_vc_elm_core_set_object_hint_direction(obj, direction))
927 return VC_ELM_ERROR_NONE;
929 return VC_ELM_ERROR_OPERATION_FAILED;
932 int _vc_elm_get_object_hint_direction(Evas_Object *obj, vc_elm_direction_e *direction)
934 if (_vc_elm_core_get_object_hint_direction(obj, direction))
935 return VC_ELM_ERROR_NONE;
937 return VC_ELM_ERROR_OPERATION_FAILED;
940 int _vc_elm_set_sub_item_hint_direction(Evas_Object *obj, vc_elm_direction_e direction)
942 if (_vc_elm_core_set_sub_item_hint_direction(obj, direction))
943 return VC_ELM_ERROR_NONE;
945 return VC_ELM_ERROR_OPERATION_FAILED;
948 int _vc_elm_get_sub_item_hint_direction(Evas_Object *obj, vc_elm_direction_e *direction)
950 if (_vc_elm_core_get_sub_item_hint_direction(obj, direction))
951 return VC_ELM_ERROR_NONE;
953 return VC_ELM_ERROR_OPERATION_FAILED;
956 int _vc_elm_set_text_domain(const char *domain, const char *locale_dir)
960 return VC_ELM_ERROR_OPERATION_FAILED;
962 if (NULL != g_app_domain)
965 g_app_domain = strdup(domain);
966 bindtextdomain(g_app_domain, locale_dir);
968 return VC_ELM_ERROR_NONE;
971 int _vc_elm_get_text_domain(char **domain)
973 if (NULL == g_app_domain) {
975 return VC_ELM_ERROR_OPERATION_FAILED;
978 *domain = strdup(g_app_domain);
979 return VC_ELM_ERROR_NONE;
982 int vc_elm_is_supported_vt_auto(int* is_vt_automode)
984 if (0 != __vc_elm_get_feature_enabled()) {
985 return VC_ELM_ERROR_NOT_SUPPORTED;
988 *is_vt_automode = g_is_vt_automode;
989 VC_ELM_LOG_DBG("Success to get vconfkey(%d)", *is_vt_automode);
991 return VC_ELM_ERROR_NONE;
994 int _vc_elm_set_auto_register_mode(int mode, int click_method)
997 g_click_method = click_method;
999 VC_ELM_LOG_DBG("g_auto_mode: %d, g_click_method: %d", g_auto_mode, g_click_method);
1004 int _vc_elm_get_auto_register_mode(int* mode, int* click_method)
1006 if (0 == g_is_vt_automode) {
1007 VC_ELM_LOG_DBG("vt_automode is FALSE");
1008 *mode = g_auto_mode;
1009 *click_method = g_click_method;
1011 VC_ELM_LOG_DBG("vt_automode is TRUE");
1012 *mode = (int)VC_ELM_MODE_AUTO_APPFW;
1013 *click_method = g_click_method;
1017 VC_ELM_LOG_DBG("mode: %d, click_method: %d", *mode, *click_method);
1022 int vc_elm_set_auto_register_mode(int mode, int click_method)
1024 if (0 != __vc_elm_get_feature_enabled()) {
1025 return VC_ELM_ERROR_NOT_SUPPORTED;
1028 if (0 == g_is_vt_automode) {
1029 VC_ELM_LOG_DBG("vt_automode is FALSE");
1030 return _vc_elm_set_auto_register_mode(mode, click_method);
1033 VC_ELM_LOG_DBG("vt_automode is TRUE");
1034 return _vc_elm_set_auto_register_mode((int)VC_ELM_MODE_AUTO_APPFW, click_method);
1037 int vc_elm_get_auto_register_mode(int* mode, int* click_method)
1039 if (0 != __vc_elm_get_feature_enabled()) {
1040 return VC_ELM_ERROR_NOT_SUPPORTED;
1043 return _vc_elm_get_auto_register_mode(mode, click_method);
1046 int vc_elm_add_allowed_text_part(const char* text_part)
1048 if (0 != __vc_elm_get_feature_enabled()) {
1049 return VC_ELM_ERROR_NOT_SUPPORTED;
1052 if (NULL == text_part) {
1053 VC_ELM_LOG_ERR("Invalid parameter");
1054 return VC_ELM_ERROR_INVALID_PARAMETER;
1057 if (0 != _vc_elm_core_add_allowed_text_part(text_part)) {
1058 return VC_ELM_ERROR_OPERATION_FAILED;
1061 return VC_ELM_ERROR_NONE;
1064 int vc_elm_remove_allowed_text_part(void)
1066 if (0 != __vc_elm_get_feature_enabled()) {
1067 return VC_ELM_ERROR_NOT_SUPPORTED;
1070 if (0 != _vc_elm_core_remove_allowed_text_part()) {
1071 return VC_ELM_ERROR_OPERATION_FAILED;
1074 return VC_ELM_ERROR_NONE;
1077 int vc_elm_set_geometry_info(int x, int y, int w, int h)
1079 if (0 != __vc_elm_get_feature_enabled()) {
1080 return VC_ELM_ERROR_NOT_SUPPORTED;
1083 if (0 != _vc_elm_core_set_geometry_info(x, y, w, h)) {
1084 return VC_ELM_ERROR_OPERATION_FAILED;
1087 return VC_ELM_ERROR_NONE;
1090 int vc_elm_unset_geometry_info()
1092 if (0 != __vc_elm_get_feature_enabled()) {
1093 return VC_ELM_ERROR_NOT_SUPPORTED;
1096 if (0 != _vc_elm_core_unset_geometry_info()) {
1097 return VC_ELM_ERROR_OPERATION_FAILED;
1100 return VC_ELM_ERROR_NONE;
1103 int vc_elm_set_click_time(float time)
1105 if (0 != __vc_elm_get_feature_enabled()) {
1106 return VC_ELM_ERROR_NOT_SUPPORTED;
1109 if (0 != _vc_elm_core_set_click_time(time)) {
1110 return VC_ELM_ERROR_OPERATION_FAILED;
1113 return VC_ELM_ERROR_NONE;
1116 int vc_elm_unset_click_time()
1118 if (0 != __vc_elm_get_feature_enabled()) {
1119 return VC_ELM_ERROR_NOT_SUPPORTED;
1122 if (0 != _vc_elm_core_unset_click_time()) {
1123 return VC_ELM_ERROR_OPERATION_FAILED;
1126 return VC_ELM_ERROR_NONE;
1131 * @brief Wrapper for making internal function public - for automated test purposes
1139 * @brief Wrapper for making internal function public - for automated test purposes