## Dependent packages ##
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- aul capi-media-audio-io capi-system-info dbus-1 dlog ecore
+ aul capi-media-audio-io capi-appfw-app-manager capi-system-info dbus-1 dlog ecore
glib-2.0 libtzplatform-config libxml-2.0 vconf bundle buxton2
)
* limitations under the License.
*/
+#include <app_manager.h>
#include <dirent.h>
#include <Ecore.h>
#include <iconv.h>
return TTS_ERROR_NONE;
}
+int tts_set_server_tts(tts_h tts, const char* credential)
+{
+ if (0 != __tts_get_feature_enabled()) {
+ return TTS_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == tts || NULL == credential) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] 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] Get state : A handle is not valid");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (TTS_STATE_CREATED != client->current_state && TTS_STATE_READY != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid (%d).", client->current_state);
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ if (NULL != client->credential) {
+ free(client->credential);
+ client->credential = NULL;
+ }
+
+ client->credential = strdup(credential);
+ if (NULL == client->credential) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
+ return TTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ client->internal = true;
+
+ char* key = NULL;
+ if (NULL != credential)
+ key = strdup("EnableServerTTS");
+ else
+ key = strdup("DisableServerTTS");
+ if (NULL == key) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
+ return TTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ int pid = getpid();
+ char* appid = NULL;
+ int ret = app_manager_get_app_id(pid, &appid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get appid, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
+ free(key);
+ key = NULL;
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ ret = tts_set_private_data(tts, key, appid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set private data, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
+ free(key);
+ key = NULL;
+ return ret;
+ }
+
+ free(appid);
+ appid = NULL;
+ free(key);
+ key = NULL;
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return TTS_ERROR_NONE;
+}
+
static Eina_Bool __tts_connect_daemon(void *data)
{
tts_h tts = (tts_h)data;
return TTS_ERROR_INVALID_STATE;
}
+ if (true != client->internal && (0 == strcmp(key, "EnableServerTTS") || 0 == strcmp(key, "DisableServerTTS"))) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] This is not an internal app");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
int ret = -1;
int count = 0;
while (0 != ret) {
client->credential = NULL;
client->credential_needed = false;
+ client->internal = false;
g_client_list = g_list_append(g_client_list, client);
/* options */
char* credential;
bool credential_needed;
+ bool internal;
} tts_client_s;
int tts_client_new(tts_h* tts);
dbus_connection_read_write_dispatch(g_conn_listener, 50);
- DBusMessage* msg = NULL;
- msg = dbus_connection_pop_message(g_conn_listener);
+ while (1) {
+ DBusMessage* msg = NULL;
+ msg = dbus_connection_pop_message(g_conn_listener);
- if (true != dbus_connection_get_is_connected(g_conn_listener)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection is disconnected");
- return ECORE_CALLBACK_RENEW;
- }
+ if (true != dbus_connection_get_is_connected(g_conn_listener)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection is disconnected");
+ break;
+ }
- /* loop again if we haven't read a message */
- if (NULL == msg) {
- return ECORE_CALLBACK_RENEW;
- }
+ /* loop again if we haven't read a message */
+ if (NULL == msg) {
+ break;
+ }
- DBusError err;
- dbus_error_init(&err);
+ DBusError err;
+ dbus_error_init(&err);
- char if_name[64] = {0, };
- snprintf(if_name, 64, "%s", TTS_CLIENT_SERVICE_INTERFACE);
+ char if_name[64] = {0, };
+ snprintf(if_name, 64, "%s", TTS_CLIENT_SERVICE_INTERFACE);
- if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) {
- int uid = 0;
- int uttid = 0;
+ if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) {
+ int uid = 0;
+ int uttid = 0;
- dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- }
+ dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ }
- if (0 == __tts_cb_utt_started(uid, uttid)) {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance started : uid(%d) uttid(%d)", uid, uttid);
- }
- } /* TTSD_METHOD_UTTERANCE_STARTED */
+ if (0 == __tts_cb_utt_started(uid, uttid)) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance started : uid(%d) uttid(%d)", uid, uttid);
+ }
+ } /* TTSD_METHOD_UTTERANCE_STARTED */
- else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) {
- int uid = 0;
- int uttid = 0;
+ else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) {
+ int uid = 0;
+ int uttid = 0;
- dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- }
+ dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ }
- if (0 == __tts_cb_utt_completed(uid, uttid)) {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance completed : uid(%d) uttid(%d)", uid, uttid);
- }
- } /* TTS_SIGNAL_UTTERANCE_STARTED */
+ if (0 == __tts_cb_utt_completed(uid, uttid)) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance completed : uid(%d) uttid(%d)", uid, uttid);
+ }
+ } /* TTS_SIGNAL_UTTERANCE_STARTED */
- else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_SET_STATE)) {
- int uid = 0;
- int state = 0;
+ else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_SET_STATE)) {
+ int uid = 0;
+ int state = 0;
- dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- }
+ dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ }
- if (0 == __tts_cb_set_state(uid, state)) {
- SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts state changed : uid(%d) state(%d)", uid, state);
- }
- } /* TTSD_SIGNAL_SET_STATE */
-
- else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_ERROR)) {
- int uid;
- int uttid;
- int reason;
- char* err_msg;
-
- dbus_message_get_args(msg, &err,
- DBUS_TYPE_INT32, &uid,
- DBUS_TYPE_INT32, &uttid,
- DBUS_TYPE_INT32, &reason,
- DBUS_TYPE_STRING, &err_msg,
- DBUS_TYPE_INVALID);
+ if (0 == __tts_cb_set_state(uid, state)) {
+ SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts state changed : uid(%d) state(%d)", uid, state);
+ }
+ } /* TTSD_SIGNAL_SET_STATE */
+
+ else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_ERROR)) {
+ int uid;
+ int uttid;
+ int reason;
+ char* err_msg;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_INT32, &uttid,
+ DBUS_TYPE_INT32, &reason,
+ DBUS_TYPE_STRING, &err_msg,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message - Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message : uid(%d), error(%d), uttid(%d), err_msg(%s)", uid, reason, uttid, (NULL == err_msg) ? "NULL" : err_msg);
+ __tts_cb_error(uid, reason, uttid, err_msg);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message - Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- } else {
- SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message : uid(%d), error(%d), uttid(%d), err_msg(%s)", uid, reason, uttid, (NULL == err_msg) ? "NULL" : err_msg);
- __tts_cb_error(uid, reason, uttid, err_msg);
+ }
+ } /* TTSD_SIGNAL_ERROR */
+ else {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Message is NOT valid");
+ dbus_message_unref(msg);
+ break;
}
- } /* TTSD_SIGNAL_ERROR */
-
- /* free the message */
- dbus_message_unref(msg);
+ /* free the message */
+ dbus_message_unref(msg);
+ }
return ECORE_CALLBACK_PASS_ON;
}
INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-setting.pc" DESTINATION ${LIBDIR}/pkgconfig)
INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-engine.pc" DESTINATION ${LIBDIR}/pkgconfig)
INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts_internal.h" DESTINATION ${INCLUDEDIR})
INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts_setting.h" DESTINATION ${INCLUDEDIR})
INSTALL(FILES "${CMAKE_BINARY_DIR}/include/ttse.h" DESTINATION ${INCLUDEDIR})
--- /dev/null
+/*
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TTS_INTERNAL_H__
+#define __TTS_INTERNAL_H__
+
+#include <tizen.h>
+#include <tts.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @brief Sets server tts.
+ * @details Using this API, the application can ask server tts with a credential.
+ * The credential is a key to verify the authorization about using the engine based on server, not embeded engine.
+ * If the application sets the credential, it will be able to use functions of the server engine entirely.
+ * @since_tizen @if MOBILE 3.0
+ *
+ * @remarks The necessity of the credential depends on the engine. In case of the engine which is basically embedded in Tizen, the credential is not necessary so far.
+ * However, if the user wants to apply the 3rd party's engine, the credential may be necessary. In that case, please follow the policy provided by the corresponding engine.
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] credential The credential
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Success
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ * @retval #TTS_ERROR_OUT_OF_MEMORY TTS Out of memory
+ *
+ * @pre The state should be #TTS_STATE_CREATED or #TTS_STATE_READY.
+ *
+ * @see tts_play()
+*/
+int tts_set_server_tts(tts_h tts, const char* credential);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}@}
+ */
+
+#endif /* __TTS_INTERNAL_H__ */
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/tts.pc
%{_includedir}/tts.h
+%{_includedir}/tts_internal.h
%files setting-devel
%defattr(-,root,root,-)
dbus_connection_read_write_dispatch(g_conn_listener, 50);
- DBusMessage* msg = NULL;
- msg = dbus_connection_pop_message(g_conn_listener);
+ while (1) {
+ DBusMessage* msg = NULL;
+ msg = dbus_connection_pop_message(g_conn_listener);
- if (true != dbus_connection_get_is_connected(g_conn_listener)) {
- SLOG(LOG_ERROR, tts_tag(), "[ERROR] Connection is disconnected");
- return ECORE_CALLBACK_RENEW;
- }
+ if (true != dbus_connection_get_is_connected(g_conn_listener)) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Connection is disconnected");
+ return ECORE_CALLBACK_RENEW;
+ }
- /* loop again if we haven't read a message */
- if (NULL == msg) {
- return ECORE_CALLBACK_RENEW;
- }
+ /* loop again if we haven't read a message */
+ if (NULL == msg) {
+ return ECORE_CALLBACK_RENEW;
+ }
- /* client event */
- if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO)) {
- ttsd_dbus_server_hello(g_conn_listener, msg);
+ /* client event */
+ if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO)) {
+ ttsd_dbus_server_hello(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE)) {
- ttsd_dbus_server_initialize(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE)) {
+ ttsd_dbus_server_initialize(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE)) {
- ttsd_dbus_server_finalize(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE)) {
+ ttsd_dbus_server_finalize(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES)) {
- ttsd_dbus_server_get_support_voices(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES)) {
+ ttsd_dbus_server_get_support_voices(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE)) {
- ttsd_dbus_server_get_current_voice(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE)) {
+ ttsd_dbus_server_get_current_voice(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_QUEUE)) {
- ttsd_dbus_server_add_text(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_QUEUE)) {
+ ttsd_dbus_server_add_text(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) {
- ttsd_dbus_server_play(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) {
+ ttsd_dbus_server_play(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) {
- ttsd_dbus_server_stop(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) {
+ ttsd_dbus_server_stop(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) {
- ttsd_dbus_server_pause(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) {
+ ttsd_dbus_server_pause(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_SET_PRIVATE_DATA)) {
- ttsd_dbus_server_set_private_data(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_SET_PRIVATE_DATA)) {
+ ttsd_dbus_server_set_private_data(g_conn_listener, msg);
- } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_PRIVATE_DATA)) {
- ttsd_dbus_server_get_private_data(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_PRIVATE_DATA)) {
+ ttsd_dbus_server_get_private_data(g_conn_listener, msg);
- } else {
- /* Invalid method */
+ } else {
+ SLOG(LOG_DEBUG, TAG_TTSC, "Message is NOT valid");
+ /* Invalid method */
+ }
}
-
/* free the message */
dbus_message_unref(msg);
*/
int ttsd_send_error(ttse_error_e error, const char* msg)
{
+ int uid = g_utt.uid;
+ int uttid = g_utt.uttid;
+ int tmp_pid = ttsd_data_get_pid(uid);
+
+ SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Error msg from engine, pid(%d), uid(%d), uttid(%d), error(%d), msg(%s)", tmp_pid, uid, uttid, error, msg);
+
+ __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+
+ if (0 != ttsd_player_clear(uid))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_player_stop()");
+
+ if (0 != ttsd_data_clear_data(uid))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_clear_data()");
+
+ if (0 != ttsdc_send_error_message(tmp_pid, uid, uttid, error, (char*)msg))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_error_message()");
+
+ if (0 != ttsd_data_set_client_state(uid, APP_STATE_READY))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_set_client_state()");
+
+ if (0 != ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_set_state_message()");
+
return 0;
}