*/
#include <string.h>
-#include <dbus/dbus.h>
#include <glib.h>
#include <dlog.h>
#include <vconf.h>
#include "bt-internal-types.h"
#include "bluetooth-media-control.h"
+#ifndef GATT_DIRECT
+#include "bluetooth-gatt-server-api.h"
+#endif
+
#include "bt-common.h"
#include "bt-event-handler.h"
#include "bt-gatt-client.h"
#include "bt-request-sender.h"
+#include "bt-gatt-server.h"
#define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
#define BT_RELIABLE_DISABLE_TIME 300 /* 300 ms */
static int obex_server_id;
static guint disable_timer_id;
static gboolean is_initialized;
-static GSList *sending_list = NULL;
-static GSList *server_list = NULL;
-static GSList *event_list = NULL;
-static int owner_sig_id = -1;
+static GSList *sending_list;
+static GSList *server_list;
+static GSList *event_list;
+static guint owner_sig_id;
void _bt_add_push_request_id(int request_id)
{
if (info == NULL)
continue;
+ BT_DBG("compare %d with %d", info->request_id, request_id);
if (info->request_id == request_id)
return TRUE;
}
}
handle = (bt_hf_call_list_s *)list;
call_status = g_malloc0(sizeof(bt_hf_call_status_info_t));
- /* Fix : NULL_RETURNS */
- retv_if(call_status == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
call_status->number = g_strdup(number);
call_status->direction = dir;
call_status->status = status;
GVariant *manufacturer_var = NULL;
const char *manufacturer_data = NULL;
- g_variant_get(parameters, "(isunsbub@asn@ay)", &result, &address,
+ g_variant_get(parameters, "(i&sun&sbub@asn@ay)", &result, &address,
&dev_class, &rssi, &name, &paired,
&connected, &trust, &string_var, &manufacturer_data_len, &manufacturer_var);
manufacturer_data = (char *)g_variant_get_data(manufacturer_var);
dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
- /* Fix : NULL_RETURNS */
- if (dev_info == NULL) {
- result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto done;
- }
-
dev_info->rssi = rssi;
dev_info->paired = paired;
dev_info->connected = connected;
if (manufacturer_data)
for (i = 0; i < manufacturer_data_len; i++)
dev_info->manufacturer_data.data[i] = manufacturer_data[i];
-done:
*ret = result;
g_free(uuids);
g_variant_unref(string_var);
scan_data = (char *)g_variant_get_data(scan_var);
le_dev_info = g_malloc0(sizeof(bluetooth_le_device_info_t));
- /* Fix : NULL_RETURNS */
- if (le_dev_info == NULL) {
- result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto done;
- }
_bt_convert_addr_string_to_type(le_dev_info->device_address.addr, address);
le_dev_info->addr_type = addr_type;
le_dev_info->rssi = rssi;
if (scan_data)
le_dev_info->scan_resp_data.data.data[i] = scan_data[i];
-done:
*ret = result;
-
g_variant_unref(adv_var);
g_variant_unref(scan_var);
return le_dev_info;
}
-static bluetooth_ibeacon_device_info_t *__bt_get_ibeacon_device_info_in_message(GVariant *parameters, int *ret)
-{
- bluetooth_ibeacon_device_info_t *ibeacon_dev_info = NULL;
- const char *address = NULL;
- short addr_type = 0;
- int company_id = 0;
- int ibeacon_type = 0;
- int major_id = 0;
- int minor_id = 0;
- int measured_power = 0;
- const char *uuid = NULL;
- int result = BLUETOOTH_ERROR_NONE;
-
- g_variant_get(parameters, "(i&snnn&snnn)", &result, &address,
- &addr_type, &company_id, &ibeacon_type, &uuid, &major_id, &minor_id, &measured_power);
- ibeacon_dev_info = g_malloc0(sizeof(bluetooth_ibeacon_device_info_t));
- if (ibeacon_dev_info == NULL) {
- result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto done;
- }
-
- _bt_convert_addr_string_to_type(ibeacon_dev_info->device_address.addr, address);
- ibeacon_dev_info->addr_type = addr_type;
- ibeacon_dev_info->company_id = company_id;
- ibeacon_dev_info->ibeacon_type = ibeacon_type;
- ibeacon_dev_info->major_id = major_id;
- ibeacon_dev_info->minor_id = minor_id;
- ibeacon_dev_info->measured_power = measured_power;
- ibeacon_dev_info->uuid_len = strlen(uuid);
- memcpy(ibeacon_dev_info->uuid, uuid, ibeacon_dev_info->uuid_len);
-done:
-
- *ret = result;
-
- return ibeacon_dev_info;
-}
-
gboolean __bt_reliable_disable_cb(gpointer user_data)
{
BT_DBG("+");
obex_server_id = BT_NO_SERVER;
__bt_remove_all_server();
__bt_remove_all_push_request_id();
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
_bt_rfcomm_server_free_all();
#endif
- _bluetooth_hid_free_hid_info();
+ _bt_hid_free_hid_info();
BT_DBG("-");
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);
+
+ }
+}
+
void __bt_adapter_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
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->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;
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,
} 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,
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,
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,
}
g_free(le_device_info);
- } else if (strcasecmp(signal_name, BT_IBEACON_DEVICE_FOUND) == 0) {
- bluetooth_ibeacon_device_info_t *ibeacon_device_info;
- BT_DBG("BT_IBEACON_DEVICE_FOUND");
- ibeacon_device_info = __bt_get_ibeacon_device_info_in_message(parameters,
- &result);
- ret_if(ibeacon_device_info == NULL);
-
- _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND,
- result, ibeacon_device_info,
- event_info->cb, event_info->user_data);
-
- g_free(ibeacon_device_info);
}
}
#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} };
+ BT_DBG("BT_GATT_SERVER_CONNECTED");
+ g_variant_get(parameters, "(i&s)", &result, &address);
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_CONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ BT_DBG("BT_GATT_SERVER_DISCONNECTED");
+ g_variant_get(parameters, "(i&s)", &result, &address);
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_CLIENT_CONNECTED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ BT_DBG("BT_GATT_CLIENT_CONNECTED");
+ g_variant_get(parameters, "(i&s)", &result, &address);
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_CONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_CLIENT_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ BT_DBG("BT_GATT_CLIENT_DISCONNECTED");
+ g_variant_get(parameters, "(i&s)", &result, &address);
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ _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} };
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);
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} };
guint8 status;
BT_DBG("BT_GATT_REQ_ATT_MTU_CHANGED");
g_variant_get(parameters, "(i&sqy)", &result, &address, &mtu, &status);
+ BT_DBG("Result [%d] Address [%s] MTU [%d] status [%d]", result, address, mtu, status);
_bt_convert_addr_string_to_type(dev_address.addr, address);
/* Fix : FORWARD_NULL : g_variant_get_data can return NULL */
if (char_val.val_len > 0 && value != NULL) {
char_val.char_value = (unsigned char*) g_malloc0(char_val.val_len);
- /* Fix : NULL_RETURNS */
- if (char_val.char_value == NULL) {
- BT_ERR("BLUETOOTH_ERROR_OUT_OF_MEMORY");
- g_free(char_val.char_handle);
- g_variant_unref(char_value_var);
- return;
- }
memcpy(char_val.char_value, value, len);
_bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
result, &char_val,
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);
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);
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);
BT_DBG("BT_LE_DATA_LENGTH_CHANGED");
g_variant_get(parameters, "(i&sqqqq)", &result, &address,
- tx_octets, tx_time, rx_octets, rx_time);
+ &tx_octets, &tx_time, &rx_octets, &rx_time);
params.max_tx_octets = tx_octets;
params.max_tx_time = tx_time;
_bt_common_event_cb(BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED,
result, ¶ms, event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_PXP_PROPERTY_CHANGED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ int role, type, level;
+ bt_pxp_property_changed_params_t params;
+
+ BT_DBG("BT_PXP_PROPERTY_CHANGED");
+
+ g_variant_get(parameters, "(isiii)", &result, &address, &role, &type, &level);
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ memcpy(¶ms.device_address, &dev_address, BLUETOOTH_ADDRESS_LENGTH);
+ params.role = role;
+ params.service_type = type;
+ params.alert_lvl = level;
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED,
+ result, ¶ms, event_info->cb, event_info->user_data);
}
}
address);
int ctrl = -1, intr = -1;
_bt_hid_device_get_fd(address, &ctrl, &intr);
- if (ctrl != -1 && intr != -1) {
- new_hid_connection(NULL, ctrl, &dev_address);
- new_hid_connection(NULL, intr, &dev_address);
- }
+ if (ctrl != -1 && intr != -1)
+ _bt_hid_new_connection(&dev_address, ctrl, intr);
+ else
+ BT_ERR("fd is invalid.(ctrl=%d, intr=%d)", ctrl, intr);
} else if (strcasecmp(signal_name, BT_INPUT_HID_DEVICE_DISCONNECTED) == 0) {
const char *address = NULL;
g_variant_get(parameters, "(i&s)", &result, &address);
_bt_avrcp_event_cb(BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS,
result, &status,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_MEDIA_DELAY_CHANGE) == 0) {
+ unsigned int delay;
+
+ g_variant_get(parameters, "(u)", &delay);
+ _bt_avrcp_event_cb(BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED,
+ result, &delay,
+ event_info->cb, event_info->user_data);
}
}
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_MEDIA_TRACK_CHANGE) == 0) {
media_metadata_attributes_t metadata;
- const char *title;
- const char *artist;
- const char *album;
- const char *genre;
+ GVariant *title = NULL;
+ GVariant *artist = NULL;
+ GVariant *album = NULL;
+ GVariant *genre = NULL;
+
unsigned int total_tracks;
unsigned int number;
unsigned int duration;
- g_variant_get(parameters, "(&s&s&s&suuu)", &title,
- &artist, &album, &genre,
- &total_tracks, &number,
- &duration);
- memset(&metadata, 0x00, sizeof(media_metadata_attributes_t));
+ g_variant_get(parameters, "(@ay@ay@ay@ayuuu)",
+ &title, &artist, &album, &genre,
+ &total_tracks, &number, &duration);
- metadata.title = title;
- metadata.artist = artist;
- metadata.album = album;
- metadata.genre = genre;
+ metadata.title = g_variant_get_bytestring(title);
+ metadata.artist = g_variant_get_bytestring(artist);
+ metadata.album = g_variant_get_bytestring(album);
+ metadata.genre = g_variant_get_bytestring(genre);
metadata.total_tracks = total_tracks;
metadata.number = number;
- metadata.duration = (int64_t)duration;
+ metadata.duration = duration;
_bt_avrcp_event_cb(BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED,
result, &metadata,
event_info->cb, event_info->user_data);
+
+ g_variant_unref(title);
+ g_variant_unref(artist);
+ g_variant_unref(album);
+ g_variant_unref(genre);
}
}
result, &dev_address,
event_info->cb, event_info->user_data);
- if (result != BLUETOOTH_ERROR_NONE) {
+ if (result != BLUETOOTH_ERROR_NONE)
__bt_remove_push_request_id(request_id);
- }
+
} else if (strcasecmp(signal_name, BT_OPP_DISCONNECTED) == 0) {
const char *address = NULL;
int request_id = 0;
}
}
+void __bt_map_client_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_DBG("Entered __bt_map_client_event_filter");
+ bt_event_info_t *event_info;
+ int result = BLUETOOTH_ERROR_NONE;
+ event_info = (bt_event_info_t *)user_data;
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(object_path, BT_MAP_CLIENT_PATH) != 0)
+ return;
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ if (strcasecmp(signal_name, BT_MAP_CONNECTED) == 0) {
+ const char *address = NULL;
+ int request_id = 0;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ g_variant_get(parameters, "(i&si)", &result,
+ &address, &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_CONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ __bt_remove_push_request_id(request_id);
+ } else if (strcasecmp(signal_name, BT_MAP_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ int request_id = 0;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ g_variant_get(parameters, "(i&si)", &result, &address,
+ &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_DISCONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+ } else if (strcasecmp(signal_name, BT_MAP_LIST_FOLDERS_COMPLETE) == 0) {
+ int request_id = 0;
+ GVariant* folder_list_var = NULL;
+
+ g_variant_get(parameters, "(iiv)", &result, &request_id, &folder_list_var);
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ GVariantIter* iter;
+
+ bt_map_client_folders_s folders_struct = {0,};
+ g_variant_get(folder_list_var, "(aa{sv})", &iter);
+
+ folders_struct.size = g_variant_iter_n_children(iter);
+ folders_struct.names = (char**) g_malloc0(folders_struct.size * sizeof(*(folders_struct.names)));
+ BT_DBG("g_variant_iter_n_children: %lli", (long long int)folders_struct.size);
+ GVariantIter* res = NULL;
+ int i = 0;
+ while (g_variant_iter_loop(iter, "a{sv}", &res)) {
+ char* key = NULL;
+ GVariant* value = NULL;
+ while (g_variant_iter_loop(res, "{sv}", &key, &value)) {
+ char* string_value = NULL;
+ g_variant_get(value, "s", &string_value);
+ BT_DBG("got folder name: %s", string_value);
+ folders_struct.names[i] = strdup(string_value);
+ }
+ ++i;
+ }
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE,
+ result, &folders_struct,
+ event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+
+ // freeing resources
+ while (--i >= 0) {
+ free(folders_struct.names[i]);
+ folders_struct.names[i] = NULL;
+ }
+ g_free(folders_struct.names);
+
+ g_variant_unref(folder_list_var);
+
+ } else if (strcasecmp(signal_name, BT_MAP_FILTER_FIELDS_COMPLETE) == 0) {
+ BT_DBG("BT_MAP_LIST_FOLDERS_COMPLETE");
+
+ GVariant *value;
+ int request_id = 0;
+ int i = 0;
+ bt_map_list_filter_fields_info_t fields_info = {0,};
+
+ g_variant_get(parameters, "(ivi)", &result, &value, &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ if (value) {
+ GVariantIter *iter = NULL;
+ g_variant_get(value, "(as)", &iter);
+ fields_info.size = g_variant_iter_n_children(iter);
+ char* field = NULL;
+
+ fields_info.fields = g_malloc0(fields_info.size * sizeof(char*));
+ while (g_variant_iter_loop(iter, "s", &field)) {
+ fields_info.fields[i] = strdup(field);
+ i++;
+ }
+ }
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
+ request_id, &fields_info,
+ event_info->cb, event_info->user_data);
+
+ while (--i >= 0) {
+ free(fields_info.fields[i]);
+ fields_info.fields[i] = NULL;
+ }
+ g_free(fields_info.fields);
+
+ __bt_remove_push_request_id(request_id);
+ g_variant_unref(value);
+ } else if (strcasecmp(signal_name, BT_MAP_LIST_MESSAGES_COMPLETE) == 0) {
+ int request_id = 0;
+ GVariant* messages_list_var = NULL;
+ g_variant_get(parameters, "(iiv)", &result, &request_id, &messages_list_var);
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ bt_map_client_message_items_s messages_struct = {0,};
+
+ GVariantIter* iter;
+ g_variant_get(messages_list_var, "(a{oa{sv}})", &iter);
+ messages_struct.size = g_variant_iter_n_children(iter);
+ messages_struct.message_items = (bt_map_client_message_item_t*)
+ g_malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
+ BT_DBG("g_variant_iter_n_children: %lli", (long long int)messages_struct.size);
+
+ char *object = NULL;
+ GVariantIter *properites = NULL;
+ int i = 0;
+ while (g_variant_iter_loop(iter, "{oa{sv}}", &object, &properites)) {
+ messages_struct.message_items[i].message_object = strdup(object);
+ BT_DBG("Message found: %s", messages_struct.message_items[i].message_object);
+ messages_struct.message_items[i].folder = NULL;
+ messages_struct.message_items[i].subject = NULL;
+ messages_struct.message_items[i].timestamp = NULL;
+ messages_struct.message_items[i].sender = NULL;
+ messages_struct.message_items[i].sender_address = NULL;
+ messages_struct.message_items[i].reply_to = NULL;
+ messages_struct.message_items[i].recipient = NULL;
+ messages_struct.message_items[i].recipient_address = NULL;
+ messages_struct.message_items[i].type = NULL;
+ messages_struct.message_items[i].size = -1;
+ messages_struct.message_items[i].is_text = -1;
+ messages_struct.message_items[i].status = NULL;
+ messages_struct.message_items[i].attachment_size = -1;
+ messages_struct.message_items[i].is_priority = -1;
+ messages_struct.message_items[i].is_read = -1;
+ messages_struct.message_items[i].is_sent = -1;
+ messages_struct.message_items[i].is_protected = -1;
+ char *key = NULL;
+ GVariant *value = NULL;
+ while (g_variant_iter_loop(properites, "{sv}", &key, &value)) {
+ char *value_string = NULL;
+ uint64_t value_int = -1;
+ bool value_bool = false;
+ if (strcmp(key, "Folder") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].folder = strdup(value_string);
+ BT_DBG(" Folder: %s", value_string);
+ } else if (strcmp(key, "Subject") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].subject = strdup(value_string);
+ BT_DBG(" Subject: %s", value_string);
+ } else if (strcmp(key, "Timestamp") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].timestamp = strdup(value_string);
+ BT_DBG(" Timestamp: %s", value_string);
+ } else if (strcmp(key, "Sender") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].sender = strdup(value_string);
+ BT_DBG(" Sender: %s", value_string);
+ } else if (strcmp(key, "SenderAddress") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].sender_address = strdup(value_string);
+ BT_DBG(" SenderAddress: %s", value_string);
+ } else if (strcmp(key, "ReplyTo") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].reply_to = strdup(value_string);
+ BT_DBG(" ReplyTo: %s", value_string);
+ } else if (strcmp(key, "Recipient") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].recipient = strdup(value_string);
+ BT_DBG(" Recipient: %s", value_string);
+ } else if (strcmp(key, "RecipientAddress") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].recipient_address = strdup(value_string);
+ BT_DBG(" RecipientAddress: %s", value_string);
+ } else if (strcmp(key, "Type") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].type = strdup(value_string);
+ BT_DBG(" Type: %s", value_string);
+ } else if (strcmp(key, "Size") == 0) {
+ g_variant_get(value, "t", &value_int);
+ messages_struct.message_items[i].size = value_int;
+ BT_DBG(" Size: %llu", (unsigned long long int)value_int);
+ } else if (strcmp(key, "Text") == 0) {
+ g_variant_get(value, "b", &value_bool);
+ messages_struct.message_items[i].is_text = value_bool ? 1 : 0;
+ BT_DBG(" Text: %s", value_bool ? "true" : "false");
+ } else if (strcmp(key, "Status") == 0) {
+ g_variant_get(value, "s", &value_string);
+ messages_struct.message_items[i].status = strdup(value_string);
+ BT_DBG(" Status: %s", value_string);
+ } else if (strcmp(key, "AttachmentSize") == 0) {
+ g_variant_get(value, "t", &value_int);
+ messages_struct.message_items[i].attachment_size = value_int;
+ BT_DBG(" AttachmentSize: %llu", (unsigned long long int)value_int);
+ } else if (strcmp(key, "Priority") == 0) {
+ g_variant_get(value, "b", &value_bool);
+ messages_struct.message_items[i].is_priority = value_bool ? 1 : 0;
+ BT_DBG(" Priority: %s", value_bool ? "true" : "false");
+ } else if (strcmp(key, "Read") == 0) {
+ g_variant_get(value, "b", &value_bool);
+ messages_struct.message_items[i].is_read = value_bool ? 1 : 0;
+ BT_DBG(" Read: %s", value_bool ? "true" : "false");
+ } else if (strcmp(key, "Sent") == 0) {
+ g_variant_get(value, "b", &value_bool);
+ messages_struct.message_items[i].is_sent = value_bool ? 1 : 0;
+ BT_DBG(" Sent: %s", value_bool ? "true" : "false");
+ } else if (strcmp(key, "Protected") == 0) {
+ g_variant_get(value, "b", &value_bool);
+ messages_struct.message_items[i].is_protected = value_bool ? 1 : 0;
+ BT_DBG(" Protected: %s", value_bool ? "true" : "false");
+ }
+ }
+ ++i;
+ }
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE,
+ result, &messages_struct,
+ event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+
+ while (--i >= 0) {
+ free(messages_struct.message_items[i].folder);
+ free(messages_struct.message_items[i].subject);
+ free(messages_struct.message_items[i].timestamp);
+ free(messages_struct.message_items[i].sender);
+ free(messages_struct.message_items[i].sender_address);
+ free(messages_struct.message_items[i].reply_to);
+ free(messages_struct.message_items[i].recipient);
+ free(messages_struct.message_items[i].recipient_address);
+ free(messages_struct.message_items[i].type);
+ free(messages_struct.message_items[i].status);
+ }
+ g_free(messages_struct.message_items);
+
+ g_variant_unref(messages_list_var);
+ } else if (strcasecmp(signal_name, BT_MAP_GET_MESSAGE_COMPLETE) == 0) {
+ BT_DBG("BT_MAP_GET_MESSAGE_COMPLETE");
+ int request_id = 0;
+
+ g_variant_get(parameters, "(ii)", &result, &request_id);
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ // currently there is no result value passed from here, just passing NULL
+ void* some_result_value = NULL;
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_GET_MESSAGE_COMPLETE,
+ result, some_result_value, event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+ } else if (strcasecmp(signal_name, BT_MAP_PUSH_MESSAGE_COMPLETE) == 0) {
+ BT_DBG("BT_MAP_PUSH_MESSAGE_COMPLETE");
+ int request_id = 0;
+
+ g_variant_get(parameters, "(ii)", &result, &request_id);
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ // currently there is no result value passed from here, just passing NULL
+ void* some_result_value = NULL;
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_COMPLETE,
+ result, some_result_value, event_info->cb, event_info->user_data);
+
+ __bt_remove_push_request_id(request_id);
+ }
+
+}
+
void __bt_pbap_client_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
for (i = 0; i < count; i++)
BT_DBG("%s", list[i]);
- BT_DBG("address: %s, result: %d, count: %d, success: %d",
+ BT_DBG("address: %s, result: %d, count: %zd, success: %d",
address, result, count, success);
_bt_convert_addr_string_to_type(vc_list.btaddr.addr,
bluetooth_rfcomm_connection_request_t req_ind;
char *address = NULL;
char *uuid = NULL;
+ int socket_fd = 0;
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
char *name = NULL;
char *path = NULL;
- int socket_fd = 0;
g_variant_get(parameters, "(i&s&s&s&sn)", &result, &address,
&uuid, &name, &path, &socket_fd);
if (_check_uuid_path(path, uuid) == FALSE)
return;
+#else
+ gboolean auto_accept = FALSE;
+
+ g_variant_get(parameters, "(i&s&s)", &result, &address, &uuid);
+ socket_fd = _get_rfcomm_server_id(uuid, &auto_accept);
+ if (0 > socket_fd)
+ return;
+ _bt_rfcomm_server_set_pending_conn(socket_fd, address);
+ if (auto_accept) {
+ bluetooth_rfcomm_accept_connection(socket_fd);
+ return;
+ }
+#endif
memset(&req_ind, 0x00, sizeof(bluetooth_rfcomm_connection_request_t));
_bt_convert_addr_string_to_type(req_ind.device_addr.addr,
address);
GVariant *parameters,
gpointer user_data)
{
- BT_DBG("+\n");
+ BT_DBG("+");
bt_event_info_t *event_info;
int result = BLUETOOTH_ERROR_NONE;
event_info = (bt_event_info_t *)user_data;
ret_if(event_info == NULL);
- BT_DBG("+\n");
if (strcasecmp(object_path, BT_HF_AGENT_PATH) != 0)
return;
if (strcasecmp(interface_name, BT_HF_SERVICE_INTERFACE) != 0)
if (strcasecmp(signal_name, "Connected") == 0) {
char *address = NULL;
- g_variant_get(parameters, "(s)", &address);
+ g_variant_get(parameters, "(&s)", &address);
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CONNECTED,
result, address,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, "Disconnected") == 0) {
char *address = NULL;
- g_variant_get(parameters, "(s)", &address);
+ g_variant_get(parameters, "(&s)", &address);
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_DISCONNECTED,
result, address,
event_info->cb, event_info->user_data);
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CIEV_DEVICE_STATUS_CHANGED,
result, &dev_event,
event_info->cb, event_info->user_data);
- } else if (strcasecmp(property, "SignalStrength") == 0) {
+ } else if (strcasecmp(property, "SignalStrength") == 0) {
dev_event.event = BLUETOOTH_HF_CIEV_SIGNAL;
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CIEV_DEVICE_STATUS_CHANGED,
result, &dev_event,
event_info->cb, event_info->user_data);
- } else if (strcasecmp(property, "RegistrationStatus") == 0) {
+ } else if (strcasecmp(property, "RegistrationStatus") == 0) {
dev_event.event = BLUETOOTH_HF_CIEV_SERVICE;
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CIEV_DEVICE_STATUS_CHANGED,
result, &dev_event,
event_info->cb, event_info->user_data);
}
}
- BT_DBG("-\n");
+ BT_DBG("-");
}
-static void __bt_remove_all_events(void)
+static void __bt_tds_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_event_info_t *info;
+ bt_event_info_t *event_info;
+ event_info = (bt_event_info_t *)user_data;
+ int result = BLUETOOTH_ERROR_NONE;
- while ((info = g_slist_nth_data(event_list, 0)) != NULL) {
- _bt_unregister_event(info->event_type);
- }
+ ret_if(event_info == NULL);
- if (event_list) {
+ if (strcasecmp(object_path, BT_TDS_PATH) != 0)
+ return;
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ BT_DBG("+");
+
+ if (strcasecmp(signal_name, BT_TDS_ACTIVATION_REQUESTED) == 0) {
+ bluetooth_tds_activation_req_t act_req;
+ const char *address = NULL;
+ char *buffer = NULL;
+ int transport = 0;
+ GVariant *byte_var;
+
+ g_variant_get(parameters, "(&si@ay)", &address,
+ &transport, &byte_var);
+
+ memset(&act_req, 0x00, sizeof(bluetooth_tds_activation_req_t));
+
+ act_req.transport = transport;
+
+ act_req.tds_data.length = g_variant_get_size(byte_var);
+ if (act_req.tds_data.length > BLUETOOTH_TDS_DATA_LENGTH_MAX) {
+ BT_INFO("tds data length > BLUETOOTH_TDS_DATA_LENGTH_MAX");
+ act_req.tds_data.length = BLUETOOTH_TDS_DATA_LENGTH_MAX;
+ }
+ buffer = (char *) g_variant_get_data(byte_var);
+ memcpy(act_req.tds_data.data, buffer, act_req.tds_data.length);
+ g_variant_unref(byte_var);
+
+ _bt_convert_addr_string_to_type(act_req.rem_addr.addr, address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_TDS_ACTIVATION_REQUESTED,
+ BLUETOOTH_ERROR_NONE, &act_req,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_TDS_TRANSPORT_DATA_RECEIVED) == 0) {
+ BT_DBG("TDS Complete Block Data received");
+ const char *address = NULL;
+ char *data;
+ int data_len = 0;
+ GVariant *var = NULL;
+ bluetooth_tds_transport_data_info_t *info = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ay)", &result, &address, &data_len, &var);
+ data = (char *)g_variant_get_data(var);
+
+ if (data) {
+ if (data_len == 0) {
+ BT_ERR("No data");
+ g_variant_unref(var);
+ return;
+ }
+
+ info = g_malloc0(sizeof(bluetooth_tds_transport_data_info_t));
+ info->data_length = data_len;
+ info->data = g_memdup(data, data_len);
+
+ _bt_convert_addr_string_to_type(info->device_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_TDS_TRANSPORT_DATA_RECEIVED,
+ result, info,
+ event_info->cb, event_info->user_data);
+
+ if (info->data) {
+ g_free(info->data);
+ g_free(info);
+ }
+ }
+ g_variant_unref(var);
+ } else if (strcasecmp(signal_name, BT_TDS_ACTIVATION_RESULT) == 0) {
+ BT_DBG("TDS Control point Activation result");
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &address);
+ BT_DBG("Address [%s]", address);
+ BT_DBG("Result [%d]", result);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_TDS_ACTIVATION_RESULT,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_TDS_ACTIVATION_INDICATION) == 0) {
+ BT_DBG("TDS Control point Indication Response");
+ bluetooth_tds_indication_res_t ind_res;
+ const char *address = NULL;
+ char *buffer = NULL;
+ GVariant *byte_var = NULL;
+
+ g_variant_get(parameters, "(&s@ay)", &address, &byte_var);
+
+ memset(&ind_res, 0x00, sizeof(bluetooth_tds_indication_res_t));
+
+ ind_res.tds_data.length = g_variant_get_size(byte_var);
+
+ buffer = (char *) g_variant_get_data(byte_var);
+ BT_DBG("[len = %d]", ind_res.tds_data.length);
+ memcpy(ind_res.tds_data.data, buffer, ind_res.tds_data.length);
+
+ _bt_convert_addr_string_to_type(ind_res.rem_addr.addr, address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_TDS_ACTIVATION_INDICATION,
+ BLUETOOTH_ERROR_NONE, &ind_res,
+ event_info->cb, event_info->user_data);
+
+ g_variant_unref(byte_var);
+ } else if (strcasecmp(signal_name, BT_TDS_CONTROL_POINT_ENABLED) == 0) {
+ BT_DBG("TDS Control point Enabled event");
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &address);
+ BT_DBG("Address [%s]", address);
+ BT_DBG("Result [%d]", result);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_TDS_CONTROL_POINT_ENABLED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
+ }
+
+ BT_DBG("-");
+}
+
+static void __bt_otp_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_event_info_t *event_info;
+ event_info = (bt_event_info_t *)user_data;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(object_path, BT_OTP_PATH) != 0)
+ return;
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ BT_DBG("+");
+
+ if (strcasecmp(signal_name, BT_OTP_SERVER_STATE_CHANGED) == 0) {
+ BT_DBG("OTP Server State Changed Event");
+ bool status = FALSE;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(ib)", &result, &status);
+ BT_DBG("Result [%d]", result);
+ BT_DBG("Status [%s]", status ? "enabled" : "disabled");
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_SERVER_STATE_CHANGED,
+ result, &status, event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_READ_CHAR_VAL) == 0) {
+ BT_DBG("OTP Read Data received");
+ const char *handle = NULL;
+ char *data;
+ int data_len = 0;
+ GVariant *var = NULL;
+ bluetooth_otp_resp_info_t *info = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ay)", &result, &handle, &data_len, &var);
+ if (!var) {
+ BT_ERR("No data");
+ return;
+ }
+ data = (char *)g_variant_get_data(var);
+
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Data len [%d]", data_len);
+
+ if (data_len == 0) {
+ BT_ERR("No data");
+ if (var)
+ g_variant_unref(var);
+ return;
+ }
+
+ info = g_malloc0(sizeof(bluetooth_otp_resp_info_t));
+ info->data_length = data_len;
+ info->data = g_memdup(data, data_len);
+ info->handle = g_strdup(handle);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_READ_CHAR_VAL,
+ result, info,
+ event_info->cb, event_info->user_data);
+
+ if (info->handle)
+ g_free(info->handle);
+
+ if (info->data) {
+ g_free(info->data);
+ g_free(info);
+ }
+ g_variant_unref(var);
+ } else if (strcasecmp(signal_name, BT_OTP_NOTIFICATION_ENABLED) == 0) {
+ BT_DBG("OTP Notification Enabled event");
+ char *handle = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &handle);
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Result [%d]", result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_NOTIFICATION_ENABLED,
+ result, handle,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_WRITE_CHAR_VAL) == 0) {
+ BT_DBG("OTP Control point Activation result");
+ char *handle = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &handle);
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Result [%d]", result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL,
+ result, handle,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_INDICATION) == 0) {
+ BT_DBG("OTP Control point Indication Response");
+ bluetooth_otp_resp_info_t *ind_res = NULL;
+ char *buffer = NULL;
+ GVariant *byte_var = NULL;
+ char *handle = NULL;
+
+ g_variant_get(parameters, "(i&s@ay)", &result, &handle, &byte_var);
+ if (!byte_var) {
+ BT_ERR("No Indication data from Server");
+ return;
+ }
+
+ ind_res = g_malloc0(sizeof(bluetooth_otp_resp_info_t));
+ ind_res->data_length = g_variant_get_size(byte_var);
+ buffer = (char *)g_variant_get_data(byte_var);
+ ind_res->data = g_memdup(buffer, ind_res->data_length);
+ ind_res->handle = g_strdup(handle);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_INDICATION,
+ result, ind_res,
+ event_info->cb, event_info->user_data);
+
+ if (ind_res->handle)
+ g_free(ind_res->handle);
+
+ if (ind_res->data) {
+ g_free(ind_res->data);
+ g_free(ind_res);
+ }
+ g_variant_unref(byte_var);
+ } else if (strcasecmp(signal_name, BT_OTC_STATE_CHANGED) == 0) {
+ BT_DBG("OTC State Changed");
+ char *address = NULL;
+ int fd = -1;
+ gboolean connected = FALSE;
+ bluetooth_otc_info_t *otc_info = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(ib&sn)", &result, &connected, &address, &fd);
+ BT_DBG("Result [%d]", result);
+ BT_DBG("Address [%s]", address);
+ BT_DBG("Connected [%d]", connected);
+ BT_DBG("Fd [%d]", fd);
+
+ otc_info = g_malloc0(sizeof(bluetooth_otc_info_t));
+ otc_info->fd = fd;
+ otc_info->connected = connected;
+ otc_info->address = g_strdup(address);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTC_STATE_CHANGED,
+ result, otc_info,
+ event_info->cb, event_info->user_data);
+ }
+
+ BT_DBG("-");
+}
+
+void __bt_hdp_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_event_info_t *event_info;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ BT_DBG("+");
+ event_info = (bt_event_info_t *)user_data;
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(object_path, BT_HDP_DEVICE_PATH) != 0)
+ return;
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ if (strcasecmp(signal_name, BT_HDP_CONNECTED) == 0) {
+ const char *address = NULL;
+ char *app_handle = NULL;
+ bt_hdp_connected_t conn_info;
+
+ g_variant_get(parameters, "(i&s&sui)", &result,
+ &address, &app_handle,
+ &(conn_info.channel_id), &(conn_info.type));
+
+ conn_info.app_handle = app_handle;
+
+ BT_DBG("address: %s, app_handle: %s, ch_id: %d, ch_type: %d",
+ address, conn_info.app_handle, conn_info.channel_id, conn_info.type);
+ _bt_convert_addr_string_to_type(conn_info.device_address.addr, address);
+
+ if (BLUETOOTH_ERROR_NONE == result)
+ result = _bt_hdp_app_acquire_fd(&conn_info);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
+ result, &conn_info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_HDP_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ bt_hdp_disconnected_t disconn_info;
+
+ g_variant_get(parameters, "(i&su)", &result,
+ &address, &(disconn_info.channel_id));
+
+ BT_DBG("address: %s", address);
+ _bt_convert_addr_string_to_type(disconn_info.device_address.addr, address);
+
+ _bt_hdp_app_remove_obj_info(disconn_info.channel_id);
+ _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+ result, &disconn_info,
+ event_info->cb, event_info->user_data);
+ }
+
+ BT_DBG("-");
+}
+
+static void __bt_remove_all_events(void)
+{
+ bt_event_info_t *info;
+
+ while ((info = g_slist_nth_data(event_list, 0)) != NULL)
+ _bt_unregister_event(info->event_type);
+
+ if (event_list) {
g_slist_free(event_list);
event_list = NULL;
}
if (info == NULL)
continue;
- if (info->server_fd == server_fd) {
+ if (info->server_fd == server_fd)
server_list = g_slist_remove(server_list, (void *)info);
- }
g_free(info);
}
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,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ bt_event_info_t *event_info;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ event_info = (bt_event_info_t *)user_data;
+ ret_if(event_info == NULL);
+
+ if (strcasecmp(signal_name, BT_GATT_CHAR_VAL_CHANGED) == 0) { /* Done */
+ /* Event: BLUETOOTH_EVENT_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;
+ GVariant *svc_uuid_var = NULL;
+ int svc_inst;
+ GVariant *char_uuid_var = NULL;
+ int svc_uuid_len = 0;
+ int char_uuid_len = 0;
+
+ memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ayin@ayin@ay)",
+ &result,
+ &address,
+ &svc_uuid_len,
+ &svc_uuid_var,
+ &svc_inst,
+ &char_uuid_len,
+ &char_uuid_var,
+ &char_prop.prop.instance_id,
+ &char_prop.val_len,
+ &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);
+
+ if (char_prop.val_len > 0) {
+ /* Copy Data */
+ memcpy(&char_prop.value, g_variant_get_data(data_var), char_prop.val_len);
+ }
+
+ memcpy(&char_prop.prop.uuid, g_variant_get_data(char_uuid_var), 16);
+
+ /* Copy SVC data */
+ memcpy(&char_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16);
+ char_prop.svc_prop.instance_id = svc_inst;
+
+ _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_DBG("GATT Client event[BT_GATT_CLIENT_READ_CHAR]");
+ bt_gatt_char_property_t char_prop;
+ const char *address = NULL;
+ GVariant *data_var = NULL;
+ GVariant *svc_uuid_var = NULL;
+ int svc_inst = 0;
+ GVariant *char_uuid_var = NULL;
+ int svc_uuid_len = 0;
+ int char_uuid_len = 0;
+
+ memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ayin@ayin@ay)",
+ &result,
+ &address,
+ &svc_uuid_len,
+ &svc_uuid_var,
+ &svc_inst,
+ &char_uuid_len,
+ &char_uuid_var,
+ &char_prop.prop.instance_id,
+ &char_prop.val_len,
+ &data_var);
+ g_strlcpy(char_prop.address, address, BT_ADDRESS_STRING_SIZE);
+
+ 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) {
+ /* Copy Data */
+ memcpy(&char_prop.value, g_variant_get_data(data_var), char_prop.val_len);
+ }
+
+ memcpy(&char_prop.prop.uuid, g_variant_get_data(char_uuid_var), 16);
+
+ /* Copy Svc Data */
+ memcpy(&char_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16);
+ char_prop.svc_prop.instance_id = svc_inst;
+
+ _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_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;
+ int svc_inst = 0;
+ GVariant *char_uuid_var = NULL;
+ int svc_uuid_len = 0;
+ int char_uuid_len = 0;
+
+ memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ayin@ayi)",
+ &result,
+ &address,
+ &svc_uuid_len,
+ &svc_uuid_var,
+ &svc_inst,
+ &char_uuid_len,
+ &char_uuid_var,
+ &char_prop.prop.instance_id);
+
+ g_strlcpy(char_prop.address, address, BT_ADDRESS_STRING_SIZE);
+
+ BT_DBG("GATT Client Char Write Done in remote Server [%s]", address);
+
+ /* Copy Data */
+ memcpy(&char_prop.prop.uuid, g_variant_get_data(char_uuid_var), 16);
+
+ /* Copy Svc Data */
+ memcpy(&char_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16);
+ char_prop.svc_prop.instance_id = svc_inst;
+
+ _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_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;
+ GVariant *svc_uuid_var = NULL;
+ int svc_inst = 0;
+ GVariant *char_uuid_var = NULL;
+ int char_inst = 0;
+ GVariant *desc_uuid_var = NULL;
+ int svc_uuid_len = 0;
+ int char_uuid_len = 0;
+ int desc_uuid_len = 0;
+
+ memset(&desc_prop, 0x00, sizeof(bt_gatt_char_descriptor_property_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ayin@ayin@ayin@ay)",
+ &result,
+ &address,
+ &svc_uuid_len,
+ &svc_uuid_var,
+ &svc_inst,
+ &char_uuid_len,
+ &char_uuid_var,
+ &char_inst,
+ &desc_uuid_len,
+ &desc_uuid_var,
+ &desc_prop.prop.instance_id,
+ &desc_prop.val_len,
+ &data_var);
+ g_strlcpy(desc_prop.address, address, BT_ADDRESS_STRING_SIZE);
+
+ BT_DBG("GATT Client Read Descriptor Callback from [%s]", address);
+ BT_DBG("GATT Client Descriptor Val len: [%d]", desc_prop.val_len);
+
+ /* Copy Data */
+ if (desc_prop.val_len > 0) {
+ BT_INFO("Get the desc read data");
+ memcpy(&desc_prop.value, g_variant_get_data(data_var), desc_prop.val_len);
+ }
+
+ memcpy(&desc_prop.prop.uuid, g_variant_get_data(desc_uuid_var), 16);
+
+ /* Copy Char Data */
+ memcpy(&desc_prop.char_prop.uuid, g_variant_get_data(char_uuid_var), 16);
+ desc_prop.char_prop.instance_id = char_inst;
+
+ /* Copy Svc Data */
+ memcpy(&desc_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16);
+ desc_prop.svc_prop.instance_id = svc_inst;
+
+ _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_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;
+ int svc_inst = 0;
+ GVariant *char_uuid_var = NULL;
+ int char_inst;
+ GVariant *desc_uuid_var = NULL;
+ int svc_uuid_len = 0;
+ int char_uuid_len = 0;
+ int desc_uuid_len = 0;
+
+ memset(&desc_prop, 0x00, sizeof(bt_gatt_char_descriptor_property_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ayin@ayin@ayi)",
+ &result,
+ &address,
+ &svc_uuid_len,
+ &svc_uuid_var,
+ &svc_inst,
+ &char_uuid_len,
+ &char_uuid_var,
+ &char_inst,
+ &desc_uuid_len,
+ &desc_uuid_var,
+ &desc_prop.prop.instance_id);
+
+ 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);
+
+ /* Copy Data */
+ memcpy(&desc_prop.prop.uuid, g_variant_get_data(desc_uuid_var), 16);
+
+ /* Copy Char Data */
+ memcpy(&desc_prop.char_prop.uuid, g_variant_get_data(char_uuid_var), 16);
+ desc_prop.char_prop.instance_id = char_inst;
+
+ /* Copy Svc Data */
+ memcpy(&desc_prop.svc_prop.uuid, g_variant_get_data(svc_uuid_var), 16);
+ desc_prop.svc_prop.instance_id = svc_inst;
+
+ _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_WRITE_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);
+
+ } else if (strcasecmp(signal_name, BT_GATT_CLIENT_SERVICE_CHANGED) == 0) {
+ BT_DBG("GATT Client event[BT_GATT_CLIENT_SERVICE_CHANGED]");
+ bt_gatt_service_change_t change = {0, };
+ char *address_str = NULL;
+ char *name = NULL;
+
+ g_variant_get(parameters, "(i&s&s)", &change.change_type, &address_str, &change.uuid);
+
+ _bt_convert_addr_string_to_type(change.device_addr.addr, address_str);
+ bluetooth_get_uuid_name(change.uuid, &name);
+ BT_INFO(" ### GATT Service %s [%s]", change.change_type ? "Added" : "Removed", name);
+ g_free(name);
+
+ if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr) == FALSE) {
+ BT_INFO("No watcher for %s", address_str);
+ return;
+ }
+
+ _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
+ BLUETOOTH_ERROR_NONE, &change,
+ event_info->cb, event_info->user_data);
+ }
+}
+
+#endif
+
+
+#ifndef GATT_DIRECT
+static void __bt_gatt_server_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("GATT Server event handler Entry >>");
+
+ 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]");
+ const char *address = NULL;
+ GVariant *data_var = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ bluetooth_gatt_server_write_requested_info_t write_info;
+ memset(&write_info, 0x00, sizeof(bluetooth_gatt_server_write_requested_info_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(iiiiiibb&sn@ay)",
+ &result,
+ &write_info.connection_id,
+ &write_info.request_id,
+ &write_info.attribute_handle,
+ &write_info.offset,
+ &write_info.length,
+ &write_info.need_resp,
+ &write_info.is_prep_write,
+ &address,
+ &write_info.length,
+ &data_var);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+
+ BT_DBG("GATT Server Write From Remote Client [%s]", address);
+ BT_DBG("GATT Server Write len: [%d]", write_info.length);
+ BT_DBG("GATT Server Conn ID: [%d]", write_info.connection_id);
+ BT_DBG("GATT Server Req ID: [%d]", write_info.request_id);
+ BT_DBG("GATT Server att handle:[%d]", write_info.attribute_handle);
+ BT_DBG("GATT Server Offset: [%d]", write_info.offset);
+ BT_DBG("GATT Server Need Resp: [%d]", write_info.need_resp);
+ BT_DBG("GATT Server Is Prep: [%d]", write_info.is_prep_write);
+
+ /* Copy Data */
+ memcpy(&write_info.data.data, g_variant_get_data(data_var), write_info.length);
+
+ memcpy(write_info.device_address.addr,
+ dev_address.addr,
+ BLUETOOTH_ADDRESS_LENGTH);
+
+ _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} };
+ bluetooth_gatt_server_read_requested_info_t read_info;
+
+ memset(&read_info, 0x00, sizeof(bluetooth_gatt_server_read_requested_info_t));
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(iiiiib&s)", &result,
+ &read_info.connection_id, &read_info.request_id,
+ &read_info.attribute_handle, &read_info.offset,
+ &read_info.is_long, &address);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+ /* Copy Data */
+ memcpy(read_info.device_address.addr,
+ dev_address.addr,
+ BLUETOOTH_ADDRESS_LENGTH);
+
+ _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED,
+ result, &read_info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_ACQUIRE_WRITE) == 0) {
+
+ bluetooth_gatt_server_send_acquire_write_response(parameters);
+
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_ACQUIRE_NOTIFICATION) == 0) {
+
+ bluetooth_gatt_server_send_acquire_notify_response(parameters, event_info);
+
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_NOTIFICATION_COMPLETED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ bluetooth_gatt_server_indicate_confirmed_info_t info;
+ memset(&info, 0x00, sizeof(bluetooth_gatt_server_indicate_confirmed_info_t));
+
+ BT_INFO("GATT Server event[BT_GATT_SERVER_NOTIFICATION_COMPLETED]");
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sib)", &result, &address, &info.handle, &info.completed);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+ /* Copy Data */
+ memcpy(info.device_address.addr,
+ dev_address.addr,
+ BLUETOOTH_ADDRESS_LENGTH);
+
+ BT_INFO("GATT Server: Indicate confirmed Handle: [%d] address [%s] completed [%d] result [%d]",
+ info.handle, address, info.completed, result);
+
+
+ _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_COMPLETED,
+ result, &info,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_GATT_SERVER_NOTIFICATION_CHANGED) == 0) {
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+ 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_CHANGED]");
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sib)", &result, &address, &info.handle, &info.notification);
+
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ address);
+ /* Copy Data */
+ memcpy(info.device_address.addr,
+ dev_address.addr,
+ BLUETOOTH_ADDRESS_LENGTH);
+
+ BT_INFO("GATT Server: Notification Enabled?? Handle: [%d] address [%s] Is Enabled [%d] result [%d]",
+ info.handle, address, info.notification, result);
+
+ if (info.notification == FALSE)
+ cleanup_gatt_acquire_fd(info.handle);
+
+ _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
+
int _bt_register_event(int event_type, void *event_cb, void *user_data)
{
GDBusConnection *connection_type;
event_func = __bt_opp_server_event_filter;
path = BT_OPP_SERVER_PATH;
break;
+ case BT_MAP_CLIENT_EVENT:
+ event_func = __bt_map_client_event_filter;
+ path = BT_MAP_CLIENT_PATH;
+ break;
case BT_PBAP_CLIENT_EVENT:
event_func = __bt_pbap_client_event_filter;
path = BT_PBAP_CLIENT_PATH;
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:
+ event_func = __bt_tds_event_filter;
+ path = BT_TDS_PATH;
+ break;
+ case BT_OTP_EVENT:
+ event_func = __bt_otp_event_filter;
+ path = BT_OTP_PATH;
+ break;
+ case BT_HDP_EVENT:
+ event_func = __bt_hdp_event_filter;
+ path = BT_HDP_DEVICE_PATH;
+ break;
+#ifndef GATT_DIRECT
+ case BT_GATT_SERVER_EVENT:
+ event_func = __bt_gatt_server_event_filter;
+ 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
default:
BT_ERR("Unknown event");
return BLUETOOTH_ERROR_INTERNAL;
}
- connection_type = _bt_gdbus_get_system_gconn();
+ connection_type = _bt_get_system_private_conn();
if (connection_type == NULL)
return BLUETOOTH_ERROR_INTERNAL;
return BLUETOOTH_ERROR_INTERNAL;
}
- connection_type = _bt_gdbus_get_system_gconn();
+ connection_type = _bt_get_system_private_conn();
event_list = g_slist_remove(event_list, (void *)cb_data);
{
GDBusConnection *connection_type;
- connection_type = _bt_gdbus_get_system_gconn();
+ connection_type = _bt_get_system_private_conn();
if (connection_type == NULL) {
BT_ERR("Unable to get the bus");
return;
}
owner_sig_id = g_dbus_connection_signal_subscribe(connection_type,
- NULL, DBUS_INTERFACE_DBUS,
+ NULL, BT_EVENT_FREEDESKTOP,
BT_NAME_OWNER_CHANGED, NULL, NULL, 0,
__bt_name_owner_changed, NULL, NULL);
}
{
GDBusConnection *connection_type;
- connection_type = _bt_gdbus_get_system_gconn();
- if (connection_type != NULL && owner_sig_id != -1) {
+ connection_type = _bt_get_system_private_conn();
+ if (connection_type != NULL && owner_sig_id > 0) {
g_dbus_connection_signal_unsubscribe(connection_type,
owner_sig_id);
- owner_sig_id = -1;
+ owner_sig_id = 0;
}
}
+static void __bt_gatt_get_uuid_from_path(char *path, char **service_uuid)
+{
+ GDBusProxy *proxy = NULL;
+ GError *err = NULL;
+ GDBusConnection *g_conn;
+ GVariant *ret = NULL;
+ GVariant *value = NULL;
+
+ g_conn = _bt_get_system_private_conn();
+ ret_if(g_conn == NULL);
+
+ proxy = g_dbus_proxy_new_sync(g_conn,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ BT_BLUEZ_NAME,
+ path,
+ BT_PROPERTIES_INTERFACE,
+ NULL, &err);
+
+ ret_if(proxy == NULL);
+
+ ret = g_dbus_proxy_call_sync(proxy, "Get",
+ g_variant_new("(ss)", GATT_SERV_INTERFACE, "UUID"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (err) {
+ BT_ERR("DBus Error : %s", err->message);
+ g_clear_error(&err);
+ } else {
+ g_variant_get(ret, "(v)", &value);
+ *service_uuid = g_variant_dup_string(value, NULL);
+ g_variant_unref(value);
+ g_variant_unref(ret);
+ }
+
+ if (proxy)
+ g_object_unref(proxy);
+
+ return;
+}
+
+
static void __bt_manager_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
GVariantIter *interface_iter = NULL;
char *interface_str = NULL;
bt_gatt_service_change_t change;
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
bt_user_info_t *user_info = NULL;
+ user_info = _bt_get_user_data(BT_COMMON);
+ if (user_info == NULL) {
+ BT_ERR("There is no registered common event callback");
+ return;
+ }
+
if (strcasecmp(signal_name, "GattServiceAdded") == 0) {
g_variant_get(parameters, "(&s)", &path);
- _bt_convert_device_path_to_address(path, address);
- _bt_convert_addr_string_to_type(change.device_addr.addr, address);
- _bt_convert_addr_string_to_secure_string(secure_address, address);
+ _bt_convert_device_path_to_addr_type(path, change.device_addr.addr);
+ _bt_convert_addr_type_to_secure_string(secure_address,
+ change.device_addr.addr);
if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)
== FALSE) {
BT_INFO("GATT Service [%s] added, but no watcher for %s",
- path, secure_address);
+ path, secure_address);
return;
- } else
- BT_INFO("GATT Service [%s] added : %s",
- path, secure_address);
+ } else {
+ char *uuid = NULL;
+ char *name = NULL;
+ __bt_gatt_get_uuid_from_path(path, &uuid);
+ bluetooth_get_uuid_name(uuid, &name);
+
+ BT_INFO(" ### GATT Service added [%s] [%s]",
+ path, name);
+ g_free(name);
+ g_free(uuid);
+ }
change.svc_path = g_strdup(path);
change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD;
-
- user_info = _bt_get_user_data(BT_COMMON);
- if (user_info != NULL) {
- _bt_common_event_cb(
- BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
- BLUETOOTH_ERROR_NONE, &change,
- user_info->cb, user_info->user_data);
- }
-
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
+ BLUETOOTH_ERROR_NONE, &change,
+ user_info->cb, user_info->user_data);
g_free(change.svc_path);
} else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
- g_variant_get(parameters, "(&oas)",
- &path, &interface_iter);
-
+ g_variant_get(parameters, "(&oas)", &path, &interface_iter);
if (!path) {
BT_ERR("Invalid adapter path");
+ g_variant_iter_free(interface_iter);
return;
}
- _bt_convert_device_path_to_address(path, address);
- _bt_convert_addr_string_to_type(change.device_addr.addr, address);
- _bt_convert_addr_string_to_secure_string(secure_address, address);
-
- if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)
- == FALSE) {
- BT_INFO("GATT Service [%s] removed, but no watcher for %s",
- path, secure_address);
+ _bt_convert_device_path_to_addr_type(path, change.device_addr.addr);
+ if (!_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)) {
+ g_variant_iter_free(interface_iter);
return;
}
- while (g_variant_iter_loop(interface_iter, "s", &interface_str)) {
- if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) == 0) {
- change.svc_path = g_strdup(path);
- change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
+ while (g_variant_iter_loop(interface_iter, "&s", &interface_str)) {
+ if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) != 0)
+ continue;
- BT_INFO("GATT Service [%s] is removed : %s",
- path, secure_address);
+ BT_INFO(" ### GATT Service removed [%s]", path);
- user_info = _bt_get_user_data(BT_COMMON);
- if (user_info != NULL) {
- _bt_common_event_cb(
- BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
- BLUETOOTH_ERROR_NONE, &change,
- user_info->cb, user_info->user_data);
- }
-
- g_free(change.svc_path);
- break;
- }
+ change.svc_path = g_strdup(path);
+ change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
+ _bt_common_event_cb(
+ BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
+ BLUETOOTH_ERROR_NONE, &change,
+ user_info->cb, user_info->user_data);
+ g_free(change.svc_path);
+ break;
}
g_variant_iter_free(interface_iter);
}
int _bt_register_manager_subscribe_signal(gboolean subscribe)
{
GDBusConnection *g_conn;
- static int service_added_id = -1;
- static int interface_removed_id = -1;
+ static guint service_added_id = 0;
+ static guint interface_removed_id = 0;
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_get_system_private_conn();
if (g_conn == NULL)
return BLUETOOTH_ERROR_INTERNAL;
if (subscribe == TRUE) {
- if (service_added_id == -1) {
+ if (service_added_id == 0) {
service_added_id = g_dbus_connection_signal_subscribe(g_conn,
NULL, GATT_SERV_INTERFACE,
"GattServiceAdded", NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (interface_removed_id == -1) {
+ if (interface_removed_id == 0) {
interface_removed_id = g_dbus_connection_signal_subscribe(g_conn,
NULL, BT_MANAGER_INTERFACE,
"InterfacesRemoved", NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (service_added_id != -1) {
+ if (service_added_id > 0) {
g_dbus_connection_signal_unsubscribe(g_conn,
service_added_id);
- service_added_id = -1;
+ service_added_id = 0;
}
- if (interface_removed_id != -1) {
+ if (interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(g_conn,
interface_removed_id);
- interface_removed_id = -1;
+ interface_removed_id = 0;
}
}