Fix - Coding rule
[platform/core/uifw/stt.git] / client / stt.c
old mode 100644 (file)
new mode 100755 (executable)
index fa4dd9c..82c47cb
@@ -85,7 +85,7 @@ static int __check_privilege_initialize()
        int ret = cynara_initialize(&p_cynara, NULL);
        if (CYNARA_API_SUCCESS != ret)
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] fail to initialize");
-       
+
        return ret == CYNARA_API_SUCCESS;
 }
 
@@ -133,7 +133,7 @@ static int __stt_check_privilege()
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied");
                return STT_ERROR_PERMISSION_DENIED;
        } else if (-1 == g_privilege_allowed) {
-               if (false == __check_privilege_initialize()){
+               if (false == __check_privilege_initialize()) {
                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed");
                        return STT_ERROR_PERMISSION_DENIED;
                }
@@ -148,7 +148,7 @@ static int __stt_check_privilege()
        }
 
        g_privilege_allowed = 1;
-       return STT_ERROR_NONE;  
+       return STT_ERROR_NONE;
 }
 
 static const char* __stt_get_error_code(stt_error_e err)
@@ -168,6 +168,7 @@ static const char* __stt_get_error_code(stt_error_e err)
        case STT_ERROR_ENGINE_NOT_FOUND:        return "STT_ERROR_ENGINE_NOT_FOUND";
        case STT_ERROR_OPERATION_FAILED:        return "STT_ERROR_OPERATION_FAILED";
        case STT_ERROR_NOT_SUPPORTED_FEATURE:   return "STT_ERROR_NOT_SUPPORTED_FEATURE";
+       case STT_ERROR_SERVICE_RESET:           return "STT_ERROR_SERVICE_RESET";
        default:
                return "Invalid error code";
        }
@@ -531,6 +532,8 @@ int stt_set_engine(stt_h stt, const char* engine_id)
                free(client->current_engine_id);
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "===== engined_id(%s)", engine_id);
+
        client->current_engine_id = strdup(engine_id);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -671,6 +674,11 @@ int stt_get_private_data(stt_h stt, const char* key, char** data)
                }
        }
 
+       if (0 == strncmp(*data, "NULL", strlen(*data))) {
+               free(*data);
+               *data = NULL;
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, "");
 
@@ -730,6 +738,8 @@ static Eina_Bool __stt_connect_daemon(void *data)
                int count = 0;
                silence_supported = false;
                credential_needed = false;
+               SLOG(LOG_DEBUG, TAG_STTC, "[WARNING] current_engine_id(%s)", client->current_engine_id);
+
                while (0 != ret) {
                        ret = stt_dbus_request_set_current_engine(client->uid, client->current_engine_id, &silence_supported, &credential_needed);
                        if (0 != ret) {
@@ -1664,6 +1674,15 @@ int __stt_cb_error(int uid, int reason, char* err_msg)
                SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
        }
 
+       if (STT_ERROR_SERVICE_RESET == reason) {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Service reset");
+
+               client->current_state = STT_STATE_CREATED;
+               if (0 != stt_prepare(client->stt)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare");
+               }
+       }
+
        return 0;
 }