/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ * 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*/
#include <string.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <glib.h>
#include <dlog.h>
+#include <gio/gio.h>
+#include <cynara-client.h>
+#include <cynara-creds-gdbus.h>
#include "bluetooth-api.h"
#include "bt-service-common.h"
#include "bt-service-util.h"
#include "bt-service-event.h"
#include "bt-service-adapter.h"
+#include "bt-service-adapter-le.h"
#include "bt-service-device.h"
#include "bt-service-hid.h"
#include "bt-service-network.h"
#include "bt-service-audio.h"
#include "bt-service-oob.h"
#include "bt-service-avrcp.h"
+#include "bt-service-avrcp-controller.h"
#include "bt-service-opp-client.h"
#include "bt-service-obex-server.h"
#include "bt-service-rfcomm-client.h"
#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;
+cynara *p_cynara;
+cynara_configuration *conf;
+
+static const gchar bt_service_introspection_xml[] =
+"<node name='/org/projectx/bt_service'>"
+" <interface name='org.projectx.bt'>"
+" <method name='service_request'>"
+ /* Input Parameters */
+" <arg type='i' name='service_type' direction='in' />"
+" <arg type='i' name='service_function' direction='in' />"
+" <arg type='i' name='request_type' direction='in' />"
+" <arg type='ay' name='input_param1' direction='in' />"
+" <arg type='ay' name='input_param2' direction='in' />"
+" <arg type='ay' name='input_param3' direction='in' />"
+" <arg type='ay' name='input_param4' direction='in' />"
+" <arg type='ay' name='input_param5' direction='in' />"
+ /* Return Parameters */
+" <arg type='i' name='output_param1' direction='out' />"
+" <arg type='v' name='output_param2' direction='out' />"
+" </method>"
+" </interface>"
+"</node>";
+
+static gboolean name_acquired = FALSE;
+
+static char *current_sender_playing = NULL;
+
+static void __bt_service_method(GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+int __bt_bluez_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);
+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);
+int __bt_agent_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);
+int __bt_core_request(int function_name,
+ int request_type,
+ int request_id,
+ GDBusMethodInvocation *context,
+ GVariant *in_param1);
-/* auto generated header by bt-request-service.xml*/
-#include "bt-service-method.h"
+gboolean __bt_service_check_privilege(int function_name,
+ int service_type,
+ const char *unique_name);
-DBusGConnection *bt_service_conn;
-BtService *service_object;
+/* Function definitions*/
+static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
+{
+ char *data;
+ int size;
-GType bt_service_get_type (void);
+ size = g_variant_get_size(var);
+ if (size > 0) {
+ data = (char *)g_variant_get_data(var);
+ if (data)
+ param = g_array_append_vals(param, data, size);
-G_DEFINE_TYPE(BtService, bt_service, G_TYPE_OBJECT);
+ }
+}
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_service_class_init (BtServiceClass *service_class)
+static void __bt_service_get_parameters(GVariant *in_param,
+ void *value, int size)
{
- dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(service_class),
- &dbus_glib_bt_object_info);
+ void *buf = NULL;
+ buf = (void *)g_variant_get_data(in_param);
+ memcpy(value, buf, size);
}
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_service_init (BtService *service)
+static void __bt_service_method(GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
+ FN_START;
+
+ BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
+ method_name, object_path, interface_name);
+
+ if (g_strcmp0(method_name, "service_request") == 0) {
+ int service_type;
+ int service_function;
+ int request_type;
+ GVariant *param1 = NULL;
+ GVariant *param2 = NULL;
+ GVariant *param3 = NULL;
+ GVariant *param4 = NULL;
+ GVariant *param5 = NULL;
+ GArray *out_param1 = NULL;
+ GVariant *out_var = NULL;
+ int result = 0;
+ int request_id = -1;
+ const char *sender = NULL;
+
+ g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
+ &service_function, &request_type,
+ ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
+
+ out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+
+ sender = g_dbus_method_invocation_get_sender(invocation);
+
+ if (service_type == BT_CORE_SERVICE) {
+ BT_DBG("No need to check privilege from bt-core");
+ } else if (__bt_service_check_privilege(service_function,
+ service_type, (const char *)sender) == FALSE) {
+ BT_ERR("Client don't have the privilege to excute this function");
+ result = BLUETOOTH_ERROR_PERMISSION_DEINED;
+ goto fail;
+ }
+
+ if (request_type == BT_ASYNC_REQ
+ || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) {
+ /* Set the timer */
+ request_id = _bt_assign_request_id();
+ BT_DBG("Request ID: %d", request_id);
+
+ if (request_id < 0) {
+ BT_ERR("Fail to assign the request id");
+ result = BLUETOOTH_ERROR_INTERNAL;
+
+ goto fail;
+ }
+ }
+
+ 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,
+ request_type, request_id,
+ invocation, param1, param2,
+ param3, param4, &out_param1);
+ break;
+ case BT_OBEX_SERVICE:
+ result = __bt_obexd_request(service_function,
+ request_type, request_id,
+ invocation, param1,
+ param2, param3,
+ param4, &out_param1);
+ break;
+ case BT_AGENT_SERVICE:
+ result = __bt_agent_request(service_function,
+ request_type, request_id,
+ invocation, param1,
+ param2, param3,
+ param4, &out_param1);
+ break;
+ case BT_CORE_SERVICE:
+ result = __bt_core_request(service_function,
+ request_type, request_id,
+ invocation, param1);
+ break;
+ case BT_CHECK_PRIVILEGE:
+ result = BLUETOOTH_ERROR_NONE;
+ break;
+ default:
+ BT_ERR("Unknown service type");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ goto fail;
+ }
+
+ if (result != BLUETOOTH_ERROR_NONE)
+ goto fail;
+
+ if ((request_type == BT_ASYNC_REQ ||
+ service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) &&
+ service_function != BT_OPP_PUSH_FILES) {
+ BT_DBG("INSERT INTO REQ LIST");
+ _bt_insert_request_list(request_id, service_function,
+ NULL, invocation);
+ } else {
+ /* Return result */
+ if (service_type == BT_CHECK_PRIVILEGE ||
+ service_function != BT_OPP_PUSH_FILES) {
+ out_var = g_variant_new_from_data((const GVariantType *)"ay",
+ out_param1->data, out_param1->len,
+ TRUE, NULL, NULL);
+
+ GVariant *temp = g_variant_new("(iv)", result, out_var);
+ g_dbus_method_invocation_return_value(invocation, temp);
+ }
+ }
+
+ 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);
+ FN_END;
+ return;
+fail:
+ 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",
+ out_param1->data, out_param1->len,
+ TRUE, NULL, NULL);
+
+ 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;
+
+ if (request_type == BT_ASYNC_REQ)
+ _bt_delete_request_id(request_id);
+
+ g_variant_unref(param1);
+ g_variant_unref(param2);
+ g_variant_unref(param3);
+ g_variant_unref(param4);
+ g_variant_unref(param5);
+ }
+
+ FN_END;
+ return;
}
-static int __bt_bluez_request(int function_name,
+
+static const GDBusInterfaceVTable method_table = {
+ __bt_service_method,
+ NULL,
+ NULL,
+};
+
+int __bt_bluez_request(int function_name,
int request_type,
int request_id,
- DBusGMethodInvocation *context,
- GArray *in_param1,
- GArray *in_param2,
- GArray *in_param3,
- GArray *in_param4,
+ GDBusMethodInvocation *context,
+ GVariant *in_param1,
+ GVariant *in_param2,
+ GVariant *in_param3,
+ GVariant *in_param4,
GArray **out_param1)
{
int result = BLUETOOTH_ERROR_NONE;
case BT_DISABLE_ADAPTER:
result = _bt_disable_adapter();
break;
+ case BT_RECOVER_ADAPTER:
+ 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:
result = _bt_reset_adapter();
break;
case BT_CHECK_ADAPTER: {
- int enabled = 0;
+ int enabled = BT_ADAPTER_DISABLED;
result = _bt_check_adapter(&enabled);
sizeof(bluetooth_device_address_t));
break;
}
+ case BT_GET_LOCAL_VERSION: {
+ bluetooth_version_t ver = { {0} };
+ result = _bt_get_local_version(&ver);
+
+ g_array_append_vals(*out_param1, &ver,
+ sizeof(bluetooth_version_t));
+ break;
+ }
case BT_GET_LOCAL_NAME: {
bluetooth_device_name_t local_name = { {0} };
result = _bt_get_local_name(&local_name);
}
case BT_SET_LOCAL_NAME: {
bluetooth_device_name_t local_name = { {0} };
-
- local_name = g_array_index(in_param1,
- bluetooth_device_name_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &local_name, sizeof(bluetooth_device_name_t));
result = _bt_set_local_name(local_name.name);
char *uuid;
gboolean used = FALSE;
- uuid = &g_array_index(in_param1, char, 0);
+ uuid = (char *)g_variant_get_data(in_param1);
result = _bt_is_service_used(uuid, &used);
int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
int time = 0;
- mode = g_array_index(in_param1, int, 0);
- time = g_array_index(in_param2, int, 0);
+ __bt_service_get_parameters(in_param1, &mode, sizeof(int));
+ __bt_service_get_parameters(in_param2, &time, sizeof(int));
result = _bt_set_discoverable_mode(mode, time);
break;
}
case BT_START_DISCOVERY:
result = _bt_start_discovery();
+
break;
+ case BT_START_CUSTOM_DISCOVERY: {
+ bt_discovery_role_type_t role;
+ __bt_service_get_parameters(in_param1,
+ &role, sizeof(bt_discovery_role_type_t));
+ result = _bt_start_custom_discovery(role);
+
+ break;
+ }
case BT_CANCEL_DISCOVERY:
result = _bt_cancel_discovery();
break;
-
case BT_IS_DISCOVERYING: {
gboolean discovering = FALSE;
discovering = _bt_is_discovering();
-
- g_array_append_vals(*out_param1, &discovering, sizeof(gboolean));
+ g_array_append_vals(*out_param1,
+ &discovering, sizeof(gboolean));
break;
}
- case BT_GET_BONDED_DEVICES:
- result = _bt_get_bonded_devices(out_param1);
- break;
+ case BT_START_LE_DISCOVERY: {
+ char *sender = NULL;
- case BT_GET_BONDED_DEVICE: {
- bluetooth_device_address_t address = { {0} };
- bluetooth_device_info_t dev_info;
-
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ result = _bt_start_le_scan(sender);
- memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
- result = _bt_get_bonded_device_info(&address, &dev_info);
-
- if (result == BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &dev_info,
- sizeof(bluetooth_device_info_t));
- }
break;
}
- case BT_BOND_DEVICE: {
- bluetooth_device_address_t address = { {0} };
+ case BT_STOP_LE_DISCOVERY: {
+ char *sender = NULL;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ result = _bt_stop_le_scan(sender);
- result = _bt_bond_device(request_id, &address, out_param1);
break;
}
- case BT_CANCEL_BONDING: {
- result = _bt_cancel_bonding();
+ case BT_IS_LE_DISCOVERYING: {
+ gboolean le_discovering = FALSE;
+
+ le_discovering = _bt_is_le_scanning();
+ g_array_append_vals(*out_param1,
+ &le_discovering, sizeof(gboolean));
+
break;
}
- case BT_UNBOND_DEVICE: {
- bluetooth_device_address_t address = { {0} };
+ case BT_REGISTER_SCAN_FILTER: {
+ char *sender = NULL;
+ bluetooth_le_scan_filter_t scan_filter;
+ int slot_id;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ __bt_service_get_parameters(in_param1, &scan_filter,
+ sizeof(bluetooth_le_scan_filter_t));
+ BT_DBG("bluetooth_le_scan_filter_t [features : %.2x]",
+ scan_filter.added_features);
- result = _bt_unbond_device(request_id, &address, out_param1);
+ result = _bt_register_scan_filter(sender,
+ &scan_filter, &slot_id);
+ g_array_append_vals(*out_param1, &slot_id, sizeof(int));
break;
}
- case BT_SET_ALIAS: {
- bluetooth_device_address_t address = { {0} };
- const char *local_name;
+ case BT_UNREGISTER_SCAN_FILTER:{
+ char *sender = NULL;
+ int slot_id;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ __bt_service_get_parameters(in_param1, &slot_id, sizeof(int));
+ BT_DBG("Remove scan filter [Slot ID : %d]", slot_id);
- local_name = &g_array_index(in_param2, char, 0);
+ result = _bt_unregister_scan_filter(sender, slot_id);
- result = _bt_set_alias(&address, local_name);
break;
}
- case BT_SEARCH_SERVICE: {
- bluetooth_device_address_t address = { {0} };
+ case BT_UNREGISTER_ALL_SCAN_FILTERS:{
+ char *sender = NULL;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ BT_DBG("Remove all scan filters [Sender : %s]", sender);
+
+ result = _bt_unregister_all_scan_filters(sender);
- result = _bt_search_device(request_id, &address);
- if (result != BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &address,
- sizeof(bluetooth_device_address_t));
- }
- break;
- }
- case BT_CANCEL_SEARCH_SERVICE: {
- result = _bt_cancel_search_device();
break;
}
- case BT_SET_AUTHORIZATION: {
- bluetooth_device_address_t address = { {0} };
- gboolean authorize;
+ case BT_IS_SCAN_FILTER_SUPPORTED:{
+ int is_supported = 0;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ if (_bt_is_scan_filter_supported() == TRUE)
+ is_supported = 1;
- authorize = g_array_index(in_param2, gboolean, 0);
+ g_array_append_vals(*out_param1,
+ &is_supported, sizeof(int));
- result = _bt_set_authorization(&address, authorize);
break;
}
- case BT_IS_DEVICE_CONNECTED: {
- bluetooth_device_address_t address = { {0} };
- int type;
- gboolean connected = FALSE;
-
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ case BT_ENABLE_RSSI: {
+ bluetooth_device_address_t bd_addr;
+ int link_type;
+ bt_rssi_threshold_t rssi_threshold;
+ int low_threshold;
+ int in_range_threshold;
+ int high_threshold;
- type = g_array_index(in_param2, int, 0);
+ BT_DBG("Enable RSSI");
- result = _bt_is_device_connected(&address, type, &connected);
+ __bt_service_get_parameters(in_param1,
+ &bd_addr, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &link_type, sizeof(int));
+ __bt_service_get_parameters(in_param3,
+ &rssi_threshold, sizeof(bt_rssi_threshold_t));
- if (result == BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &connected,
- sizeof(gboolean));
- }
+ low_threshold = rssi_threshold.low_threshold;
+ in_range_threshold = rssi_threshold.in_range_threshold;
+ high_threshold = rssi_threshold.high_threshold;
+ result = _bt_enable_rssi(&bd_addr,
+ link_type, low_threshold,
+ in_range_threshold, high_threshold);
break;
}
- case BT_HID_CONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_GET_RSSI: {
+ int link_type;
+ bluetooth_device_address_t bd_addr;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ BT_DBG("Get RSSI Strength");
- result = _bt_hid_connect(request_id, &address);
- if (result != BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &address,
- sizeof(bluetooth_device_address_t));
- }
+ __bt_service_get_parameters(in_param1,
+ &bd_addr, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &link_type, sizeof(int));
+
+ result = _bt_get_rssi_strength(&bd_addr, link_type);
break;
}
- case BT_HID_DISCONNECT: {
- bluetooth_device_address_t address = { {0} };
-
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ case BT_IS_CONNECTABLE: {
+ gboolean is_connectable;
- result = _bt_hid_disconnect(request_id, &address);
- if (result != BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &address,
- sizeof(bluetooth_device_address_t));
- }
+ is_connectable = _bt_is_connectable();
+ g_array_append_vals(*out_param1,
+ &is_connectable, sizeof(gboolean));
break;
}
- case BT_NETWORK_ACTIVATE:
- result = _bt_network_activate();
- break;
- case BT_NETWORK_DEACTIVATE:
- result = _bt_network_deactivate();
+ case BT_SET_CONNECTABLE: {
+ gboolean is_connectable;
+
+ __bt_service_get_parameters(in_param1,
+ &is_connectable, sizeof(gboolean));
+ result = _bt_set_connectable(is_connectable);
break;
- case BT_NETWORK_CONNECT: {
- bluetooth_device_address_t address = { {0} };
- int role;
+ }
+ case BT_SET_ADVERTISING: {
+ char *sender = NULL;
+ int adv_handle;
+ gboolean enable = FALSE;
+ gboolean use_reserved_slot = FALSE;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &adv_handle, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &enable, sizeof(gboolean));
+ __bt_service_get_parameters(in_param3,
+ &use_reserved_slot, sizeof(gboolean));
- role = g_array_index(in_param2, int, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- result = _bt_network_connect(request_id, role, &address);
- if (result != BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &address,
- sizeof(bluetooth_device_address_t));
- }
+ result = _bt_set_advertising(sender, adv_handle,
+ enable, use_reserved_slot);
break;
}
- case BT_NETWORK_DISCONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_SET_CUSTOM_ADVERTISING: {
+ char *sender = NULL;
+ int adv_handle;
+ gboolean enable = FALSE;
+ bluetooth_advertising_params_t adv_params;
+ gboolean use_reserved_slot = FALSE;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- result = _bt_network_disconnect(request_id, &address);
- if (result != BLUETOOTH_ERROR_NONE) {
- g_array_append_vals(*out_param1, &address,
- sizeof(bluetooth_device_address_t));
- }
+ __bt_service_get_parameters(in_param1, &adv_handle,
+ sizeof(int));
+ __bt_service_get_parameters(in_param2, &enable,
+ sizeof(gboolean));
+ __bt_service_get_parameters(in_param3, &adv_params,
+ sizeof(bluetooth_advertising_params_t));
+ __bt_service_get_parameters(in_param4, &use_reserved_slot,
+ sizeof(gboolean));
+
+ BT_DBG("bluetooth_advertising_params_t [%f %f %d %d]",
+ adv_params.interval_min, adv_params.interval_max,
+ adv_params.filter_policy, adv_params.type);
+ result = _bt_set_custom_advertising(sender, adv_handle,
+ enable, &adv_params, use_reserved_slot);
break;
}
- case BT_AUDIO_CONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_GET_ADVERTISING_DATA: {
+ bluetooth_advertising_data_t adv = { {0} };
+ int length = 0;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ result = _bt_get_advertising_data(&adv, &length);
+ if (result == BLUETOOTH_ERROR_NONE)
+ g_array_append_vals(*out_param1, adv.data, length);
- result = _bt_audio_connect(request_id, BT_AUDIO_ALL,
- &address, out_param1);
break;
}
- case BT_AUDIO_DISCONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_SET_ADVERTISING_DATA: {
+ char *sender = NULL;
+ int adv_handle;
+ bluetooth_advertising_data_t adv = { {0} };
+ int length;
+ gboolean use_reserved_slot = FALSE;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- result = _bt_audio_disconnect(request_id, BT_AUDIO_ALL,
- &address, out_param1);
+ __bt_service_get_parameters(in_param1,
+ &adv_handle, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &adv, sizeof(bluetooth_advertising_data_t));
+ __bt_service_get_parameters(in_param3,
+ &length, sizeof(int));
+ __bt_service_get_parameters(in_param4,
+ &use_reserved_slot, sizeof(gboolean));
+
+ result = _bt_set_advertising_data(sender, adv_handle,
+ &adv, length, use_reserved_slot);
break;
}
- case BT_AG_CONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_GET_SCAN_RESPONSE_DATA: {
+ bluetooth_scan_resp_data_t rsp = { {0} };
+ int length = 0;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ result = _bt_get_scan_response_data(&rsp, &length);
+ if (result == BLUETOOTH_ERROR_NONE)
+ g_array_append_vals(*out_param1, rsp.data, length);
- result = _bt_audio_connect(request_id, BT_AUDIO_HSP,
- &address, out_param1);
break;
}
- case BT_AG_DISCONNECT: {
- bluetooth_device_address_t address = { {0} };
+ case BT_SET_SCAN_RESPONSE_DATA: {
+ char *sender = NULL;
+ int adv_handle;
+ bluetooth_scan_resp_data_t rsp = { {0} };
+ int length;
+ gboolean use_reserved_slot = FALSE;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- result = _bt_audio_disconnect(request_id, BT_AUDIO_HSP,
- &address, out_param1);
- break;
- }
- case BT_AV_CONNECT: {
- bluetooth_device_address_t address = { {0} };
+ __bt_service_get_parameters(in_param1,
+ &adv_handle, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &rsp, sizeof(bluetooth_scan_resp_data_t));
+ __bt_service_get_parameters(in_param3,
+ &length, sizeof(int));
+ __bt_service_get_parameters(in_param4,
+ &use_reserved_slot, sizeof(gboolean));
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ result = _bt_set_scan_response_data(sender, adv_handle,
+ &rsp, length, use_reserved_slot);
- result = _bt_audio_connect(request_id, BT_AUDIO_A2DP,
- &address, out_param1);
break;
}
- case BT_AV_DISCONNECT: {
- bluetooth_device_address_t address = { {0} };
-
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ case BT_SET_MANUFACTURER_DATA: {
+ bluetooth_manufacturer_data_t m_data = { 0 };
+ __bt_service_get_parameters(in_param1,
+ &m_data, sizeof(bluetooth_manufacturer_data_t));
- result = _bt_audio_disconnect(request_id, BT_AUDIO_A2DP,
- &address, out_param1);
+ result = _bt_set_manufacturer_data(&m_data);
break;
}
- case BT_GET_SPEAKER_GAIN: {
- unsigned int volume;
+ case BT_SET_SCAN_PARAMETERS: {
+ bluetooth_le_scan_params_t scan_params;
+ __bt_service_get_parameters(in_param1, &scan_params,
+ sizeof(bluetooth_le_scan_params_t));
- result = _bt_audio_get_speaker_gain(&volume);
+ BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
+ scan_params.interval, scan_params.window,
+ scan_params.type);
- g_array_append_vals(*out_param1, &volume,
- sizeof(unsigned int));
+ result = _bt_set_scan_parameters(&scan_params);
break;
}
- case BT_SET_SPEAKER_GAIN: {
- unsigned int volume;
+ case BT_LE_CONN_UPDATE: {
+ char *sender = NULL;
+ bluetooth_device_address_t local_address = { {0} };
+ bluetooth_le_connection_param_t parameters = {0};
- volume = g_array_index(in_param1,
- unsigned int, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
- result = _bt_audio_set_speaker_gain(volume);
+ __bt_service_get_parameters(in_param1, &local_address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, ¶meters,
+ sizeof(bluetooth_le_connection_param_t));
+ result = _bt_le_conn_update(sender,
+ local_address.addr,
+ parameters.interval_min,
+ parameters.interval_max,
+ parameters.latency,
+ parameters.timeout);
break;
}
- case BT_OOB_READ_LOCAL_DATA: {
- bt_oob_data_t local_oob_data;
+ case BT_IS_ADVERTISING: {
+ gboolean advertising = FALSE;
+ advertising = _bt_is_advertising();
- memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
- result = _bt_oob_read_local_data(&local_oob_data);
+ g_array_append_vals(*out_param1, &advertising,
+ sizeof(gboolean));
+ break;
+ }
+ case BT_ADD_WHITE_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ int addr_type = 0;
- g_array_append_vals(*out_param1, &local_oob_data,
- sizeof(bt_oob_data_t));
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &addr_type,
+ sizeof(int));
+ result = _bt_add_white_list(&address, addr_type);
break;
}
- case BT_OOB_ADD_REMOTE_DATA: {
+ case BT_REMOVE_WHITE_LIST: {
bluetooth_device_address_t address = { {0} };
- bt_oob_data_t local_oob_data;
+ int addr_type = 0;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &addr_type, sizeof(int));
- local_oob_data = g_array_index(in_param2,
- bt_oob_data_t, 0);
+ result = _bt_remove_white_list(&address, addr_type);
+ break;
+ }
+ case BT_CLEAR_WHITE_LIST: {
+ result = _bt_clear_white_list();
+ break;
+ }
+ case BT_GET_BONDED_DEVICES: {
+ 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;
- result = _bt_oob_add_remote_data(&address, &local_oob_data);
+ 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_OOB_REMOVE_REMOTE_DATA: {
+ case BT_GET_BONDED_DEVICE: {
bluetooth_device_address_t address = { {0} };
+ bluetooth_device_info_t dev_info;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- result = _bt_oob_remove_remote_data(&address);
+ memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
+ result = _bt_get_bonded_device_info(&address, &dev_info);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &dev_info,
+ sizeof(bluetooth_device_info_t));
+ }
break;
}
- case BT_AVRCP_SET_TRACK_INFO: {
- media_metadata_t data;
- media_player_settings_t properties;
+ case BT_GET_IS_ALIAS_SET: {
+ bluetooth_device_address_t address = { {0} };
+ gboolean is_alias_set = FALSE;
- memset(&data, 0x00, sizeof(media_metadata_t));
- memset(&properties, 0x00, sizeof(media_player_settings_t));
+ __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));
- data = g_array_index(in_param1,
- media_metadata_t, 0);
+ break;
+ }
+ case BT_DISCONNECT_DEVICE: {
+ bluetooth_device_address_t addr = { {0} };
+ char address[BLUETOOTH_ADDRESS_STRING_LENGTH + 1];
- properties.metadata.title = g_strdup(data.title);
- properties.metadata.artist = g_malloc0(sizeof(char *));
- properties.metadata.artist[0] = g_strdup(data.artist);
- properties.metadata.album = g_strdup(data.album);
- properties.metadata.genre = g_malloc0(sizeof(char *));
- properties.metadata.genre[0] = g_strdup(data.genre);
- properties.metadata.tracknumber = data.number;
- properties.metadata.duration = data.duration;
+ __bt_service_get_parameters(in_param1,
+ &addr, sizeof(bluetooth_device_address_t));
+ _bt_convert_addr_type_to_string(address, addr.addr);
- result = _bt_avrcp_set_properties(&properties);
+ result = _bt_disconnect_all(address);
+ break;
+ }
+ case BT_BOND_DEVICE: {
+ bluetooth_device_address_t address = { {0} };
- g_free((gpointer)properties.metadata.title);
- g_free((gpointer)properties.metadata.artist);
- g_free((gpointer)properties.metadata.album);
- g_free((gpointer)properties.metadata.genre);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ result = _bt_bond_device(request_id, &address,
+ BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
break;
}
- case BT_AVRCP_SET_PROPERTY: {
- int type;
- unsigned int value;
+ case BT_BOND_DEVICE_BY_TYPE: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned short conn_type = 0;
- type = g_array_index(in_param1, int, 0);
- value = g_array_index(in_param2, unsigned int, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &conn_type, sizeof(unsigned short));
- result = _bt_avrcp_set_property(type, value);
+ result = _bt_bond_device(request_id, &address,
+ conn_type, out_param1);
+ break;
+ }
+ case BT_CANCEL_BONDING: {
+ 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_AVRCP_SET_PROPERTIES: {
- media_player_settings_t properties;
+ case BT_PASSKEY_CONFIRMATION_REPLY: {
+ gboolean confirmation_reply = FALSE;
- memset(&properties, 0x00, sizeof(media_player_settings_t));
+ __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} };
- properties = g_array_index(in_param1,
- media_player_settings_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- result = _bt_avrcp_set_properties(&properties);
+ result = _bt_unbond_device(request_id, &address, out_param1);
break;
}
- case BT_RFCOMM_CLIENT_CONNECT: {
+ case BT_SET_ALIAS: {
bluetooth_device_address_t address = { {0} };
- char *input_string;
- int connect_type;
+ const char *local_name;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ local_name = (const char *)g_variant_get_data(in_param2);
- input_string = &g_array_index(in_param2, char, 0);
+ result = _bt_set_alias(&address, local_name);
+ break;
+ }
+ case BT_SEARCH_SERVICE: {
+ bluetooth_device_address_t address = { {0} };
- connect_type = g_array_index(in_param3, int, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- if (connect_type == BT_RFCOMM_UUID) {
- result = _bt_rfcomm_connect_using_uuid(request_id,
- &address, input_string);
- } else {
- result = _bt_rfcomm_connect_using_channel(request_id,
- &address, input_string);
+ result = _bt_search_device(request_id, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
+ break;
+ }
+ case BT_CANCEL_SEARCH_SERVICE: {
+ result = _bt_cancel_search_device();
+ break;
+ }
+ case BT_SET_AUTHORIZATION: {
+ bluetooth_device_address_t address = { {0} };
+ gboolean authorize;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &authorize, sizeof(gboolean));
+
+ result = _bt_set_authorization(&address, authorize);
+ break;
+ }
+ case BT_IS_DEVICE_CONNECTED: {
+ bluetooth_device_address_t address = { {0} };
+ int type;
+ gboolean connected = FALSE;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &type, sizeof(int));
+
+ result = _bt_is_device_connected(&address, type, &connected);
+ BT_DBG("is_connected: %d", connected);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &connected,
+ sizeof(gboolean));
+ }
+
+ break;
+ }
+ case BT_GET_CONNECTED_LINK_TYPE: {
+ bluetooth_device_address_t address = { {0} };
+ bluetooth_connected_link_t connected = BLUETOOTH_CONNECTED_LINK_NONE;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_get_connected_link(&address, &connected);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &connected,
+ sizeof(guint));
+ }
+
+ 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} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_hid_connect(request_id, &address);
if (result != BLUETOOTH_ERROR_NONE) {
g_array_append_vals(*out_param1, &address,
sizeof(bluetooth_device_address_t));
}
break;
}
- case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
- result = _bt_rfcomm_cancel_connect();
+ case BT_HID_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_hid_disconnect(request_id, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
- case BT_RFCOMM_CLIENT_IS_CONNECTED: {
- gboolean connected = FALSE;
- result = _bt_rfcomm_is_connected(&connected);
+ }
+ case BT_HID_ENABLE_BARCODE_FEATURE: {
+ result = _bt_hid_enable_barcode_feature();
+ break;
+ }
+ case BT_NETWORK_ACTIVATE:
+ result = _bt_network_activate();
+ break;
+ case BT_NETWORK_DEACTIVATE:
+ result = _bt_network_deactivate();
+ break;
+ case BT_NETWORK_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
+ int role;
- g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &role, sizeof(int));
+
+ result = _bt_network_connect(request_id, role, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
}
- case BT_RFCOMM_SOCKET_DISCONNECT: {
- int socket_fd;
+ case BT_NETWORK_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
- socket_fd = g_array_index(in_param1, int, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- result = _bt_rfcomm_disconnect(socket_fd);
+ result = _bt_network_disconnect(request_id, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
}
- case BT_RFCOMM_SOCKET_WRITE: {
- int socket_fd;
- int length;
- char *buffer;
+ case BT_NETWORK_SERVER_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
- socket_fd = g_array_index(in_param1, int, 0);
- length = g_array_index(in_param2, int, 0);
- buffer = &g_array_index(in_param3, char, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- result = _bt_rfcomm_write(socket_fd, buffer, length);
+ result = _bt_network_server_disconnect(request_id, &address);
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
break;
}
- case BT_RFCOMM_CREATE_SOCKET: {
- char *sender;
- char *uuid;
- int socket_fd = -1;
- int result;
- sender = dbus_g_method_get_sender(context);
- uuid = &g_array_index(in_param1, char, 0);
+ case BT_AUDIO_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
- result = _bt_rfcomm_create_socket(sender, uuid);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- if (result > 0) {
- socket_fd = result;
- result = BLUETOOTH_ERROR_NONE;
+ result = _bt_audio_connect(request_id, BT_AUDIO_ALL,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AUDIO_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_AUDIO_ALL,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AG_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_AUDIO_HSP,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AG_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_AUDIO_HSP,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AV_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_AUDIO_A2DP,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AV_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_AUDIO_A2DP,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AVRCP_CONTROL_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,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AVRCP_CONTROL_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,
+ &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} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_audio_connect(request_id, BT_AUDIO_A2DP_SOURCE,
+ &address, *out_param1);
+ break;
+ }
+ case BT_AV_SOURCE_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_AUDIO_A2DP_SOURCE,
+ &address, *out_param1);
+ break;
+ }
+ case BT_HF_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_hf_connect(request_id, &address, *out_param1);
+ break;
+ }
+ case BT_HF_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_hf_disconnect(request_id, &address, *out_param1);
+ break;
+ }
+ case BT_SET_CONTENT_PROTECT: {
+ gboolean status;
+
+ __bt_service_get_parameters(in_param1,
+ &status, sizeof(gboolean));
+
+ result = _bt_audio_set_content_protect(status);
+
+ break;
+ }
+ case BT_OOB_READ_LOCAL_DATA: {
+ bt_oob_data_t local_oob_data;
+
+ memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
+ result = _bt_oob_read_local_data(&local_oob_data);
+
+ g_array_append_vals(*out_param1, &local_oob_data,
+ sizeof(bt_oob_data_t));
+
+ break;
+ }
+ case BT_OOB_ADD_REMOTE_DATA: {
+ bluetooth_device_address_t address = { {0} };
+ 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,
+ &remote_oob_data, sizeof(bt_oob_data_t));
+
+ result = _bt_oob_add_remote_data(&address, &remote_oob_data);
+
+ break;
+ }
+ case BT_OOB_REMOVE_REMOTE_DATA: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_oob_remove_remote_data(&address);
+
+ break;
+ }
+ case BT_AVRCP_SET_TRACK_INFO: {
+ media_metadata_t data;
+ media_metadata_attributes_t meta_data;
+
+ memset(&data, 0x00, sizeof(media_metadata_t));
+ memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
+
+ __bt_service_get_parameters(in_param1,
+ &data, sizeof(media_metadata_t));
+
+ meta_data.title = g_strdup(data.title);
+ meta_data.artist = g_strdup(data.artist);
+ meta_data.album = g_strdup(data.album);
+ meta_data.genre = g_strdup(data.genre);
+ meta_data.total_tracks = data.total_tracks;
+ 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);
+ g_free((gpointer)meta_data.artist);
+ g_free((gpointer)meta_data.album);
+ g_free((gpointer)meta_data.genre);
+
+ break;
+ }
+ 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;
+ }
+ case BT_AVRCP_SET_PROPERTIES: {
+ media_player_settings_t properties;
+
+ memset(&properties, 0x00, sizeof(media_player_settings_t));
+ __bt_service_get_parameters(in_param1,
+ &properties, sizeof(media_player_settings_t));
+
+ result = _bt_avrcp_set_properties(&properties);
+
+ break;
+ }
+ case BT_AVRCP_HANDLE_CONTROL: {
+ int type;
+
+ __bt_service_get_parameters(in_param1, &type, sizeof(int));
+
+ result = _bt_avrcp_control_cmd(type);
+
+ break;
+ }
+ case BT_AVRCP_CONTROL_SET_PROPERTY: {
+ int type;
+ unsigned int value;
+
+ __bt_service_get_parameters(in_param1,
+ &type, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &value, sizeof(unsigned int));
+
+ result = _bt_avrcp_control_set_property(type, value);
+
+ break;
+ }
+ case BT_AVRCP_CONTROL_GET_PROPERTY: {
+ int type;
+ unsigned int value;
+
+ __bt_service_get_parameters(in_param1, &type, sizeof(int));
+
+ result = _bt_avrcp_control_get_property(type, &value);
+ g_array_append_vals(*out_param1, &value, sizeof(int));
+
+ break;
+ }
+ case BT_AVRCP_GET_TRACK_INFO: {
+ media_metadata_t meta_data;
+ media_metadata_attributes_t metadata;
+
+ memset(&meta_data, 0x00, sizeof(media_metadata_t));
+ memset(&metadata, 0x00, sizeof(media_metadata_attributes_t));
+
+ result = _bt_avrcp_control_get_track_info(&metadata);
+
+ if (BLUETOOTH_ERROR_NONE != result)
+ break;
+
+ if (_bt_copy_utf8_string(meta_data.title, metadata.title,
+ BT_META_DATA_MAX_LEN))
+ BT_ERR("Error in copying Title\n");
+ if (_bt_copy_utf8_string(meta_data.artist, metadata.artist,
+ BT_META_DATA_MAX_LEN))
+ BT_ERR("Error in copying Artist\n");
+ if (_bt_copy_utf8_string(meta_data.album, metadata.album,
+ BT_META_DATA_MAX_LEN))
+ BT_ERR("Error in copying Album\n");
+ if (_bt_copy_utf8_string(meta_data.genre, metadata.genre,
+ BT_META_DATA_MAX_LEN))
+ BT_ERR("Error in copying Genre\n");
+
+ if (_bt_utf8_validate(meta_data.title) == FALSE)
+ meta_data.title[0] = '\0';
+
+ if (_bt_utf8_validate(meta_data.artist) == FALSE)
+ meta_data.artist[0] = '\0';
+
+ if (_bt_utf8_validate(meta_data.album) == FALSE)
+ meta_data.album[0] = '\0';
+
+ if (_bt_utf8_validate(meta_data.genre) == FALSE)
+ meta_data.genre[0] = '\0';
+
+ meta_data.total_tracks = metadata.total_tracks;
+ meta_data.number = metadata.number;
+ meta_data.duration = metadata.duration;
+
+ g_free((gpointer)metadata.title);
+ g_free((gpointer)metadata.artist);
+ g_free((gpointer)metadata.album);
+ g_free((gpointer)metadata.genre);
+
+ g_array_append_vals(*out_param1, &meta_data,
+ sizeof(media_metadata_t));
+ break;
+ }
+ case BT_RFCOMM_CLIENT_CONNECT: {
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ result = BLUETOOTH_ERROR_NONE;
+#else
+ bluetooth_device_address_t address = { {0} };
+ char *input_string;
+ int connect_type;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ input_string = &g_array_index(in_param2, char, 0);
+
+ connect_type = g_array_index(in_param3, int, 0);
+
+ if (connect_type == BT_RFCOMM_UUID) {
+ result = _bt_rfcomm_connect_using_uuid(request_id,
+ &address, input_string);
+ } else {
+ result = _bt_rfcomm_connect_using_channel(request_id,
+ &address, input_string);
+ }
+
+ if (result != BLUETOOTH_ERROR_NONE) {
+ g_array_append_vals(*out_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ }
+#endif
+ break;
+ }
+ case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
+ result = _bt_rfcomm_cancel_connect();
+ break;
+ case BT_RFCOMM_CLIENT_IS_CONNECTED: {
+ gboolean connected = FALSE;
+ result = _bt_rfcomm_is_connected(&connected);
+
+ g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
+ break;
+ }
+ case BT_RFCOMM_SOCKET_DISCONNECT: {
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ result = BLUETOOTH_ERROR_NONE;
+#else
+ int socket_fd;
+
+ socket_fd = g_array_index(in_param1, int, 0);
+
+ result = _bt_rfcomm_disconnect(socket_fd);
+#endif
+ break;
+ }
+ case BT_RFCOMM_SOCKET_WRITE: {
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ result = BLUETOOTH_ERROR_NONE;
+#else
+ int socket_fd;
+ int length;
+ char *buffer;
+
+ socket_fd = g_array_index(in_param1, int, 0);
+ length = g_array_index(in_param2, int, 0);
+ buffer = &g_array_index(in_param3, char, 0);
+
+ result = _bt_rfcomm_write(socket_fd, buffer, length);
+#endif
+ break;
+ }
+ case BT_RFCOMM_CREATE_SOCKET: {
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ result = BLUETOOTH_ERROR_NONE;
+#else
+ char *sender;
+ char *uuid;
+ int socket_fd = -1;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ uuid = &g_array_index(in_param1, char, 0);
+
+ result = _bt_rfcomm_create_socket(sender, uuid);
+
+ if (result > 0) {
+ socket_fd = result;
+ result = BLUETOOTH_ERROR_NONE;
+ }
+
+ g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+
+ g_free(sender);
+#endif
+ break;
+ }
+ case BT_RFCOMM_REMOVE_SOCKET: {
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ result = BLUETOOTH_ERROR_NONE;
+#else
+ int socket_fd;
+
+ socket_fd = g_array_index(in_param1, int, 0);
+
+ result = _bt_rfcomm_remove_socket(socket_fd);
+#endif
+ break;
+ }
+ case BT_RFCOMM_LISTEN: {
+ int socket_fd;
+ int pending;
+ gboolean is_native;
+
+ __bt_service_get_parameters(in_param1, &socket_fd,
+ sizeof(int));
+ __bt_service_get_parameters(in_param2, &pending,
+ sizeof(int));
+ __bt_service_get_parameters(in_param3, &is_native,
+ sizeof(gboolean));
+
+ result = _bt_rfcomm_listen(socket_fd, pending, is_native);
+ break;
+ }
+ case BT_RFCOMM_IS_UUID_AVAILABLE: {
+ gboolean available = TRUE;
+ char *uuid;
+
+ uuid = (char *)g_variant_get_data(in_param1);
+
+ result = _bt_rfcomm_is_uuid_available(uuid, &available);
+
+ g_array_append_vals(*out_param1, &available, sizeof(gboolean));
+ break;
+ }
+ case BT_RFCOMM_ACCEPT_CONNECTION: {
+ int socket_fd;
+
+ __bt_service_get_parameters(in_param1, &socket_fd, sizeof(int));
+ BT_DBG(" socket fd %d", socket_fd);
+ result = _bt_rfcomm_accept_connection();
+ break;
+ }
+ case BT_RFCOMM_REJECT_CONNECTION: {
+ int socket_fd;
+
+ __bt_service_get_parameters(in_param1, &socket_fd, sizeof(int));
+ BT_DBG(" socket fd %d", socket_fd);
+ result = _bt_rfcomm_reject_connection();
+ break;
+ }
+ case BT_RFCOMM_CREATE_SOCKET_EX: {
+ result = BLUETOOTH_ERROR_NONE;
+ break;
+ }
+ case BT_RFCOMM_REMOVE_SOCKET_EX: {
+ result = BLUETOOTH_ERROR_NONE;
+ break;
+ }
+ case BT_CONNECT_LE: {
+ bluetooth_device_address_t address = { {0} };
+ gboolean auto_connect;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &auto_connect, sizeof(gboolean));
+
+ 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;
+ }
+ case BT_DISCONNECT_LE: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ 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;
+ }
+ case BT_SET_LE_PRIVACY: {
+ gboolean set_privacy;
+
+ __bt_service_get_parameters(in_param1, &set_privacy,
+ sizeof(gboolean));
+
+ result = _bt_set_le_privacy(set_privacy);
+
+ 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_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_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;
+#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;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ result = _bt_delete_gatt_client_sender(sender);
+
+ 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));
+
+ result = _bt_connect_le_ipsp_device(&address);
+ break;
+ }
+ case BT_LE_IPSP_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ 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};
+
+ result = _bt_le_read_maximum_data_length(&max_le_datalength);
+
+ 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;
+
+ __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_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_LE_SET_DATA_LENGTH: {
+ int max_tx_Octets = 0;
+ int max_tx_Time = 0;
+ bluetooth_device_address_t address = { {0} };
+
+ __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));
- g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+ result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
- g_free(sender);
break;
}
- case BT_RFCOMM_REMOVE_SOCKET: {
- int socket_fd;
+ case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
- socket_fd = g_array_index(in_param1, int, 0);
+ value = _bt_dpm_get_bluetooth_limited_discoverable_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
- result = _bt_rfcomm_remove_socket(socket_fd);
break;
}
- case BT_RFCOMM_LISTEN: {
- int socket_fd;
- int pending;
- gboolean is_native;
+ case BT_DPM_SET_DATA_TRANSFER_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
- socket_fd = g_array_index(in_param1, int, 0);
- pending = g_array_index(in_param2, int, 0);
- is_native = g_array_index(in_param3, gboolean, 0);
+ __bt_service_get_parameters(in_param1, &value,
+ sizeof(int));
+
+ result = _bt_dpm_set_bluetooth_data_transfer_state(value);
- result = _bt_rfcomm_listen(socket_fd, pending, is_native);
break;
}
- case BT_RFCOMM_IS_UUID_AVAILABLE: {
- gboolean available = TRUE;
- char *uuid;
+ case BT_DPM_GET_DATA_TRANSFER_STATE: {
+ dpm_status_t value = DPM_BT_ERROR;
- uuid = &g_array_index(in_param1, char, 0);
+ value = _bt_dpm_get_allow_bluetooth_data_transfer_state();
+ result = DPM_RESULT_SUCCESS;
+ g_array_append_vals(*out_param1, &value, sizeof(int));
- result = _bt_rfcomm_is_uuid_available(uuid, &available);
+ break;
+ }
+ case BT_PXP_SET_PROPERTY: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
+ unsigned int value = 0;
- g_array_append_vals(*out_param1, &available, sizeof(gboolean));
+ __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_RFCOMM_ACCEPT_CONNECTION: {
- int socket_fd;
+ case BT_PXP_GET_PROPERTY: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
+ int value = 0;
- socket_fd = g_array_index(in_param1, int, 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_rfcomm_accept_connection(socket_fd, request_id);
+ 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_RFCOMM_REJECT_CONNECTION: {
- int socket_fd;
+ case BT_PXP_GET_SUPPORTED_SERIVCES: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned int property = 0;
- socket_fd = g_array_index(in_param1, int, 0);
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
- result = _bt_rfcomm_reject_connection(socket_fd);
+ 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:
return result;
}
-static int __bt_obexd_request(int function_name,
+int __bt_obexd_request(int function_name,
int request_type,
int request_id,
- DBusGMethodInvocation *context,
- GArray *in_param1,
- GArray *in_param2,
- GArray *in_param3,
- GArray *in_param4,
+ 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;
+ bt_file_path_t *path;
char **file_path;
int file_count;
+ GArray *param2;
- address = g_array_index(in_param1,
- bluetooth_device_address_t, 0);
-
- file_count = g_array_index(in_param3, int, 0);
+ __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);
- for (i = 0; i < file_count; i++) {
- path = g_array_index(in_param2,
- bt_file_path_t, i);
+ param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+ __bt_fill_garray_from_variant(in_param2, param2);
- file_path[i] = g_strdup(path.path);
+ 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++) {
+ for (i = 0; i < file_count; i++)
g_free(file_path[i]);
- }
g_free(file_path);
+ g_array_free(param2, TRUE);
break;
}
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));
+
+ break;
+ }
case BT_OBEX_SERVER_ALLOCATE: {
int app_pid;
gboolean is_native;
char *path;
char *sender;
- sender = dbus_g_method_get_sender(context);
- path = &g_array_index(in_param1, char, 0);
- is_native = g_array_index(in_param2, gboolean, 0);
- app_pid = g_array_index(in_param3, int, 0);
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ path = (char *)g_variant_get_data(in_param1);
+ __bt_service_get_parameters(in_param2, &is_native,
+ sizeof(gboolean));
+ __bt_service_get_parameters(in_param3, &app_pid,
+ sizeof(int));
- result = _bt_obex_server_allocate(sender, path, app_pid, is_native);
+ result = _bt_obex_server_allocate(sender,
+ path, app_pid, is_native);
- g_free(sender);
break;
}
case BT_OBEX_SERVER_DEALLOCATE: {
int app_pid;
gboolean is_native;
- is_native = g_array_index(in_param1, gboolean, 0);
- app_pid = g_array_index(in_param2, int, 0);
+ __bt_service_get_parameters(in_param1, &is_native,
+ sizeof(gboolean));
+ __bt_service_get_parameters(in_param2, &app_pid,
+ sizeof(int));
result = _bt_obex_server_deallocate(app_pid, is_native);
break;
case BT_OBEX_SERVER_ACCEPT_FILE: {
char *file_name;
- file_name = &g_array_index(in_param1, char, 0);
+ file_name = (char *)g_variant_get_data(in_param1);
result = _bt_obex_server_accept_authorize(file_name, TRUE);
gboolean is_native;
char *destination_path;
- destination_path = &g_array_index(in_param1, char, 0);
- is_native = g_array_index(in_param2, gboolean, 0);
+ destination_path = (char *)g_variant_get_data(in_param1);
+ __bt_service_get_parameters(in_param2, &is_native,
+ sizeof(gboolean));
result = _bt_obex_server_set_destination_path(destination_path,
is_native);
case BT_OBEX_SERVER_SET_ROOT: {
char *root;
- root = &g_array_index(in_param1, char, 0);
+ root = (char *)g_variant_get_data(in_param1);
result = _bt_obex_server_set_root(root);
case BT_OBEX_SERVER_CANCEL_TRANSFER: {
int transfer_id;
- transfer_id = g_array_index(in_param1, int, 0);
+ __bt_service_get_parameters(in_param1, &transfer_id,
+ sizeof(int));
result = _bt_obex_server_cancel_transfer(transfer_id);
sizeof(gboolean));
break;
}
+ case BT_PBAP_CONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_pbap_connect(&address);
+ break;
+ }
+ case BT_PBAP_DISCONNECT: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+
+ result = _bt_pbap_disconnect(&address);
+ break;
+ }
+ case BT_PBAP_GET_PHONEBOOK_SIZE: {
+ bluetooth_device_address_t address = { {0} };
+ bt_pbap_folder_t folder = { 0, };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &folder,
+ sizeof(bt_pbap_folder_t));
+
+ result = _bt_pbap_get_phonebook_size(&address,
+ folder.addressbook, folder.folder_type);
+ break;
+ }
+ case BT_PBAP_GET_PHONEBOOK: {
+ bluetooth_device_address_t address = { {0} };
+ bt_pbap_folder_t folder = { 0, };
+ bt_pbap_pull_parameters_t app_param = { 0, };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &folder,
+ sizeof(bt_pbap_folder_t));
+ __bt_service_get_parameters(in_param3, &app_param,
+ sizeof(bt_pbap_pull_parameters_t));
+
+ result = _bt_pbap_get_phonebook(&address, folder.addressbook,
+ folder.folder_type, &app_param);
+ break;
+ }
+ case BT_PBAP_GET_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ bt_pbap_folder_t folder = { 0, };
+ bt_pbap_list_parameters_t app_param = { 0, };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &folder,
+ sizeof(bt_pbap_folder_t));
+ __bt_service_get_parameters(in_param3, &app_param,
+ sizeof(bt_pbap_list_parameters_t));
+
+ result = _bt_pbap_get_list(&address, folder.addressbook,
+ folder.folder_type, &app_param);
+ break;
+ }
+ case BT_PBAP_PULL_VCARD: {
+ bluetooth_device_address_t address = { {0} };
+ bt_pbap_folder_t folder = { 0, };
+ bt_pbap_pull_vcard_parameters_t app_param = { 0, };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &folder,
+ sizeof(bt_pbap_folder_t));
+ __bt_service_get_parameters(in_param3, &app_param,
+ sizeof(bt_pbap_pull_vcard_parameters_t));
+
+ result = _bt_pbap_pull_vcard(&address, folder.addressbook,
+ folder.folder_type, &app_param);
+ break;
+ }
+ case BT_PBAP_PHONEBOOK_SEARCH: {
+ bluetooth_device_address_t address = { {0} };
+ bt_pbap_folder_t folder = { 0, };
+ bt_pbap_search_parameters_t app_param = { 0, };
+
+ __bt_service_get_parameters(in_param1, &address,
+ sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2, &folder,
+ sizeof(bt_pbap_folder_t));
+ __bt_service_get_parameters(in_param3, &app_param,
+ sizeof(bt_pbap_search_parameters_t));
+
+ result = _bt_pbap_phonebook_search(&address, folder.addressbook,
+ folder.folder_type, &app_param);
+ break;
+ }
+
default:
BT_ERR("Unknown function!");
result = BLUETOOTH_ERROR_INTERNAL;
break;
}
+ FN_END;
+
return result;
}
-gboolean bt_service_request(
- BtService *service,
- int service_type,
- int service_function,
+int __bt_agent_request(int function_name,
int request_type,
- GArray *in_param1,
- GArray *in_param2,
- GArray *in_param3,
- GArray *in_param4,
- GArray *in_param5,
- DBusGMethodInvocation *context)
+ int request_id,
+ GDBusMethodInvocation *context,
+ GVariant *in_param1,
+ GVariant *in_param2,
+ GVariant *in_param3,
+ GVariant *in_param4,
+ GArray **out_param1)
{
int result;
- int request_id = -1;
- GArray *out_param1 = NULL;
- GArray *out_param2 = NULL;
-
- out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
- out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
- if (request_type == BT_ASYNC_REQ
- || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION
- || service_function == BT_RFCOMM_ACCEPT_CONNECTION) {
- /* Set the timer */
- request_id = _bt_assign_request_id();
- if (request_id < 0) {
- BT_ERR("Fail to assign the request id");
- result = BLUETOOTH_ERROR_INTERNAL;
- goto fail;
+ switch (function_name) {
+ case BT_SET_AUTHORIZATION: {
+ int type;
+ char *uuid;
+ char *path;
+ int fd;
+
+ __bt_service_get_parameters(in_param1, &type, sizeof(int));
+ uuid = (char *)g_variant_get_data(in_param2);
+ path = (char *)g_variant_get_data(in_param3);
+ __bt_service_get_parameters(in_param4, &fd, sizeof(int));
+
+ result = _bt_register_osp_server_in_agent(type, uuid, path, fd);
+ break;
+ }
+ case BT_UNSET_AUTHORIZATION: {
+ int type;
+ char *uuid;
+
+ __bt_service_get_parameters(in_param1, &type, sizeof(int));
+ uuid = (char *)g_variant_get_data(in_param2);
+
+ result = _bt_unregister_osp_server_in_agent(type, uuid);
+ break;
+ }
+ default:
+ BT_ERR("Unknown function!");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ break;
+ }
+
+ return result;
+}
+
+int __bt_core_request(int function_name,
+ int request_type,
+ int request_id,
+ GDBusMethodInvocation *context,
+ GVariant *in_param1)
+{
+ int result;
+
+ switch (function_name) {
+ case BT_ENABLE_ADAPTER:
+ {
+ bt_status_t status;
+
+ status = _bt_adapter_get_status();
+
+ if (status == BT_ACTIVATING) {
+ BT_DBG("Enabling in progress");
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ } else if (status == BT_ACTIVATED) {
+ BT_DBG("Already enabled");
+ result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
+ } else {
+ _bt_adapter_set_status(BT_ACTIVATING);
+ _bt_adapter_start_enable_timer();
+ result = BLUETOOTH_ERROR_NONE;
+ }
+
+ break;
+ }
+ case BT_DISABLE_ADAPTER:
+ {
+ bt_status_t status;
+
+ status = _bt_adapter_get_status();
+ if (status == BT_DEACTIVATING) {
+ BT_DBG("Disabling in progress");
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ } else if (status == BT_DEACTIVATED) {
+ BT_DBG("Already disabled");
+ result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+ } else {
+ _bt_adapter_set_status(BT_DEACTIVATING);
+ result = BLUETOOTH_ERROR_NONE;
}
+
+ break;
}
+ case BT_ENABLE_ADAPTER_LE:
+ {
+ bt_le_status_t le_status;
+
+ le_status = _bt_adapter_get_le_status();
+ if (le_status == BT_LE_ACTIVATING) {
+ BT_DBG("Enabling in progress");
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ } else if (le_status == BT_LE_ACTIVATED) {
+ BT_DBG("Already enabled");
+ result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
+ } else {
+ _bt_adapter_set_le_status(BT_LE_ACTIVATING);
+ _bt_adapter_start_le_enable_timer();
+ result = BLUETOOTH_ERROR_NONE;
+ }
- switch (service_type) {
- case BT_BLUEZ_SERVICE:
- result = __bt_bluez_request(service_function, request_type,
- request_id, context, in_param1, in_param2,
- in_param3, in_param4, &out_param1);
break;
- case BT_OBEX_SERVICE:
- result = __bt_obexd_request(service_function, request_type,
- request_id, context, in_param1,
- in_param2, in_param3,
- in_param4, &out_param1);
+ }
+ case BT_DISABLE_ADAPTER_LE:
+ {
+ bt_le_status_t le_status;
+
+ le_status = _bt_adapter_get_le_status();
+ if (le_status == BT_LE_DEACTIVATING) {
+ BT_DBG("Disabling in progress");
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ } else if (le_status == BT_LE_DEACTIVATED) {
+ BT_DBG("Already disabled");
+ result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+ } else {
+ _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
+ result = BLUETOOTH_ERROR_NONE;
+ }
+
break;
+ }
default:
- BT_ERR("Unknown service type");
+ BT_ERR("Unknown function!");
result = BLUETOOTH_ERROR_INTERNAL;
- goto fail;
+ break;
}
- if (result != BLUETOOTH_ERROR_NONE) {
- BT_ERR("result is not error none: %x", result);
- goto fail;
+ return result;
+}
+
+gboolean __bt_service_check_privilege(int function_name,
+ int service_type,
+ const char *unique_name)
+{
+ 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;
}
- g_array_append_vals(out_param2, &result, sizeof(int));
+ 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;
+ }
- if (request_type == BT_ASYNC_REQ
- || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION
- || service_function == BT_RFCOMM_ACCEPT_CONNECTION) {
- _bt_insert_request_list(request_id, service_function,
- NULL, context);
- } else {
- /* Return result */
- dbus_g_method_return(context, out_param1, out_param2);
+ 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;
}
- g_array_free(out_param1, TRUE);
- g_array_free(out_param2, TRUE);
+ BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
- return TRUE;
-fail:
- g_array_append_vals(out_param2, &result, sizeof(int));
- dbus_g_method_return(context, out_param1, out_param2);
+ 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;
+ }
- g_array_free(out_param1, TRUE);
- g_array_free(out_param2, TRUE);
+ if (client_creds)
+ free(client_creds);
- if (request_type == BT_ASYNC_REQ)
- _bt_delete_request_id(request_id);
+ if (user_creds)
+ free(user_creds);
- return FALSE;
+ return result;
}
-int _bt_service_register(void)
+GDBusNodeInfo *__bt_service_create_method_node_info
+ (const gchar *introspection_data)
{
- BtService *bt_service;
- DBusGConnection *conn;
- DBusGProxy *proxy;
- GError* err = NULL;
- guint result = 0;
+ GError *err = NULL;
+ GDBusNodeInfo *node_info = NULL;
- conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
- retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+ if (introspection_data == NULL) {
+ ERR("Introspection XML not present");
+ return NULL;
+ }
- proxy = dbus_g_proxy_new_for_name(conn, DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
- if (proxy == NULL) {
- BT_ERR("proxy is NULL");
- goto fail;
+ if (err) {
+ ERR("Unable to create node: %s", err->message);
+ g_clear_error(&err);
}
+ return node_info;
+}
- if (!dbus_g_proxy_call(proxy, "RequestName", &err, G_TYPE_STRING,
- BT_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
- G_TYPE_UINT, &result, G_TYPE_INVALID)) {
- if (err != NULL) {
- BT_ERR("RequestName RPC failed[%s]\n", err->message);
- g_error_free(err);
+int __bt_service_register_object(GDBusConnection *conn,
+ GDBusNodeInfo *node_info, gboolean reg)
+{
+ static guint service_id = 0;
+ GError *error = NULL;
+
+ if (reg) {
+ if (node_info == NULL)
+ return -1;
+
+ service_id = g_dbus_connection_register_object(conn,
+ BT_SERVICE_PATH,
+ node_info->interfaces[0],
+ &method_table,
+ NULL, NULL, &error);
+ if (service_id == 0)
+ return -1;
+ } else {
+ if (service_id > 0) {
+ g_dbus_connection_unregister_object(conn,
+ service_id);
+ service_id = 0;
}
- g_object_unref(proxy);
-
- goto fail;
}
- g_object_unref(proxy);
+ return 0;
+}
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- BT_ERR("Failed to get the primary well-known name.\n");
- goto fail;
- }
+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;
+}
- bt_service = g_object_new(BT_SERVICE_TYPE, NULL);
+gboolean _is_name_acquired(void)
+{
+ return name_acquired;
+}
- dbus_g_connection_register_g_object(conn, BT_SERVICE_PATH,
- G_OBJECT(bt_service));
+int _bt_service_register(void)
+{
+ GDBusConnection *conn;
+ GError *err = NULL;
- service_object = bt_service;
+ 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,
+ __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;
+
return BLUETOOTH_ERROR_NONE;
fail:
if (bt_service_conn) {
- dbus_g_connection_unref(bt_service_conn);
+ g_object_unref(bt_service_conn);
bt_service_conn = NULL;
}
void _bt_service_unregister(void)
{
if (bt_service_conn) {
- if (service_object) {
- dbus_g_connection_unregister_g_object(bt_service_conn,
- G_OBJECT(service_object));
- g_object_unref(service_object);
- service_object = NULL;
+ __bt_service_register_object(bt_service_conn, NULL, FALSE);
+ if (bt_service_conn) {
+ g_object_unref(bt_service_conn);
+ bt_service_conn = NULL;
}
+ if (owner_id > 0) {
+ g_bus_unown_name(owner_id);
+ owner_id = 0;
+ }
+ }
+}
- dbus_g_connection_unref(bt_service_conn);
- bt_service_conn = NULL;
+int _bt_service_cynara_init(void)
+{
+ int result;
+ char err_msg[256] = {0, };
+
+ retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
+
+ 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;
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_service_cynara_deinit(void)
+{
+ int result;
+ char err_msg[256] = {0, };
+
+ ret_if(p_cynara == NULL);
+
+ 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;
}
+
+ p_cynara = NULL;
+ conf = NULL;
}