Add interfaces for transfering service state
[platform/core/uifw/tts.git] / client / tts_tidl.c
index 8b6edca..f773654 100644 (file)
@@ -102,6 +102,13 @@ static void __notify_cb(void *user_data, int pid, int uid, bundle *msg)
                if (val) {
                        tts_core_notify_state_changed(client, (tts_state_e)atoi(val));
                }
+       } else if (0 == strncmp(TTSD_METHOD_SET_SERVICE_STATE, method, strlen(TTSD_METHOD_SET_SERVICE_STATE))) {
+               char* before_state = NULL;
+               char* current_state = NULL;
+               bundle_get_str(msg, TTS_BUNDLE_BEFORE_STATE, &before_state);
+               bundle_get_str(msg, TTS_BUNDLE_CURRENT_STATE, &current_state);
+
+               // TODO: Implement notifier
        } else if (0 == strncmp(TTSD_METHOD_ERROR, method, strlen(TTSD_METHOD_ERROR))) {
                char *uttid = NULL;
                char *reason = NULL;
@@ -785,3 +792,34 @@ int tts_tidl_request_add_pcm(unsigned int uid, int event, const char* data, int
 
        return TTS_ERROR_NONE;
 }
+
+int tts_tidl_request_get_service_state(unsigned int uid, tts_service_state_e* service_state)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_get_service_state");
+
+       tts_client_s* client = tts_client_get_by_uid(uid);
+       RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get client");
+
+       tts_tidl_info_s* info = __get_tidl_info_s(uid);
+       RETVM_IF(NULL == info, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+
+       RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+       int state = (int)TTS_SERVICE_STATE_READY;
+       int ret = rpc_port_proxy_tts_invoke_get_service_state(info->rpc_h, uid, &state);
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request get service state : Fail to invoke message");
+               return ret;
+       }
+
+       *service_state = (tts_service_state_e)state;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< get service state : service state(%d)", state);
+
+       return TTS_ERROR_NONE;
+}