Add synchronous prepare function for web API 06/151806/3
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 18 Sep 2017 11:02:29 +0000 (20:02 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 22 Sep 2017 06:18:32 +0000 (15:18 +0900)
Change-Id: Ie70180121c1569d602d439cd9a295d2ec617be36
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/vc.c
include/voice_control_internal.h

index e5bb5c697a4d0d670b7563b137604d533dd52377..7fe220e3ea7a25f9a21d83561cea7e06250a20fd 100644 (file)
@@ -310,13 +310,13 @@ int vc_initialize(void)
 
        /* check handle */
        if (true == vc_client_is_valid(g_vc)) {
-               SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Already initialized");
-               return VC_ERROR_INVALID_STATE;
+               SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized");
+               return VC_ERROR_NONE;
        }
 
        if (0 < vc_client_get_count()) {
                SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized");
-               return VC_ERROR_INVALID_STATE;
+               return VC_ERROR_NONE;
        }
 
        if (0 != vc_dbus_open_connection()) {
@@ -572,6 +572,38 @@ int vc_prepare(void)
        return VC_ERROR_NONE;
 }
 
+int vc_prepare_sync(void)
+{
+       if (0 != __vc_get_feature_enabled()) {
+               return VC_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __vc_check_privilege()) {
+               return VC_ERROR_PERMISSION_DENIED;
+       }
+
+       SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare");
+
+       vc_state_e state;
+       if (0 != vc_client_get_client_state(g_vc, &state)) {
+               SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       /* check state */
+       if (state != VC_STATE_INITIALIZED) {
+               SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'CREATED'");
+               SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       while (EINA_TRUE == __vc_connect_daemon(NULL));
+
+       SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+
+       return VC_ERROR_NONE;
+}
+
 int vc_unprepare(void)
 {
        if (0 != __vc_get_feature_enabled()) {
index 8465e9ec2f145da12e37726afbb2d556baa2a5b2..d73dcfb9cb3f1b5fe42f26029c8c268fb9d1d6e5 100644 (file)
@@ -68,6 +68,8 @@ typedef bool (*vc_asr_result_cb)(vc_result_event_e event, const char* result, vo
  */
 int vc_set_command_list_from_file(const char* file_path, int type);
 
+int vc_prepare_sync(void);
+
 
 #ifdef __cplusplus
 }