Merge "Support download engine language" into tizen
[platform/core/uifw/tts.git] / client / tts.c
index 6fdc4eb..19684fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+*  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
@@ -82,6 +82,8 @@ static const char* __tts_get_error_code(tts_error_e err)
        case TTS_ERROR_ENGINE_NOT_FOUND:        return "TTS_ERROR_ENGINE_NOT_FOUND";
        case TTS_ERROR_OPERATION_FAILED:        return "TTS_ERROR_OPERATION_FAILED";
        case TTS_ERROR_AUDIO_POLICY_BLOCKED:    return "TTS_ERROR_AUDIO_POLICY_BLOCKED";
+       case TTS_ERROR_NOT_SUPPORTED_FEATURE:   return "TTS_ERROR_NOT_SUPPORTED_FEATURE";
+       case TTS_ERROR_SERVICE_RESET:           return "TTS_ERROR_SERVICE_RESET";
        default:
                return "Invalid error code";
        }
@@ -98,7 +100,7 @@ static int __tts_convert_config_error_code(tts_config_error_e code)
        if (code == TTS_CONFIG_ERROR_INVALID_VOICE)             return TTS_ERROR_INVALID_VOICE;
        if (code == TTS_CONFIG_ERROR_ENGINE_NOT_FOUND)          return TTS_ERROR_ENGINE_NOT_FOUND;
        if (code == TTS_CONFIG_ERROR_OPERATION_FAILED)          return TTS_ERROR_OPERATION_FAILED;
-       if (code == TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE)     return TTS_ERROR_OPERATION_FAILED;
+       if (code == TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE)     return TTS_ERROR_NOT_SUPPORTED_FEATURE;
 
        return code;
 }
@@ -1477,7 +1479,7 @@ int tts_set_private_data(tts_h tts, const char* key, const char* data)
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
-       
+
        if (NULL == key || NULL == data) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1495,11 +1497,6 @@ int tts_set_private_data(tts_h tts, const char* key, const char* data)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
-               return TTS_ERROR_INVALID_STATE;
-       }
-
        int ret = -1;
        int count = 0;
        while (0 != ret) {
@@ -1538,7 +1535,7 @@ int tts_get_private_data(tts_h tts, const char* key, char** data)
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
-       
+
        if (NULL == key || NULL == data) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1556,11 +1553,6 @@ int tts_get_private_data(tts_h tts, const char* key, char** data)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
-               return TTS_ERROR_INVALID_STATE;
-       }
-
        int ret = -1;
        int count = 0;
        while (0 != ret) {
@@ -1639,6 +1631,15 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg)
                SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
        }
 
+       if (TTS_ERROR_SERVICE_RESET == reason) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Service Reset");
+
+               client->current_state = TTS_STATE_CREATED;
+               if (0 != tts_prepare(client->tts)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare");
+               }
+       }
+
        return 0;
 }