X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-api%2Fbt-event-handler.c;h=de5e298155ead1baa4dd97096a203c70578acf08;hb=a97bce8622f95e66254b5927b6561185515519e1;hp=105d1cca28aca5116e82a5980a9579a878167d3c;hpb=f95664bc0a52a095222e6a327512bf49bccd4697;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 105d1cc..de5e298 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -30,6 +30,8 @@ #include "bluetooth-gatt-server-api.h" #endif +#include "bluetooth-mesh-api.h" + #include "bt-common.h" #include "bt-event-handler.h" #include "bt-gatt-client.h" @@ -386,6 +388,367 @@ gboolean __bt_reliable_disable_cb(gpointer user_data) return FALSE; } +static void __bt_fill_garray_from_variant(GVariant *var, GArray *param) +{ + char *data; + int size; + + size = g_variant_get_size(var); + if (size > 0) { + data = (char *)g_variant_get_data(var); + if (data) + param = g_array_append_vals(param, data, size); + + } +} + +/* Mesh Event Handler */ +static void __bt_mesh_event_filter(GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + BT_INFO("Mesh event handler Entry >>"); + bt_event_info_t *event_info; + + event_info = (bt_event_info_t *)user_data; + ret_if(event_info == NULL); + + if (strcasecmp(signal_name, BT_MESH_SCAN_STARTED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_network_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_network_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_STARTED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_SCAN_FINISHED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_network_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_network_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_FINISHED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_SCAN_RESULT) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_scan_result_t *info = NULL; + BT_INFO("Mesh: BT_MESH_SCAN_RESULT"); + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_scan_result_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_SCAN_RESULT, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_AUTHENTICATION_REQ) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_authentication_request_t *info = NULL; + BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REQ"); + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_authentication_request_t, 0); + BT_INFO("Mesh: Authentication Type [%d]", info->auth_type); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_AUTHENTICATION_REQUEST, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_PROVISIONING_RESULT) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_provisioning_result_t *info = NULL; + BT_INFO("Mesh: BT_MESH_PROVISIONING_RESULT"); + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_provisioning_result_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_PROVISIONING_FINISHED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_NODE_BROWSED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_node_discover_t *info = NULL; + BT_INFO("Mesh: Node browsed event"); + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_node_discover_t, 0); + + BT_INFO("Mesh: Send Node Browse event: Net UID [%s], Node UUID [%s]", + info->net_uuid, info->dev_uuid); + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_BROWSED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_NODE_VEND_FEATS) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_node_features_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_node_features_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_VENDOR_FEATURES, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_NODE_KEY_CONFIGURED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_key_configure_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_APPKEY_CONFIGURED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_model_configure_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_model_configure_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_APPKEY_LIST) == 0) { + int result; + GVariantIter *iter = NULL; + bluetooth_mesh_model_configure_t info; + uint16_t node_unicast; + int elem_idx; + uint32_t model; + const char *net_uuid = NULL; + int total = 0; + uint16_t appkey_idx; + int i; + + g_variant_get(parameters, "(i&sqiui(aq))", &result, &net_uuid, + &node_unicast, &elem_idx, &model, &total, &iter); + + memset(&info, 0x00, sizeof(bluetooth_mesh_model_configure_t)); + info.primary_unicast = node_unicast; + g_strlcpy(info.net_uuid, net_uuid, 33); + info.elem_index = elem_idx; + info.model = model; + info.appkeylist_count = total; + BT_INFO("Mesh: Total appkeys bound to model [%d]", total); + if (total) { + info.appkey_list = (uint16_t**)g_malloc0(sizeof(uint16_t*) * total); + + for (i = 0; i < total && g_variant_iter_loop(iter, "q", &appkey_idx); ++i) { + info.appkey_list[i] = g_malloc0(sizeof(uint16_t)); + *info.appkey_list[i] = appkey_idx; + } + } + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST, + result, &info, + event_info->cb, event_info->user_data); + + for (i = 0; i < total; i++) + g_free(info.appkey_list[i]); + if (info.appkey_list) { + g_free(info.appkey_list); + g_variant_iter_free(iter); + } + + } else if (strcasecmp(signal_name, BT_MESH_MODEL_SUB_LIST) == 0) { + int result; + GVariantIter *iter = NULL; + bluetooth_mesh_model_configure_t info; + uint16_t node_unicast; + int elem_idx; + uint32_t model; + const char *net_uuid = NULL; + int total = 0; + uint16_t sub_addr; + int i; + + g_variant_get(parameters, "(i&sqiui(aq))", &result, &net_uuid, + &node_unicast, &elem_idx, &model, &total, &iter); + + memset(&info, 0x00, sizeof(bluetooth_mesh_model_configure_t)); + info.primary_unicast = node_unicast; + g_strlcpy(info.net_uuid, net_uuid, 33); + info.elem_index = elem_idx; + info.model = model; + info.sublist_count = total; + + BT_INFO("Mesh: Total Subscriptions Bound to model [%d]", total); + if (total) { + info.sub_list = (uint16_t**)g_malloc0(sizeof(uint16_t*) * total); + for (i = 0; i < total && g_variant_iter_loop(iter, "q", &sub_addr); ++i) { + info.sub_list[i] = g_malloc0(sizeof(uint16_t)); + *info.sub_list[i] = sub_addr; + BT_INFO("Mesh: Subscription Address [0x%2.2x]", sub_addr); + } + } + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST, + result, &info, + event_info->cb, event_info->user_data); + + for (i = 0; i < total; i++) + g_free(info.sub_list[i]); + if (info.sub_list) { + g_free(info.sub_list); + g_variant_iter_free(iter); + } + } else if (strcasecmp(signal_name, BT_MESH_NODE_TTL_CONFIGURED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_node_ttl_info_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_node_ttl_info_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_SUB_CONF) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_key_configure_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_VIR_SUB_CONF) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_key_configure_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_PUB_STATUS) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_key_configure_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_key_configure_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, + result, info, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MESH_MODEL_MSG_EXECUTED) == 0) { + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bluetooth_mesh_model_msg_t *info = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bluetooth_mesh_model_msg_t, 0); + + _bt_mesh_event_cb(BLUETOOTH_EVENT_MESH_MODEL_MSG_EXECUTED, + result, info, + event_info->cb, event_info->user_data); + } + BT_INFO("Mesh event handler Exit <<"); +} + void __bt_adapter_event_filter(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -422,6 +785,80 @@ void __bt_adapter_event_filter(GDBusConnection *connection, disable_timer_id = g_timeout_add(BT_RELIABLE_DISABLE_TIME, (GSourceFunc)__bt_reliable_disable_cb, event_info); + } else if (strcasecmp(signal_name, BT_DISABLED_BATTERY_DATA) == 0) { + BT_INFO("BT_DISABLED_BATTERY_DATA"); + + int result; + GVariant *param = NULL; + GArray *dbus_data = NULL; + bt_battery_dbus_data_t *info = NULL; + bt_battery_data *data = NULL; + + g_variant_get(parameters, "(iv)", &result, ¶m); + + if (!param) { + result = BLUETOOTH_ERROR_INTERNAL; + BT_ERR("No data reveived"); + _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED_BATTERY_DATA, + result, data, + event_info->cb, event_info->user_data); + return; + } + + dbus_data = g_array_new(TRUE, TRUE, sizeof(gchar)); + + if (dbus_data == NULL) { + BT_ERR("g_array_new failed"); + g_variant_unref(param); + return; + } + __bt_fill_garray_from_variant(param, dbus_data); + g_variant_unref(param); + + info = &g_array_index(dbus_data, bt_battery_dbus_data_t, 0); + + data = g_new0(bt_battery_data, 1); + + data->session_start_time = info->session_start_time; + data->session_end_time = info->session_end_time; + data->session_scan_time = info->session_scan_time; + data->session_connected_time = info->session_connected_time; + data->tx_time = info->tx_time; + data->rx_time = info->rx_time; + data->idle_time = info->idle_time; + data->atm_list = NULL; + + BT_INFO("Received battery data in bt-api: %ld %ld %d %d.", + data->session_start_time, data->session_end_time, + data->session_scan_time, data->session_connected_time); + + /*Copying app wise details*/ + int n = NUM_APP_MAX < info->num_app ? NUM_APP_MAX : info->num_app; //Maximum NUM_APP_MAX details will be fetched + + for (int i = 0; i < n; i++) { + bt_battery_app_data *app_data = NULL; + app_data = g_malloc0(sizeof(bt_battery_app_data)); + memcpy(app_data, &(info->app_data[i]), sizeof(bt_battery_app_data)); + data->atm_list = g_slist_append(data->atm_list, app_data); + } + + if (data->atm_list == NULL) { + BT_INFO("No app data transaction in this session"); + } + else { + BT_INFO("App-wise data transaction details:"); + for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) { + bt_battery_app_data *t = (bt_battery_app_data *)(l->data); + BT_DBG("%ld %ld %d %d %u", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes, t->time); + } + } + + _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED_BATTERY_DATA, + result, data, + event_info->cb, event_info->user_data); + g_slist_free(data->atm_list); + g_free(data); + g_array_free(dbus_data, TRUE); } else if (strcasecmp(signal_name, BT_DISCOVERABLE_MODE_CHANGED) == 0) { int mode = 0; @@ -613,34 +1050,41 @@ void __bt_adapter_event_filter(GDBusConnection *connection, const char *address = NULL; const char *name = NULL; const char *str_passkey = NULL; + bool incoming = false; bluetooth_authentication_request_info_t auth_info; memset(&auth_info, 0x00, sizeof(bluetooth_authentication_request_info_t)); - g_variant_get(parameters, "(i&s&s&s)", &result, &address, &name, &str_passkey); + g_variant_get(parameters, "(b&s&s&s)", &incoming, &address, &name, &str_passkey); g_strlcpy(auth_info.device_name.name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1); _bt_convert_addr_string_to_type(auth_info.device_address.addr, address); g_strlcpy(auth_info.str_passkey, str_passkey, strlen(str_passkey)+1); + auth_info.incoming = incoming; + BT_INFO("BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY"); _bt_common_event_cb(BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY, result, &auth_info, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_PIN_REQ_RECEIVED) == 0) { const char *address = NULL; const char *name = NULL; + bool incoming = false; bluetooth_authentication_request_info_t auth_info; memset(&auth_info, 0x00, sizeof(bluetooth_authentication_request_info_t)); - g_variant_get(parameters, "(i&s&s)", &result, &address, &name); + g_variant_get(parameters, "(b&s&s)", &incoming, &address, &name); g_strlcpy(auth_info.device_name.name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1); _bt_convert_addr_string_to_type(auth_info.device_address.addr, address); + auth_info.incoming = incoming; + + BT_INFO("BLUETOOTH_EVENT_PIN_REQUEST"); _bt_common_event_cb(BLUETOOTH_EVENT_PIN_REQUEST, result, &auth_info, @@ -648,16 +1092,20 @@ void __bt_adapter_event_filter(GDBusConnection *connection, } else if (strcasecmp(signal_name, BT_PASSKEY_REQ_RECEIVED) == 0) { const char *address = NULL; const char *name = NULL; + bool incoming = false; bluetooth_authentication_request_info_t auth_info; memset(&auth_info, 0x00, sizeof(bluetooth_authentication_request_info_t)); - g_variant_get(parameters, "(i&s&s)", &result, &address, &name); + g_variant_get(parameters, "(b&s&s)", &incoming, &address, &name); g_strlcpy(auth_info.device_name.name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1); _bt_convert_addr_string_to_type(auth_info.device_address.addr, address); + auth_info.incoming = incoming; + + BT_INFO("BLUETOOTH_EVENT_PASSKEY_REQUEST"); _bt_common_event_cb(BLUETOOTH_EVENT_PASSKEY_REQUEST, result, &auth_info, @@ -666,17 +1114,21 @@ void __bt_adapter_event_filter(GDBusConnection *connection, const char *address = NULL; const char *name = NULL; const char *str_passkey = NULL; + bool incoming = false; bluetooth_authentication_request_info_t auth_info; memset(&auth_info, 0x00, sizeof(bluetooth_authentication_request_info_t)); - g_variant_get(parameters, "(i&s&s&s)", &result, &address, &name, &str_passkey); + g_variant_get(parameters, "(b&s&s&s)", &incoming, &address, &name, &str_passkey); g_strlcpy(auth_info.device_name.name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1); _bt_convert_addr_string_to_type(auth_info.device_address.addr, address); g_strlcpy(auth_info.str_passkey, str_passkey, strlen(str_passkey)+1); + auth_info.incoming = incoming; + + BT_INFO("BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST"); _bt_common_event_cb(BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST, result, &auth_info, @@ -719,6 +1171,7 @@ void __bt_adapter_le_event_filter(GDBusConnection *connection, BLUETOOTH_ERROR_NONE, NULL, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_LE_DISCOVERY_FINISHED) == 0) { + _bt_set_le_scan_status(FALSE); g_variant_get(parameters, "(i)", &result); _bt_common_event_cb(BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED, result, NULL, @@ -774,7 +1227,7 @@ void __bt_device_event_filter(GDBusConnection *connection, #endif ret_if(signal_name == NULL); -#ifdef TIZEN_GATT_CLIENT + if (strcasecmp(signal_name, BT_GATT_SERVER_CONNECTED) == 0) { const char *address = NULL; bluetooth_device_address_t dev_address = { {0} }; @@ -782,7 +1235,6 @@ void __bt_device_event_filter(GDBusConnection *connection, g_variant_get(parameters, "(i&s)", &result, &address); _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_CONNECTED, result, &dev_address, event_info->cb, event_info->user_data); @@ -793,7 +1245,6 @@ void __bt_device_event_filter(GDBusConnection *connection, g_variant_get(parameters, "(i&s)", &result, &address); _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED, result, &dev_address, event_info->cb, event_info->user_data); @@ -804,7 +1255,6 @@ void __bt_device_event_filter(GDBusConnection *connection, g_variant_get(parameters, "(i&s)", &result, &address); _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_CONNECTED, result, &dev_address, event_info->cb, event_info->user_data); @@ -815,34 +1265,9 @@ void __bt_device_event_filter(GDBusConnection *connection, g_variant_get(parameters, "(i&s)", &result, &address); _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_DISCONNECTED, result, &dev_address, event_info->cb, event_info->user_data); -#else - if (strcasecmp(signal_name, BT_GATT_CONNECTED) == 0) { - const char *address = NULL; - bluetooth_device_address_t dev_address = { {0} }; - BT_DBG("BT_GATT_CONNECTED"); - g_variant_get(parameters, "(i&s)", &result, &address); - - _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); - _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CONNECTED, - result, &dev_address, - event_info->cb, event_info->user_data); - } else if (strcasecmp(signal_name, BT_GATT_DISCONNECTED) == 0) { - const char *address = NULL; - bluetooth_device_address_t dev_address = { {0} }; - BT_DBG("BT_GATT_DISCONNECTED"); - g_variant_get(parameters, "(i&s)", &result, &address); - - _bt_convert_addr_string_to_type(dev_address.addr, address); - BT_DBG("Sending Event to Framework"); - _bt_common_event_cb(BLUETOOTH_EVENT_GATT_DISCONNECTED, - result, &dev_address, - event_info->cb, event_info->user_data); -#endif } else if (strcasecmp(signal_name, BT_GATT_REQ_ATT_MTU_CHANGED) == 0) { const char *address = NULL; bluetooth_device_address_t dev_address = { {0} }; @@ -918,7 +1343,6 @@ void __bt_device_event_filter(GDBusConnection *connection, conn_info.addr_type = addr_type; conn_info.disc_reason = 0; - BT_DBG("Sending Event to Framework"); _bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_CONNECTED, result, &conn_info, event_info->cb, event_info->user_data); @@ -928,8 +1352,9 @@ void __bt_device_event_filter(GDBusConnection *connection, unsigned char addr_type; bt_connection_info_t conn_info; bluetooth_device_address_t dev_address = { {0} }; - BT_DBG("BT_DEVICE_DISCONNECTED"); - g_variant_get(parameters, "(i&sy)", &result, &address, &addr_type); + int rssi; + g_variant_get(parameters, "(i&syi)", &result, &address, &addr_type, &rssi); + BT_DBG("BT_DEVICE_DISCONNECTED reason(%d)", result); _bt_convert_addr_string_to_type(dev_address.addr, address); @@ -942,7 +1367,7 @@ void __bt_device_event_filter(GDBusConnection *connection, conn_info.addr_type = addr_type; conn_info.disc_reason = result; - BT_DBG("Sending Event to Framework"); + conn_info.rssi = rssi; _bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_DISCONNECTED, result, &conn_info, event_info->cb, event_info->user_data); @@ -953,7 +1378,7 @@ void __bt_device_event_filter(GDBusConnection *connection, int link_type; gboolean rssi_enabled = FALSE; - g_variant_get(parameters, "(isib)", &result, &address, + g_variant_get(parameters, "(i&sib)", &result, &address, &link_type, &rssi_enabled); BT_DBG("RSSI Enabled[Address:%s LinkType:%d RSSI_dbm:%d]", @@ -972,7 +1397,7 @@ void __bt_device_event_filter(GDBusConnection *connection, int link_type; bt_rssi_alert_t alert = { 0, }; - g_variant_get(parameters, "(isiii)", &result, &address, + g_variant_get(parameters, "(i&siii)", &result, &address, &link_type, &alert_type, &rssi_dbm); alert.alert_type = alert_type; @@ -990,7 +1415,7 @@ void __bt_device_event_filter(GDBusConnection *connection, char *address; bt_raw_rssi_t raw_rssi = { 0, }; - g_variant_get(parameters, "(isii)", &result, + g_variant_get(parameters, "(i&sii)", &result, &address, &link_type, &rssi_dbm); BT_DBG("Address [%s] Link Type[%d] dBm[%d]", @@ -1137,7 +1562,7 @@ void __bt_device_event_filter(GDBusConnection *connection, BT_DBG("BT_PXP_PROPERTY_CHANGED"); - g_variant_get(parameters, "(isiii)", &result, &address, &role, &type, &level); + g_variant_get(parameters, "(i&siii)", &result, &address, &role, &type, &level); _bt_convert_addr_string_to_type(dev_address.addr, address); memcpy(¶ms.device_address, &dev_address, BLUETOOTH_ADDRESS_LENGTH); @@ -1291,6 +1716,21 @@ void __bt_headset_event_filter(GDBusConnection *connection, _bt_headset_event_cb(BLUETOOTH_EVENT_AG_MIC_GAIN, result, &gain, event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_AUDIO_AVC_MODE_CHANGED) == 0) { + bool mode; + + g_variant_get(parameters, "(b)", &mode); + + _bt_headset_event_cb(BLUETOOTH_EVENT_AUDIO_AVC_STATUS, + result, &mode, + event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_MEDIA_VOLUME_CHANGE) == 0) { + unsigned int volume; + + g_variant_get(parameters, "(u)", &volume); + _bt_avrcp_event_cb(BLUETOOTH_EVENT_AVRCP_VOLUME_CHANGED, + result, &volume, + event_info->cb, event_info->user_data); } } @@ -2133,7 +2573,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection, GVariant* value = NULL; while (g_variant_iter_loop(res, "{sv}", &key, &value)) { char* string_value = NULL; - g_variant_get(value, "s", &string_value); + g_variant_get(value, "&s", &string_value); BT_DBG("got folder name: %s", string_value); folders_struct.names[i] = strdup(string_value); } @@ -2152,6 +2592,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection, } g_free(folders_struct.names); + g_variant_iter_free(iter); g_variant_unref(folder_list_var); } else if (strcasecmp(signal_name, BT_MAP_FILTER_FIELDS_COMPLETE) == 0) { @@ -2180,6 +2621,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection, fields_info.fields[i] = strdup(field); i++; } + g_variant_iter_free(iter); } _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE, @@ -2310,9 +2752,12 @@ void __bt_map_client_event_filter(GDBusConnection *connection, messages_struct.message_items[i].is_protected = value_bool ? 1 : 0; BT_DBG(" Protected: %s", value_bool ? "true" : "false"); } + + g_free(value_string); } ++i; } + g_variant_iter_free(iter); _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE, result, &messages_struct, @@ -3012,7 +3457,6 @@ static void __bt_tds_event_filter(GDBusConnection *connection, const char *address = NULL; char *data; int data_len = 0; - int k; GVariant *var = NULL; bluetooth_tds_transport_data_info_t *info = NULL; @@ -3021,13 +3465,6 @@ static void __bt_tds_event_filter(GDBusConnection *connection, data = (char *)g_variant_get_data(var); if (data) { - BT_DBG("Address [%s]", address); - BT_DBG("Data len [%d]", data_len); - - /* DEBUG */ - for (k = 0; k < data_len ; k++) - BT_DBG("Data[%d] [0x%x]", k, data[k]); - if (data_len == 0) { BT_ERR("No data"); g_variant_unref(var); @@ -3266,6 +3703,11 @@ static void __bt_otp_event_filter(GDBusConnection *connection, _bt_common_event_cb(BLUETOOTH_EVENT_OTC_STATE_CHANGED, result, otc_info, event_info->cb, event_info->user_data); + if (otc_info->address) + g_free(otc_info->address); + + if (otc_info) + g_free(otc_info); } BT_DBG("-"); @@ -3459,7 +3901,6 @@ static void __bt_event_data_free(void *data) g_free(cb_data); } -#ifdef TIZEN_GATT_CLIENT static void __bt_gatt_client_event_filter(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -3468,8 +3909,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { - BT_DBG("GATT Client event handler Entry >>"); - bt_event_info_t *event_info; int result = BLUETOOTH_ERROR_NONE; @@ -3478,7 +3917,7 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, if (strcasecmp(signal_name, BT_GATT_CHAR_VAL_CHANGED) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED */ - BT_INFO("GATT Client event[BT_GATT_CHAR_VAL_CHANGED]"); + BT_DBG("GATT Client event[BT_GATT_CHAR_VAL_CHANGED]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3487,7 +3926,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *char_uuid_var = NULL; int svc_uuid_len = 0; int char_uuid_len = 0; - unsigned int i; memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t)); @@ -3505,8 +3943,8 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, &data_var); g_strlcpy(char_prop.address, address, BT_ADDRESS_STRING_SIZE); - BT_INFO("GATT Client Char value changed in remote Server [%s]", address); - BT_INFO("GATT Client Char Val len: [%d]", char_prop.val_len); + BT_DBG("GATT Client Char value changed in remote Server [%s]", address); + BT_DBG("GATT Client Char Val len: [%d]", char_prop.val_len); if (char_prop.val_len > 0) { /* Copy Data */ @@ -3519,16 +3957,16 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, memcpy(&char_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16); char_prop.svc_prop.instance_id = svc_inst; - /* DEBUG */ - for (i = 0; i < char_prop.val_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); - _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED, result, &char_prop, event_info->cb, event_info->user_data); + + g_variant_unref(svc_uuid_var); + g_variant_unref(char_uuid_var); + g_variant_unref(data_var); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_READ_CHAR) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_READ_CHAR */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_READ_CHAR]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_READ_CHAR]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3537,7 +3975,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *char_uuid_var = NULL; int svc_uuid_len = 0; int char_uuid_len = 0; - unsigned int i; memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t)); @@ -3555,11 +3992,10 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, &data_var); g_strlcpy(char_prop.address, address, BT_ADDRESS_STRING_SIZE); - BT_INFO("GATT Client Read Callback from [%s] svc inst [%d] char val len [%d] char inst [%d]", + BT_DBG("GATT Client Read Callback from [%s] svc inst [%d] char val len [%d] char inst [%d]", address, svc_inst, char_prop.val_len, char_prop.prop.instance_id); if (char_prop.val_len > 0) { - BT_INFO("Get the read data"); /* Copy Data */ memcpy(&char_prop.value, g_variant_get_data(data_var), char_prop.val_len); } @@ -3570,16 +4006,16 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, memcpy(&char_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16); char_prop.svc_prop.instance_id = svc_inst; - /* DEBUG */ - for (i = 0; i < char_prop.val_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); - _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_READ_CHAR, result, &char_prop, event_info->cb, event_info->user_data); + + g_variant_unref(svc_uuid_var); + g_variant_unref(char_uuid_var); + g_variant_unref(data_var); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_WRITE_CHAR) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_WRITE_CHAR */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_WRITE_CHAR]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_WRITE_CHAR]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *svc_uuid_var = NULL; @@ -3615,9 +4051,12 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_WRITE_CHAR, result, &char_prop, event_info->cb, event_info->user_data); + + g_variant_unref(svc_uuid_var); + g_variant_unref(char_uuid_var); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_READ_DESC) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_READ_DESC */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_READ_DESC]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_READ_DESC]"); bt_gatt_char_descriptor_property_t desc_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3629,7 +4068,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, int svc_uuid_len = 0; int char_uuid_len = 0; int desc_uuid_len = 0; - unsigned int i; memset(&desc_prop, 0x00, sizeof(bt_gatt_char_descriptor_property_t)); @@ -3669,16 +4107,17 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, memcpy(&desc_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16); desc_prop.svc_prop.instance_id = svc_inst; - /* DEBUG */ - for (i = 0; i < desc_prop.val_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, desc_prop.value[i]); - _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_READ_DESC, result, &desc_prop, event_info->cb, event_info->user_data); + + g_variant_unref(svc_uuid_var); + g_variant_unref(char_uuid_var); + g_variant_unref(desc_uuid_var); + g_variant_unref(data_var); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_WRITE_DESC) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_WRITE_DESC */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_WRITE_DESC]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_WRITE_DESC]"); bt_gatt_char_descriptor_property_t desc_prop; const char *address = NULL; GVariant *svc_uuid_var = NULL; @@ -3708,8 +4147,8 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, g_strlcpy(desc_prop.address, address, BT_ADDRESS_STRING_SIZE); - BT_INFO("GATT Client Write Descriptor Callback from [%s]", address); - BT_INFO("GATT Client Descriptor Val len: [%d]", desc_prop.val_len); + BT_DBG("GATT Client Write Descriptor Callback from [%s]", address); + BT_DBG("GATT Client Descriptor Val len: [%d]", desc_prop.val_len); /* Copy Data */ memcpy(&desc_prop.prop.uuid, g_variant_get_data(desc_uuid_var), 16); @@ -3725,13 +4164,33 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_WRITE_DESC, result, &desc_prop, event_info->cb, event_info->user_data); - } - BT_DBG("GATT Client event handler Exit <<"); -} + g_variant_unref(svc_uuid_var); + g_variant_unref(char_uuid_var); + g_variant_unref(desc_uuid_var); + } else if (strcasecmp(signal_name, BT_GATT_CLIENT_SERVICE_CHANGED) == 0) { + bt_gatt_service_change_t change = {0, }; + char *address_str = NULL; + char *name = NULL; -#endif + g_variant_get(parameters, "(ii&s&s)", &change.inst_id, &change.change_type, &address_str, &change.uuid); + + _bt_convert_addr_string_to_type(change.device_addr.addr, address_str); + + if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr) == FALSE) { + BT_DBG("GATT Service changed, but no watcher for %s", address_str); + return; + } + + bluetooth_get_uuid_name(change.uuid, &name); + BT_INFO(" ### GATT Service %s [%s]", change.change_type ? "Added" : "Removed", name); + g_free(name); + _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED, + BLUETOOTH_ERROR_NONE, &change, + event_info->cb, event_info->user_data); + } +} #ifndef GATT_DIRECT static void __bt_gatt_server_event_filter(GDBusConnection *connection, @@ -3742,42 +4201,17 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { - BT_INFO("GATT Server event handler Entry >>"); + BT_DBG("Signal : %s", signal_name); bt_event_info_t *event_info; int result = BLUETOOTH_ERROR_NONE; event_info = (bt_event_info_t *)user_data; ret_if(event_info == NULL); -#ifdef TIZEN_GATT_CLIENT - if (strcasecmp(signal_name, BT_GATT_VALUE_CHANGED) == 0) { -#else - if (strcasecmp(signal_name, BT_GATT_CONNECTED) == 0) { - const char *address = NULL; - bluetooth_device_address_t dev_address = { {0} }; - BT_DBG("BT_GATT_CONNECTED"); - g_variant_get(parameters, "(i&s)", &result, &address); - _bt_convert_addr_string_to_type(dev_address.addr, address); - _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_CONNECTED, - result, &dev_address, - event_info->cb, event_info->user_data); - } else if (strcasecmp(signal_name, BT_GATT_DISCONNECTED) == 0) { - const char *address = NULL; - bluetooth_device_address_t dev_address = { {0} }; - BT_DBG("BT_GATT_DISCONNECTED"); - g_variant_get(parameters, "(i&s)", &result, &address); - - _bt_convert_addr_string_to_type(dev_address.addr, address); - _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_DISCONNECTED, - result, &dev_address, - event_info->cb, event_info->user_data); - } else if (strcasecmp(signal_name, BT_GATT_VALUE_CHANGED) == 0) { -#endif - BT_INFO("GATT Server event[BT_GATT_SERVER_WRITE_REQUESTED]"); + if (strcasecmp(signal_name, BT_GATT_VALUE_CHANGED) == 0) { const char *address = NULL; GVariant *data_var = NULL; - int i; bluetooth_device_address_t dev_address = { {0} }; bluetooth_gatt_server_write_requested_info_t write_info; @@ -3816,13 +4250,11 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection, dev_address.addr, BLUETOOTH_ADDRESS_LENGTH); - /* DEBUG */ - for (i = 0; i < write_info.length; i++) - BT_DBG("Data[%d] = [0x%x]", i, write_info.data.data[i]); - _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED, BLUETOOTH_ERROR_NONE, &write_info, event_info->cb, event_info->user_data); + + g_variant_unref(data_var); } else if (strcasecmp(signal_name, BT_GATT_SERVER_READ_REQ) == 0) { const char *address = NULL; bluetooth_device_address_t dev_address = { {0} }; @@ -3884,7 +4316,7 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection, bluetooth_gatt_server_notification_changed_t info; memset(&info, 0x00, sizeof(bluetooth_gatt_server_notification_changed_t)); - BT_INFO("GATT Server event[BT_GATT_SERVER_NOTIFICATION_COMPLETED]"); + BT_INFO("GATT Server event[BT_GATT_SERVER_NOTIFICATION_CHANGED]"); /* Extract data from DBUS params */ g_variant_get(parameters, "(i&sib)", &result, &address, &info.handle, &info.notification); @@ -3904,9 +4336,30 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection, _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, result, &info, event_info->cb, event_info->user_data); + } else if (strcasecmp(signal_name, BT_GATT_SERVER_ATT_MTU_CHANGED) == 0) { + const char *address = NULL; + bluetooth_device_address_t dev_address = { {0} }; + bluetooth_le_att_mtu_info_t att_mtu_info; + guint16 mtu; + guint8 status; + BT_DBG("BT_GATT_SERVER_ATT_MTU_CHANGED"); + g_variant_get(parameters, "(i&sqy)", &result, &address, &mtu, &status); + + _bt_convert_addr_string_to_type(dev_address.addr, address); + + memset(&att_mtu_info, 0x00, sizeof(bluetooth_le_att_mtu_info_t)); + memcpy(att_mtu_info.device_address.addr, + dev_address.addr, + BLUETOOTH_ADDRESS_LENGTH); + + att_mtu_info.mtu = mtu; + att_mtu_info.status = status; + + _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_ATT_MTU_CHANGED, + result, &att_mtu_info, + event_info->cb, event_info->user_data); } - BT_INFO("GATT Server event handler Exit <<"); } #endif @@ -3918,8 +4371,17 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) const char *path; const char *interface = BT_EVENT_SERVICE; - if (is_initialized == FALSE) - _bt_init_event_handler(); + if (is_initialized == FALSE) { + int ret; + + ret = _bt_init_event_handler(); + + if (ret != BLUETOOTH_ERROR_NONE && + ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) { + BT_ERR("Fail to init the event handler"); + return ret; + } + } if (__bt_event_is_registered(event_type) == TRUE) { BT_ERR("The event is already registed"); @@ -3984,41 +4446,34 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) path = BT_RFCOMM_SERVER_PATH; break; case BT_HF_AGENT_EVENT: - BT_DBG("BT_HF_AGENT_EVENT\n"); event_func = __bt_hf_agent_event_filter; path = BT_HF_AGENT_PATH; interface = BT_HF_SERVICE_INTERFACE; break; case BT_A2DP_SOURCE_EVENT: - BT_DBG("BT_A2DP_SOURCE_EVENT"); event_func = __bt_a2dp_source_event_filter; path = BT_A2DP_SOURCE_PATH; break; case BT_HID_DEVICE_EVENT: - BT_DBG("BT_HID_DEVICE_EVENT"); event_func = __bt_hid_device_event_filter; path = BT_HID_DEVICE_PATH; break; #ifdef GATT_NO_RELAY case BT_GATT_BLUEZ_EVENT: - BT_DBG("BT_GATT_BLUEZ_EVENT"); event_func = __bt_device_event_filter; interface = BT_GATT_CHARACTERISTIC_INTERFACE; path = NULL; break; #endif case BT_TDS_EVENT: - BT_DBG("BT_TDS_EVENT"); event_func = __bt_tds_event_filter; path = BT_TDS_PATH; break; case BT_OTP_EVENT: - BT_DBG("BT_OTP_EVENT"); event_func = __bt_otp_event_filter; path = BT_OTP_PATH; break; case BT_HDP_EVENT: - BT_DBG("BT_HDP_EVENT"); event_func = __bt_hdp_event_filter; path = BT_HDP_DEVICE_PATH; break; @@ -4028,19 +4483,20 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) path = BT_GATT_SERVER_PATH; break; #endif - -#ifdef TIZEN_GATT_CLIENT case BT_GATT_CLIENT_EVENT: event_func = __bt_gatt_client_event_filter; path = BT_GATT_CLIENT_PATH; break; -#endif + case BT_MESH_EVENT: + event_func = __bt_mesh_event_filter; + path = BT_MESH_PATH; + break; default: BT_ERR("Unknown event"); return BLUETOOTH_ERROR_INTERNAL; } - connection_type = _bt_get_system_private_conn(); + connection_type = _bt_get_system_common_conn(); if (connection_type == NULL) return BLUETOOTH_ERROR_INTERNAL; @@ -4081,7 +4537,7 @@ int _bt_unregister_event(int event_type) return BLUETOOTH_ERROR_INTERNAL; } - connection_type = _bt_get_system_private_conn(); + connection_type = _bt_get_system_common_conn(); event_list = g_slist_remove(event_list, (void *)cb_data); @@ -4129,13 +4585,13 @@ void _bt_register_name_owner_changed(void) { GDBusConnection *connection_type; - connection_type = _bt_get_system_private_conn(); + connection_type = _bt_get_system_common_conn(); if (connection_type == NULL) { BT_ERR("Unable to get the bus"); return; } owner_sig_id = g_dbus_connection_signal_subscribe(connection_type, - NULL, BT_EVENT_FREEDESKTOP, + BT_DBUS_NAME, BT_EVENT_FREEDESKTOP, BT_NAME_OWNER_CHANGED, NULL, NULL, 0, __bt_name_owner_changed, NULL, NULL); } @@ -4144,7 +4600,7 @@ void _bt_unregister_name_owner_changed(void) { GDBusConnection *connection_type; - connection_type = _bt_get_system_private_conn(); + connection_type = _bt_get_system_common_conn(); if (connection_type != NULL && owner_sig_id > 0) { g_dbus_connection_signal_unsubscribe(connection_type, owner_sig_id); @@ -4160,7 +4616,7 @@ static void __bt_gatt_get_uuid_from_path(char *path, char **service_uuid) GVariant *ret = NULL; GVariant *value = NULL; - g_conn = _bt_get_system_private_conn(); + g_conn = _bt_get_system_common_conn(); ret_if(g_conn == NULL); proxy = g_dbus_proxy_new_sync(g_conn, @@ -4282,7 +4738,7 @@ int _bt_register_manager_subscribe_signal(gboolean subscribe) static guint service_added_id = 0; static guint interface_removed_id = 0; - g_conn = _bt_get_system_private_conn(); + g_conn = _bt_get_system_common_conn(); if (g_conn == NULL) return BLUETOOTH_ERROR_INTERNAL;