*/
#include <string.h>
-#include <dbus/dbus.h>
#include <glib.h>
#include <dlog.h>
#include <vconf.h>
#include "bluetooth-api.h"
#include "bluetooth-audio-api.h"
+#include "bluetooth-hid-api.h"
#include "bt-internal-types.h"
#include "bluetooth-media-control.h"
#include "bt-common.h"
#include "bt-event-handler.h"
+#include "bt-gatt-client.h"
#include "bt-request-sender.h"
+#define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
#define BT_RELIABLE_DISABLE_TIME 300 /* 300 ms */
typedef struct {
static GSList *server_list = NULL;
static GSList *event_list = NULL;
static int owner_sig_id = -1;
-static gboolean is_adapter_enabled = TRUE;
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;
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;
_bt_set_le_scan_status(FALSE);
+ _bt_set_adapter_internal_status(FALSE);
+
if (is_initialized != FALSE) {
- if (is_adapter_enabled == TRUE) {
- is_adapter_enabled = FALSE;
- _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED,
- BLUETOOTH_ERROR_NONE, NULL,
- event_info->cb, event_info->user_data);
- _bt_common_event_cb(BLUETOOTH_EVENT_LE_DISABLED,
- BLUETOOTH_ERROR_NONE, NULL,
- event_info->cb, event_info->user_data);
- }
+ _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED,
+ BLUETOOTH_ERROR_NONE, NULL,
+ event_info->cb, event_info->user_data);
}
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_DBG("-");
return FALSE;
}
if (strcasecmp(signal_name, BT_ENABLED) == 0) {
BT_INFO("BT_ENABLED");
g_variant_get(parameters, "(i)", &result);
- if (result == BLUETOOTH_ERROR_NONE) {
- if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
- BT_ERR("Set vconf failed");
-
- if (vconf_set_int(BT_OFF_DUE_TO_POWER_SAVING_MODE, 0) != 0)
- BT_ERR("Set vconf failed");
-
- if (vconf_set_int(BT_OFF_DUE_TO_TIMEOUT, 0) != 0)
- BT_ERR("Set vconf failed");
- }
-
- is_adapter_enabled = TRUE;
_bt_common_event_cb(BLUETOOTH_EVENT_ENABLED,
result, NULL,
event_info->cb, event_info->user_data);
g_variant_unref(var);
+ } else if (strcasecmp(signal_name, BT_PASSKEY_NOTIFICATION) == 0) {
+ const char *address = NULL;
+ const char *passkey = NULL;
+ const char *passkey_info[2];
+
+ g_variant_get(parameters, "(&s&s)", &address, &passkey);
+ passkey_info[0] = address;
+ passkey_info[1] = passkey;
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_PASSKEY_NOTIFICATION,
+ BLUETOOTH_ERROR_NONE, (void*)passkey_info,
+ event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_DEVICE_FOUND) == 0) {
int event;
bluetooth_device_info_t *device_info;
&result);
ret_if(le_device_info == NULL);
- _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND,
+ if (bluetooth_is_le_scanning() == TRUE) {
+ _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND,
result, le_device_info,
event_info->cb, event_info->user_data);
+ }
g_free(le_device_info);
}
event_info = (bt_event_info_t *)user_data;
ret_if(event_info == NULL);
-#ifdef GATT_NO_RELAY
gboolean gatt_interface = FALSE;
if (strcasecmp(interface_name, BT_GATT_CHARACTERISTIC_INTERFACE) == 0)
if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0 &&
gatt_interface == FALSE)
return;
-#else
- if (strcasecmp(object_path, BT_DEVICE_PATH) != 0)
- return;
- if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
- return;
-#endif
ret_if(signal_name == NULL);
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);
-#ifdef GATT_NO_RELAY
+ } else if (strcasecmp(signal_name, BT_GATT_REQ_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_REQ_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_ATT_MTU_CHANGED,
+ result, &att_mtu_info,
+ event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_GATT_BLUEZ_CHAR_VAL_CHANGED) == 0) {
-#else
- } else if (strcasecmp(signal_name, BT_GATT_CHAR_VAL_CHANGED) == 0) {
-#endif
const char *char_handle = NULL;
int len = 0;
const char * value = NULL;
GVariant *char_value_var = NULL;
bt_gatt_char_value_t char_val = { 0, };
- BT_DBG("BT_GATT_CHAR_VAL_CHANGED");
g_variant_get(parameters, "(i&s@ay)", &result, &char_handle, &char_value_var);
len = g_variant_get_size(char_value_var);
+ ret_if(char_value_var == NULL);
+
if (len > 0)
value = (char *)g_variant_get_data(char_value_var);
/* 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);
- if (char_value_var)
- 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,
event_info->cb, event_info->user_data);
g_free(char_val.char_value);
- if (char_value_var)
- g_variant_unref(char_value_var);
+ g_variant_unref(char_value_var);
}
g_free(char_val.char_handle);
} else if (strcasecmp(signal_name, BT_DEVICE_CONNECTED) == 0) {
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);
conn_info.addr_type = addr_type;
conn_info.disc_reason = result;
- BT_DBG("Sending Event to Framework");
_bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_DISCONNECTED,
result, &conn_info,
event_info->cb, event_info->user_data);
_bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED,
result, &dev_address,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_SUPPORTED_PROFILE_TRUSTED) == 0) {
+ char *address;
+ bt_supported_profile_trusted_t profile_info = { 0, };
+ int trust;
+
+ g_variant_get(parameters, "(i&si)", &result,
+ &address, &trust);
+
+ BT_DBG("Address [%s] trust[%d]", address, trust);
+ profile_info.address = address;
+ if (trust & (PROFILE_SUPPORTED << 0)) { /* Bit 0 & 1 - for PBAP Supported */
+ profile_info.profile = TRUSTED_PROFILE_PBAP;
+ profile_info.supported = TRUE;
+ if (trust & (1 << 1)) /* Bit 1 - for PBAP Trusted */
+ profile_info.trusted = TRUE;
+ else
+ profile_info.trusted = FALSE;
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_SUPPORTED_PROFILE_TRUSTED,
+ result, &profile_info,
+ event_info->cb, event_info->user_data);
+ }
+ if (trust & (PROFILE_SUPPORTED << 2)) { /* Bit 2 & 3 - for MAP Supported */
+ profile_info.profile = TRUSTED_PROFILE_MAP;
+ profile_info.supported = TRUE;
+ if (trust & (1 << 3)) /* Bit 3 - for PBAP Trusted */
+ profile_info.trusted = TRUE;
+ else
+ profile_info.trusted = FALSE;
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_SUPPORTED_PROFILE_TRUSTED,
+ result, &profile_info,
+ event_info->cb, event_info->user_data);
+ }
+ if (trust & (PROFILE_SUPPORTED << 4)) { /* Bit 4 & 5- for SAP Supported */
+ profile_info.profile = TRUSTED_PROFILE_SAP;
+ profile_info.supported = TRUE;
+ if (trust & (1 << 5)) /* Bit 5 - for SAP Trusted */
+ profile_info.trusted = TRUE;
+ else
+ profile_info.trusted = FALSE;
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_SUPPORTED_PROFILE_TRUSTED,
+ result, &profile_info,
+ event_info->cb, event_info->user_data);
+ }
} else if (strcasecmp(signal_name, BT_IPSP_CONNECTED) == 0) {
const char *address = NULL;
- bluetooth_device_address_t dev_address = { {0} };
+ const char *if_name = NULL;
+ bt_ipsp_connection_info_t bt_ipsp_iface_info;
+ memset(&bt_ipsp_iface_info, 0, sizeof(bt_ipsp_iface_info));
BT_DBG("BT_IPSP_CONNECTED");
- g_variant_get(parameters, "(i&s)", &result, &address);
+ g_variant_get(parameters, "(i&s&s)", &result, &address, &if_name);
- _bt_convert_addr_string_to_type(dev_address.addr, address);
+ _bt_convert_addr_string_to_type(bt_ipsp_iface_info.btaddr.addr, address);
+ memcpy(bt_ipsp_iface_info.if_name, if_name, 16);
_bt_common_event_cb(BLUETOOTH_EVENT_IPSP_CONNECTED,
- result, &dev_address,
+ result, &bt_ipsp_iface_info,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_IPSP_DISCONNECTED) == 0) {
const char *address = NULL;
- bluetooth_device_address_t dev_address = { {0} };
- BT_DBG("BT_IPSP_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_IPSP_DISCONNECTED,
- result, &dev_address,
- event_info->cb, event_info->user_data);
- } else if (strcasecmp(signal_name, BT_IPSP_BT_INTERFACE_INFO) == 0) {
- const char *address = NULL;
const char *if_name = NULL;
- bt_ipsp_interface_info_t ipsp_iface_info;
- memset(&ipsp_iface_info, 0, sizeof(ipsp_iface_info));
+ bt_ipsp_connection_info_t bt_ipsp_iface_info;
+ memset(&bt_ipsp_iface_info, 0, sizeof(bt_ipsp_iface_info));
- BT_DBG("BT_IPSP_BT_INTERFACE_INFO");
+ BT_DBG("BT_IPSP_DISCONNECTED");
g_variant_get(parameters, "(i&s&s)", &result, &address, &if_name);
- _bt_convert_addr_string_to_type(ipsp_iface_info.btaddr.addr, address);
- memcpy(ipsp_iface_info.if_name, if_name, 16);
+ _bt_convert_addr_string_to_type(bt_ipsp_iface_info.btaddr.addr, address);
+ memcpy(bt_ipsp_iface_info.if_name, if_name, 16);
- _bt_common_event_cb(BLUETOOTH_EVENT_IPSP_BT_INTERFACE_INFO,
- result, &ipsp_iface_info,
+ _bt_common_event_cb(BLUETOOTH_EVENT_IPSP_DISCONNECTED,
+ result, &bt_ipsp_iface_info,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_LE_DATA_LENGTH_CHANGED) == 0) {
const char *address = NULL;
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);
}
}
event_info = (bt_event_info_t *)user_data;
ret_if(event_info == NULL);
-
if (strcasecmp(object_path, BT_HID_DEVICE_PATH) != 0)
return;
if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
_bt_input_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
result, &dev_address,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_INPUT_HID_DEVICE_CONNECTED) == 0) {
+ BT_INFO_C("Type %s", g_variant_get_type_string(parameters));
+ const char *address = NULL;
+ bluetooth_device_address_t dev_address = { {0} };
+
+ g_variant_get(parameters, "(i&s)", &result, &address);
+
+ BT_DBG("address: %s", address);
+ _bt_convert_addr_string_to_type(dev_address.addr,
+ 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);
+ }
+ } else if (strcasecmp(signal_name, BT_INPUT_HID_DEVICE_DISCONNECTED) == 0) {
+ const char *address = NULL;
+ g_variant_get(parameters, "(i&s)", &result, &address);
+
+ BT_DBG("address: %s", address);
}
}
void __bt_a2dp_source_event_filter(GDBusConnection *connection,
metadata.genre = 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,
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;
__bt_remove_push_request_id(request_id);
} else if (strcasecmp(signal_name, BT_TRANSFER_STARTED) == 0) {
const char *file_name = NULL;
+ const char *device_addr = NULL;
int request_id = 0;
guint64 size = 0;
bt_opc_transfer_info_t transfer_info;
- g_variant_get(parameters, "(i&sti)", &result, &file_name,
+ g_variant_get(parameters, "(i&s&sti)", &result, &device_addr, &file_name,
&size, &request_id);
if (__bt_is_request_id_exist(request_id) == FALSE) {
memset(&transfer_info, 0x00, sizeof(bt_opc_transfer_info_t));
transfer_info.filename = g_strdup(file_name);
+ transfer_info.device_addr = g_strdup(device_addr);
transfer_info.size = size;
_bt_common_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_STARTED,
result, &transfer_info,
event_info->cb, event_info->user_data);
+ g_free(transfer_info.device_addr);
g_free(transfer_info.filename);
} else if (strcasecmp(signal_name, BT_TRANSFER_PROGRESS) == 0) {
const char *file_name = NULL;
g_free(transfer_info.filename);
} else if (strcasecmp(signal_name, BT_TRANSFER_COMPLETED) == 0) {
const char *file_name = NULL;
+ const char *device_addr = NULL;
int request_id = 0;
guint64 size = 0;
bt_opc_transfer_info_t transfer_info;
- g_variant_get(parameters, "(i&sti)", &result,
+ g_variant_get(parameters, "(i&s&sti)", &result, &device_addr,
&file_name, &size, &request_id);
if (__bt_is_request_id_exist(request_id) == FALSE) {
memset(&transfer_info, 0x00, sizeof(bt_opc_transfer_info_t));
+ transfer_info.device_addr = g_strdup(device_addr);
transfer_info.filename = g_strdup(file_name);
transfer_info.size = size;
result, &transfer_info,
event_info->cb, event_info->user_data);
+ g_free(transfer_info.device_addr);
g_free(transfer_info.filename);
}
}
if (strcasecmp(signal_name, BT_TRANSFER_AUTHORIZED) == 0) {
/* Native only event */
const char *file_name = NULL;
+ const char *address = NULL;
+ const char *device_name = NULL;
guint64 size = 0;
bt_obex_server_authorize_into_t auth_info;
- g_variant_get(parameters, "(i&st)", &result, &file_name, &size);
+ g_variant_get(parameters, "(i&st&s&s)", &result, &file_name, &size,
+ &address, &device_name);
/* OSP server: Don't get this event */
ret_if(obex_server_id == BT_CUSTOM_SERVER);
auth_info.filename = g_strdup(file_name);
auth_info.length = size;
-
+ auth_info.address = g_strdup(address);
+ auth_info.name = g_strdup(device_name);
_bt_common_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE,
result, &auth_info,
event_info->cb, event_info->user_data);
g_free(auth_info.filename);
+ g_free(auth_info.address);
+ g_free(auth_info.name);
} else if (strcasecmp(signal_name, BT_CONNECTION_AUTHORIZED) == 0) {
/* OSP only event */
const char *address = NULL;
result, &dev_address,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_TRANSFER_CONNECTED) == 0) {
+ bt_obex_server_connection_info_t conn_info = {0, };
+ char *address = NULL;
+ char *name = NULL;
+ int transfer_id = -1;
+ g_variant_get(parameters, "(i&s&si)", &result,
+ &address, &name, &transfer_id);
- g_variant_get(parameters, "(i)", &result);
+ conn_info.address = g_strdup(address);
+ conn_info.device_name = g_strdup(name);
+ conn_info.transfer_id = transfer_id;
_bt_common_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED,
- result, NULL, event_info->cb,
+ result, &conn_info, event_info->cb,
event_info->user_data);
+
+ g_free(conn_info.address);
+ g_free(conn_info.device_name);
} else if (strcasecmp(signal_name, BT_TRANSFER_DISCONNECTED) == 0) {
+ bt_obex_server_transfer_info_t transfer_info = {0, };
+ char *address = NULL;
+ int transfer_id = -1;
+ g_variant_get(parameters, "(i&si)", &result, &address, &transfer_id);
+ DBG_SECURE("address: %s, transfer_id: %d", address, transfer_id);
- g_variant_get(parameters, "(i)", &result);
+ transfer_info.address = g_strdup(address);
+ transfer_info.transfer_id = transfer_id;
_bt_common_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED,
- result, NULL, event_info->cb,
+ result, &transfer_info, event_info->cb,
event_info->user_data);
+ g_free(transfer_info.address);
} else if (strcasecmp(signal_name, BT_TRANSFER_STARTED) == 0) {
+ const char *device_name = NULL;
const char *file_name = NULL;
const char *type = NULL;
+ const char *address = NULL;
+ GVariantIter *iter = NULL;
+ int i = 0;
+ guchar byte;
int transfer_id = 0;
int server_type = 0; /* bt_server_type_t */
guint64 size = 0;
bt_obex_server_transfer_info_t transfer_info;
- g_variant_get(parameters, "(i&s&stii)", &result, &file_name,
- &type, &size, &transfer_id, &server_type);
+ g_variant_get(parameters, "(i&s&s&s&stii(ay))", &result, &device_name,
+ &file_name, &type, &address, &size, &transfer_id, &server_type, &iter);
/* Other server's event */
ret_if(obex_server_id != server_type &&
memset(&transfer_info, 0x00, sizeof(bt_obex_server_transfer_info_t));
+ transfer_info.contact_auth_info = g_malloc0(sizeof(unsigned char) * 5);
+
+ for (i = 0; i < 5 && g_variant_iter_loop(iter, "y", &byte); ++i)
+ transfer_info.contact_auth_info[i] = byte;
+
+ transfer_info.device_name = g_strdup(device_name);
transfer_info.filename = g_strdup(file_name);
transfer_info.type = g_strdup(type);
+ transfer_info.address = g_strdup(address);
transfer_info.file_size = size;
transfer_info.transfer_id = transfer_id;
transfer_info.server_type = (server_type == BT_FTP_SERVER) ?
g_free(transfer_info.filename);
g_free(transfer_info.type);
+ g_free(transfer_info.device_name);
+ g_free(transfer_info.address);
+ g_free(transfer_info.contact_auth_info);
+ g_variant_iter_free(iter);
} else if (strcasecmp(signal_name, BT_TRANSFER_PROGRESS) == 0) {
const char *file_name = NULL;
const char *type = NULL;
+ const char *device_name = NULL;
+ const char *address = NULL;
int transfer_id = 0;
int progress = 0;
int server_type = 0; /* bt_server_type_t */
guint64 size = 0;
bt_obex_server_transfer_info_t transfer_info;
- g_variant_get(parameters, "(i&s&stiii)", &result, &file_name,
- &type, &size, &transfer_id,
+ g_variant_get(parameters, "(i&s&s&s&stiii)", &result, &file_name,
+ &type, &device_name, &address, &size, &transfer_id,
&progress, &server_type);
/* Other server's event */
transfer_info.filename = g_strdup(file_name);
transfer_info.type = g_strdup(type);
+ transfer_info.device_name = g_strdup(device_name);
+ transfer_info.address = g_strdup(address);
transfer_info.file_size = size;
transfer_info.transfer_id = transfer_id;
transfer_info.percentage = progress;
event_info->cb, event_info->user_data);
g_free(transfer_info.filename);
+ g_free(transfer_info.device_name);
+ g_free(transfer_info.address);
g_free(transfer_info.type);
} else if (strcasecmp(signal_name, BT_TRANSFER_COMPLETED) == 0) {
const char *file_name = NULL;
const char *device_name = NULL;
+ const char *address = NULL;
const char *type = NULL;
const char *file_path;
int transfer_id = 0;
guint64 size = 0;
bt_obex_server_transfer_info_t transfer_info;
- g_variant_get(parameters, "(i&s&s&s&stii)", &result, &file_name,
- &type, &device_name, &file_path, &size,
+ g_variant_get(parameters, "(i&s&s&s&s&stii)", &result, &file_name,
+ &type, &device_name, &file_path, &address, &size,
&transfer_id, &server_type);
/* Other server's event */
transfer_info.type = g_strdup(type);
transfer_info.device_name = g_strdup(device_name);
transfer_info.file_path = g_strdup(file_path);
+ transfer_info.address = g_strdup(address);
transfer_info.file_size = size;
transfer_info.transfer_id = transfer_id;
transfer_info.server_type = (server_type == BT_FTP_SERVER) ?
g_free(transfer_info.filename);
g_free(transfer_info.type);
g_free(transfer_info.device_name);
+ g_free(transfer_info.address);
g_free(transfer_info.file_path);
}
}
-void __bt_pbap_client_event_filter(GDBusConnection *connection,
+void __bt_map_client_event_filter(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
const gchar *interface_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_PBAP_CLIENT_PATH) != 0)
+ if (strcasecmp(object_path, BT_MAP_CLIENT_PATH) != 0)
return;
if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
return;
ret_if(signal_name == NULL);
- BT_DBG("Type: %s", g_variant_get_type_string(parameters));
- if (strcasecmp(signal_name, BT_PBAP_CONNECTED) == 0) {
- bt_pbap_connected_t connected = { { { 0 }, }, };
- char *address = NULL;
- g_variant_get(parameters, "(is)", &result, &address);
- BT_DBG("address: %s", address);
+ if (strcasecmp(signal_name, BT_MAP_CONNECTED) == 0) {
+ const char *address = NULL;
+ int request_id = 0;
+ bluetooth_device_address_t dev_address = { {0} };
- _bt_convert_addr_string_to_type(connected.btaddr.addr,
+ 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);
- connected.connected = 1;
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_CONNECTED,
+ result, &dev_address,
+ event_info->cb, event_info->user_data);
- _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED,
- result, &connected,
+ 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);
- } else if (strcasecmp(signal_name, BT_PBAP_DISCONNECTED) == 0) {
+
+ __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**) malloc(folders_struct.size * sizeof(*(folders_struct.names)));
+ BT_DBG("g_variant_iter_n_children: %d", 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;
+ }
+ 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 = malloc(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;
+ }
+ 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*)
+ malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
+ BT_DBG("g_variant_iter_n_children: %d", 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: %d", 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: %d", 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);
+ }
+ 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,
+ 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(object_path, BT_PBAP_CLIENT_PATH) != 0)
+ return;
+
+ if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+ return;
+
+ ret_if(signal_name == NULL);
+
+ BT_DBG("Type: %s", g_variant_get_type_string(parameters));
+
+ if (strcasecmp(signal_name, BT_PBAP_CONNECTED) == 0) {
bt_pbap_connected_t connected = { { { 0 }, }, };
char *address = NULL;
- g_variant_get(parameters, "(is)", &result, &address);
+ g_variant_get(parameters, "(i&s)", &result, &address);
BT_DBG("address: %s", address);
_bt_convert_addr_string_to_type(connected.btaddr.addr,
address);
+ if (result == 0)
+ connected.connected = 1;
+ else
+ connected.connected = 0;
- connected.connected = 0;
-
- _bt_common_event_cb(BLUETOOTH_PBAP_DISCONNECTED,
+ _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED,
result, &connected,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_PBAP_DISCONNECTED) == 0) {
bt_pbap_connected_t disconnected = { { { 0 }, }, };
char *address = NULL;
- g_variant_get(parameters, "(is)", &result, &address);
+ g_variant_get(parameters, "(i&s)", &result, &address);
BT_DBG("address: %s", address);
_bt_convert_addr_string_to_type(disconnected.btaddr.addr,
address);
disconnected.connected = 0;
- _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED,
+ _bt_common_event_cb(BLUETOOTH_PBAP_DISCONNECTED,
result, &disconnected,
event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, BT_PBAP_PHONEBOOK_SIZE) == 0) {
char *address = NULL;
int size = 0;
- g_variant_get(parameters, "(isi)", &result, &address, &size);
+ g_variant_get(parameters, "(i&si)", &result, &address, &size);
- BT_DBG("address: %s", address);
- BT_DBG("size: %d", size);
+ BT_DBG("address: %s, size: %d", address, size);
_bt_convert_addr_string_to_type(pb_size.btaddr.addr,
address);
char *vcf_file = NULL;
int success = -1;
- g_variant_get(parameters, "(issi)", &result, &address, &vcf_file, &success);
+ g_variant_get(parameters, "(i&s&si)", &result, &address, &vcf_file, &success);
- BT_DBG("address: %s", address);
- BT_DBG("vcf_file: %s", vcf_file);
- BT_DBG("success: %d", success);
+ BT_DBG("address: %s, vcf_file: %s, success: %d",
+ address, vcf_file, success);
_bt_convert_addr_string_to_type(pb_pull.btaddr.addr,
address);
int success = -1;
int i = 0;
- g_variant_get(parameters, "(isv)", &result, &address, &string_var);
+ g_variant_get(parameters, "(i&sv)", &result, &address, &string_var);
list = (gchar **)g_variant_get_strv(string_var, &count);
success = !result;
- BT_DBG("address: %s", address);
- BT_DBG("result: %d", result);
- BT_DBG("count: %d", count);
+
for (i = 0; i < count; i++)
BT_DBG("%s", list[i]);
- BT_DBG("success: %d", success);
+
+ BT_DBG("address: %s, result: %d, count: %d, success: %d",
+ address, result, count, success);
_bt_convert_addr_string_to_type(vc_list.btaddr.addr,
address);
char *vcf_file = NULL;
int success = -1;
- g_variant_get(parameters, "(issi)", &result, &address, &vcf_file, &success);
+ g_variant_get(parameters, "(i&s&si)",
+ &result, &address, &vcf_file, &success);
- BT_DBG("address: %s", address);
- BT_DBG("vcf_file: %s", vcf_file);
- BT_DBG("success: %d", success);
+ BT_DBG("address: %s, vcf_file: %s, success: %d",
+ address, vcf_file, success);
- _bt_convert_addr_string_to_type(vc_pull.btaddr.addr,
- address);
+ _bt_convert_addr_string_to_type(vc_pull.btaddr.addr, address);
vc_pull.vcf_file = vcf_file;
vc_pull.success = success;
_bt_common_event_cb(BLUETOOTH_PBAP_VCARD_PULL,
int success = -1;
int i = 0;
- g_variant_get(parameters, "(is@as)", &result, &address, &string_var);
+ g_variant_get(parameters, "(i&s@as)", &result, &address, &string_var);
list = (gchar **)g_variant_get_strv(string_var, &count);
success = !result;
- BT_DBG("address: %s", address);
for (i = 0; i < count; i++)
BT_DBG("%s", list[i]);
- BT_DBG("success: %d", success);
- _bt_convert_addr_string_to_type(vc_list.btaddr.addr,
- address);
+ BT_DBG("address: %s success: %d", address, success);
+
+ _bt_convert_addr_string_to_type(vc_list.btaddr.addr, address);
vc_list.vcards = list;
vc_list.length = count;
vc_list.success = success;
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALL_TERMINATED,
result, NULL,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "FailedToDial") == 0) {
+ _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALL_FAILED_TO_DIAL,
+ result, NULL,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "CallIdle") == 0) {
+ _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALL_IDLE,
+ result, NULL,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "CallSetupIncoming") == 0) {
+ _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALLSETUP_INCOMING,
+ result, NULL,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "CallSetupDialing") == 0) {
+ _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALLSETUP_DIALING,
+ result, NULL,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "CallSetupAlerting") == 0) {
+ _bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALLSETUP_ALERTING,
+ result, NULL,
+ event_info->cb, event_info->user_data);
} else if (strcasecmp(signal_name, "CallStarted") == 0) {
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_CALL_STARTED,
result, NULL,
_bt_hf_event_cb(BLUETOOTH_EVENT_HF_VENDOR_DEP_CMD,
result, &cmd,
event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, "PropertyChanged") == 0) {
+ GVariant *value;
+ gchar *property;
+ bluetooth_hf_ciev_device_event_t dev_event;
+
+ g_variant_get(parameters, "(&sv)", &property, &value);
+ dev_event.value = g_variant_get_uint16(value);
+
+ BT_DBG("Property: %s , value: %d", property, dev_event.value);
+ g_variant_unref(value);
+
+ if (strcasecmp(property, "BatteryCharge") == 0) {
+ dev_event.event = BLUETOOTH_HF_CIEV_BATTCHG;
+ _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) {
+ 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) {
+ 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");
}
+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 *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_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);
+
+ _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;
+ int k;
+ 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);
+
+ 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);
+ 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);
+ 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);
+ 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);
+ }
+ if (var)
+ 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);
+
+ 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);
+ }
+ if (byte_var)
+ g_variant_unref(byte_var);
+ }
+
+ BT_DBG("-");
+}
+
static void __bt_remove_all_events(void)
{
- GSList *l;
bt_event_info_t *info;
- for (l = event_list; l != NULL; l = g_slist_next(l)) {
- info = l->data;
+ while ((info = g_slist_nth_data(event_list, 0)) != NULL)
+ _bt_unregister_event(info->event_type);
- if (info)
- _bt_unregister_event(info->event_type);
+ if (event_list) {
+ g_slist_free(event_list);
+ event_list = NULL;
}
-
- g_slist_free(event_list);
- event_list = NULL;
}
static gboolean __bt_event_is_registered(int event_type)
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);
}
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;
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;
default:
BT_ERR("Unknown event");
return BLUETOOTH_ERROR_INTERNAL;
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);
}
owner_sig_id = -1;
}
}
+
+static void __bt_manager_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)
+{
+ char *path = NULL;
+ 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;
+
+ 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);
+
+ 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);
+ return;
+ } else
+ BT_INFO(" ### GATT Service added [%s] [%s]",
+ path, secure_address);
+
+ 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);
+ }
+
+ g_free(change.svc_path);
+ } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
+ g_variant_get(parameters, "(&oas)",
+ &path, &interface_iter);
+
+ if (!path) {
+ BT_ERR("Invalid adapter path");
+ 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);
+ 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;
+
+ BT_INFO(" ### GATT Service removed [%s] [%s]",
+ path, secure_address);
+
+ 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;
+ }
+ }
+ 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;
+
+ g_conn = _bt_gdbus_get_system_gconn();
+ if (g_conn == NULL)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ if (subscribe == TRUE) {
+ if (service_added_id == -1) {
+ 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) {
+ interface_removed_id = g_dbus_connection_signal_subscribe(g_conn,
+ NULL, BT_MANAGER_INTERFACE,
+ "InterfacesRemoved", NULL, NULL, 0,
+ __bt_manager_event_filter,
+ NULL, NULL);
+ }
+ } else {
+ if (service_added_id != -1) {
+ g_dbus_connection_signal_unsubscribe(g_conn,
+ service_added_id);
+ service_added_id = -1;
+ }
+ if (interface_removed_id != -1) {
+ g_dbus_connection_signal_unsubscribe(g_conn,
+ interface_removed_id);
+ interface_removed_id = -1;
+ }
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
+