Add interfaces for transfering service state
[platform/core/uifw/tts.git] / server / ttsd_tidl.c
index a516f7f..495b737 100644 (file)
@@ -452,6 +452,17 @@ static int __add_pcm_cb(rpc_port_stub_tts_context_h context, int uid, int event,
        return TTSD_ERROR_NONE;
 }
 
+static int __get_service_state(rpc_port_stub_tts_context_h context, int uid, int* service_state, void *user_data)
+{
+       unsigned int u_uid = (unsigned int)uid;
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET SERVICE STATE (%u)", u_uid);
+
+       // TODO: implement business logic
+
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       return TTSD_ERROR_NONE;
+}
+
 int ttsd_tidl_open_connection()
 {
        SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsd_tidl_open_connection");
@@ -471,6 +482,7 @@ int ttsd_tidl_open_connection()
        g_callback.get_private = __get_private_cb;
        g_callback.play = __play_cb;
        g_callback.add_pcm = __add_pcm_cb;
+       g_callback.get_service_state = __get_service_state;
 
 
        int ret = -1;
@@ -530,6 +542,28 @@ int ttsdc_tidl_send_set_state_message(int pid, unsigned int uid, int state)
        return __send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
 }
 
+int ttsdc_tidl_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsdc_tidl_send_set_service_state_message");
+
+       char str_before_state[10] = {0, };
+       char str_current_state[10] = {0, };
+
+       snprintf(str_before_state, 10, "%d", before_state);
+       snprintf(str_current_state, 10, "%d", current_state);
+
+       bundle* msg = bundle_create();
+       bundle_add_str(msg, TTS_BUNDLE_METHOD, TTSD_METHOD_SET_SERVICE_STATE);
+       bundle_add_str(msg, TTS_BUNDLE_BEFORE_STATE, str_before_state);
+       bundle_add_str(msg, TTS_BUNDLE_CURRENT_STATE, str_current_state);
+
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND SET SERVICE STATE MESSAGE");
+       __send_msg(pid, uid, msg);
+
+       bundle_free(msg);
+       return TTSD_ERROR_NONE;
+}
+
 int ttsdc_tidl_send_error_message(int pid, unsigned int uid, int uttid, int reason, char* err_msg)
 {
        SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsdc_tidl_send_error_message");