*/
#include <string.h>
-#include <dbus/dbus.h>
#include <glib.h>
#include <dlog.h>
#include <vconf.h>
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;
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_device_deactivate();
+
+ _bluetooth_hid_free_hid_info();
+
BT_DBG("-");
return FALSE;
}
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);
_bt_common_event_cb(BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED,
result, &att_mtu_info,
event_info->cb, event_info->user_data);
-#ifdef GATT_NO_RELAY
} 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);
result, &profile_info,
event_info->cb, event_info->user_data);
}
- if (trust & (PROFILE_SUPPORTED <<2 )) { /* Bit 2 & 3 - for MAP Supported */
+ 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 */
+ if (trust & (1 << 3)) /* Bit 3 - for PBAP Trusted */
profile_info.trusted = TRUE;
else
profile_info.trusted = FALSE;
result, &profile_info,
event_info->cb, event_info->user_data);
}
- if (trust & (PROFILE_SUPPORTED <<4 )) { /* Bit 4 & 5- for SAP Supported */
+ 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 */
+ if (trust & (1 << 5)) /* Bit 5 - for SAP Trusted */
profile_info.trusted = TRUE;
else
profile_info.trusted = FALSE;
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);
}
}
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;
}
}
+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**) 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,
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) {
success = !result;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
BT_DBG("%s", list[i]);
BT_DBG("address: %s, result: %d, count: %d, success: %d",
list = (gchar **)g_variant_get_strv(string_var, &count);
success = !result;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
BT_DBG("%s", list[i]);
BT_DBG("address: %s success: %d", address, success);
_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,
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)
{
bt_event_info_t *info;
- while ((info = g_slist_nth_data(event_list, 0)) != NULL) {
+ while ((info = g_slist_nth_data(event_list, 0)) != NULL)
_bt_unregister_event(info->event_type);
- }
if (event_list) {
g_slist_free(event_list);
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);
}
path, secure_address);
return;
} else
- BT_INFO("GATT Service [%s] added : %s",
+ BT_INFO(" ### GATT Service added [%s] [%s]",
path, secure_address);
change.svc_path = g_strdup(path);
change.svc_path = g_strdup(path);
change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
- BT_INFO("GATT Service [%s] is removed : %s",
+ BT_INFO(" ### GATT Service removed [%s] [%s]",
path, secure_address);
user_info = _bt_get_user_data(BT_COMMON);