Merge "Pass tts handle to connect_daemon in prepare_sync function" into tizen
[platform/core/uifw/tts.git] / server / ttsd_dbus.c
index c9015eb..1cf564b 100644 (file)
@@ -75,9 +75,9 @@ int ttsdc_send_hello(int pid, int uid)
 
        /* create a message & check for errors */
        msg = dbus_message_new_method_call(
-               service_name, 
-               TTS_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
+               service_name,
+               TTS_CLIENT_SERVICE_OBJECT_PATH,
+               target_if_name,
                TTSD_METHOD_HELLO);
 
        if (NULL == msg) {
@@ -312,10 +312,12 @@ void __ttsd_dbus_connection_free()
 {
        if (NULL != g_conn_listener) {
                dbus_connection_close(g_conn_listener);
+               dbus_connection_unref(g_conn_listener);
                g_conn_listener = NULL;
        }
        if (NULL != g_conn_sender) {
                dbus_connection_close(g_conn_sender);
+               dbus_connection_unref(g_conn_sender);
                g_conn_sender = NULL;
        }
 }
@@ -391,6 +393,21 @@ int ttsd_dbus_open_connection()
                snprintf(g_service_name, strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, "%s", TTS_NOTI_SERVER_SERVICE_NAME);
                snprintf(g_service_object, strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_NOTI_SERVER_SERVICE_OBJECT_PATH);
                snprintf(g_service_interface, strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_NOTI_SERVER_SERVICE_INTERFACE);
+       } else if (TTSD_MODE_INTERRUPT == ttsd_get_mode()) {
+               g_service_name = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_NAME) + 1, sizeof(char));
+               g_service_object = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
+               g_service_interface = (char*)calloc(strlen(TTS_INTERRUPT_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
+
+               if (NULL == g_service_name || NULL == g_service_object || NULL == g_service_interface) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to allocate memory");
+                       __ttsd_dbus_service_free();
+                       __ttsd_dbus_connection_free();
+                       return -1;
+               }
+
+               snprintf(g_service_name, strlen(TTS_INTERRUPT_SERVER_SERVICE_NAME) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_NAME);
+               snprintf(g_service_object, strlen(TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH);
+               snprintf(g_service_interface, strlen(TTS_INTERRUPT_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_INTERRUPT_SERVER_SERVICE_INTERFACE);
        } else {
                g_service_name = (char*)calloc(strlen(TTS_SERVER_SERVICE_NAME) + 1, sizeof(char));
                g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));