Fix double pthread mutex unlock
[platform/core/uifw/tts.git] / client / tts_dbus.c
index e7dc689..71015b6 100644 (file)
@@ -21,7 +21,7 @@
 #include "tts_dbus.h"
 #include "tts_defs.h"
 #include "tts_main.h"
-
+#include "tts_internal.h"
 
 #define HELLO_WAITING_TIME 500
 #define WAITING_TIME 5000
@@ -158,10 +158,12 @@ static void __tts_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;
        }
 }
@@ -299,21 +301,27 @@ DBusMessage* __tts_dbus_make_message(int uid, const char* method)
 
        if (TTS_MODE_DEFAULT == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_SERVER_SERVICE_NAME, 
-                       TTS_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_SERVER_SERVICE_INTERFACE, 
+                       TTS_SERVER_SERVICE_NAME,
+                       TTS_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_SERVER_SERVICE_INTERFACE,
                        method);
        } else if (TTS_MODE_NOTIFICATION == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_NOTI_SERVER_SERVICE_NAME, 
-                       TTS_NOTI_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_NOTI_SERVER_SERVICE_INTERFACE, 
+                       TTS_NOTI_SERVER_SERVICE_NAME,
+                       TTS_NOTI_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_NOTI_SERVER_SERVICE_INTERFACE,
                        method);
        } else if (TTS_MODE_SCREEN_READER == client->mode) {
                msg = dbus_message_new_method_call(
-                       TTS_SR_SERVER_SERVICE_NAME, 
-                       TTS_SR_SERVER_SERVICE_OBJECT_PATH, 
-                       TTS_SR_SERVER_SERVICE_INTERFACE, 
+                       TTS_SR_SERVER_SERVICE_NAME,
+                       TTS_SR_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_SR_SERVER_SERVICE_INTERFACE,
+                       method);
+       } else if (TTS_MODE_INTERRUPT == client->mode) {
+               msg = dbus_message_new_method_call(
+                       TTS_INTERRUPT_SERVER_SERVICE_NAME,
+                       TTS_INTERRUPT_SERVER_SERVICE_OBJECT_PATH,
+                       TTS_INTERRUPT_SERVER_SERVICE_INTERFACE,
                        method);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input mode is not available");
@@ -347,7 +355,7 @@ int tts_dbus_request_hello(int uid)
        result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, HELLO_WAITING_TIME, &err);
        dbus_message_unref(msg);
        if (dbus_error_is_set(&err)) {
-//             SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts dbus log : %s", err);
+               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts dbus log : %s", err);
                dbus_error_free(&err);
        }
 
@@ -430,6 +438,8 @@ int tts_dbus_request_initialize(int uid, bool* credential_needed)
                                        snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_NOTI_SERVER_SERVICE_INTERFACE);
                                } else if (TTS_MODE_SCREEN_READER == client->mode) {
                                        snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_SR_SERVER_SERVICE_INTERFACE);
+                               } else if (TTS_MODE_INTERRUPT == client->mode) {
+                                       snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_INTERRUPT_SERVER_SERVICE_INTERFACE);
                                }
                                dbus_bus_add_match(g_conn_listener, rule_err, &err);
                                dbus_connection_flush(g_conn_listener);
@@ -474,6 +484,8 @@ int tts_dbus_request_finalize(int uid)
                snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_NOTI_SERVER_SERVICE_INTERFACE);
        } else if (TTS_MODE_SCREEN_READER == client->mode) {
                snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_SR_SERVER_SERVICE_INTERFACE);
+       } else if (TTS_MODE_INTERRUPT == client->mode) {
+               snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_INTERRUPT_SERVER_SERVICE_INTERFACE);
        }
        dbus_bus_remove_match(g_conn_listener, rule_err, &err);
        dbus_connection_flush(g_conn_listener);