static int g_privilege_allowed = -1;
static cynara *p_cynara = NULL;
-Eina_Bool __vc_notify_state_changed(void *data);
-Eina_Bool __vc_notify_error(void *data);
+static void __vc_notify_state_changed(void *data);
+static void __vc_notify_error(void *data);
static int __vc_get_feature_enabled()
{
fp = fopen(label_path, "r");
if (fp != NULL) {
- if (sizeof(smack_label) != fread(smack_label, 1, sizeof(smack_label), fp))
+ if (strlen(smack_label) != fread(smack_label, 1, sizeof(smack_label), fp))
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to fread");
fclose(fp);
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret));
vc_client_set_error(g_vc, VC_ERROR_ENGINE_NOT_FOUND);
- ecore_timer_add(0, __vc_notify_error, g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc);
SLOG(LOG_DEBUG, TAG_VCC, "@@@");
return EINA_FALSE;
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret));
vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT);
- ecore_timer_add(0, __vc_notify_error, g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc);
SLOG(LOG_DEBUG, TAG_VCC, "@@@");
return EINA_FALSE;
}
vc_client_set_client_state(g_vc, VC_STATE_READY);
- ecore_timer_add(0, __vc_notify_state_changed, g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc);
vc_client_set_mgr_pid(g_vc, mgr_pid);
return EINA_FALSE;
}
+static void __start_prepare_thread(void *data, Ecore_Thread *thread)
+{
+ SLOG(LOG_ERROR, TAG_VCC, "@@@ Start prepare thread");
+ int ret = -1, retry_count = 0;
+
+ /* Send hello */
+ while (0 != ret) {
+
+ if (retry_count == 10) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!");
+ return;
+ }
+
+ ret = vc_dbus_request_hello();
+ if (ret == 0) {
+ SLOG(LOG_DEBUG, TAG_VCC, "Success to request hello. retry count(%d)", retry_count);
+ break;
+ } else {
+ retry_count++;
+ }
+ }
+
+ ret = -1;
+ retry_count = 0;
+ while (0 != ret) {
+ if (retry_count == 10) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to connect daemon !!");
+ return;
+ }
+ ret = __vc_connect_daemon(NULL);
+ if (ret == 0)
+ break;
+ else
+ retry_count++;
+ }
+
+ return;
+}
+
+static void __end_prepare_thread(void *data, Ecore_Thread *thread)
+{
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@ End prepare thread");
+}
+
int vc_prepare(void)
{
if (0 != __vc_get_feature_enabled()) {
return VC_ERROR_INVALID_STATE;
}
- g_connect_timer = ecore_timer_add(0, __vc_connect_daemon, NULL);
+ ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL);
SLOG(LOG_DEBUG, TAG_VCC, "@@@");
__vc_internal_unprepare();
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
- ecore_timer_add(0, __vc_notify_state_changed, g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc);
SLOG(LOG_DEBUG, TAG_VCC, "@@@");
}
#endif
-Eina_Bool __vc_notify_error(void *data)
+static void __vc_notify_error(void *data)
{
vc_h vc = (vc_h)data;
} else {
SLOG(LOG_WARN, TAG_VCC, "[WARNING] Error callback is null");
}
-
- return EINA_FALSE;
}
int __vc_cb_error(int reason, int daemon_pid, char* msg)
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] VC daemon reset");
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
- __vc_notify_state_changed(g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc);
if (0 != vc_prepare()) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to prepare");
}
}
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Error reason(%d), msg(%s)", reason, msg);
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg);
vc_client_set_error(g_vc, reason);
- ecore_timer_add(0, __vc_notify_error, g_vc);
+ ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc);
return 0;
}
-Eina_Bool __vc_notify_state_changed(void *data)
+static void __vc_notify_state_changed(void *data)
{
vc_h vc = (vc_h)data;
} else {
SLOG(LOG_WARN, TAG_VCC, "[WARNING] State changed callback is null");
}
-
- return EINA_FALSE;
}
static Eina_Bool __vc_notify_result(void *data)
static bool g_err_callback_status = false;
static Eina_Bool __vc_mgr_notify_state_changed(void *data);
-static Eina_Bool __vc_mgr_notify_error(void *data);
+static void __vc_mgr_notify_error(void *data);
static Eina_Bool __vc_mgr_notify_result(void *data);
static const char* __vc_mgr_get_error_code(vc_error_e err)
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize : %s", __vc_mgr_get_error_code(ret));
vc_mgr_client_set_error(g_vc_m, VC_ERROR_ENGINE_NOT_FOUND);
- ecore_timer_add(0, __vc_mgr_notify_error, g_vc_m);
+ ecore_main_loop_thread_safe_call_async(__vc_mgr_notify_error, (void*)g_vc_m);
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
return EINA_FALSE;
int ret = 1, retry_count = 0;
/* Send hello */
- while (ret) {
+ while (0 != ret) {
if (retry_count == 10) {
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request hello !!");
ret = 1;
retry_count = 0;
- while (ret) {
+ while (0 != ret) {
if (retry_count == 10) {
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to connect daemon !!");
return;
return ret;
}
-static Eina_Bool __vc_mgr_notify_error(void *data)
+static void __vc_mgr_notify_error(void *data)
{
vc_h vc_m = (vc_h)data;
} else {
SLOG(LOG_WARN, TAG_VCM, "[WARNING] Error callback is null");
}
-
- return EINA_FALSE;
}
int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg)