Add not supported error description and checker logic 03/279803/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 18 Aug 2022 05:25:23 +0000 (14:25 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 18 Aug 2022 05:25:23 +0000 (14:25 +0900)
- Issue:
New APIs are related with the TTS feature, but there is no information
about the feature in description of APIs.

- Solution:
This patch adds description for feature not supported error. And also,
this patch implements feature checker logic. Through this patch, the
APIs will not working if the feature is not enabled and return not
supported error.

Change-Id: I4c92376db2f98562c8792bc9446cb7a77d8a4626
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
include/ttse.h
server/ttse.c

index 1cf441fcdebb5b8522e331424931c2da2cf10eb9..32c52a228a1c9a7b76aa21a81cae8faf79ce71f7 100755 (executable)
@@ -660,6 +660,7 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_NOT_SUPPORTED TTS NOT supported
 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
 * @pre The ttse_main() function should be invoked before this function is called.
@@ -676,6 +677,7 @@ int ttse_get_activated_mode(int* activated_mode);
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_NOT_SUPPORTED TTS NOT supported
 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
 * @pre The ttse_main() function should be invoked before this function is called.
index e9b8c3655ba8a796449e2a018f9068e0b71e198e..729f4daee0521f36de45053dad7e737c117344e9 100755 (executable)
 #include <Ecore.h>
 #include <vconf.h>
 #include <app_manager.h>
+#include <system_info.h>
 
 #include "ttse.h"
 
+static int g_feature_enabled = -1;
 static bool g_is_terminated = false;
 
+
 const char* tts_tag()
 {
        return "ttsd";
 }
 
+static bool __is_feature_enabled()
+{
+       if (1 == g_feature_enabled) {
+               return true;
+       }
+
+       if (0 == g_feature_enabled) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS feature NOT supported");
+               return false;
+       }
+
+       bool tts_supported = false;
+       if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get feature value");
+               return false;
+       }
+
+       if (false == tts_supported) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS feature NOT supported");
+               g_feature_enabled = 0;
+               return false;
+       }
+
+       g_feature_enabled = 1;
+       return true;
+}
+
 static bool __is_default_engine()
 {
        char* engine = NULL;
@@ -243,6 +273,10 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f
 
 int ttse_get_activated_mode(int* activated_mode)
 {
+       if (false == __is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == activated_mode) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
                return TTSE_ERROR_INVALID_PARAMETER;
@@ -263,6 +297,10 @@ int ttse_get_activated_mode(int* activated_mode)
 
 int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback)
 {
+       if (false == __is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == callback) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
                return TTSE_ERROR_INVALID_PARAMETER;