Add the session timer to handle the exception case
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-main.c
index 8006b74..e4a29d2 100644 (file)
@@ -36,9 +36,16 @@ static GMainLoop *main_loop;
 static gboolean terminated = FALSE;
 static gboolean is_initialized = FALSE;
 
+static void __on_log_glib(const gchar *log_domain, GLogLevelFlags log_level,
+               const gchar *msg, gpointer user_data)
+{
+       BT_ERR_C("%s", msg);
+}
+
 static void __bt_release_service(void)
 {
        _bt_service_unregister_vconf_handler();
+       _bt_service_unregister_poweroff_event();
 
        _bt_service_adapter_le_deinit();
        _bt_deinit_service_event_sender();
@@ -105,7 +112,7 @@ gboolean _bt_reliable_terminate_service(gpointer user_data)
 
        terminated = TRUE;
 
-       BT_INFO_C("Terminating the bt-service daemon");
+       BT_INFO_C("### Terminating the bt-service daemon");
 
        if (main_loop != NULL)
                g_main_loop_quit(main_loop);
@@ -127,6 +134,11 @@ static gboolean __bt_check_bt_service(void *data)
                int ps_mode_deactivation = 0;
 #endif
 
+               if (_is_name_acquired() == FALSE) {
+                       BT_ERR("dbus name is NOT acquired yet");
+                       return TRUE;
+               }
+
                status = _bt_adapter_get_status();
                le_status = _bt_adapter_get_le_status();
                BT_DBG("State: %d, LE State: %d", status, le_status);
@@ -205,6 +217,7 @@ int _bt_service_initialize(void)
        }
 
        _bt_service_register_vconf_handler();
+       _bt_service_register_poweroff_event();
 
        /* Event reciever Init */
        ret = _bt_init_service_event_receiver();
@@ -272,6 +285,8 @@ int main(void)
                return 0;
        }
 
+       g_log_set_default_handler(__on_log_glib, NULL);
+
        main_loop = g_main_loop_new(NULL, FALSE);
 
        g_main_loop_run(main_loop);