static bool g_is_terminated = false;
+static int g_activated_mode = 0;
/* Function definitions */
static int __stop_and_send_ready_state(unsigned int uid)
SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to create timer");
}
+ g_activated_mode = 0;
+
return TTSD_ERROR_NONE;
}
return TTSD_ERROR_NONE;
}
+static void __set_and_notify_activated_mode()
+{
+ int activated_mode = ttsd_data_get_activated_mode();
+ if (g_activated_mode == activated_mode) {
+ return;
+ }
+
+ SLOG(LOG_INFO, tts_tag(), "[Server] Activated mode is changed from(%d) to (%d)", g_activated_mode, activated_mode);
+
+ g_activated_mode = activated_mode;
+ int ret = ttsd_engine_notify_activated_mode_changed(g_activated_mode);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to notify activated mode changed event.(%d)", ret);
+ }
+}
+
+static int __check_app_agreed(int pid, unsigned int uid, bool credential_needed)
+{
+ if (false == credential_needed) {
+ return TTSD_ERROR_NONE;
+ }
+
+ char* appid = NULL;
+ if (APP_MANAGER_ERROR_NONE != app_manager_get_app_id(pid, &appid)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id, pid(%d)", pid);
+ }
+
+ bool is_agreed = false;
+ int ret = ttsd_engine_check_app_agreed(appid, &is_agreed);
+ free(appid);
+ appid = NULL;
+
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "Server ERROR] Fail to check app agreed");
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ if (false == is_agreed) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] App is not agreed");
+ return TTSD_ERROR_PERMISSION_DENIED;
+ }
+
+ return TTSD_ERROR_NONE;
+}
+
int ttsd_server_initialize(int pid, unsigned int uid, ttsd_mode_e mode, tts_ipc_method_e method, bool* credential_needed)
{
SLOG(LOG_INFO, tts_tag(), "[Server] Server initialize");
return TTSD_ERROR_NONE;
}
- if (0 != ttsd_data_new_client(pid, uid, mode, method)) {
+ if (TTSD_ERROR_NONE != ttsd_data_new_client(pid, uid, mode, method)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
return TTSD_ERROR_OPERATION_FAILED;
}
+ __set_and_notify_activated_mode();
+
if (TTSD_ERROR_NONE != ttsd_engine_agent_load_current_engine()) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to load current engine");
ttsd_data_delete_client(uid);
return TTSD_ERROR_OPERATION_FAILED;
}
- if (0 != ttsd_engine_agent_is_credential_needed(uid, credential_needed)) {
+ bool is_needed = false;
+ if (TTSD_ERROR_NONE != ttsd_engine_agent_is_credential_needed(uid, &is_needed)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get credential necessity");
ttsd_data_delete_client(uid);
return TTSD_ERROR_OPERATION_FAILED;
}
- if (true == *credential_needed) {
- char* appid = NULL;
- if (0 != app_manager_get_app_id(pid, &appid)) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id, pid(%d)", pid);
- }
- bool is_agreed = false;
- if (0 != ttsd_engine_check_app_agreed(appid, &is_agreed)) {
- SLOG(LOG_ERROR, tts_tag(), "Server ERROR] Fail to check app agreed");
- if (!appid)
- free(appid);
- ttsd_data_delete_client(uid);
- return TTSD_ERROR_OPERATION_FAILED;
- }
- if (!appid)
- free(appid);
-
- if (false == is_agreed) {
- SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] App is not agreed");
- ttsd_data_delete_client(uid);
- return TTSD_ERROR_PERMISSION_DENIED;
- }
+ int ret = __check_app_agreed(pid, uid, is_needed);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Checking credential is finished(%d)", ret);
+ ttsd_data_delete_client(uid);
+ return ret;
}
+ *credential_needed = is_needed;
+
return TTSD_ERROR_NONE;
}
}
ttsd_data_delete_client(uid);
+ __set_and_notify_activated_mode();
/* unload engine, if ref count of client is 0 */
if (0 == ttsd_data_get_client_count()) {
return ret;
}
+int ttsd_get_activated_mode(int* activated_mode)
+{
+ if (NULL == activated_mode) {
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ *activated_mode = ttsd_data_get_activated_mode();
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback)
+{
+ int ret = ttsd_engine_agent_set_activated_mode_changed_cb(callback);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set private data requested cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
int ttsd_server_play_pcm(unsigned int uid)
{
app_tts_state_e state = ttsd_data_get_client_state(uid);