Modify the pid and gid of bt-service to network_fw
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-event-receiver.c
index 5feb958..a7944a5 100644 (file)
@@ -44,6 +44,7 @@
 #include "bt-service-opp-client.h"
 #include "bt-service-map-client.h"
 #include "bt-service-tds.h"
+#include "bt-service-otp.h"
 
 #ifdef TIZEN_FEATURE_BT_DPM
 #include "bt-service-dpm.h"
@@ -1180,7 +1181,8 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path)
                        }
 
                        BT_DBG("LegacyPairing Failed with %s. Show Error Popup", remote_dev_info->name);
-                       _bt_launch_system_popup(BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE,
+                       if (headed_plugin_info->plugin_headed_enabled)
+                               headed_plugin_info->headed_plugin->bt_launch_system_popup(BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE,
                                                remote_dev_info->name, auth_info, NULL, NULL, NULL);
 
                        _bt_free_device_info(remote_dev_info);
@@ -1708,6 +1710,9 @@ void _bt_handle_gatt_event(GVariant *msg, const char *member, const char *path)
        if (strcasecmp(member, "GattValueChanged") == 0) {
                /* Check TDS seekers waiting for Indication  */
                _bt_tds_check_indication(path, msg);
+#ifdef TIZEN_FEATURE_BT_OTP
+               _bt_otp_check_indication(path, msg);
+#endif
        } else {
                BT_INFO("Unhandled event");
        }
@@ -2291,6 +2296,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        ipsp_proxy = _bt_get_ipsp_proxy();
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
+                               g_free(address);
                                return;
                        }
 
@@ -2302,6 +2308,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        ipsp_proxy = _bt_get_ipsp_proxy();
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
+                               g_free(address);
                                return;
                        }
 
@@ -2340,6 +2347,21 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        param);
 
                g_free(address);
+       }  else if (strcasecmp(member, "OtcDisconnected") == 0) {
+               gboolean connected = FALSE;
+               GVariant *otc_param = NULL;
+
+               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+               _bt_convert_device_path_to_address(path, address);
+
+               BT_DBG("OTC Disconnected, address: %s", address);
+               otc_param = g_variant_new("(ibsn)", result, connected, address);
+
+               /* Send event to application */
+               _bt_send_event(BT_OTP_EVENT,
+                                               BLUETOOTH_EVENT_OTC_STATE_CHANGED,
+                                               otc_param);
+               g_free(address);
        }
 }
 
@@ -3159,7 +3181,7 @@ int _bt_opp_client_event_init(void)
        GError *error = NULL;
 
        if (opc_obexd_conn == NULL) {
-               opc_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+               opc_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
 
                if (!opc_obexd_conn) {
                        if (error) {
@@ -3221,7 +3243,7 @@ int _bt_map_client_event_init(void)
        GError *error = NULL;
 
        if (map_obexd_conn == NULL) {
-               map_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+               map_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
 
                if (!map_obexd_conn) {
                        if (error) {
@@ -3872,7 +3894,7 @@ static int __bt_init_obexd_receiver(void)
                GError *error = NULL;
 
                if (obexd_conn == NULL) {
-                       obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+                       obexd_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
                        if (error != NULL) {
                                BT_ERR("ERROR: Can't get on session bus [%s]", error->message);
                                g_clear_error(&error);