static Eina_Bool __vc_widget_notify_state_changed(void *data);
static void __vc_widget_notify_error(void *data);
+static void __vc_widget_delete_focus_event_handler(void *data);
static int __vc_widget_get_feature_enabled()
{
SLOG(LOG_WARN, TAG_VCW, "[ERROR] Fail to request finalize : %s", __vc_widget_get_error_code(ret));
}
- if (NULL != g_focus_in_handler) {
- ecore_event_handler_del(g_focus_in_handler);
- g_focus_in_handler = NULL;
- }
- if (NULL != g_focus_out_handler) {
- ecore_event_handler_del(g_focus_out_handler);
- g_focus_out_handler = NULL;
- }
+ __vc_widget_delete_focus_event_handler(NULL);
ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET);
if (0 != ret)
return VC_ERROR_INVALID_STATE;
}
-
- int thread_count = ecore_thread_active_get();
- int count = 0;
- while (0 < thread_count) {
- usleep(50000);
- count++;
- if (100 == count) {
- SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is blocked, cnt(%d), thread count(%d)", count, thread_count);
- break;
- } else if (0 == count % 5) {
- SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is alive, cnt(%d), thread count(%d)", count, thread_count);
- }
- thread_count = ecore_thread_active_get();
- }
-
vc_state_e state;
vc_widget_client_get_state(vc_w, &state);
vc_widget_s* widget = widget_get(vc_w);
return ECORE_CALLBACK_RENEW;
}
-static void __vc_widget_connect_daemon(void *data)
+static void __vc_widget_add_focus_event_handler(void *data)
+{
+ SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] add focus event handler");
+
+ if (NULL == g_focus_in_handler)
+ g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL);
+ if (NULL == g_focus_out_handler)
+ g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL);
+
+ return;
+}
+
+static void __vc_widget_delete_focus_event_handler(void *data)
+{
+ SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] delete focus event handler");
+
+ if (NULL != g_focus_in_handler) {
+ ecore_event_handler_del(g_focus_in_handler);
+ g_focus_in_handler = NULL;
+ }
+ if (NULL != g_focus_out_handler) {
+ ecore_event_handler_del(g_focus_out_handler);
+ g_focus_out_handler = NULL;
+ }
+
+ return;
+}
+
+static Eina_Bool __vc_widget_connect_daemon(void *data)
{
vc_h vc_w = (vc_h)data;
ecore_main_loop_thread_safe_call_async(__vc_widget_notify_error, vc_w);
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
- return;
+ return EINA_FALSE;
} else if (VC_ERROR_INVALID_PARAMETER == ret) {
SLOG(LOG_WARN, TAG_VCW, "[WARNING] Invalid Parameter");
ecore_main_loop_thread_safe_call_async(__vc_widget_notify_error, vc_w);
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
- return;
+ return EINA_TRUE;
}
vc_widget_client_set_service_state(vc_w, (vc_service_state_e)service_state);
SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] Connect daemon");
- if (NULL == g_focus_in_handler)
- g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL);
- if (NULL == g_focus_out_handler)
- g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL);
-
char appid[1024] = {'\0',};
aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1);
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
- return;
+ return EINA_FALSE;
}
static void __start_prepare_thread(void *data, Ecore_Thread *thread)
while (0 != ret) {
if (retry_count == 30) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request hello !!");
+ ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL);
return;
}
}
}
-#if 0
ret = -1;
retry_count = 0;
while (0 != ret) {
if (retry_count == 10) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to connect daemon !!");
+ ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL);
return;
}
ret = __vc_widget_connect_daemon((void*)vc_w);
else
retry_count++;
}
-#endif
- ecore_main_loop_thread_safe_call_async(__vc_widget_connect_daemon, vc_w);
+ SLOG(LOG_DEBUG, TAG_VCW, "@@@");
return;
}
return VC_ERROR_INVALID_STATE;
}
+ // Add focus event handler before start sub thread. If connection fails, event handler will be deleted.
+ __vc_widget_add_focus_event_handler(NULL);
+
ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, (void*)vc_w);
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
return VC_ERROR_NONE;
}
+ int thread_count = ecore_thread_active_get();
+ int count = 0;
+ SLOG(LOG_INFO, TAG_VCW, "[Widget] Thread count(%d)", thread_count);
+ while (0 < thread_count) {
+ usleep(50000);
+ if (100 == count) {
+ SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is blocked, cnt(%d), thread count(%d)", count, thread_count);
+ break;
+ } else if (0 == count % 5) {
+ SLOG(LOG_WARN, TAG_VCW, "[WARNING!!] Thread is alive, cnt(%d), thread count(%d)", count, thread_count);
+ }
+ count++;
+ thread_count = ecore_thread_active_get();
+ }
+
vc_state_e state;
if (0 != vc_widget_client_get_state(vc_w, &state)) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available");
/* check state */
if (state != VC_STATE_READY) {
- SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'");
+ SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY', state(%d)", state);
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
return VC_ERROR_INVALID_STATE;
}