Implement set/unset engine_changed_cb and Fix ttsd_dbus_server_get_private_data 71/78571/2
authorsooyeon.kim <sooyeon.kim@samsung.com>
Wed, 6 Jul 2016 06:28:01 +0000 (15:28 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Wed, 6 Jul 2016 08:53:03 +0000 (17:53 +0900)
Change-Id: I111819064cb758cad94965ca3bd2b84795048d01
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/tts.c
client/tts_client.h
client/tts_setting.c
common/tts_config_mgr.c
common/tts_config_mgr.h
common/tts_config_parser.h
server/ttsd_config.c
server/ttsd_dbus_server.c

index 19684fc..bcf848b 100644 (file)
@@ -136,6 +136,30 @@ void __tts_config_voice_changed_cb(const char* before_lang, int before_voice_typ
        return;
 }
 
+void _tts_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data)
+{
+       tts_h tts = (tts_h)user_data;
+
+       tts_client_s* client = tts_client_get(tts);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[WARNING] A handle is not valid");
+               return;
+       }
+
+       if (NULL != engine_id)  SLOG(LOG_DEBUG, TAG_TTSC, "Engine id(%s)", engine_id);
+       if (NULL != setting)    SLOG(LOG_DEBUG, TAG_TTSC, "Engine setting(%s)", setting);
+       if (NULL != language)   SLOG(LOG_DEBUG, TAG_TTSC, "Language(%s)", language);
+       SLOG(LOG_DEBUG, TAG_TTSC, "Voice type(%d), Auto voice(%s), Credential(%s)", voice_type, auto_voice? "on" : "off", need_credential ? "need" : "no need");
+
+       /* call callback function */
+       if (NULL != client->engine_changed_cb) {
+               client->engine_changed_cb(tts, engine_id, language, voice_type, need_credential, client->engine_changed_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function for changed engine");
+       }
+       return;
+}
+
 int tts_create(tts_h* tts)
 {
        if (0 != __tts_get_feature_enabled()) {
@@ -177,7 +201,7 @@ int tts_create(tts_h* tts)
                return __tts_convert_config_error_code(ret);
        }
 
-       ret = tts_config_mgr_set_callback(client->uid, NULL, __tts_config_voice_changed_cb, NULL, NULL, NULL);
+       ret = tts_config_mgr_set_callback(client->uid, _tts_config_engine_changed_cb, __tts_config_voice_changed_cb, NULL, NULL, NULL);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
                tts_client_destroy(*tts);
@@ -2054,3 +2078,66 @@ int tts_unset_default_voice_changed_cb(tts_h tts)
 
        return 0;
 }
+
+int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* user_data)
+{
+       if (0 != __tts_get_feature_enabled()) {
+               return TTS_ERROR_NOT_SUPPORTED;
+       }
+
+       if (NULL == tts || NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set engine changed cb : Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set engine changed cb : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set engine changed cb : Current state is not 'Created'.");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       client->engine_changed_cb = callback;
+       client->engine_changed_user_data = user_data;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set engine changed cb");
+
+       return 0;
+}
+
+int tts_unset_engine_changed_cb(tts_h tts)
+{
+       if (0 != __tts_get_feature_enabled()) {
+               return TTS_ERROR_NOT_SUPPORTED;
+       }
+
+       if (NULL == tts) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset engine changed cb : Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset engine changed cb : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset engine changed cb : Current state is not 'Created'.");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       client->engine_changed_cb = NULL;
+       client->engine_changed_user_data = NULL;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset engine changed cb");
+
+       return 0;
+}
+
index 6d68d23..008a2c4 100644 (file)
@@ -43,6 +43,8 @@ typedef struct {
        void*                           error_user_data;
        tts_default_voice_changed_cb    default_voice_changed_cb;
        void*                           default_voice_changed_user_data;
+       tts_engine_changed_cb           engine_changed_cb;
+       void*                           engine_changed_user_data;
        tts_supported_voice_cb          supported_voice_cb;
        void*                           supported_voice_user_data;
 
index fa11422..dee9257 100644 (file)
@@ -68,7 +68,7 @@ static int __setting_convert_config_error_code(tts_config_error_e code)
        return TTS_SETTING_ERROR_NONE;
 }
 
-void __setting_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, void* user_data)
+void __setting_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "Engine chagned : engine(%s) setting(%s) lang(%s) type(%d)",
                 engine_id, setting, language, language, voice_type);
index f52ffb2..45a8349 100644 (file)
@@ -378,7 +378,7 @@ Eina_Bool tts_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl
                                                SECURE_SLOG(LOG_DEBUG, tts_tag(), "Engine changed callback : uid(%d)", temp_client->uid);
                                                temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting, 
                                                        g_config_info->language, g_config_info->type, 
-                                                       g_config_info->auto_voice, temp_client->user_data);
+                                                       g_config_info->auto_voice, g_config_info->credential, temp_client->user_data);
                                        }
                                }
 
@@ -896,9 +896,9 @@ static Eina_Bool __tts_config_mgr_engine_config_inotify_event_callback(void* dat
                        if (NULL != temp_client) {
                                if (NULL != temp_client->engine_cb) {
                                        SECURE_SLOG(LOG_DEBUG, tts_tag(), "Engine changed callback : uid(%d)", temp_client->uid);
-                                       temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting, 
+                                       temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting,        
                                                g_config_info->language, g_config_info->type, 
-                                               g_config_info->auto_voice, temp_client->user_data);
+                                               g_config_info->auto_voice, g_config_info->credential, temp_client->user_data);
                                }
                        }
 
index 1f6a509..c9eb1d7 100644 (file)
@@ -51,7 +51,7 @@ typedef bool (*tts_config_supported_engine_cb)(const char* engine_id, const char
 typedef bool (*tts_config_supported_voice_cb)(const char* engine_id, const char* language, int type, void* user_data);
 
 typedef void (*tts_config_engine_changed_cb)(const char* engine_id, const char* setting, 
-                                            const char* language, int voice_type, bool auto_voice, void* user_data);
+                                            const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data);
 
 typedef void (*tts_config_voice_changed_cb)(const char* before_language, int before_voice_type, 
                                            const char* current_language, int current_voice_type, 
index 5eb6216..f32c620 100644 (file)
@@ -41,6 +41,7 @@ typedef struct {
        char*   setting;
        GSList* voices;
        bool    pitch_support;
+       bool    need_credential;
 } tts_engine_info_s;
 
 typedef struct {
@@ -51,6 +52,7 @@ typedef struct {
        int     type;
        int     speech_rate;
        int     pitch;
+       bool    credential;
 } tts_config_s;
 
 
index e8878b5..d21ae3a 100644 (file)
@@ -24,7 +24,7 @@ static ttsd_config_changed_cb g_callback;
 
 static ttsd_config_screen_reader_changed_cb g_sr_callback;
 
-void __ttsd_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, void* user_data)
+void __ttsd_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data)
 {
        /* Need to check engine is valid */
        if (false == tts_config_check_default_engine_is_valid(engine_id)) {
index 776e2c4..65fcd58 100644 (file)
@@ -588,10 +588,11 @@ int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
        if (NULL != reply) {
                dbus_message_append_args(reply,
                        DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_STRING, &data,
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts get private data : (%d)", ret);
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts get private data : Result(%d), data(%s)", ret, (NULL == data) ? "NULL" : data);
                } else {
                        SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
                }