/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- * Girishashok Joshi <girish.joshi@samsung.com>
- * Chanyeol Park <chanyeol.park@samsung.com>
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "bt-service-rfcomm-server.h"
#include "bt-request-handler.h"
#include "bt-service-pbap.h"
+#include "bt-service-dpm.h"
+#include "bt-service-agent.h"
+#include "bt-service-proximity.h"
static GDBusConnection *bt_service_conn;
static guint owner_id = 0;
" </interface>"
"</node>";
-GDBusNodeInfo *node_info = NULL;
+static gboolean name_acquired = FALSE;
+
+static char *current_sender_playing = NULL;
static void __bt_service_method(GDBusConnection *connection,
const gchar *sender,
gpointer user_data)
{
FN_START;
+
BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
method_name, object_path, interface_name);
GVariant *out_var = NULL;
int result = 0;
int request_id = -1;
- char *sender = NULL;
+ const char *sender = NULL;
g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
&service_function, &request_type,
}
}
- BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
- service_type, service_function);
+ BT_DBG("Service type = %s, fn = %s (0x%x)", __bt_convert_service_type_to_string(service_type),
+ _bt_convert_service_function_to_string(service_function), service_function);
switch (service_type) {
case BT_BLUEZ_SERVICE:
result = __bt_bluez_request(service_function,
goto fail;
}
- if (result != BLUETOOTH_ERROR_NONE) {
+ if (result != BLUETOOTH_ERROR_NONE)
goto fail;
- }
if ((request_type == BT_ASYNC_REQ ||
service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) &&
GVariant *temp = g_variant_new("(iv)", result, out_var);
g_dbus_method_invocation_return_value(invocation, temp);
-
- g_array_free(out_param1, TRUE);
- out_param1 = NULL;
}
}
+ g_array_free(out_param1, TRUE);
g_variant_unref(param1);
g_variant_unref(param2);
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
-// g_free(sender);
FN_END;
return;
fail:
- BT_ERR_C("Request is failed [%s] [%x]",
+ BT_ERR_C("Request is failed [%s] [0x%x]",
_bt_convert_error_to_string(result), result);
out_var = g_variant_new_from_data((const GVariantType *)"ay",
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
-// g_free(sender);
}
FN_END;
result = _bt_recover_adapter();
break;
case BT_ENABLE_ADAPTER_LE:
+ _bt_set_le_intended_status(TRUE);
result = _bt_enable_adapter_le();
break;
case BT_DISABLE_ADAPTER_LE:
+ _bt_set_le_intended_status(FALSE);
result = _bt_disable_adapter_le();
break;
case BT_RESET_ADAPTER:
break;
}
+ case BT_IS_SCAN_FILTER_SUPPORTED:{
+ int is_supported = 0;
+
+ if (_bt_is_scan_filter_supported() == TRUE)
+ is_supported = 1;
+
+ g_array_append_vals(*out_param1,
+ &is_supported, sizeof(int));
+
+ break;
+ }
case BT_ENABLE_RSSI: {
bluetooth_device_address_t bd_addr;
int link_type;
int length = 0;
result = _bt_get_advertising_data(&adv, &length);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
g_array_append_vals(*out_param1, adv.data, length);
- }
+
break;
}
case BT_SET_ADVERTISING_DATA: {
int length = 0;
result = _bt_get_scan_response_data(&rsp, &length);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
g_array_append_vals(*out_param1, rsp.data, length);
- }
break;
}
break;
}
case BT_LE_CONN_UPDATE: {
+ char *sender = NULL;
bluetooth_device_address_t local_address = { {0} };
- bluetooth_le_conn_update_t parameters = {0};
+ bluetooth_le_connection_param_t parameters = {0};
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
__bt_service_get_parameters(in_param1, &local_address,
sizeof(bluetooth_device_address_t));
__bt_service_get_parameters(in_param2, ¶meters,
- sizeof(bluetooth_le_conn_update_t));
+ sizeof(bluetooth_le_connection_param_t));
- result = _bt_le_conn_update(local_address.addr,
+ result = _bt_le_conn_update(sender,
+ local_address.addr,
parameters.interval_min,
parameters.interval_max,
parameters.latency,
- parameters.time_out);
+ parameters.timeout);
break;
}
case BT_IS_ADVERTISING: {
result = _bt_get_bonded_devices(out_param1);
break;
}
+ case BT_GET_PROFILE_CONNECTED_DEVICES: {
+ char *uuid;
+ uuid = (char *)g_variant_get_data(in_param1);
+ result = _bt_get_profile_connected_devices(uuid, out_param1);
+ break;
+ }
+ case BT_SET_PASSKEY_NOTIFICATION: {
+ char *sender = NULL;
+ gboolean enable;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ __bt_service_get_parameters(in_param1,
+ &enable, sizeof(gboolean));
+
+ result = _bt_set_passkey_notification(sender, enable);
+ break;
+ }
case BT_GET_BONDED_DEVICE: {
bluetooth_device_address_t address = { {0} };
bluetooth_device_info_t dev_info;
}
break;
}
+ case BT_GET_IS_ALIAS_SET: {
+ bluetooth_device_address_t address = { {0} };
+ gboolean is_alias_set = FALSE;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_is_alias_set(&address, &is_alias_set);
+ if (result == BLUETOOTH_ERROR_NONE)
+ g_array_append_vals(*out_param1, &is_alias_set, sizeof(gboolean));
+
+ break;
+ }
+ case BT_DISCONNECT_DEVICE: {
+ bluetooth_device_address_t addr = { {0} };
+ char address[BLUETOOTH_ADDRESS_STRING_LENGTH + 1];
+
+ __bt_service_get_parameters(in_param1,
+ &addr, sizeof(bluetooth_device_address_t));
+ _bt_convert_addr_type_to_string(address, addr.addr);
+
+ result = _bt_disconnect_all(address);
+ break;
+ }
case BT_BOND_DEVICE: {
bluetooth_device_address_t address = { {0} };
result = _bt_cancel_bonding();
break;
}
+ case BT_PASSKEY_REPLY: {
+ const char *passkey = NULL;
+ gboolean authentication_reply = FALSE;
+
+ passkey = g_variant_get_data(in_param1);
+ __bt_service_get_parameters(in_param2,
+ &authentication_reply, sizeof(gboolean));
+ result = _bt_passkey_reply(passkey, authentication_reply);
+ break;
+ }
+ case BT_PASSKEY_CONFIRMATION_REPLY: {
+ gboolean confirmation_reply = FALSE;
+
+ __bt_service_get_parameters(in_param1,
+ &confirmation_reply, sizeof(gboolean));
+ result = _bt_passkey_confirmation_reply(confirmation_reply);
+ break;
+ }
case BT_UNBOND_DEVICE: {
bluetooth_device_address_t address = { {0} };
break;
}
+ case BT_SET_PIN_CODE: {
+ bluetooth_device_address_t address = { {0} };
+ bluetooth_device_pin_code_t pin_code = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &pin_code, sizeof(bluetooth_device_pin_code_t));
+
+ result = _bt_set_pin_code(&address, &pin_code);
+ break;
+ }
+ case BT_UNSET_PIN_CODE: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_unset_pin_code(&address);
+ break;
+ }
+ case BT_UPDATE_LE_CONNECTION_MODE: {
+ char *sender = NULL;
+ bluetooth_device_address_t remote_address = { { 0 } };
+ bluetooth_le_connection_param_t param = { 0 };
+ bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
+
+ __bt_service_get_parameters(in_param1, &remote_address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &mode,
+ sizeof(bluetooth_le_connection_mode_t));
+
+ result = _bt_get_le_connection_parameter(mode, ¶m);
+ if (result != BLUETOOTH_ERROR_NONE)
+ break;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ result = _bt_le_conn_update(sender,
+ remote_address.addr,
+ param.interval_min,
+ param.interval_max,
+ param.latency,
+ param.timeout);
+ break;
+ }
+
+ case BT_SET_PROFILE_TRUSTED: {
+ bluetooth_device_address_t bd_addr = { {0} };
+ int profile;
+ int trust;
+
+ __bt_service_get_parameters(in_param1, &bd_addr,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+ __bt_service_get_parameters(in_param3, &trust, sizeof(int));
+
+ result = _bt_set_trust_profile(&bd_addr, profile, trust);
+ break;
+ }
+ case BT_GET_PROFILE_TRUSTED: {
+ bluetooth_device_address_t bd_addr = { {0} };
+ int profile;
+ guint trusted_profile = 0;
+
+ __bt_service_get_parameters(in_param1, &bd_addr,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+
+ result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
+ BT_DBG("TRUST %d", trusted_profile);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &trusted_profile,
+ sizeof(guint));
+ }
+
+ break;
+ }
+ case BT_SET_PROFILE_RESTRICTED: {
+ bluetooth_device_address_t bd_addr = { {0} };
+ int profile;
+ int restricted;
+ __bt_service_get_parameters(in_param1, &bd_addr,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+ __bt_service_get_parameters(in_param3, &restricted, sizeof(int));
+
+ result = _bt_set_restrict_profile(&bd_addr, profile, restricted);
+ break;
+ }
+ case BT_GET_PROFILE_RESTRICTED: {
+ bluetooth_device_address_t bd_addr = { {0} };
+ int profile;
+ guint restricted_profile = 0;
+
+ __bt_service_get_parameters(in_param1, &bd_addr,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+
+ result = _bt_get_restrict_profile(&bd_addr, profile, &restricted_profile);
+ BT_DBG("Restricted %d", restricted_profile);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &restricted_profile,
+ sizeof(guint));
+ }
+
+ break;
+ }
case BT_HID_CONNECT: {
bluetooth_device_address_t address = { {0} };
}
break;
}
+ case BT_HID_ENABLE_BARCODE_FEATURE: {
+ result = _bt_hid_enable_barcode_feature();
+ break;
+ }
case BT_NETWORK_ACTIVATE:
result = _bt_network_activate();
break;
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_connect(request_id, BT_AUDIO_ALL,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AUDIO_DISCONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_disconnect(request_id, BT_AUDIO_ALL,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AG_CONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_connect(request_id, BT_AUDIO_HSP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AG_DISCONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_disconnect(request_id, BT_AUDIO_HSP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AV_CONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_connect(request_id, BT_AUDIO_A2DP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AV_DISCONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_disconnect(request_id, BT_AUDIO_A2DP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AVRCP_CONTROL_CONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_connect(request_id, BT_AVRCP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AVRCP_CONTROL_DISCONNECT: {
&address, sizeof(bluetooth_device_address_t));
result = _bt_audio_disconnect(request_id, BT_AVRCP,
- &address, out_param1);
+ &address, *out_param1);
break;
}
+ case BT_AVRCP_TARGET_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ result = _bt_audio_connect(request_id, BT_AVRCP_TARGET,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AVRCP_TARGET_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ result = _bt_audio_disconnect(request_id, BT_AVRCP_TARGET,
+ &address, *out_param1);
+ break;
+ }
case BT_AV_SOURCE_CONNECT: {
bluetooth_device_address_t address = { {0} };
sizeof(bluetooth_device_address_t));
result = _bt_audio_connect(request_id, BT_AUDIO_A2DP_SOURCE,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_AV_SOURCE_DISCONNECT: {
sizeof(bluetooth_device_address_t));
result = _bt_audio_disconnect(request_id, BT_AUDIO_A2DP_SOURCE,
- &address, out_param1);
+ &address, *out_param1);
break;
}
case BT_HF_CONNECT: {
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_hf_connect(request_id, &address, out_param1);
+ result = _bt_hf_connect(request_id, &address, *out_param1);
break;
}
case BT_HF_DISCONNECT: {
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_hf_disconnect(request_id, &address, out_param1);
+ result = _bt_hf_disconnect(request_id, &address, *out_param1);
break;
}
case BT_SET_CONTENT_PROTECT: {
}
case BT_OOB_ADD_REMOTE_DATA: {
bluetooth_device_address_t address = { {0} };
- bt_oob_data_t local_oob_data;
+ bt_oob_data_t remote_oob_data;
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
__bt_service_get_parameters(in_param2,
- &local_oob_data, sizeof(bt_oob_data_t));
+ &remote_oob_data, sizeof(bt_oob_data_t));
- result = _bt_oob_add_remote_data(&address, &local_oob_data);
+ result = _bt_oob_add_remote_data(&address, &remote_oob_data);
break;
}
meta_data.number = data.number;
meta_data.duration = (int64_t) data.duration;
+ if (meta_data.title)
+ BT_INFO("title [%s]", meta_data.title);
+ if (meta_data.artist)
+ BT_INFO("artist [%s]", meta_data.artist);
+ if (meta_data.album)
+ BT_INFO("album [%s]", meta_data.album);
+ if (meta_data.genre)
+ BT_INFO("genre [%s]", meta_data.genre);
+ BT_INFO("total_tracks[%d], number[%d], duration[%d]",
+ meta_data.total_tracks, meta_data.number, meta_data.duration);
+
result = _bt_avrcp_set_track_info(&meta_data);
g_free((gpointer)meta_data.title);
case BT_AVRCP_SET_PROPERTY: {
int type;
unsigned int value;
+ char *sender = NULL;
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ BT_INFO("Sender %s", sender);
__bt_service_get_parameters(in_param1,
&type, sizeof(int));
__bt_service_get_parameters(in_param2,
&value, sizeof(unsigned int));
+ if (value == STATUS_PLAYING) {
+ if (current_sender_playing)
+ g_free(current_sender_playing);
+ current_sender_playing = g_strdup(sender);
+ }
+ if (g_strcmp0(sender, current_sender_playing) == 0 ||
+ current_sender_playing == NULL) {
+ BT_INFO("Current Player Status %d type %d", value, type);
+ } else {
+ BT_INFO("Current Player and this sender are different");
+ result = BLUETOOTH_ERROR_NONE;
+ break;
+ }
result = _bt_avrcp_set_property(type, value);
break;
break;
}
case BT_RFCOMM_CLIENT_CONNECT: {
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
result = BLUETOOTH_ERROR_NONE;
#else
bluetooth_device_address_t address = { {0} };
break;
}
case BT_RFCOMM_SOCKET_DISCONNECT: {
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
result = BLUETOOTH_ERROR_NONE;
#else
int socket_fd;
break;
}
case BT_RFCOMM_SOCKET_WRITE: {
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
result = BLUETOOTH_ERROR_NONE;
#else
int socket_fd;
break;
}
case BT_RFCOMM_CREATE_SOCKET: {
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
result = BLUETOOTH_ERROR_NONE;
#else
char *sender;
char *uuid;
int socket_fd = -1;
- sender = dbus_g_method_get_sender(context);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
uuid = &g_array_index(in_param1, char, 0);
result = _bt_rfcomm_create_socket(sender, uuid);
break;
}
case BT_RFCOMM_REMOVE_SOCKET: {
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
result = BLUETOOTH_ERROR_NONE;
#else
int socket_fd;
__bt_service_get_parameters(in_param2,
&auto_connect, sizeof(gboolean));
- result = _bt_connect_le_device(&address, auto_connect);
+ result = _bt_connect_le_device(request_id, &address,
+ auto_connect);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
}
__bt_service_get_parameters(in_param1, &address,
sizeof(bluetooth_device_address_t));
- result = _bt_disconnect_le_device(&address);
+ result = _bt_disconnect_le_device(request_id, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
}
break;
}
+ case BT_REQ_ATT_MTU: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int mtu;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &mtu, sizeof(unsigned int));
+
+ result = _bt_request_att_mtu(request_id, &address, mtu);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_info_t));
+ }
+ break;
+ }
+ case BT_GET_ATT_MTU: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int mtu = 0;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_get_att_mtu(&address, &mtu);
+ BT_DBG("MTU: %d", mtu);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &mtu,
+ sizeof(unsigned int));
+ }
+ break;
+ }
+ case BT_GET_DEVICE_IDA: {
+ bluetooth_device_address_t address = { {0} };
+ bluetooth_device_address_t id_addr = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_get_device_ida(&address, &id_addr);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &id_addr,
+ sizeof(bluetooth_device_address_t));
+ }
+ break;
+ }
+ case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
+ gboolean is_enable;
+
+ __bt_service_get_parameters(in_param1, &is_enable,
+ sizeof(gboolean));
+
+ result = _bt_set_le_static_random_address(is_enable);
+
+ break;
+ }
case BT_HDP_CONNECT:
case BT_HDP_DISCONNECT:
case BT_HDP_SEND_DATA:
case BT_GATT_SET_PROPERTY_REQUEST:
case BT_GATT_READ_CHARACTERISTIC:
case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
+
+ case BT_HID_DEVICE_ACTIVATE:
+ case BT_HID_DEVICE_DEACTIVATE:
+ case BT_HID_DEVICE_CONNECT:
+ case BT_HID_DEVICE_DISCONNECT:
+ case BT_HID_DEVICE_SEND_MOUSE_EVENT:
+ case BT_HID_DEVICE_SEND_KEY_EVENT:
+ case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
/* Just call to check the privilege */
break;
- default:
- result = BLUETOOTH_ERROR_INTERNAL;
+#ifndef GATT_NO_RELAY
+ case BT_GATT_WATCH_CHARACTERISTIC: {
+ char *sender = NULL;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ result = _bt_insert_gatt_client_sender(sender);
+
break;
}
+ case BT_GATT_UNWATCH_CHARACTERISTIC: {
+ char *sender = NULL;
- return result;
-}
-
-int __bt_obexd_request(int function_name,
- int request_type,
- int request_id,
- GDBusMethodInvocation *context,
- GVariant *in_param1,
- GVariant *in_param2,
- GVariant *in_param3,
- GVariant *in_param4,
- GArray **out_param1)
-{
- BT_DBG("+");
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- int result;
+ result = _bt_delete_gatt_client_sender(sender);
- BT_DBG("function_name : %x", function_name);
+ break;
+ }
+#endif
+ case BT_LE_IPSP_INIT:
+ result = _bt_initialize_ipsp();
+ break;
+ case BT_LE_IPSP_DEINIT:
+ result = _bt_deinitialize_ipsp();
+ break;
+ case BT_LE_IPSP_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
- switch (function_name) {
- case BT_OPP_PUSH_FILES: {
- BT_DBG("BT_OPP_PUSH_FILES");
- int i;
+ result = _bt_connect_le_ipsp_device(&address);
+ break;
+ }
+ case BT_LE_IPSP_DISCONNECT: {
bluetooth_device_address_t address = { {0} };
- bt_file_path_t path;
- char **file_path;
- int file_count;
- GArray *param2;
__bt_service_get_parameters(in_param1, &address,
sizeof(bluetooth_device_address_t));
- __bt_service_get_parameters(in_param3, &file_count,
- sizeof(int));
- file_path = g_new0(char *, file_count + 1);
+ result = _bt_disconnect_le_ipsp_device(&address);
+ break;
+ }
+ case BT_LE_READ_MAXIMUM_DATA_LENGTH: {
+ bluetooth_le_read_maximum_data_length_t max_le_datalength = {0};
- param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
- __bt_fill_garray_from_variant(in_param2, param2);
+ result = _bt_le_read_maximum_data_length(&max_le_datalength);
- for (i = 0; i < file_count; i++) {
- path = g_array_index(param2, bt_file_path_t, i);
- file_path[i] = g_strdup(path.path);
- }
- BT_DBG("_bt_opp_client_push_files");
- result = _bt_opp_client_push_files(request_id, context,
- &address, file_path,
- file_count);
+ g_array_append_vals(*out_param1, &max_le_datalength,
+ sizeof(bluetooth_le_read_maximum_data_length_t));
+ break;
+ }
+ case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH: {
+ unsigned int def_tx_Octects = 0;
+ unsigned int def_tx_Time = 0;
- for (i = 0; i < file_count; i++) {
- g_free(file_path[i]);
- }
- g_free(file_path);
- g_array_free(param2, TRUE);
+ __bt_service_get_parameters(in_param1,
+ &def_tx_Octects, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &def_tx_Time, sizeof(int));
+ result = _bt_le_write_host_suggested_default_data_length(
+ def_tx_Octects, def_tx_Time);
break;
}
- case BT_OPP_CANCEL_PUSH: {
- result = _bt_opp_client_cancel_push();
+ case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH: {
+ bluetooth_le_read_host_suggested_data_length_t def_data_length = {0};
+
+ result = _bt_le_read_host_suggested_default_data_length(&def_data_length);
+
+ g_array_append_vals(*out_param1, &def_data_length,
+ sizeof(bluetooth_le_read_host_suggested_data_length_t));
break;
}
- case BT_OPP_IS_PUSHING_FILES: {
- gboolean is_sending = FALSE;
+ case BT_LE_SET_DATA_LENGTH: {
+ int max_tx_Octets = 0;
+ int max_tx_Time = 0;
+ bluetooth_device_address_t address = { {0} };
- result = _bt_opp_client_is_sending(&is_sending);
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &max_tx_Octets, sizeof(int));
+ __bt_service_get_parameters(in_param3,
+ &max_tx_Time, sizeof(int));
+
+ result = _bt_le_set_data_length(&address, max_tx_Octets, max_tx_Time);
+ break;
+ }
+ case BT_DPM_SET_ALLOW_BT_MODE: {
+ dpm_bt_allow_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_allow_bluetooth_mode(value);
+ break;
+ }
+ case BT_DPM_GET_ALLOW_BT_MODE: {
+ dpm_bt_allow_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_allow_bluetooth_mode();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_DEVICE_RESTRITION: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_activate_bluetooth_device_restriction(value);
+ break;
+ }
+ case BT_DPM_GET_DEVICE_RESTRITION: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_is_bluetooth_device_restriction_active();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_UUID_RESTRITION: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
+ break;
+ }
+ case BT_DPM_GET_UUID_RESTRITION: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_is_bluetooth_uuid_restriction_active();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_ADD_DEVICES_BLACKLIST: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
+ break;
+ }
+ case BT_DPM_ADD_DEVICES_WHITELIST: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
+ break;
+ }
+ case BT_DPM_ADD_UUIDS_BLACKLIST: {
+ const char *uuid = NULL;
+
+ uuid = g_variant_get_data(in_param1);
+
+ result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
+ break;
+ }
+ case BT_DPM_ADD_UUIDS_WHITELIST: {
+ const char *uuid = NULL;
+
+ uuid = g_variant_get_data(in_param1);
+
+ result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
+ break;
+ }
+ case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
+ result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
+ break;
+ }
+ case BT_DPM_CLEAR_DEVICES_WHITELIST: {
+ result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
+ break;
+ }
+ case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
+ result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
+ break;
+ }
+ case BT_DPM_CLEAR_UUIDS_WHITELIST: {
+ result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
+ break;
+ }
+ case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
+ break;
+ }
+ case BT_DPM_REMOVE_DEVICE_WHITELIST: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
+ break;
+ }
+ case BT_DPM_REMOVE_UUID_BLACKLIST: {
+ const char *uuid = NULL;
+
+ uuid = g_variant_get_data(in_param1);
+
+ result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
+ break;
+ }
+ case BT_DPM_REMOVE_UUID_WHITELIST: {
+ const char *uuid = NULL;
+
+ uuid = g_variant_get_data(in_param1);
+
+ result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
+
+ break;
+ }
+ case BT_DPM_GET_DEVICES_BLACKLIST: {
+ result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
+ break;
+ }
+ case BT_DPM_GET_DEVICES_WHITELIST: {
+ result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
+ break;
+ }
+ case BT_DPM_GET_UUIDS_BLACKLIST: {
+ result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
+ break;
+ }
+ case BT_DPM_GET_UUIDS_WHITELIST: {
+ result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
+ break;
+ }
+ case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
+
+ break;
+ }
+ case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_allow_bluetooth_outgoing_call();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_PAIRING_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_pairing_state(value);
+
+ break;
+ }
+ case BT_DPM_GET_PAIRING_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_bluetooth_pairing_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_PROFILE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+ dpm_profile_t profile = DPM_PROFILE_NONE;
+
+ __bt_service_get_parameters(in_param1, &profile,
+ sizeof(int));
+ __bt_service_get_parameters(in_param2, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_profile_state(profile, value);
+
+ break;
+ }
+ case BT_DPM_GET_PROFILE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+ dpm_profile_t profile = DPM_PROFILE_NONE;
+
+ __bt_service_get_parameters(in_param2, &profile,
+ sizeof(int));
+
+ value = _bt_dpm_get_bluetooth_profile_state(profile);
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
+
+ break;
+ }
+ case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_bluetooth_desktop_connectivity_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_DISCOVERABLE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_discoverable_state(value);
+
+ break;
+ }
+ case BT_DPM_GET_DISCOVERABLE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_bluetooth_discoverable_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
+
+ break;
+ }
+ case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_bluetooth_limited_discoverable_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_DPM_SET_DATA_TRANSFER_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_data_transfer_state(value);
+
+ break;
+ }
+ case BT_DPM_GET_DATA_TRANSFER_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
+
+ value = _bt_dpm_get_allow_bluetooth_data_transfer_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_PXP_SET_PROPERTY: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
+ unsigned int value = 0;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &property, sizeof(int));
+ __bt_service_get_parameters(in_param3,
+ &value, sizeof(int));
+
+ result = bt_set_proximity_property(&address, property, value);
+ break;
+ }
+ case BT_PXP_GET_PROPERTY: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
+ int value = 0;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &property, sizeof(unsigned int));
+
+ result = bt_get_proximity_property(&address, property, &value);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &value,
+ sizeof(int));
+ }
+ break;
+ }
+ case BT_PXP_GET_SUPPORTED_SERIVCES: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = bt_get_proximity_supported_services(&address, &property);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &property,
+ sizeof(int));
+ }
+ break;
+ }
+ case BT_PXP_REGISTER_REPORTER: {
+ result = bt_register_proximity_reporter();
+ break;
+ }
+ case BT_PXP_UNREGISTER_REPORTER: {
+ result = bt_unregister_proximity_reporter();
+ break;
+ }
+ default:
+ result = BLUETOOTH_ERROR_INTERNAL;
+ break;
+ }
+
+ return result;
+}
+
+int __bt_obexd_request(int function_name,
+ int request_type,
+ int request_id,
+ GDBusMethodInvocation *context,
+ GVariant *in_param1,
+ GVariant *in_param2,
+ GVariant *in_param3,
+ GVariant *in_param4,
+ GArray **out_param1)
+{
+ BT_DBG("+");
+
+ int result;
+
+ BT_DBG("function_name : %x", function_name);
+
+ switch (function_name) {
+ case BT_OPP_PUSH_FILES: {
+ BT_DBG("BT_OPP_PUSH_FILES");
+ int i;
+ bluetooth_device_address_t address = { {0} };
+ bt_file_path_t *path;
+ char **file_path;
+ int file_count;
+ GArray *param2;
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param3, &file_count,
+ sizeof(int));
+
+ file_path = g_new0(char *, file_count + 1);
+
+ param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+ __bt_fill_garray_from_variant(in_param2, param2);
+
+ for (i = 0; i < file_count; i++) {
+ path = &g_array_index(param2, bt_file_path_t, i);
+ file_path[i] = g_strdup(path->path);
+ }
+ BT_DBG("_bt_opp_client_push_files");
+ result = _bt_opp_client_push_files(request_id, context,
+ &address, file_path,
+ file_count);
+
+ for (i = 0; i < file_count; i++)
+ g_free(file_path[i]);
+
+ g_free(file_path);
+ g_array_free(param2, TRUE);
+
+ break;
+ }
+ case BT_OPP_CANCEL_PUSH: {
+ result = _bt_opp_client_cancel_push();
+
+ break;
+ }
+ case BT_OPP_IS_PUSHING_FILES: {
+ gboolean is_sending = FALSE;
+
+ result = _bt_opp_client_is_sending(&is_sending);
+
+ g_array_append_vals(*out_param1, &is_sending,
+ sizeof(gboolean));
+ break;
+ }
+ case BT_OPP_GET_TRANSFER_PROGRESS: {
+ int direction;
+ int transfer_id;
+ guint8 progress = 0;
+
+ __bt_service_get_parameters(in_param1, &direction,
+ sizeof(int));
+ __bt_service_get_parameters(in_param2, &transfer_id,
+ sizeof(int));
+ if (direction)
+ result = _bt_opp_get_client_progress(&progress);
+ else
+ result = _bt_opp_get_server_progress(transfer_id, &progress);
+
+ g_array_append_vals(*out_param1, &progress,
+ sizeof(guint8));
- g_array_append_vals(*out_param1, &is_sending,
- sizeof(gboolean));
break;
}
case BT_OBEX_SERVER_ALLOCATE: {
int service_type,
const char *unique_name)
{
- int ret_val;
- gboolean result = TRUE;
- char *client_creds = NULL;
- char *user_creds = NULL;
- char *client_session = "";
- int client_creds_method = CLIENT_METHOD_SMACK;
- int user_creds_method = USER_METHOD_UID;
- char err_msg[256] = {0, };
-
- retv_if(unique_name == NULL, FALSE);
-
- BT_DBG("unique_name: %s", unique_name);
-
- retv_if(bt_service_conn == NULL, FALSE);
-
- ret_val = cynara_creds_get_default_client_method(&client_creds_method);
- if (ret_val != CYNARA_API_SUCCESS) {
- cynara_strerror(ret_val, err_msg, sizeof(err_msg));
- BT_ERR("Fail to get default client method: %s", err_msg);
- return FALSE;
- }
-
- ret_val = cynara_creds_get_default_user_method(&user_creds_method);
- if (ret_val != CYNARA_API_SUCCESS) {
- cynara_strerror(ret_val, err_msg, sizeof(err_msg));
- BT_ERR("Fail to get default user method: %s", err_msg);
- return FALSE;
- }
-
- ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
- if (ret_val != CYNARA_API_SUCCESS) {
- cynara_strerror(ret_val, err_msg, sizeof(err_msg));
- BT_ERR("Fail to get client credential: %s", err_msg);
- return FALSE;
- }
-
- BT_DBG("client_creds: %s", client_creds);
-
- ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
- if (ret_val != CYNARA_API_SUCCESS) {
- cynara_strerror(ret_val, err_msg, sizeof(err_msg));
- BT_ERR("Fail to get user credential: %s", err_msg);
- if (client_creds)
- free(client_creds);
- return FALSE;
- }
-
- BT_DBG("user_creds: %s", user_creds);
-
- switch (function_name) {
- case BT_SET_LOCAL_NAME:
- case BT_START_DISCOVERY:
- case BT_START_CUSTOM_DISCOVERY:
- case BT_CANCEL_DISCOVERY:
- case BT_OOB_ADD_REMOTE_DATA:
- case BT_OOB_REMOVE_REMOTE_DATA:
- case BT_SET_ADVERTISING:
- case BT_SET_CUSTOM_ADVERTISING:
- case BT_SET_ADVERTISING_PARAMETERS:
- case BT_START_LE_DISCOVERY:
- case BT_STOP_LE_DISCOVERY:
-
- case BT_BOND_DEVICE:
- case BT_CANCEL_BONDING:
- case BT_UNBOND_DEVICE:
- case BT_SET_ALIAS:
- case BT_SET_AUTHORIZATION:
- case BT_UNSET_AUTHORIZATION:
- case BT_SEARCH_SERVICE:
-
- case BT_RFCOMM_CLIENT_CONNECT:
- case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
- case BT_RFCOMM_SOCKET_DISCONNECT:
- case BT_RFCOMM_SOCKET_WRITE:
- case BT_RFCOMM_CREATE_SOCKET:
- case BT_RFCOMM_REMOVE_SOCKET:
-
- case BT_OPP_PUSH_FILES:
- case BT_OPP_CANCEL_PUSH:
-
- case BT_OBEX_SERVER_ACCEPT_CONNECTION:
- case BT_OBEX_SERVER_REJECT_CONNECTION:
- case BT_OBEX_SERVER_ACCEPT_FILE:
- case BT_OBEX_SERVER_REJECT_FILE:
- case BT_OBEX_SERVER_SET_PATH:
- case BT_OBEX_SERVER_SET_ROOT:
- case BT_OBEX_SERVER_CANCEL_TRANSFER:
- case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
-
- case BT_AUDIO_CONNECT:
- case BT_AUDIO_DISCONNECT:
- case BT_AG_CONNECT:
- case BT_AG_DISCONNECT:
- case BT_AV_CONNECT:
- case BT_AV_DISCONNECT:
- case BT_AVRCP_CONTROL_CONNECT:
- case BT_AVRCP_CONTROL_DISCONNECT:
- case BT_HF_CONNECT:
- case BT_HF_DISCONNECT:
-
- case BT_HID_CONNECT:
- case BT_HID_DISCONNECT:
-
- case BT_CONNECT_LE:
- case BT_DISCONNECT_LE:
-
- case BT_SET_ADVERTISING_DATA:
- case BT_SET_SCAN_RESPONSE_DATA:
-
- case BT_HDP_CONNECT:
- case BT_HDP_DISCONNECT:
- case BT_HDP_SEND_DATA:
-
- case BT_NETWORK_ACTIVATE:
- case BT_NETWORK_DEACTIVATE:
- case BT_NETWORK_CONNECT:
- case BT_NETWORK_DISCONNECT:
- case BT_NETWORK_SERVER_DISCONNECT:
-
- case BT_GATT_GET_PRIMARY_SERVICES:
- case BT_GATT_DISCOVER_CHARACTERISTICS:
- case BT_GATT_SET_PROPERTY_REQUEST:
- case BT_GATT_READ_CHARACTERISTIC:
- case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
- ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
- BT_PRIVILEGE_PUBLIC);
-
- if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
- BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
- result = FALSE;
- }
- break;
-
- case BT_ENABLE_ADAPTER:
- case BT_DISABLE_ADAPTER:
- case BT_RESET_ADAPTER:
- case BT_RECOVER_ADAPTER:
- case BT_ENABLE_ADAPTER_LE:
- case BT_DISABLE_ADAPTER_LE:
- case BT_SET_CONNECTABLE:
- case BT_SET_DISCOVERABLE_MODE:
- case BT_ADD_WHITE_LIST:
- case BT_REMOVE_WHITE_LIST:
- case BT_CLEAR_WHITE_LIST:
- case BT_SET_MANUFACTURER_DATA:
- case BT_SET_SCAN_PARAMETERS:
-
- case BT_CANCEL_SEARCH_SERVICE:
- case BT_ENABLE_RSSI:
-
- case BT_RFCOMM_ACCEPT_CONNECTION:
- case BT_RFCOMM_REJECT_CONNECTION:
- case BT_RFCOMM_LISTEN:
-
- case BT_AVRCP_SET_TRACK_INFO:
- case BT_AVRCP_SET_PROPERTY:
- case BT_AVRCP_SET_PROPERTIES:
- case BT_AVRCP_HANDLE_CONTROL:
- case BT_AVRCP_CONTROL_SET_PROPERTY:
- case BT_AVRCP_CONTROL_GET_PROPERTY:
- case BT_AVRCP_GET_TRACK_INFO:
-
- case BT_SET_CONTENT_PROTECT:
- case BT_BOND_DEVICE_BY_TYPE:
- case BT_SET_LE_PRIVACY:
- case BT_LE_CONN_UPDATE:
- ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
- BT_PRIVILEGE_PLATFORM);
-
- if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
- BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
- result = FALSE;
- }
- break;
-
- case BT_CHECK_ADAPTER:
- case BT_GET_RSSI:
-
- case BT_GET_LOCAL_NAME:
- case BT_GET_LOCAL_ADDRESS:
- case BT_GET_LOCAL_VERSION:
- case BT_IS_SERVICE_USED:
- case BT_GET_DISCOVERABLE_MODE:
- case BT_GET_DISCOVERABLE_TIME:
- case BT_IS_DISCOVERYING:
- case BT_IS_LE_DISCOVERYING:
- case BT_IS_CONNECTABLE:
- case BT_GET_BONDED_DEVICES:
- case BT_GET_BONDED_DEVICE:
- case BT_IS_DEVICE_CONNECTED:
- case BT_GET_SPEAKER_GAIN:
- case BT_SET_SPEAKER_GAIN:
- case BT_OOB_READ_LOCAL_DATA:
- case BT_RFCOMM_CLIENT_IS_CONNECTED:
- case BT_RFCOMM_IS_UUID_AVAILABLE:
- case BT_GET_ADVERTISING_DATA:
- case BT_GET_SCAN_RESPONSE_DATA:
- case BT_IS_ADVERTISING:
-
- case BT_OBEX_SERVER_ALLOCATE:
- case BT_OBEX_SERVER_DEALLOCATE:
-
- /* Non-privilege control */
- break;
- default:
- BT_ERR("Unknown function!");
- result = FALSE;
- break;
- }
-
- if (client_creds)
- free(client_creds);
-
- if (user_creds)
- free(user_creds);
-
- return result;
+ int ret_val;
+ gboolean result = TRUE;
+ char *client_creds = NULL;
+ char *user_creds = NULL;
+ char *client_session = "";
+ enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
+ enum cynara_user_creds user_creds_method = USER_METHOD_UID;
+ char err_msg[256] = {0, };
+
+ retv_if(unique_name == NULL, FALSE);
+ retv_if(bt_service_conn == NULL, FALSE);
+
+ ret_val = cynara_creds_get_default_client_method(&client_creds_method);
+ if (ret_val != CYNARA_API_SUCCESS) {
+ cynara_strerror(ret_val, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to get default client method: %s", err_msg);
+ return FALSE;
+ }
+
+ ret_val = cynara_creds_get_default_user_method(&user_creds_method);
+ if (ret_val != CYNARA_API_SUCCESS) {
+ cynara_strerror(ret_val, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to get default user method: %s", err_msg);
+ return FALSE;
+ }
+
+ ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
+ if (ret_val != CYNARA_API_SUCCESS) {
+ cynara_strerror(ret_val, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to get client credential: %s", err_msg);
+ return FALSE;
+ }
+
+ ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
+ if (ret_val != CYNARA_API_SUCCESS) {
+ cynara_strerror(ret_val, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to get user credential: %s", err_msg);
+ if (client_creds)
+ free(client_creds);
+ return FALSE;
+ }
+
+ BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
+
+ switch (function_name) {
+ case BT_SET_LOCAL_NAME:
+ case BT_START_DISCOVERY:
+ case BT_START_CUSTOM_DISCOVERY:
+ case BT_CANCEL_DISCOVERY:
+ case BT_OOB_ADD_REMOTE_DATA:
+ case BT_OOB_REMOVE_REMOTE_DATA:
+ case BT_SET_ADVERTISING:
+ case BT_SET_CUSTOM_ADVERTISING:
+ case BT_SET_ADVERTISING_PARAMETERS:
+ case BT_START_LE_DISCOVERY:
+ case BT_STOP_LE_DISCOVERY:
+ case BT_SET_SCAN_PARAMETERS:
+
+ case BT_BOND_DEVICE:
+ case BT_CANCEL_BONDING:
+ case BT_UNBOND_DEVICE:
+ case BT_SET_ALIAS:
+ case BT_SET_AUTHORIZATION:
+ case BT_UNSET_AUTHORIZATION:
+ case BT_SEARCH_SERVICE:
+
+ case BT_RFCOMM_CLIENT_CONNECT:
+ case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
+ case BT_RFCOMM_SOCKET_DISCONNECT:
+ case BT_RFCOMM_SOCKET_WRITE:
+ case BT_RFCOMM_CREATE_SOCKET:
+ case BT_RFCOMM_REMOVE_SOCKET:
+
+ case BT_OPP_PUSH_FILES:
+ case BT_OPP_CANCEL_PUSH:
+
+ case BT_OBEX_SERVER_ACCEPT_CONNECTION:
+ case BT_OBEX_SERVER_REJECT_CONNECTION:
+ case BT_OBEX_SERVER_ACCEPT_FILE:
+ case BT_OBEX_SERVER_REJECT_FILE:
+ case BT_OBEX_SERVER_SET_PATH:
+ case BT_OBEX_SERVER_SET_ROOT:
+ case BT_OBEX_SERVER_CANCEL_TRANSFER:
+ case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
+
+ case BT_AUDIO_CONNECT:
+ case BT_AUDIO_DISCONNECT:
+ case BT_AG_CONNECT:
+ case BT_AG_DISCONNECT:
+ case BT_AV_CONNECT:
+ case BT_AV_DISCONNECT:
+ case BT_AV_SOURCE_CONNECT:
+ case BT_AV_SOURCE_DISCONNECT:
+ case BT_AVRCP_CONTROL_CONNECT:
+ case BT_AVRCP_CONTROL_DISCONNECT:
+ case BT_AVRCP_HANDLE_CONTROL:
+ case BT_AVRCP_SET_TRACK_INFO:
+ case BT_AVRCP_SET_PROPERTY:
+ case BT_AVRCP_SET_PROPERTIES:
+ case BT_AVRCP_CONTROL_SET_PROPERTY:
+
+ case BT_HF_CONNECT:
+ case BT_HF_DISCONNECT:
+
+ case BT_HID_CONNECT:
+ case BT_HID_DISCONNECT:
+
+ case BT_HID_DEVICE_ACTIVATE:
+ case BT_HID_DEVICE_DEACTIVATE:
+ case BT_HID_DEVICE_CONNECT:
+ case BT_HID_DEVICE_DISCONNECT:
+ case BT_HID_DEVICE_SEND_MOUSE_EVENT:
+ case BT_HID_DEVICE_SEND_KEY_EVENT:
+ case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
+ case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
+
+ case BT_CONNECT_LE:
+ case BT_DISCONNECT_LE:
+
+ case BT_SET_ADVERTISING_DATA:
+ case BT_SET_SCAN_RESPONSE_DATA:
+
+ case BT_HDP_CONNECT:
+ case BT_HDP_DISCONNECT:
+ case BT_HDP_SEND_DATA:
+ case BT_HDP_REGISTER_SINK_APP:
+ case BT_HDP_UNREGISTER_SINK_APP:
+
+ case BT_DPM_SET_ALLOW_BT_MODE:
+ case BT_DPM_GET_ALLOW_BT_MODE:
+ case BT_DPM_SET_DEVICE_RESTRITION:
+ case BT_DPM_GET_DEVICE_RESTRITION:
+ case BT_DPM_SET_UUID_RESTRITION:
+ case BT_DPM_GET_UUID_RESTRITION:
+ case BT_DPM_ADD_DEVICES_BLACKLIST:
+ case BT_DPM_ADD_DEVICES_WHITELIST:
+ case BT_DPM_ADD_UUIDS_BLACKLIST:
+ case BT_DPM_ADD_UUIDS_WHITELIST:
+ case BT_DPM_CLEAR_DEVICES_BLACKLIST:
+ case BT_DPM_CLEAR_DEVICES_WHITELIST:
+ case BT_DPM_CLEAR_UUIDS_BLACKLIST:
+ case BT_DPM_CLEAR_UUIDS_WHITELIST:
+ case BT_DPM_REMOVE_DEVICE_BLACKLIST:
+ case BT_DPM_REMOVE_DEVICE_WHITELIST:
+ case BT_DPM_REMOVE_UUID_BLACKLIST:
+ case BT_DPM_REMOVE_UUID_WHITELIST:
+ case BT_DPM_GET_DEVICES_BLACKLIST:
+ case BT_DPM_GET_DEVICES_WHITELIST:
+ case BT_DPM_GET_UUIDS_BLACKLIST:
+ case BT_DPM_GET_UUIDS_WHITELIST:
+ case BT_DPM_SET_ALLOW_OUTGOING_CALL:
+ case BT_DPM_GET_ALLOW_OUTGOING_CALL:
+ case BT_DPM_SET_PAIRING_STATE:
+ case BT_DPM_GET_PAIRING_STATE:
+ case BT_DPM_SET_PROFILE_STATE:
+ case BT_DPM_GET_PROFILE_STATE:
+ case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
+ case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
+ case BT_DPM_SET_DISCOVERABLE_STATE:
+ case BT_DPM_GET_DISCOVERABLE_STATE:
+ case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
+ case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
+ case BT_DPM_SET_DATA_TRANSFER_STATE:
+ case BT_DPM_GET_DATA_TRANSFER_STATE:
+
+ case BT_NETWORK_ACTIVATE:
+ case BT_NETWORK_DEACTIVATE:
+ case BT_NETWORK_CONNECT:
+ case BT_NETWORK_DISCONNECT:
+ case BT_NETWORK_SERVER_DISCONNECT:
+
+ case BT_GATT_GET_PRIMARY_SERVICES:
+ case BT_GATT_DISCOVER_CHARACTERISTICS:
+ case BT_GATT_SET_PROPERTY_REQUEST:
+ case BT_GATT_READ_CHARACTERISTIC:
+ case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
+ case BT_GATT_REGISTER_APPLICATION:
+ case BT_GATT_REGISTER_SERVICE:
+ case BT_GATT_SEND_RESPONSE:
+
+ case BT_REQ_ATT_MTU:
+ case BT_PBAP_CONNECT:
+ case BT_PBAP_DISCONNECT:
+ case BT_PBAP_GET_PHONEBOOK_SIZE:
+ case BT_PBAP_GET_PHONEBOOK:
+ case BT_PBAP_GET_LIST:
+ case BT_PBAP_PULL_VCARD:
+ case BT_PBAP_PHONEBOOK_SEARCH:
+ case BT_AUDIO_SELECT_ROLE:
+
+ ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
+ BT_PRIVILEGE_PUBLIC);
+
+ if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
+ BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
+ result = FALSE;
+ }
+
+ /* Need to check mediastorage privilege */
+ if (function_name == BT_PBAP_GET_PHONEBOOK ||
+ function_name == BT_PBAP_PULL_VCARD) {
+ ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
+ MEDIASTORAGE_PRIVILEGE);
+
+ if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
+ BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
+ result = FALSE;
+ }
+ }
+ break;
+
+ case BT_ENABLE_ADAPTER:
+ case BT_DISABLE_ADAPTER:
+ case BT_RESET_ADAPTER:
+ case BT_RECOVER_ADAPTER:
+ case BT_ENABLE_ADAPTER_LE:
+ case BT_DISABLE_ADAPTER_LE:
+ case BT_SET_CONNECTABLE:
+ case BT_SET_DISCOVERABLE_MODE:
+ case BT_ADD_WHITE_LIST:
+ case BT_REMOVE_WHITE_LIST:
+ case BT_CLEAR_WHITE_LIST:
+ case BT_SET_MANUFACTURER_DATA:
+ case BT_SET_PASSKEY_NOTIFICATION:
+ case BT_SET_PROFILE_RESTRICTED:
+
+ case BT_DISCONNECT_DEVICE:
+ case BT_CANCEL_SEARCH_SERVICE:
+ case BT_ENABLE_RSSI:
+
+ case BT_RFCOMM_ACCEPT_CONNECTION:
+ case BT_RFCOMM_REJECT_CONNECTION:
+ case BT_RFCOMM_LISTEN:
+ case BT_RFCOMM_CREATE_SOCKET_EX:
+ case BT_RFCOMM_REMOVE_SOCKET_EX:
+
+ case BT_HID_ENABLE_BARCODE_FEATURE:
+
+ case BT_AVRCP_CONTROL_GET_PROPERTY:
+ case BT_AVRCP_GET_TRACK_INFO:
+ case BT_AVRCP_TRANSPORT_SET_PROPERTY:
+
+
+ case BT_SET_CONTENT_PROTECT:
+ case BT_BOND_DEVICE_BY_TYPE:
+ case BT_SET_LE_PRIVACY:
+ case BT_SET_LE_STATIC_RANDOM_ADDRESS:
+ case BT_LE_CONN_UPDATE:
+ case BT_UPDATE_LE_CONNECTION_MODE:
+ case BT_GET_DEVICE_IDA:
+ case BT_ENABLE_FORCE_HCI_DUMP:
+ case BT_LE_READ_MAXIMUM_DATA_LENGTH:
+ case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
+ case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
+ case BT_LE_SET_DATA_LENGTH:
+
+ case BT_LE_IPSP_INIT:
+ case BT_LE_IPSP_DEINIT:
+ case BT_LE_IPSP_CONNECT:
+ case BT_LE_IPSP_DISCONNECT:
+ case BT_PXP_SET_PROPERTY:
+ case BT_PXP_GET_PROPERTY:
+ case BT_PXP_GET_SUPPORTED_SERIVCES:
+ case BT_PXP_REGISTER_REPORTER:
+ case BT_PXP_UNREGISTER_REPORTER:
+ ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
+ BT_PRIVILEGE_PLATFORM);
+
+ if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
+ BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
+ result = FALSE;
+ }
+ break;
+
+ case BT_CHECK_ADAPTER:
+ case BT_GET_RSSI:
+
+ case BT_GET_LOCAL_NAME:
+ case BT_GET_LOCAL_ADDRESS:
+ case BT_GET_LOCAL_VERSION:
+ case BT_IS_SERVICE_USED:
+ case BT_GET_DISCOVERABLE_MODE:
+ case BT_GET_DISCOVERABLE_TIME:
+ case BT_IS_DISCOVERYING:
+ case BT_IS_LE_DISCOVERYING:
+ case BT_IS_CONNECTABLE:
+ case BT_GET_BONDED_DEVICES:
+ case BT_GET_PROFILE_CONNECTED_DEVICES:
+ case BT_GET_BONDED_DEVICE:
+ case BT_PASSKEY_REPLY:
+ case BT_PASSKEY_CONFIRMATION_REPLY:
+ case BT_GET_IS_ALIAS_SET:
+ case BT_IS_DEVICE_CONNECTED:
+ case BT_GET_CONNECTED_LINK_TYPE:
+ case BT_SET_PROFILE_TRUSTED:
+ case BT_GET_PROFILE_TRUSTED:
+ case BT_GET_SPEAKER_GAIN:
+ case BT_SET_SPEAKER_GAIN:
+ case BT_OOB_READ_LOCAL_DATA:
+ case BT_RFCOMM_CLIENT_IS_CONNECTED:
+ case BT_RFCOMM_IS_UUID_AVAILABLE:
+ case BT_GET_ADVERTISING_DATA:
+ case BT_GET_SCAN_RESPONSE_DATA:
+ case BT_IS_ADVERTISING:
+ case BT_REGISTER_SCAN_FILTER:
+ case BT_UNREGISTER_SCAN_FILTER:
+ case BT_UNREGISTER_ALL_SCAN_FILTERS:
+ case BT_IS_SCAN_FILTER_SUPPORTED:
+ case BT_GET_PROFILE_RESTRICTED:
+ case BT_GET_ATT_MTU:
+
+ case BT_OBEX_SERVER_ALLOCATE:
+ case BT_OBEX_SERVER_DEALLOCATE:
+ case BT_OBEX_SERVER_IS_ACTIVATED:
+ case BT_OPP_GET_TRANSFER_PROGRESS:
+ /* Non-privilege control */
+ break;
+ default:
+ BT_ERR("Unknown function!");
+ result = FALSE;
+ break;
+ }
+
+ if (client_creds)
+ free(client_creds);
+
+ if (user_creds)
+ free(user_creds);
+
+ return result;
}
GDBusNodeInfo *__bt_service_create_method_node_info
return 0;
}
+static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ GDBusNodeInfo *node_info = NULL;
+
+ BT_INFO("bus acquired");
+
+ ret_if(connection == NULL);
+
+ node_info = __bt_service_create_method_node_info(
+ bt_service_introspection_xml);
+ ret_if(node_info == NULL);
+
+ __bt_service_register_object(connection, node_info, TRUE);
+ g_dbus_node_info_unref(node_info);
+
+ bt_service_conn = connection;
+}
+
+static void __bt_service_name_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name acquired");
+ name_acquired = TRUE;
+}
+
+static void __bt_service_name_lost_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name lost");
+ name_acquired = FALSE;
+}
+
+gboolean _is_name_acquired(void)
+{
+ return name_acquired;
+}
+
int _bt_service_register(void)
{
GDBusConnection *conn;
GError *err = NULL;
- int result;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+ bt_service_conn = conn;
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL,
+ __bt_service_bus_acquired_handler,
+ __bt_service_name_acquired_handler,
+ __bt_service_name_lost_handler,
NULL, NULL);
BT_DBG("owner_id is [%d]", owner_id);
if (owner_id == 0)
goto fail;
- node_info = __bt_service_create_method_node_info(
- bt_service_introspection_xml);
-
- if (node_info == NULL)
- goto fail;
-
- result = __bt_service_register_object(conn, node_info, TRUE);
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
-
- if (result != BLUETOOTH_ERROR_NONE)
- goto fail;
-
- bt_service_conn = conn;
-
return BLUETOOTH_ERROR_NONE;
fail:
g_object_unref(bt_service_conn);
bt_service_conn = NULL;
}
- if (node_info) {
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
- }
if (owner_id > 0) {
g_bus_unown_name(owner_id);
owner_id = 0;
int _bt_service_cynara_init(void)
{
- int result;
- char err_msg[256] = {0, };
+ int result;
+ char err_msg[256] = {0, };
- retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
+ retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
- result = cynara_initialize(&p_cynara, conf);
+ result = cynara_initialize(&p_cynara, conf);
- if (result != CYNARA_API_SUCCESS) {
- cynara_strerror(result, err_msg, sizeof(err_msg));
- BT_ERR("Fail to initialize cynara: [%s]", err_msg);
- return BLUETOOTH_ERROR_INTERNAL;
- }
+ if (result != CYNARA_API_SUCCESS) {
+ cynara_strerror(result, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to initialize cynara: [%s]", err_msg);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- return BLUETOOTH_ERROR_NONE;
+ return BLUETOOTH_ERROR_NONE;
}
void _bt_service_cynara_deinit(void)
{
- int result;
- char err_msg[256] = {0, };
+ int result;
+ char err_msg[256] = {0, };
- ret_if(p_cynara == NULL);
+ ret_if(p_cynara == NULL);
- result = cynara_finish(p_cynara);
+ result = cynara_finish(p_cynara);
- if (result != CYNARA_API_SUCCESS) {
- cynara_strerror(result, err_msg, sizeof(err_msg));
- BT_ERR("Fail to finish cynara: [%s]", err_msg);
- return;
- }
+ if (result != CYNARA_API_SUCCESS) {
+ cynara_strerror(result, err_msg, sizeof(err_msg));
+ BT_ERR("Fail to finish cynara: [%s]", err_msg);
+ return;
+ }
- p_cynara = NULL;
- conf = NULL;
+ p_cynara = NULL;
+ conf = NULL;
}