X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=server%2Fttsd_dbus.c;h=c69cd3060abc330ed5e5129e737e5632b38ae92f;hb=7877f3f91a0b81ba298fdd94f9b4b80cf37b0666;hp=76bc2eac2dc8b4f11b9e21c873ca14468c129374;hpb=61d512de9fcd491863d96439b17c412fe915fb59;p=platform%2Fcore%2Fuifw%2Ftts.git diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index 76bc2ea..c69cd30 100644 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -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) { @@ -331,7 +331,7 @@ int ttsd_dbus_open_connection() int ret; /* Create connection for sender */ - g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + g_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); dbus_error_free(&err); @@ -342,8 +342,10 @@ int ttsd_dbus_open_connection() return -1; } + dbus_connection_set_exit_on_disconnect(g_conn_sender, false); + /* connect to the bus and check for errors */ - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); + g_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); dbus_error_free(&err); @@ -357,6 +359,8 @@ int ttsd_dbus_open_connection() return -1; } + dbus_connection_set_exit_on_disconnect(g_conn_listener, false); + __ttsd_dbus_service_free(); if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) { @@ -389,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)); @@ -421,6 +440,11 @@ int ttsd_dbus_open_connection() return -1; } + /* Flush messages which are received before fd event handler registration */ + while (DBUS_DISPATCH_DATA_REMAINS == dbus_connection_get_dispatch_status(g_conn_listener)) { + listener_event_callback(NULL, NULL); + } + /* add a rule for getting signal */ char rule[128]; snprintf(rule, 128, "type='method_call',interface='%s'", g_service_interface);