2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <gio/gunixfdlist.h>
24 #include <cynara-client.h>
25 #include <cynara-creds-gdbus.h>
26 #include <systemd/sd-daemon.h>
28 #include "bluetooth-api.h"
29 #include "bluetooth-audio-api.h"
30 #include "bluetooth-gatt-server-api.h"
31 #include "bluetooth-mesh-api.h"
32 #include "bt-request-handler.h"
33 #include "bt-service-common.h"
34 #include "bt-service-util.h"
36 #include "bt-service-core-adapter.h"
37 #include "bt-service-core-adapter-le.h"
38 #include "bt-service-core-device.h"
40 #include "bt-service-audio-common.h"
41 #include "bt-service-avrcp-tg.h"
42 #include "bt-service-avrcp-ctrl.h"
43 #include "bt-service-gatt.h"
44 #include "bt-service-mesh-main.h"
45 #include "bt-service-mesh-util.h"
46 #include "bt-service-mesh-network.h"
47 #include "bt-service-mesh-config-client.h"
49 #ifdef TIZEN_FEATURE_BT_DPM
50 #include "bt-service-dpm.h"
52 #include "bt-service-hidhost.h"
53 #include "bt-service-rfcomm.h"
54 #include "bt-service-hdp.h"
57 #include "bt-service-obex-server.h"
58 #include "bt-service-opp-client.h"
59 #include "bt-service-map-client.h"
60 #include "bt-service-pbap.h"
61 #include "bt-service-oob.h"
63 #include "bt-service-battery-monitor.h"
65 #ifdef TIZEN_FEATURE_BT_PAN_NAP
66 #include "bt-service-network.h"
69 #ifdef TIZEN_FEATURE_BT_IPSP
70 #include "bt-service-ipsp.h"
72 /* For maintaining Application Sync API call requests */
73 GSList *invocation_list = NULL;
75 static GDBusConnection *bt_service_conn;
76 static guint owner_id = 0;
77 static guint owner_sig_id = 0;
78 static gboolean is_le_intended = FALSE;
80 static cynara *p_cynara;
81 static cynara_configuration *conf;
82 const char *requester_unique_creds = NULL;
84 static const gchar bt_service_introspection_xml[] =
85 "<node name='/org/projectx/bt_service'>"
86 " <interface name='org.projectx.bt'>"
87 " <method name='service_request'>"
88 /* Input Parameters */
89 " <arg type='i' name='service_type' direction='in' />"
90 " <arg type='i' name='service_function' direction='in' />"
91 " <arg type='i' name='request_type' direction='in' />"
92 " <arg type='ay' name='input_param1' direction='in' />"
93 " <arg type='ay' name='input_param2' direction='in' />"
94 " <arg type='ay' name='input_param3' direction='in' />"
95 " <arg type='ay' name='input_param4' direction='in' />"
96 " <arg type='ay' name='input_param5' direction='in' />"
97 /* Return Parameters */
98 " <arg type='i' name='output_param1' direction='out' />"
99 " <arg type='v' name='output_param2' direction='out' />"
101 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
102 " <method name='get_avc_mode'>"
104 " <arg type='u' name='avc_mode' direction='out' />"
110 static gboolean name_acquired = FALSE;
112 static char *current_sender_playing = NULL;
114 GDBusNodeInfo *node_info_g = NULL;
116 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
118 static void __bt_service_method(GDBusConnection *connection,
120 const gchar *object_path,
121 const gchar *interface_name,
122 const gchar *method_name,
123 GVariant *parameters,
124 GDBusMethodInvocation *invocation,
127 int __bt_bluez_request(int function_name,
130 GDBusMethodInvocation *context,
135 GArray **out_param1);
136 int __bt_obexd_request(int function_name,
139 GDBusMethodInvocation *context,
144 GArray **out_param1);
145 int __bt_agent_request(int function_name,
148 GDBusMethodInvocation *context,
153 GArray **out_param1);
154 int __bt_core_request(int function_name,
157 GDBusMethodInvocation *context,
158 GVariant *in_param1);
160 gboolean __bt_service_check_privilege(int function_name,
162 const char *unique_name);
164 /* Function definitions*/
165 GSList *_bt_get_invocation_list(void)
167 return invocation_list;
170 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
172 ret_if(NULL == req_info);
173 invocation_list = g_slist_remove(invocation_list, req_info);
174 g_free(req_info->sender);
175 g_free(req_info->user_data);
179 void _bt_set_le_intended_status(gboolean value)
181 is_le_intended = value;
184 static void __bt_service_get_parameters(GVariant *in_param,
185 void *value, int size)
188 buf = (void *)g_variant_get_data(in_param);
189 memcpy(value, buf, size);
192 static gboolean __bt_is_sync_function(int service_function)
194 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
195 if (service_function == BT_GET_LOCAL_ADDRESS
196 || service_function == BT_GET_LOCAL_NAME
197 || service_function == BT_GET_LOCAL_VERSION
198 || service_function == BT_GET_BONDED_DEVICES
199 || service_function == BT_GET_BONDED_DEVICE
200 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
201 || service_function == BT_GET_IS_ALIAS_SET
202 || service_function == BT_GET_CONNECTED_LINK_TYPE
203 || service_function == BT_IS_SERVICE_USED
204 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
205 || service_function == BT_RFCOMM_LISTEN
206 || service_function == BT_HDP_REGISTER_SINK_APP
207 || service_function == BT_HDP_UNREGISTER_SINK_APP
208 || service_function == BT_HDP_GET_FD
209 || service_function == BT_AVRCP_GET_TRACK_INFO
210 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
211 || service_function == BT_SET_ADVERTISING_DATA
212 || service_function == BT_SET_SCAN_RESPONSE_DATA
213 || service_function == BT_SET_ADVERTISING
214 || service_function == BT_SET_CUSTOM_ADVERTISING
215 || service_function == BT_GATT_SERVER_REGISTER
216 || service_function == BT_GATT_SERVER_ADD_SERVICE
217 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
218 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
219 || service_function == BT_GATT_SERVER_START_SERVICE
220 || service_function == BT_GATT_SERVER_STOP_SERVICE
221 || service_function == BT_GATT_SERVER_DELETE_SERVICE
222 || service_function == BT_START_LE_DISCOVERY
223 || service_function == BT_STOP_LE_DISCOVERY
224 || service_function == BT_GET_CONNECTABLE
225 #ifdef TIZEN_GATT_CLIENT
226 || service_function == BT_GATT_CLIENT_REGISTER
227 || service_function == BT_GATT_GET_PRIMARY_SERVICES
228 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
229 || service_function == BT_GATT_GET_INCLUDED_SERVICES
230 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
231 || service_function == BT_GATT_WATCH_CHARACTERISTIC
232 || service_function == BT_GATT_ACQUIRE_WRITE
234 || service_function == BT_AUDIO_SELECT_ROLE
236 || service_function == BT_MESH_NETWORK_CREATE
237 || service_function == BT_MESH_NETWORK_LOAD
238 || service_function == BT_MESH_NETWORK_SCAN
239 || service_function == BT_MESH_NETWORK_ADD_NETKEY
240 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
241 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
242 || service_function == BT_MESH_NETWORK_ADD_APPKEY
243 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
244 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
250 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
251 char *sender, int service_function,
252 gpointer invocation_data)
254 invocation_info_t *info;
255 info = g_malloc0(sizeof(invocation_info_t));
256 info->context = invocation;
257 info->result = result;
258 info->sender = g_strdup(sender);
259 info->service_function = service_function;
260 info->user_data = invocation_data;
261 invocation_list = g_slist_append(invocation_list, info);
265 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
268 char err_msg[256] = {0, };
270 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
272 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
273 if (ret != CYNARA_API_SUCCESS) {
274 cynara_strerror(ret, err_msg, sizeof(err_msg));
275 BT_ERR("Fail to get user credential: %s", err_msg);
277 return BLUETOOTH_ERROR_INTERNAL;
280 return BLUETOOTH_ERROR_NONE;
283 static int __bt_bm_request_data(_bt_battery_data_t *latest)
285 int ret = _bt_bm_read_data(latest);
286 if (ret == BLUETOOTH_ERROR_NONE) {
287 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
288 latest->session_start_time, latest->session_end_time,
289 latest->session_scan_time, latest->session_connected_time);
291 if (latest->atm_list == NULL) {
292 BT_DBG("No app data transaction for this session");
296 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
297 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
298 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
302 BT_ERR("Error encountered");
306 static void __bt_service_method(GDBusConnection *connection,
308 const gchar *object_path,
309 const gchar *interface_name,
310 const gchar *method_name,
311 GVariant *parameters,
312 GDBusMethodInvocation *invocation,
317 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
318 method_name, object_path, interface_name);
320 if (g_strcmp0(method_name, "service_request") == 0) {
322 int service_function;
324 GVariant *param1 = NULL;
325 GVariant *param2 = NULL;
326 GVariant *param3 = NULL;
327 GVariant *param4 = NULL;
328 GVariant *param5 = NULL;
329 GArray *out_param1 = NULL;
330 GVariant *out_var = NULL;
331 GVariant *temp = NULL;
335 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
336 &service_function, &request_type,
337 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
339 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
341 if (service_type == BT_CORE_SERVICE) {
342 BT_DBG("No need to check privilege from bt-core");
343 } else if (__bt_service_check_privilege(service_function,
344 service_type, (const char *)sender) == FALSE) {
345 BT_ERR("Client don't have the privilege to excute this function");
346 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
350 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
351 service_type, service_function);
352 switch (service_type) {
353 case BT_BLUEZ_SERVICE:
354 result = __bt_bluez_request(service_function,
355 request_type, request_id,
356 invocation, param1, param2,
357 param3, param4, &out_param1);
359 case BT_OBEX_SERVICE:
360 result = __bt_obexd_request(service_function,
361 request_type, request_id,
364 param4, &out_param1);
366 case BT_AGENT_SERVICE:
367 result = __bt_agent_request(service_function,
368 request_type, request_id,
371 param4, &out_param1);
373 case BT_CORE_SERVICE:
374 result = __bt_core_request(service_function,
375 request_type, request_id,
378 case BT_CHECK_PRIVILEGE:
379 result = BLUETOOTH_ERROR_NONE;
382 BT_ERR("Unknown service type");
383 result = BLUETOOTH_ERROR_INTERNAL;
387 if (result != BLUETOOTH_ERROR_NONE)
390 if (service_type == BT_CHECK_PRIVILEGE)
393 if (service_function == BT_OPP_PUSH_FILES)
396 if (request_type == BT_ASYNC_REQ ||
397 __bt_is_sync_function(service_function)) {
398 /* Do not send reply to bt-api over dbus,
399 Invocation context is already saved in service_function */
404 out_var = g_variant_new_from_data((const GVariantType *)"ay",
405 out_param1->data, out_param1->len,
408 temp = g_variant_new("(iv)", result, out_var);
409 g_dbus_method_invocation_return_value(invocation, temp);
410 g_array_free(out_param1, TRUE);
414 g_variant_unref(param1);
415 g_variant_unref(param2);
416 g_variant_unref(param3);
417 g_variant_unref(param4);
418 g_variant_unref(param5);
422 BT_ERR_C("Request is failed [%s] [0x%x]",
423 _bt_convert_error_to_string(result), result);
425 out_var = g_variant_new_from_data((const GVariantType *)"ay",
426 out_param1->data, out_param1->len,
429 temp = g_variant_new("(iv)", result, out_var);
430 g_dbus_method_invocation_return_value(invocation, temp);
432 g_array_free(out_param1, TRUE);
435 g_variant_unref(param1);
436 g_variant_unref(param2);
437 g_variant_unref(param3);
438 g_variant_unref(param4);
439 g_variant_unref(param5);
441 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
442 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
443 unsigned int mode = 0;
445 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
446 BT_ERR("Fail to get the avc mode");
448 BT_DBG("Absolute Volume Control mode: %d", mode);
450 g_dbus_method_invocation_return_value(invocation,
451 g_variant_new("(u)", mode));
460 static const GDBusInterfaceVTable method_table = {
467 int __bt_bluez_request(int function_name,
470 GDBusMethodInvocation *context,
477 int result = BLUETOOTH_ERROR_NONE;
480 switch (function_name) {
481 case BT_ENABLE_ADAPTER: {
482 result = _bt_enable_adapter();
483 _bt_adapter_start_enable_timer();
486 case BT_DISABLE_ADAPTER: {
487 result = _bt_disable_adapter();
490 case BT_RECOVER_ADAPTER:
491 result = _bt_recover_adapter();
493 case BT_RESET_ADAPTER:
494 result = _bt_reset_adapter();
496 case BT_BATTERY_READ_DATA: {
497 _bt_battery_data_t *data = NULL;
498 data = g_malloc0(sizeof(_bt_battery_data_t));
499 result = __bt_bm_request_data(data);
501 bt_battery_dbus_data_t dbus_data;
502 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
503 dbus_data.session_start_time = data->session_start_time;
504 dbus_data.session_end_time = data->session_end_time;
505 dbus_data.session_scan_time = data->session_scan_time;
506 dbus_data.session_connected_time = data->session_connected_time;
507 dbus_data.tx_time = data->tx_time;
508 dbus_data.rx_time = data->rx_time;
509 dbus_data.idle_time = data->idle_time;
511 /*Populating app data*/
513 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
514 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
515 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
518 dbus_data.num_app = n;
519 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
520 g_slist_free_full(data->atm_list, g_free);
525 case BT_CHECK_ADAPTER: {
526 int enabled = BT_ADAPTER_DISABLED;
527 result = _bt_check_adapter(&enabled);
529 g_array_append_vals(*out_param1, &enabled,
533 case BT_ENABLE_ADAPTER_LE:
534 _bt_set_le_intended_status(TRUE);
535 result = _bt_enable_adapter_le();
537 case BT_DISABLE_ADAPTER_LE:
538 _bt_set_le_intended_status(FALSE);
539 result = _bt_disable_adapter_le();
541 case BT_START_DISCOVERY: {
542 unsigned short max_response;
543 unsigned short discovery_duration;
544 unsigned int classOfDeviceMask;
547 __bt_service_get_parameters(in_param1,
548 &max_response, sizeof(unsigned short));
549 __bt_service_get_parameters(in_param2,
550 &discovery_duration, sizeof(unsigned short));
551 __bt_service_get_parameters(in_param3,
552 &classOfDeviceMask, sizeof(unsigned int));
553 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
555 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
557 if (result == BLUETOOTH_ERROR_NONE) {
560 sender = (char*)g_dbus_method_invocation_get_sender(context);
562 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
563 BT_ERR("Fail to get the sender pid");
565 BT_DBG("Remeber pid / uid for the scan operation");
566 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
571 case BT_START_CUSTOM_DISCOVERY: {
572 bt_discovery_role_type_t role;
574 __bt_service_get_parameters(in_param1,
575 &role, sizeof(bt_discovery_role_type_t));
576 result = _bt_start_custom_discovery(role);
580 case BT_CANCEL_DISCOVERY:
581 result = _bt_cancel_discovery();
583 case BT_IS_DISCOVERYING: {
584 gboolean discovering = FALSE;
585 discovering = _bt_is_discovering();
586 g_array_append_vals(*out_param1,
587 &discovering, sizeof(gboolean));
590 case BT_GET_LOCAL_ADDRESS: {
591 result = _bt_get_local_address();
593 /* Save invocation */
594 if (result == BLUETOOTH_ERROR_NONE) {
595 sender = (char*)g_dbus_method_invocation_get_sender(context);
596 _bt_save_invocation_context(context, result, sender,
597 function_name, NULL);
601 case BT_GET_LOCAL_VERSION: {
602 result = _bt_get_local_version();
604 /* Save invocation */
605 if (result == BLUETOOTH_ERROR_NONE) {
606 sender = (char*)g_dbus_method_invocation_get_sender(context);
607 _bt_save_invocation_context(context, result, sender,
608 function_name, NULL);
612 case BT_GET_LOCAL_NAME: {
613 result = _bt_get_local_name();
615 /* Save invocation */
616 if (result == BLUETOOTH_ERROR_NONE) {
617 sender = (char*)g_dbus_method_invocation_get_sender(context);
618 _bt_save_invocation_context(context, result, sender,
619 function_name, NULL);
623 case BT_SET_LOCAL_NAME: {
624 bluetooth_device_name_t local_name = { {0} };
625 __bt_service_get_parameters(in_param1,
626 &local_name, sizeof(bluetooth_device_name_t));
627 result = _bt_set_local_name(local_name.name);
630 case BT_GET_DISCOVERABLE_MODE: {
631 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
632 result = _bt_get_discoverable_mode(&discoverable_mode);
633 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
636 case BT_GET_DISCOVERABLE_TIME: {
639 result = _bt_get_timeout_value(&timeout);
640 g_array_append_vals(*out_param1, &timeout, sizeof(int));
643 case BT_SET_DISCOVERABLE_MODE: {
644 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
647 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
648 __bt_service_get_parameters(in_param2, &time, sizeof(int));
650 result = _bt_set_discoverable_mode(mode, time);
653 case BT_IS_CONNECTABLE: {
654 gboolean is_connectable = FALSE;
656 is_connectable = _bt_is_connectable();
657 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
660 case BT_GET_CONNECTABLE: {
661 result = _bt_get_connectable();
663 /* Save invocation */
664 if (result == BLUETOOTH_ERROR_NONE) {
665 sender = (char*)g_dbus_method_invocation_get_sender(context);
666 _bt_save_invocation_context(context, result, sender,
667 function_name, NULL);
671 case BT_SET_CONNECTABLE: {
672 gboolean is_connectable;
674 __bt_service_get_parameters(in_param1,
675 &is_connectable, sizeof(gboolean));
676 result = _bt_set_connectable(is_connectable);
679 case BT_IS_SERVICE_USED: {
682 uuid = (char *)g_variant_get_data(in_param1);
683 BT_INFO("UUID to be searched [%s]", uuid);
684 result = _bt_is_service_used();
686 /* Save invocation */
687 if (result == BLUETOOTH_ERROR_NONE) {
688 sender = (char*)g_dbus_method_invocation_get_sender(context);
689 _bt_save_invocation_context(context, result, sender,
690 function_name, g_strdup(uuid));
694 case BT_GET_BONDED_DEVICES: {
695 result = _bt_get_bonded_devices();
696 /* Save invocation */
697 if (result == BLUETOOTH_ERROR_NONE) {
698 sender = (char*)g_dbus_method_invocation_get_sender(context);
699 _bt_save_invocation_context(context, result, sender,
700 function_name, NULL);
704 case BT_GET_BONDED_DEVICE: {
705 bluetooth_device_address_t address = { {0} };
707 __bt_service_get_parameters(in_param1,
708 &address, sizeof(bluetooth_device_address_t));
710 result = _bt_get_bonded_device_info(&address);
711 /* Save invocation */
712 if (result == BLUETOOTH_ERROR_NONE) {
713 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
715 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
719 _bt_convert_addr_type_to_string(addr, address.addr);
720 sender = (char*)g_dbus_method_invocation_get_sender(context);
721 _bt_save_invocation_context(context, result, sender,
722 function_name, addr);
726 case BT_GET_PROFILE_CONNECTED_DEVICES: {
728 uuid = (char *)g_variant_get_data(in_param1);
729 result = _bt_get_profile_connected_devices(uuid);
731 /* Save invocation */
732 if (result == BLUETOOTH_ERROR_NONE) {
733 sender = (char *)g_dbus_method_invocation_get_sender(context);
734 _bt_save_invocation_context(context, result, sender,
735 function_name, NULL);
740 bluetooth_device_address_t address = { {0} };
741 const char *local_name;
743 __bt_service_get_parameters(in_param1,
744 &address, sizeof(bluetooth_device_address_t));
745 local_name = (const char *)g_variant_get_data(in_param2);
747 result = _bt_set_alias(&address, local_name);
750 case BT_BOND_DEVICE: {
751 bluetooth_device_address_t address = { {0} };
753 __bt_service_get_parameters(in_param1,
754 &address, sizeof(bluetooth_device_address_t));
755 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
757 /* Save invocation */
758 if (result == BLUETOOTH_ERROR_NONE) {
759 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
760 _bt_convert_addr_type_to_string(addr, address.addr);
761 sender = (char*)g_dbus_method_invocation_get_sender(context);
762 _bt_save_invocation_context(context, result, sender,
763 function_name, (gpointer)addr);
765 bluetooth_device_info_t dev_info;
767 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
768 memcpy(&dev_info.device_address, &address,
769 sizeof(bluetooth_device_address_t));
770 g_array_append_vals(*out_param1, &dev_info,
771 sizeof(bluetooth_device_info_t));
775 case BT_BOND_DEVICE_BY_TYPE: {
776 bluetooth_device_address_t address = { {0} };
777 unsigned short conn_type = 0;
779 __bt_service_get_parameters(in_param1,
780 &address, sizeof(bluetooth_device_address_t));
781 __bt_service_get_parameters(in_param2,
782 &conn_type, sizeof(unsigned short));
784 result = _bt_bond_device(&address, conn_type, out_param1);
785 /* Save invocation */
786 if (result == BLUETOOTH_ERROR_NONE) {
787 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
788 _bt_convert_addr_type_to_string(addr, address.addr);
789 sender = (char*)g_dbus_method_invocation_get_sender(context);
790 _bt_save_invocation_context(context, result, sender,
791 function_name, (gpointer)addr);
793 bluetooth_device_info_t dev_info;
795 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
796 memcpy(&dev_info.device_address, &address,
797 sizeof(bluetooth_device_address_t));
798 g_array_append_vals(*out_param1, &dev_info,
799 sizeof(bluetooth_device_info_t));
803 case BT_UNBOND_DEVICE: {
804 bluetooth_device_address_t address = { {0} };
806 __bt_service_get_parameters(in_param1,
807 &address, sizeof(bluetooth_device_address_t));
808 result = _bt_unbond_device(&address, out_param1);
810 /* Save invocation */
811 if (result == BLUETOOTH_ERROR_NONE) {
812 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
813 _bt_convert_addr_type_to_string(addr, address.addr);
814 sender = (char*)g_dbus_method_invocation_get_sender(context);
815 _bt_save_invocation_context(context, result, sender,
816 function_name, (gpointer)addr);
818 g_array_append_vals(*out_param1, &address,
819 sizeof(bluetooth_device_address_t));
823 case BT_CANCEL_BONDING:{
824 result = _bt_cancel_bonding();
827 case BT_SEARCH_SERVICE: {
828 bluetooth_device_address_t address = { {0} };
829 __bt_service_get_parameters(in_param1,
830 &address, sizeof(bluetooth_device_address_t));
831 result = _bt_search_device(&address);
832 /* Save invocation */
833 if (result == BLUETOOTH_ERROR_NONE) {
834 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
835 _bt_convert_addr_type_to_string(addr, address.addr);
836 sender = (char*)g_dbus_method_invocation_get_sender(context);
837 _bt_save_invocation_context(context, result, sender,
838 function_name, (gpointer)addr);
840 bt_sdp_info_t sdp_info;
842 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
843 memcpy(&sdp_info.device_addr, &address,
844 sizeof(bluetooth_device_address_t));
845 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
849 case BT_CANCEL_SEARCH_SERVICE: {
850 result = _bt_cancel_search_device();
853 case BT_SET_PASSKEY_NOTIFICATION: {
857 sender = (char *)g_dbus_method_invocation_get_sender(context);
858 __bt_service_get_parameters(in_param1,
859 &enable, sizeof(gboolean));
861 result = _bt_set_passkey_notification(sender, enable);
864 case BT_SET_PIN_CODE: {
865 bluetooth_device_address_t address = { {0} };
866 bluetooth_device_pin_code_t pin_code = { {0} };
868 __bt_service_get_parameters(in_param1,
869 &address, sizeof(bluetooth_device_address_t));
870 __bt_service_get_parameters(in_param2,
871 &pin_code, sizeof(bluetooth_device_pin_code_t));
873 result = _bt_set_pin_code(&address, &pin_code);
876 case BT_UNSET_PIN_CODE: {
877 bluetooth_device_address_t address = { {0} };
879 __bt_service_get_parameters(in_param1,
880 &address, sizeof(bluetooth_device_address_t));
882 result = _bt_unset_pin_code(&address);
885 case BT_PASSKEY_REPLY: {
886 const char *passkey = NULL;
887 gboolean authentication_reply = FALSE;
888 passkey = g_variant_get_data(in_param1);
889 __bt_service_get_parameters(in_param2,
890 &authentication_reply, sizeof(gboolean));
891 result = _bt_passkey_reply(passkey, authentication_reply);
894 case BT_PASSKEY_CONFIRMATION_REPLY: {
895 gboolean confirmation_reply = FALSE;
896 __bt_service_get_parameters(in_param1,
897 &confirmation_reply, sizeof(gboolean));
898 result = _bt_passkey_confirmation_reply(confirmation_reply);
901 case BT_GET_IS_ALIAS_SET: {
902 bluetooth_device_address_t address = { {0} };
904 __bt_service_get_parameters(in_param1,
905 &address, sizeof(bluetooth_device_address_t));
907 result = _bt_is_alias_set(&address);
908 if (result == BLUETOOTH_ERROR_NONE) {
909 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
911 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
915 _bt_convert_addr_type_to_string(addr, address.addr);
916 sender = (char*)g_dbus_method_invocation_get_sender(context);
917 _bt_save_invocation_context(context, result, sender,
918 function_name, addr);
922 case BT_SET_AUTHORIZATION: {
923 bluetooth_device_address_t address = { {0} };
925 __bt_service_get_parameters(in_param1,
926 &address, sizeof(bluetooth_device_address_t));
927 __bt_service_get_parameters(in_param2,
928 &authorize, sizeof(gboolean));
929 result = _bt_set_authorization(&address, authorize);
932 case BT_SET_LE_PRIVACY: {
933 gboolean set_privacy;
934 __bt_service_get_parameters(in_param1, &set_privacy,
936 result = _bt_set_le_privacy(set_privacy);
939 case BT_ADD_WHITE_LIST: {
940 bluetooth_device_address_t address = { {0} };
941 int address_type = 0;
943 __bt_service_get_parameters(in_param1,
944 &address, sizeof(bluetooth_device_address_t));
945 __bt_service_get_parameters(in_param2,
946 &address_type, sizeof(int));
947 result = _bt_set_white_list(&address, address_type, is_add);
950 case BT_REMOVE_WHITE_LIST: {
951 bluetooth_device_address_t address = { {0} };
952 int address_type = 0;
954 __bt_service_get_parameters(in_param1,
955 &address, sizeof(bluetooth_device_address_t));
956 __bt_service_get_parameters(in_param2,
957 &address_type, sizeof(int));
958 result = _bt_set_white_list(&address, address_type, is_add);
961 case BT_UPDATE_LE_CONNECTION_MODE: {
963 bluetooth_device_address_t remote_address = { { 0 } };
964 bluetooth_le_connection_param_t parameters = { 0 };
965 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
967 __bt_service_get_parameters(in_param1, &remote_address,
968 sizeof(bluetooth_device_address_t));
969 __bt_service_get_parameters(in_param2, &mode,
970 sizeof(bluetooth_le_connection_mode_t));
972 result = _bt_get_le_connection_parameter(mode, ¶meters);
973 if (result != BLUETOOTH_ERROR_NONE)
976 sender = (char *)g_dbus_method_invocation_get_sender(context);
978 result = _bt_le_connection_update(sender,
980 parameters.interval_min,
981 parameters.interval_max,
986 case BT_SET_MANUFACTURER_DATA: {
987 bluetooth_manufacturer_data_t m_data = { 0 };
988 __bt_service_get_parameters(in_param1,
989 &m_data, sizeof(bluetooth_manufacturer_data_t));
990 result = _bt_set_manufacturer_data(&m_data);
994 case BT_IS_DEVICE_CONNECTED: {
995 bluetooth_device_address_t address = { {0} };
996 gboolean connected = FALSE;
999 __bt_service_get_parameters(in_param1,
1000 &address, sizeof(bluetooth_device_address_t));
1001 __bt_service_get_parameters(in_param2,
1002 &service_type, sizeof(int));
1004 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1005 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1006 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1008 connected = _bt_is_device_connected(&address, service_type);
1010 connected = _bt_is_device_connected(&address, service_type);
1012 BT_INFO("is_connected: %d", connected);
1013 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1016 case BT_GET_CONNECTED_LINK_TYPE: {
1017 bluetooth_device_address_t address = { {0} };
1019 __bt_service_get_parameters(in_param1,
1020 &address, sizeof(bluetooth_device_address_t));
1022 result = _bt_get_connected_link(&address);
1023 if (result == BLUETOOTH_ERROR_NONE) {
1024 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1026 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1030 _bt_convert_addr_type_to_string(addr, address.addr);
1031 sender = (char*)g_dbus_method_invocation_get_sender(context);
1032 _bt_save_invocation_context(context, result, sender,
1033 function_name, addr);
1037 case BT_IS_SCAN_FILTER_SUPPORTED:{
1038 int is_supported = 0;
1040 if (_bt_is_scan_filter_supported() == TRUE)
1043 g_array_append_vals(*out_param1,
1044 &is_supported, sizeof(int));
1048 case BT_ENABLE_RSSI: {
1049 bluetooth_device_address_t bd_addr;
1051 bt_rssi_threshold_t rssi_threshold;
1053 int in_range_threshold;
1056 BT_DBG("Enable RSSI");
1058 __bt_service_get_parameters(in_param1,
1059 &bd_addr, sizeof(bluetooth_device_address_t));
1060 __bt_service_get_parameters(in_param2,
1061 &link_type, sizeof(int));
1062 __bt_service_get_parameters(in_param3,
1063 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1065 low_threshold = rssi_threshold.low_threshold;
1066 in_range_threshold = rssi_threshold.in_range_threshold;
1067 high_threshold = rssi_threshold.high_threshold;
1069 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1070 in_range_threshold, high_threshold);
1075 bluetooth_device_address_t bd_addr;
1077 BT_DBG("Get RSSI Strength");
1079 __bt_service_get_parameters(in_param1,
1080 &bd_addr, sizeof(bluetooth_device_address_t));
1081 __bt_service_get_parameters(in_param2,
1082 &link_type, sizeof(int));
1084 result = _bt_get_rssi_strength(&bd_addr, link_type);
1087 case BT_SET_PROFILE_TRUSTED: {
1088 bluetooth_device_address_t bd_addr = { {0} };
1092 __bt_service_get_parameters(in_param1, &bd_addr,
1093 sizeof(bluetooth_device_address_t));
1094 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1095 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1097 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1100 case BT_GET_PROFILE_TRUSTED: {
1101 bluetooth_device_address_t bd_addr = { {0} };
1103 guint trusted_profile = 0;
1105 __bt_service_get_parameters(in_param1, &bd_addr,
1106 sizeof(bluetooth_device_address_t));
1107 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1109 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1110 BT_DBG("TRUST %d", trusted_profile);
1111 if (result == BLUETOOTH_ERROR_NONE) {
1112 g_array_append_vals(*out_param1, &trusted_profile,
1118 case BT_HID_CONNECT: {
1119 bluetooth_device_address_t address = { {0} };
1121 __bt_service_get_parameters(in_param1,
1122 &address, sizeof(bluetooth_device_address_t));
1124 result = _bt_hid_connect(&address);
1125 if (result != BLUETOOTH_ERROR_NONE) {
1126 g_array_append_vals(*out_param1, &address,
1127 sizeof(bluetooth_device_address_t));
1129 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1130 _bt_convert_addr_type_to_string(addr, address.addr);
1131 sender = (char*)g_dbus_method_invocation_get_sender(context);
1132 _bt_save_invocation_context(context, result, sender,
1133 function_name, (gpointer)addr);
1137 case BT_HID_DISCONNECT: {
1138 bluetooth_device_address_t address = { {0} };
1140 __bt_service_get_parameters(in_param1,
1141 &address, sizeof(bluetooth_device_address_t));
1143 result = _bt_hid_disconnect(&address);
1144 if (result != BLUETOOTH_ERROR_NONE) {
1145 g_array_append_vals(*out_param1, &address,
1146 sizeof(bluetooth_device_address_t));
1148 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1149 _bt_convert_addr_type_to_string(addr, address.addr);
1150 sender = (char*)g_dbus_method_invocation_get_sender(context);
1151 _bt_save_invocation_context(context, result, sender,
1152 function_name, (gpointer)addr);
1156 #ifdef TIZEN_FEATURE_BT_DPM
1157 case BT_DPM_SET_ALLOW_BT_MODE: {
1158 dpm_bt_allow_t value = DPM_BT_ERROR;
1160 __bt_service_get_parameters(in_param1, &value,
1163 result = _bt_dpm_set_allow_bluetooth_mode(value);
1166 case BT_DPM_GET_ALLOW_BT_MODE: {
1167 int value = DPM_BT_ERROR;
1169 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1170 g_array_append_vals(*out_param1, &value, sizeof(int));
1173 case BT_DPM_SET_DEVICE_RESTRITION: {
1174 dpm_status_t value = DPM_STATUS_ERROR;
1176 __bt_service_get_parameters(in_param1, &value,
1179 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1182 case BT_DPM_GET_DEVICE_RESTRITION: {
1183 int value = DPM_STATUS_ERROR;
1185 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1186 g_array_append_vals(*out_param1, &value, sizeof(int));
1189 case BT_DPM_SET_UUID_RESTRITION: {
1190 dpm_status_t value = DPM_STATUS_ERROR;
1192 __bt_service_get_parameters(in_param1, &value,
1195 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1198 case BT_DPM_GET_UUID_RESTRITION: {
1199 int value = DPM_STATUS_ERROR;
1201 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1202 g_array_append_vals(*out_param1, &value, sizeof(int));
1205 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1206 bluetooth_device_address_t address = { {0} };
1208 __bt_service_get_parameters(in_param1, &address,
1209 sizeof(bluetooth_device_address_t));
1211 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1214 case BT_DPM_ADD_DEVICES_WHITELIST: {
1215 bluetooth_device_address_t address = { {0} };
1217 __bt_service_get_parameters(in_param1, &address,
1218 sizeof(bluetooth_device_address_t));
1220 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1223 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1224 const char *uuid = NULL;
1226 uuid = g_variant_get_data(in_param1);
1228 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1231 case BT_DPM_ADD_UUIDS_WHITELIST: {
1232 const char *uuid = NULL;
1234 uuid = g_variant_get_data(in_param1);
1236 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1239 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1240 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1243 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1244 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1247 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1248 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1251 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1252 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1255 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1256 bluetooth_device_address_t address = { {0} };
1258 __bt_service_get_parameters(in_param1, &address,
1259 sizeof(bluetooth_device_address_t));
1261 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1264 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1265 bluetooth_device_address_t address = { {0} };
1267 __bt_service_get_parameters(in_param1, &address,
1268 sizeof(bluetooth_device_address_t));
1270 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1273 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1274 const char *uuid = NULL;
1276 uuid = g_variant_get_data(in_param1);
1278 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1281 case BT_DPM_REMOVE_UUID_WHITELIST: {
1282 const char *uuid = NULL;
1284 uuid = g_variant_get_data(in_param1);
1286 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1290 case BT_DPM_GET_DEVICES_BLACKLIST: {
1291 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1294 case BT_DPM_GET_DEVICES_WHITELIST: {
1295 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1298 case BT_DPM_GET_UUIDS_BLACKLIST: {
1299 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1302 case BT_DPM_GET_UUIDS_WHITELIST: {
1303 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1306 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1307 dpm_status_t value = DPM_STATUS_ERROR;
1309 __bt_service_get_parameters(in_param1, &value,
1312 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1316 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1317 int value = DPM_STATUS_ERROR;
1319 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1320 g_array_append_vals(*out_param1, &value, sizeof(int));
1323 case BT_DPM_SET_PAIRING_STATE: {
1324 dpm_status_t value = DPM_STATUS_ERROR;
1326 __bt_service_get_parameters(in_param1, &value,
1329 result = _bt_dpm_set_bluetooth_pairing_state(value);
1333 case BT_DPM_GET_PAIRING_STATE: {
1334 int value = DPM_STATUS_ERROR;
1336 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1337 g_array_append_vals(*out_param1, &value, sizeof(int));
1340 case BT_DPM_SET_PROFILE_STATE: {
1341 int value = DPM_STATUS_ERROR;
1342 int profile = DPM_PROFILE_NONE;
1344 __bt_service_get_parameters(in_param1, &profile,
1346 __bt_service_get_parameters(in_param2, &value,
1349 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1353 case BT_DPM_GET_PROFILE_STATE: {
1354 int value = DPM_STATUS_ERROR;
1355 int profile = DPM_PROFILE_NONE;
1357 __bt_service_get_parameters(in_param1, &profile,
1360 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1361 g_array_append_vals(*out_param1, &value, sizeof(int));
1364 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1365 int value = DPM_BT_ERROR;
1367 __bt_service_get_parameters(in_param1, &value,
1370 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1374 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1375 int value = DPM_STATUS_ERROR;
1377 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1378 g_array_append_vals(*out_param1, &value, sizeof(int));
1381 case BT_DPM_SET_DISCOVERABLE_STATE: {
1382 int value = DPM_STATUS_ERROR;
1384 __bt_service_get_parameters(in_param1, &value,
1387 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1391 case BT_DPM_GET_DISCOVERABLE_STATE: {
1392 int value = DPM_STATUS_ERROR;
1394 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1395 g_array_append_vals(*out_param1, &value, sizeof(int));
1398 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1399 int value = DPM_STATUS_ERROR;
1401 __bt_service_get_parameters(in_param1, &value,
1404 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1408 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1409 int value = DPM_STATUS_ERROR;
1411 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1412 g_array_append_vals(*out_param1, &value, sizeof(int));
1415 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1416 int value = DPM_STATUS_ERROR;
1418 __bt_service_get_parameters(in_param1, &value,
1421 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1425 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1426 int value = DPM_STATUS_ERROR;
1428 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1429 g_array_append_vals(*out_param1, &value, sizeof(int));
1433 case BT_RFCOMM_CLIENT_CONNECT: {
1434 bluetooth_device_address_t address = { {0} };
1438 __bt_service_get_parameters(in_param1,
1439 &address, sizeof(bluetooth_device_address_t));
1440 input_string = (char *)g_variant_get_data(in_param2);
1441 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1443 if (connect_type == BT_RFCOMM_UUID)
1444 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1446 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1448 if (result != BLUETOOTH_ERROR_NONE) {
1449 bluetooth_rfcomm_connection_t conn_info;
1451 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1452 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1453 if (connect_type == BT_RFCOMM_UUID)
1454 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1456 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1458 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1459 conn_info.socket_fd = -1;
1460 g_array_append_vals(*out_param1, &conn_info,
1461 sizeof(bluetooth_rfcomm_connection_t));
1463 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1464 _bt_convert_addr_type_to_string(addr, address.addr);
1465 sender = (char*)g_dbus_method_invocation_get_sender(context);
1466 _bt_save_invocation_context(context, result, sender, function_name, addr);
1470 case BT_RFCOMM_SOCKET_DISCONNECT: {
1472 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1473 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1475 result = BLUETOOTH_ERROR_NONE;
1478 case BT_RFCOMM_SOCKET_WRITE: {
1480 * This call to bt-service is only used for privilege check, so return
1481 * BLUETOOTH_ERROR_NONE from here.
1483 result = BLUETOOTH_ERROR_NONE;
1486 case BT_RFCOMM_CREATE_SOCKET: {
1488 * This call to bt-service is only used for privilege check, so return
1489 * BLUETOOTH_ERROR_NONE from here.
1491 result = BLUETOOTH_ERROR_NONE;
1494 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1498 sender = (char *)g_dbus_method_invocation_get_sender(context);
1499 uuid = (char *)g_variant_get_data(in_param1);
1501 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1503 result = BLUETOOTH_ERROR_NONE;
1504 _bt_save_invocation_context(context,
1505 result, sender, function_name, NULL);
1507 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1511 case BT_RFCOMM_LISTEN: {
1515 sender = (char *)g_dbus_method_invocation_get_sender(context);
1516 uuid = (char *)g_variant_get_data(in_param1);
1518 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1520 result = BLUETOOTH_ERROR_NONE;
1521 _bt_save_invocation_context(context,
1522 result, sender, function_name, NULL);
1524 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1528 case BT_RFCOMM_ACCEPT_CONNECTION: {
1531 address = (char *)g_variant_get_data(in_param1);
1532 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1535 case BT_RFCOMM_REJECT_CONNECTION: {
1538 address = (char *)g_variant_get_data(in_param1);
1539 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1542 case BT_RFCOMM_REMOVE_SOCKET: {
1544 * This call to bt-service is only used for privilege check, so return
1545 * BLUETOOTH_ERROR_NONE from here.
1547 result = BLUETOOTH_ERROR_NONE;
1550 case BT_RFCOMM_SEND_RX_DETAILS: {
1554 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1555 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1556 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1557 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1560 case BT_RFCOMM_SEND_TX_DETAILS: {
1564 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1565 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1566 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1567 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1570 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1571 gboolean connected = FALSE;
1573 int role = RFCOMM_ROLE_SERVER;
1575 sender = (char *)g_dbus_method_invocation_get_sender(context);
1577 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1578 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1579 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1581 if (connected == TRUE)
1582 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1584 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1588 case BT_AUDIO_SELECT_ROLE: {
1589 bluetooth_audio_role_t role;
1591 __bt_service_get_parameters(in_param1,
1592 &role, sizeof(bluetooth_audio_role_t));
1594 result = _bt_audio_select_role(role);
1595 if (result == BLUETOOTH_ERROR_NONE) {
1596 sender = (char*)g_dbus_method_invocation_get_sender(context);
1597 _bt_save_invocation_context(context, result, sender,
1598 function_name, NULL);
1602 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
1603 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1604 unsigned int volume = 0;
1606 __bt_service_get_parameters(in_param1,
1607 &volume, sizeof(unsigned int));
1609 result = _bt_audio_set_absolute_volume(volume);
1612 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1613 unsigned int volume = 0;
1615 result = _bt_audio_get_absolute_volume(&volume);
1616 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1619 case BT_AUDIO_IS_AVC_ACTIVATED: {
1622 result = _bt_audio_is_avc_activated(&activated);
1623 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1627 case BT_AV_CONNECT: {
1628 bluetooth_device_address_t address = { {0} };
1629 __bt_service_get_parameters(in_param1,
1630 &address, sizeof(bluetooth_device_address_t));
1632 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1634 if (result != BLUETOOTH_ERROR_NONE) {
1635 char addr[BT_ADDRESS_STRING_SIZE];
1636 _bt_convert_addr_type_to_string(addr, address.addr);
1637 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1639 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1640 _bt_convert_addr_type_to_string(addr, address.addr);
1641 sender = (char*)g_dbus_method_invocation_get_sender(context);
1642 _bt_save_invocation_context(context, result, sender,
1643 function_name, (gpointer)addr);
1647 case BT_AUDIO_CONNECT: {
1648 bluetooth_device_address_t address = { {0} };
1649 __bt_service_get_parameters(in_param1,
1650 &address, sizeof(bluetooth_device_address_t));
1652 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1654 if (result != BLUETOOTH_ERROR_NONE) {
1655 char addr[BT_ADDRESS_STRING_SIZE];
1656 _bt_convert_addr_type_to_string(addr, address.addr);
1657 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1659 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1660 _bt_convert_addr_type_to_string(addr, address.addr);
1661 sender = (char*)g_dbus_method_invocation_get_sender(context);
1662 _bt_save_invocation_context(context, result, sender,
1663 function_name, (gpointer)addr);
1667 case BT_AUDIO_DISCONNECT: {
1668 bluetooth_device_address_t address = { {0} };
1669 __bt_service_get_parameters(in_param1,
1670 &address, sizeof(bluetooth_device_address_t));
1672 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1674 if (result != BLUETOOTH_ERROR_NONE) {
1675 char addr[BT_ADDRESS_STRING_SIZE];
1676 _bt_convert_addr_type_to_string(addr, address.addr);
1677 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1679 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1680 _bt_convert_addr_type_to_string(addr, address.addr);
1681 sender = (char*)g_dbus_method_invocation_get_sender(context);
1682 _bt_save_invocation_context(context, result, sender,
1683 function_name, (gpointer)addr);
1687 case BT_AV_DISCONNECT: {
1688 bluetooth_device_address_t address = { {0} };
1689 __bt_service_get_parameters(in_param1,
1690 &address, sizeof(bluetooth_device_address_t));
1692 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1694 if (result != BLUETOOTH_ERROR_NONE) {
1695 char addr[BT_ADDRESS_STRING_SIZE];
1696 _bt_convert_addr_type_to_string(addr, address.addr);
1697 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1699 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1700 _bt_convert_addr_type_to_string(addr, address.addr);
1701 sender = (char*)g_dbus_method_invocation_get_sender(context);
1702 _bt_save_invocation_context(context, result, sender,
1703 function_name, (gpointer)addr);
1707 case BT_AG_CONNECT: {
1708 bluetooth_device_address_t address = { {0} };
1709 __bt_service_get_parameters(in_param1,
1710 &address, sizeof(bluetooth_device_address_t));
1712 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1714 if (result != BLUETOOTH_ERROR_NONE) {
1715 char addr[BT_ADDRESS_STRING_SIZE];
1716 _bt_convert_addr_type_to_string(addr, address.addr);
1717 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1719 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1720 _bt_convert_addr_type_to_string(addr, address.addr);
1721 sender = (char*)g_dbus_method_invocation_get_sender(context);
1722 _bt_save_invocation_context(context, result, sender,
1723 function_name, (gpointer)addr);
1727 case BT_AG_DISCONNECT: {
1728 bluetooth_device_address_t address = { {0} };
1730 __bt_service_get_parameters(in_param1,
1731 &address, sizeof(bluetooth_device_address_t));
1733 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1735 if (result != BLUETOOTH_ERROR_NONE) {
1736 char addr[BT_ADDRESS_STRING_SIZE];
1737 _bt_convert_addr_type_to_string(addr, address.addr);
1738 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1740 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1741 _bt_convert_addr_type_to_string(addr, address.addr);
1742 sender = (char*)g_dbus_method_invocation_get_sender(context);
1743 _bt_save_invocation_context(context, result, sender,
1744 function_name, (gpointer)addr);
1748 case BT_AV_SOURCE_CONNECT: {
1749 bluetooth_device_address_t address = { {0} };
1751 __bt_service_get_parameters(in_param1,
1752 &address, sizeof(bluetooth_device_address_t));
1754 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1755 if (result != BLUETOOTH_ERROR_NONE) {
1756 char addr[BT_ADDRESS_STRING_SIZE];
1757 _bt_convert_addr_type_to_string(addr, address.addr);
1758 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1760 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1761 _bt_convert_addr_type_to_string(addr, address.addr);
1762 sender = (char*)g_dbus_method_invocation_get_sender(context);
1763 _bt_save_invocation_context(context, result, sender,
1764 function_name, (gpointer)addr);
1768 case BT_AV_SOURCE_DISCONNECT: {
1769 bluetooth_device_address_t address = { {0} };
1771 __bt_service_get_parameters(in_param1,
1772 &address, sizeof(bluetooth_device_address_t));
1774 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1775 if (result != BLUETOOTH_ERROR_NONE) {
1776 char addr[BT_ADDRESS_STRING_SIZE];
1777 _bt_convert_addr_type_to_string(addr, address.addr);
1778 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1780 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1781 _bt_convert_addr_type_to_string(addr, address.addr);
1782 sender = (char*)g_dbus_method_invocation_get_sender(context);
1783 _bt_save_invocation_context(context, result, sender,
1784 function_name, (gpointer)addr);
1788 case BT_HF_CONNECT: {
1789 bluetooth_device_address_t address = { {0} };
1791 __bt_service_get_parameters(in_param1,
1792 &address, sizeof(bluetooth_device_address_t));
1794 result = _bt_hf_connect(&address);
1795 if (result != BLUETOOTH_ERROR_NONE) {
1796 char addr[BT_ADDRESS_STRING_SIZE];
1797 _bt_convert_addr_type_to_string(addr, address.addr);
1798 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1800 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1801 _bt_convert_addr_type_to_string(addr, address.addr);
1802 sender = (char*)g_dbus_method_invocation_get_sender(context);
1803 _bt_save_invocation_context(context, result, sender,
1804 function_name, (gpointer)addr);
1808 case BT_HF_DISCONNECT: {
1809 bluetooth_device_address_t address = { {0} };
1811 __bt_service_get_parameters(in_param1,
1812 &address, sizeof(bluetooth_device_address_t));
1814 result = _bt_hf_disconnect(&address);
1815 if (result != BLUETOOTH_ERROR_NONE) {
1816 char addr[BT_ADDRESS_STRING_SIZE];
1817 _bt_convert_addr_type_to_string(addr, address.addr);
1818 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1820 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1821 _bt_convert_addr_type_to_string(addr, address.addr);
1822 sender = (char*)g_dbus_method_invocation_get_sender(context);
1823 _bt_save_invocation_context(context, result, sender,
1824 function_name, (gpointer)addr);
1828 case BT_AVRCP_TARGET_CONNECT: {
1829 bluetooth_device_address_t address = { {0} };
1831 __bt_service_get_parameters(in_param1,
1832 &address, sizeof(bluetooth_device_address_t));
1834 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1835 if (result != BLUETOOTH_ERROR_NONE) {
1836 char addr[BT_ADDRESS_STRING_SIZE];
1837 _bt_convert_addr_type_to_string(addr, address.addr);
1838 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1840 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1841 _bt_convert_addr_type_to_string(addr, address.addr);
1842 sender = (char*)g_dbus_method_invocation_get_sender(context);
1843 _bt_save_invocation_context(context, result, sender,
1844 function_name, (gpointer)addr);
1848 case BT_AVRCP_TARGET_DISCONNECT: {
1849 bluetooth_device_address_t address = { {0} };
1851 __bt_service_get_parameters(in_param1,
1852 &address, sizeof(bluetooth_device_address_t));
1854 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1855 if (result != BLUETOOTH_ERROR_NONE) {
1856 char addr[BT_ADDRESS_STRING_SIZE];
1857 _bt_convert_addr_type_to_string(addr, address.addr);
1858 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1860 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1861 _bt_convert_addr_type_to_string(addr, address.addr);
1862 sender = (char*)g_dbus_method_invocation_get_sender(context);
1863 _bt_save_invocation_context(context, result, sender,
1864 function_name, (gpointer)addr);
1868 case BT_AVRCP_CONTROL_CONNECT: {
1869 bluetooth_device_address_t address = { {0} };
1871 __bt_service_get_parameters(in_param1,
1872 &address, sizeof(bluetooth_device_address_t));
1874 result = _bt_audio_connect(BT_AVRCP, &address);
1875 if (result != BLUETOOTH_ERROR_NONE) {
1876 char addr[BT_ADDRESS_STRING_SIZE];
1877 _bt_convert_addr_type_to_string(addr, address.addr);
1878 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1880 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1881 _bt_convert_addr_type_to_string(addr, address.addr);
1882 sender = (char*)g_dbus_method_invocation_get_sender(context);
1883 _bt_save_invocation_context(context, result, sender,
1884 function_name, (gpointer)addr);
1888 case BT_AVRCP_CONTROL_DISCONNECT: {
1889 bluetooth_device_address_t address = { {0} };
1891 __bt_service_get_parameters(in_param1,
1892 &address, sizeof(bluetooth_device_address_t));
1894 result = _bt_audio_disconnect(BT_AVRCP, &address);
1895 if (result != BLUETOOTH_ERROR_NONE) {
1896 char addr[BT_ADDRESS_STRING_SIZE];
1897 _bt_convert_addr_type_to_string(addr, address.addr);
1898 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1900 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1901 _bt_convert_addr_type_to_string(addr, address.addr);
1902 sender = (char*)g_dbus_method_invocation_get_sender(context);
1903 _bt_save_invocation_context(context, result, sender,
1904 function_name, (gpointer)addr);
1908 case BT_AVRCP_HANDLE_CONTROL: {
1910 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1911 result = _bt_avrcp_control_cmd(key_code);
1914 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1916 bluetooth_device_address_t address = { { 0 } };
1918 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1919 __bt_service_get_parameters(in_param2,
1920 &address, sizeof(bluetooth_device_address_t));
1922 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1925 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1929 __bt_service_get_parameters(in_param1,
1930 &type, sizeof(int));
1931 __bt_service_get_parameters(in_param2,
1932 &value, sizeof(unsigned int));
1934 result = _bt_avrcp_control_set_property(type, value);
1937 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1942 __bt_service_get_parameters(in_param1,
1943 &type, sizeof(int));
1944 __bt_service_get_parameters(in_param2,
1945 &value, sizeof(unsigned int));
1947 result = _bt_avrcp_transport_set_property(type, value);
1951 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1954 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1956 result = _bt_avrcp_control_get_property(type);
1957 /* Save invocation */
1958 if (result == BLUETOOTH_ERROR_NONE) {
1959 sender = (char*)g_dbus_method_invocation_get_sender(context);
1960 _bt_save_invocation_context(context, result, sender,
1961 function_name, g_memdup(&type, sizeof(int)));
1965 case BT_AVRCP_GET_TRACK_INFO: {
1966 result = _bt_avrcp_control_get_track_info();
1967 /* Save invocation */
1968 if (result == BLUETOOTH_ERROR_NONE) {
1969 sender = (char*)g_dbus_method_invocation_get_sender(context);
1970 _bt_save_invocation_context(context, result, sender,
1971 function_name, NULL);
1975 case BT_HDP_REGISTER_SINK_APP: {
1976 unsigned short data_type;
1977 bt_hdp_role_type_t role;
1978 bt_hdp_qos_type_t channel_type;
1979 int *app_id = g_new0(int, 1);
1981 __bt_service_get_parameters(in_param1,
1982 &data_type, sizeof(short));
1983 __bt_service_get_parameters(in_param2,
1984 &role, sizeof(bt_hdp_role_type_t));
1985 __bt_service_get_parameters(in_param3,
1986 &channel_type, sizeof(bt_hdp_qos_type_t));
1987 sender = (char*)g_dbus_method_invocation_get_sender(context);
1989 result = _bt_hdp_app_register(role,
1990 channel_type, data_type, sender, app_id);
1991 if (result != BLUETOOTH_ERROR_NONE) {
1992 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1995 _bt_save_invocation_context(context, result, sender,
1996 function_name, (gpointer)app_id);
2000 case BT_HDP_UNREGISTER_SINK_APP: {
2002 int *app_id = g_new0(int, 1);
2004 app_handle = (char *)g_variant_get_data(in_param1);
2005 sscanf(app_handle, "health_app_%d", app_id);
2006 result = _bt_hdp_app_unregister(*app_id);
2007 if (result != BLUETOOTH_ERROR_NONE) {
2010 sender = (char*)g_dbus_method_invocation_get_sender(context);
2011 _bt_save_invocation_context(context, result, sender,
2012 function_name, (gpointer)app_id);
2016 case BT_HDP_CONNECT: {
2020 bt_hdp_connected_t *conn_info = NULL;
2022 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2024 app_handle = (char *)g_variant_get_data(in_param1);
2025 conn_info->app_handle = app_handle;
2026 sscanf(app_handle, "health_app_%d", &app_id);
2028 __bt_service_get_parameters(in_param2,
2029 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2030 __bt_service_get_parameters(in_param3,
2031 &(conn_info->device_address),
2032 sizeof(bluetooth_device_address_t));
2034 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2035 conn_info->type, (int *)(&(conn_info->channel_id)));
2036 if (result != BLUETOOTH_ERROR_NONE) {
2037 g_array_append_vals(*out_param1, conn_info,
2038 sizeof(bt_hdp_connected_t));
2041 sender = (char*)g_dbus_method_invocation_get_sender(context);
2042 _bt_save_invocation_context(context, result, sender,
2043 function_name, (gpointer)conn_info);
2047 case BT_HDP_DISCONNECT: {
2048 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2050 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2052 __bt_service_get_parameters(in_param1,
2053 &(hdp_disconn_info->channel_id), sizeof(int));
2054 __bt_service_get_parameters(in_param2,
2055 &(hdp_disconn_info->device_address),
2056 sizeof(bluetooth_device_address_t));
2058 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2059 if (result != BLUETOOTH_ERROR_NONE) {
2060 g_array_append_vals(*out_param1, hdp_disconn_info,
2061 sizeof(bt_hdp_disconnected_t));
2062 g_free(hdp_disconn_info);
2064 sender = (char*)g_dbus_method_invocation_get_sender(context);
2065 _bt_save_invocation_context(context, result, sender,
2066 function_name, (gpointer)hdp_disconn_info);
2070 case BT_HDP_GET_FD: {
2071 int *channel_id = g_new0(int, 1);
2073 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2075 result = _bt_hdp_get_fd(*channel_id);
2076 if (result != BLUETOOTH_ERROR_NONE) {
2079 sender = (char*)g_dbus_method_invocation_get_sender(context);
2080 _bt_save_invocation_context(context, result, sender,
2081 function_name, (gpointer)channel_id);
2085 case BT_HDP_SEND_DATA: {
2087 * This call to bt-service is only used for privilege check, so return
2088 * BLUETOOTH_ERROR_NONE from here.
2090 result = BLUETOOTH_ERROR_NONE;
2093 case BT_OOB_READ_LOCAL_DATA: { //208
2094 bt_oob_data_t local_oob_data;
2096 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2097 result = _bt_oob_read_local_data(&local_oob_data);
2099 g_array_append_vals(*out_param1, &local_oob_data,
2100 sizeof(bt_oob_data_t));
2104 case BT_OOB_ADD_REMOTE_DATA: { //209
2105 bluetooth_device_address_t address = { {0} };
2106 unsigned short address_type;
2107 bt_oob_data_t remote_oob_data;
2109 __bt_service_get_parameters(in_param1,
2110 &address, sizeof(bluetooth_device_address_t));
2111 __bt_service_get_parameters(in_param2,
2112 &address_type, sizeof(unsigned short));
2113 __bt_service_get_parameters(in_param3,
2114 &remote_oob_data, sizeof(bt_oob_data_t));
2116 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2120 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2121 bluetooth_device_address_t address = { {0} };
2123 __bt_service_get_parameters(in_param1,
2124 &address, sizeof(bluetooth_device_address_t));
2126 result = _bt_oob_remove_remote_data(&address);
2130 case BT_LE_OOB_READ_LOCAL_DATA: {
2131 bt_oob_data_t local_oob_data;
2132 bt_oob_data_t *local_oob_cache_data;
2134 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2135 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2136 g_array_append_vals(*out_param1, local_oob_cache_data,
2137 sizeof(bt_oob_data_t));
2138 return BLUETOOTH_ERROR_NONE;
2141 /* We should modify this logic in later */
2142 if (_bt_is_le_static_random_address_enabled() == false) {
2143 /* Seperate BT & LE address */
2144 _bt_set_le_static_random_address(TRUE);
2147 result = _bt_le_oob_read_local_data(&local_oob_data);
2148 _bt_le_oob_set_local_cache_data(&local_oob_data);
2150 g_array_append_vals(*out_param1, &local_oob_data,
2151 sizeof(bt_oob_data_t));
2155 case BT_LE_OOB_ADD_REMOTE_DATA: {
2156 bluetooth_device_address_t address = { {0} };
2157 unsigned short address_type;
2158 bt_oob_data_t remote_oob_data;
2160 __bt_service_get_parameters(in_param1,
2161 &address, sizeof(bluetooth_device_address_t));
2162 __bt_service_get_parameters(in_param2,
2163 &address_type, sizeof(unsigned short));
2164 __bt_service_get_parameters(in_param3,
2165 &remote_oob_data, sizeof(bt_oob_data_t));
2167 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2171 case BT_AVRCP_SET_TRACK_INFO: {
2172 media_metadata_t data;
2173 media_metadata_attributes_t meta_data;
2175 memset(&data, 0x00, sizeof(media_metadata_t));
2176 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2178 __bt_service_get_parameters(in_param1,
2179 &data, sizeof(media_metadata_t));
2181 meta_data.title = g_strdup(data.title);
2182 meta_data.artist = g_strdup(data.artist);
2183 meta_data.album = g_strdup(data.album);
2184 meta_data.genre = g_strdup(data.genre);
2185 meta_data.total_tracks = data.total_tracks;
2186 meta_data.number = data.number;
2187 meta_data.duration = (int64_t) data.duration;
2189 result = _bt_avrcp_set_track_info(&meta_data);
2191 g_free((gpointer)meta_data.title);
2192 g_free((gpointer)meta_data.artist);
2193 g_free((gpointer)meta_data.album);
2194 g_free((gpointer)meta_data.genre);
2198 case BT_AVRCP_SET_PROPERTY: {
2202 sender = (char *)g_dbus_method_invocation_get_sender(context);
2204 __bt_service_get_parameters(in_param1,
2205 &type, sizeof(int));
2206 __bt_service_get_parameters(in_param2,
2207 &value, sizeof(unsigned int));
2209 if (value == STATUS_PLAYING) {
2210 if (current_sender_playing)
2211 g_free(current_sender_playing);
2212 current_sender_playing = g_strdup(sender);
2214 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2215 current_sender_playing == NULL) {
2216 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2218 BT_INFO("Current Player and this sender (%s) are different", sender);
2219 result = BLUETOOTH_ERROR_NONE;
2222 result = _bt_avrcp_set_property(type, value);
2226 case BT_AVRCP_SET_PROPERTIES: {
2227 media_player_settings_t properties;
2229 memset(&properties, 0x00, sizeof(media_player_settings_t));
2230 __bt_service_get_parameters(in_param1,
2231 &properties, sizeof(media_player_settings_t));
2233 result = _bt_avrcp_set_properties(&properties);
2237 case BT_SET_ADVERTISING_DATA: {
2240 bluetooth_advertising_data_t adv = { {0} };
2242 gboolean use_reserved_slot = FALSE;
2244 app = (char *)g_dbus_method_invocation_get_sender(context);
2245 adv_handle = g_malloc0(sizeof(int));
2247 __bt_service_get_parameters(in_param1,
2248 adv_handle, sizeof(int));
2249 __bt_service_get_parameters(in_param3,
2250 &length, sizeof(int));
2251 __bt_service_get_parameters(in_param2,
2253 __bt_service_get_parameters(in_param4,
2254 &use_reserved_slot, sizeof(gboolean));
2255 result = _bt_set_advertising_data(app, *adv_handle,
2256 &adv, length, use_reserved_slot);
2257 if (result != BLUETOOTH_ERROR_NONE) {
2258 BT_ERR("Set Advertising data failed!!");
2261 _bt_save_invocation_context(context, result, app,
2262 function_name, (gpointer)adv_handle);
2266 case BT_SET_SCAN_RESPONSE_DATA: {
2269 bluetooth_scan_resp_data_t rsp = { {0} };
2271 gboolean use_reserved_slot = FALSE;
2273 app = (char *)g_dbus_method_invocation_get_sender(context);
2274 adv_handle = g_malloc0(sizeof(int));
2276 __bt_service_get_parameters(in_param1,
2277 adv_handle, sizeof(int));
2278 __bt_service_get_parameters(in_param3,
2279 &length, sizeof(int));
2280 __bt_service_get_parameters(in_param2,
2282 __bt_service_get_parameters(in_param4,
2283 &use_reserved_slot, sizeof(gboolean));
2285 result = _bt_set_scan_response_data(app, *adv_handle,
2286 &rsp, length, use_reserved_slot);
2288 if (result != BLUETOOTH_ERROR_NONE) {
2289 BT_ERR("Set Scan Response Data failed!!");
2292 _bt_save_invocation_context(context, result, app,
2293 function_name, (gpointer)adv_handle);
2297 case BT_SET_ADVERTISING: {
2300 gboolean enable = FALSE;
2301 gboolean use_reserved_slot = FALSE;
2303 adv_handle = g_malloc0(sizeof(int));
2304 __bt_service_get_parameters(in_param1,
2305 adv_handle, sizeof(int));
2306 __bt_service_get_parameters(in_param2,
2307 &enable, sizeof(gboolean));
2308 __bt_service_get_parameters(in_param3,
2309 &use_reserved_slot, sizeof(gboolean));
2311 app = (char *)g_dbus_method_invocation_get_sender(context);
2313 result = _bt_set_advertising(app, *adv_handle,
2314 enable, use_reserved_slot);
2315 if (result != BLUETOOTH_ERROR_NONE) {
2316 BT_ERR("Start Advertising failed!!");
2319 _bt_save_invocation_context(context, result, app,
2320 function_name, (gpointer)adv_handle);
2324 case BT_SET_CUSTOM_ADVERTISING: {
2327 gboolean enable = FALSE;
2328 bluetooth_advertising_params_t adv_params;
2329 gboolean use_reserved_slot = FALSE;
2331 app = (char *)g_dbus_method_invocation_get_sender(context);
2332 adv_handle = g_malloc0(sizeof(int));
2334 __bt_service_get_parameters(in_param1, adv_handle,
2336 __bt_service_get_parameters(in_param2, &enable,
2338 __bt_service_get_parameters(in_param3, &adv_params,
2339 sizeof(bluetooth_advertising_params_t));
2340 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2343 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2344 adv_params.interval_min, adv_params.interval_max,
2345 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2346 result = _bt_set_custom_advertising(app, *adv_handle,
2347 enable, &adv_params, use_reserved_slot);
2348 if (result != BLUETOOTH_ERROR_NONE) {
2349 BT_ERR("Start Custom Advertising failed!!");
2352 _bt_save_invocation_context(context, result, app,
2353 function_name, (gpointer)adv_handle);
2357 case BT_GET_SCAN_RESPONSE_DATA: {
2358 bluetooth_scan_resp_data_t rsp = { {0} };
2362 app = (char *)g_dbus_method_invocation_get_sender(context);
2364 __bt_service_get_parameters(in_param1, &adv_handle,
2367 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2368 if (result == BLUETOOTH_ERROR_NONE)
2369 g_array_append_vals(*out_param1, rsp.data, length);
2373 case BT_GET_ADVERTISING_DATA: {
2374 bluetooth_advertising_data_t adv = { {0} };
2378 app = (char *)g_dbus_method_invocation_get_sender(context);
2380 __bt_service_get_parameters(in_param1, &adv_handle,
2383 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2384 if (result == BLUETOOTH_ERROR_NONE)
2385 g_array_append_vals(*out_param1, adv.data, length);
2389 case BT_GATT_REGISTER_APPLICATION: {
2390 BT_DBG("Register GATT application:Unhandled!!");
2393 case BT_GATT_SERVER_REGISTER: {
2394 BT_DBG("GATT Server instance initialization");
2397 app = (char *)g_dbus_method_invocation_get_sender(context);
2398 BT_DBG("GATT Server Unique Name [%s]", app);
2400 /* No ADV handle: Set 0 */
2401 result = _bt_register_server_instance(app, 0);
2403 if (result != BLUETOOTH_ERROR_NONE) {
2404 BT_ERR("GATT Server registration failed. result %d", result);
2406 _bt_save_invocation_context(context, result, app,
2407 function_name, NULL);
2411 case BT_GATT_SERVER_DEREGISTER: {
2413 app = (char*)g_dbus_method_invocation_get_sender(context);
2415 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2418 case BT_GATT_SERVER_ADD_SERVICE: {
2419 BT_DBG("GATT Server Add Service");
2425 int *tmp_inst_id = NULL;
2427 app = (char *)g_dbus_method_invocation_get_sender(context);
2429 __bt_service_get_parameters(in_param1, &service_type,
2431 __bt_service_get_parameters(in_param2, &num_handles,
2433 svc_uuid = (char *)g_variant_get_data(in_param3);
2434 __bt_service_get_parameters(in_param4, &instance_id,
2437 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2438 if (result != BLUETOOTH_ERROR_NONE) {
2439 BT_ERR("GATT Server Add Service failed!!");
2441 tmp_inst_id = g_malloc0(sizeof(int));
2442 *tmp_inst_id = instance_id;
2443 _bt_save_invocation_context(context, result, app,
2444 function_name, (gpointer)tmp_inst_id);
2448 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2449 BT_DBG("GATT Server Add Characteristic");
2452 int *tmp_inst_id = NULL;
2453 bluetooth_gatt_server_attribute_params_t param;
2454 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2456 app = (char*)g_dbus_method_invocation_get_sender(context);
2458 __bt_service_get_parameters(in_param1, ¶m,
2459 sizeof(bluetooth_gatt_server_attribute_params_t));
2460 char_uuid = (char *)g_variant_get_data(in_param2);
2462 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2463 if (result != BLUETOOTH_ERROR_NONE) {
2464 BT_ERR("GATT Server Add Service failed!!");
2466 tmp_inst_id = g_malloc0(sizeof(int));
2467 *tmp_inst_id = param.instance_id;
2469 _bt_save_invocation_context(context, result, app,
2470 function_name, (gpointer)tmp_inst_id);
2474 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2475 BT_DBG("GATT Server Add Descriptor");
2479 bt_gatt_permission_t perm;
2481 int *tmp_inst_id = NULL;
2482 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2484 app = (char *)g_dbus_method_invocation_get_sender(context);
2486 __bt_service_get_parameters(in_param1, &service_handle,
2488 __bt_service_get_parameters(in_param2, &instance_id,
2490 desc_uuid = (char *)g_variant_get_data(in_param4);
2491 __bt_service_get_parameters(in_param3, &perm,
2492 sizeof(bt_gatt_permission_t));
2494 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2495 if (result != BLUETOOTH_ERROR_NONE) {
2496 BT_ERR("GATT Server Add Service failed!!");
2498 tmp_inst_id = g_malloc0(sizeof(int));
2499 *tmp_inst_id = instance_id;
2500 _bt_save_invocation_context(context, result, app,
2501 function_name, (gpointer)tmp_inst_id);
2505 case BT_GATT_SERVER_START_SERVICE: {
2510 int *tmp_inst_id = NULL;
2511 app = (char*)g_dbus_method_invocation_get_sender(context);
2513 __bt_service_get_parameters(in_param1, &service_handle,
2515 __bt_service_get_parameters(in_param2, &instance_id,
2518 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2520 if (BLUETOOTH_ERROR_NONE == result) {
2521 tmp_inst_id = g_malloc0(sizeof(int));
2522 *tmp_inst_id = instance_id;
2523 _bt_save_invocation_context(context, result, app,
2524 function_name, (gpointer)tmp_inst_id);
2528 case BT_GATT_SERVER_STOP_SERVICE: {
2532 int *tmp_inst_id = NULL;
2533 app = (char*)g_dbus_method_invocation_get_sender(context);
2535 __bt_service_get_parameters(in_param1, &service_handle,
2537 __bt_service_get_parameters(in_param2, &instance_id,
2540 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2542 if (BLUETOOTH_ERROR_NONE == result) {
2543 tmp_inst_id = g_malloc0(sizeof(int));
2544 *tmp_inst_id = instance_id;
2545 _bt_save_invocation_context(context, result, app,
2546 function_name, (gpointer)tmp_inst_id);
2550 case BT_GATT_SERVER_DELETE_SERVICE: {
2553 int *tmp_inst_id = NULL;
2555 app = (char*)g_dbus_method_invocation_get_sender(context);
2557 __bt_service_get_parameters(in_param1, &service_handle,
2559 __bt_service_get_parameters(in_param2, &instance_id,
2562 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2564 if (BLUETOOTH_ERROR_NONE == result) {
2565 tmp_inst_id = g_malloc0(sizeof(int));
2566 *tmp_inst_id = instance_id;
2567 _bt_save_invocation_context(context, result, app,
2568 function_name, (gpointer)tmp_inst_id);
2572 case BT_GATT_SERVER_SEND_RESPONSE: {
2573 bluetooth_gatt_server_response_params_t param;
2574 bluetooth_gatt_att_data_t data;
2577 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2578 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2580 app = (char*)g_dbus_method_invocation_get_sender(context);
2582 __bt_service_get_parameters(in_param1, &data,
2583 sizeof(bluetooth_gatt_att_data_t));
2584 __bt_service_get_parameters(in_param2, ¶m,
2585 sizeof(bluetooth_gatt_server_response_params_t));
2587 result = _bt_gatt_server_send_response(app, &data, ¶m);
2591 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2593 bluetooth_gatt_server_acquire_response_params_t param;
2596 msg = g_dbus_method_invocation_get_message(context);
2597 GUnixFDList *fd_list;
2602 fd_list = g_dbus_message_get_unix_fd_list(msg);
2604 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2606 app = (char*)g_dbus_method_invocation_get_sender(context);
2608 __bt_service_get_parameters(in_param1, ¶m,
2609 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2611 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2612 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2613 fd = fd_list_array[0];
2616 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2620 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2622 bluetooth_gatt_server_acquire_response_params_t param;
2625 msg = g_dbus_method_invocation_get_message(context);
2626 GUnixFDList *fd_list;
2631 fd_list = g_dbus_message_get_unix_fd_list(msg);
2633 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2635 app = (char*)g_dbus_method_invocation_get_sender(context);
2637 __bt_service_get_parameters(in_param1, ¶m,
2638 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2640 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2641 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2642 fd = fd_list_array[0];
2645 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2649 case BT_GATT_SERVER_SEND_INDICATION: {
2650 bluetooth_gatt_server_indication_params_t param;
2651 bluetooth_gatt_att_data_t data;
2652 bluetooth_device_address_t address;
2655 app = (char*)g_dbus_method_invocation_get_sender(context);
2657 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2658 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2659 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2661 __bt_service_get_parameters(in_param1, &data,
2662 sizeof(bluetooth_gatt_att_data_t));
2663 __bt_service_get_parameters(in_param2, ¶m,
2664 sizeof(bluetooth_gatt_server_indication_params_t));
2665 __bt_service_get_parameters(in_param3, &address,
2666 sizeof(bluetooth_device_address_t));
2668 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2672 case BT_GATT_SERVER_UPDATE_VALUE: {
2673 bluetooth_gatt_server_update_value_t param;
2677 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2679 app = (char*)g_dbus_method_invocation_get_sender(context);
2681 __bt_service_get_parameters(in_param1, &instance_id,
2683 __bt_service_get_parameters(in_param2, ¶m,
2684 sizeof(bluetooth_gatt_server_update_value_t));
2686 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2689 case BT_GET_ATT_MTU: {
2690 bluetooth_device_address_t address = { {0} };
2691 unsigned int mtu = 0;
2693 __bt_service_get_parameters(in_param1,
2694 &address, sizeof(bluetooth_device_address_t));
2695 result = _bt_get_att_mtu(&address, &mtu);
2696 BT_DBG("MTU: %d", mtu);
2698 if (result == BLUETOOTH_ERROR_NONE) {
2699 g_array_append_vals(*out_param1, &mtu,
2700 sizeof(unsigned int));
2704 case BT_REQ_ATT_MTU: {
2705 bluetooth_device_address_t address = { {0} };
2709 sender = (char*)g_dbus_method_invocation_get_sender(context);
2711 __bt_service_get_parameters(in_param1,
2712 &address, sizeof(bluetooth_device_address_t));
2713 __bt_service_get_parameters(in_param2,
2714 &mtu, sizeof(unsigned int));
2715 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2716 result = _bt_request_att_mtu(&address, mtu);
2717 if (BLUETOOTH_ERROR_NONE == result) {
2718 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2720 _bt_convert_addr_type_to_string(addr, address.addr);
2722 /* Save the informations to invocation */
2723 _bt_save_invocation_context(context, result, sender,
2724 function_name, (gpointer)addr);
2726 g_array_append_vals(*out_param1, &address,
2727 sizeof(bluetooth_device_address_t));
2731 case BT_GET_DEVICE_IDA: {
2732 bluetooth_device_address_t address = { {0} };
2733 bluetooth_device_address_t id_addr = { {0} };
2735 __bt_service_get_parameters(in_param1,
2736 &address, sizeof(bluetooth_device_address_t));
2738 result = _bt_device_get_ida(&address, &id_addr);
2740 if (result == BLUETOOTH_ERROR_NONE) {
2741 g_array_append_vals(*out_param1, &id_addr,
2742 sizeof(bluetooth_device_address_t));
2746 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2749 __bt_service_get_parameters(in_param1, &is_enable,
2752 result = _bt_set_le_static_random_address(is_enable);
2756 #ifdef TIZEN_GATT_CLIENT
2758 case BT_GATT_CLIENT_REGISTER: {
2759 bluetooth_device_address_t address = { {0} };
2762 sender = (char*)g_dbus_method_invocation_get_sender(context);
2764 __bt_service_get_parameters(in_param1,
2765 &address, sizeof(bluetooth_device_address_t));
2767 result = _bt_register_gatt_client_instance(sender, &address);
2768 if (BLUETOOTH_ERROR_NONE == result) {
2769 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2771 _bt_convert_addr_type_to_string(addr, address.addr);
2773 /* Save the informations to invocation */
2774 _bt_save_invocation_context(context, result, sender,
2775 function_name, (gpointer)addr);
2780 case BT_GATT_CLIENT_UNREGISTER: {
2783 sender = (char*)g_dbus_method_invocation_get_sender(context);
2784 __bt_service_get_parameters(in_param1,
2785 &client_id, sizeof(int));
2787 result = _bt_unregister_gatt_client_instance(sender, client_id);
2791 /* Async: Remote Interaction */
2792 case BT_GATT_ACQUIRE_WRITE: {
2796 bluetooth_gatt_client_char_prop_info_t param;
2798 sender = (char*)g_dbus_method_invocation_get_sender(context);
2800 __bt_service_get_parameters(in_param1, ¶m,
2801 sizeof(bluetooth_gatt_client_char_prop_info_t));
2804 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2806 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2808 if (BLUETOOTH_ERROR_NONE == result)
2809 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2811 BT_ERR("GATT Client: gatt acquire write failed");
2815 GUnixFDList *fd_list = NULL;
2816 GError *error = NULL;
2818 /* Add socket fd to unix_fd_list */
2819 fd_list = g_unix_fd_list_new();
2820 g_unix_fd_list_append(fd_list, fd, &error);
2821 g_assert_no_error(error);
2823 _bt_service_method_return_with_unix_fd_list(
2824 context, *out_param1, result, fd_list);
2827 g_object_unref(fd_list);
2831 /* Async: Remote Interaction */
2832 case BT_CONNECT_LE: {
2833 bluetooth_device_address_t address = { {0} };
2834 gboolean auto_connect;
2838 sender = (char*)g_dbus_method_invocation_get_sender(context);
2840 __bt_service_get_parameters(in_param1,
2841 &address, sizeof(bluetooth_device_address_t));
2842 __bt_service_get_parameters(in_param2,
2843 &auto_connect, sizeof(gboolean));
2844 __bt_service_get_parameters(in_param3,
2845 &client_id, sizeof(int));
2847 BT_DBG("GATT Client: client_id[%d]", client_id);
2848 result = _bt_connect_le_device(&address, auto_connect, client_id);
2849 if (BLUETOOTH_ERROR_NONE == result) {
2850 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2851 _bt_convert_addr_type_to_string(addr, address.addr);
2853 /* Save the informations to invocation */
2854 _bt_save_invocation_context(context, result, sender,
2855 function_name, (gpointer)addr);
2858 _bt_handle_invocation_context(function_name, (void *)addr);
2860 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2861 g_array_append_vals(*out_param1, &address,
2862 sizeof(bluetooth_device_address_t));
2866 /* Async: Remote Interaction */
2867 case BT_DISCONNECT_LE: {
2868 bluetooth_device_address_t address = { {0} };
2872 sender = (char*)g_dbus_method_invocation_get_sender(context);
2874 __bt_service_get_parameters(in_param1,
2875 &address, sizeof(bluetooth_device_address_t));
2876 __bt_service_get_parameters(in_param2,
2877 &client_id, sizeof(int));
2879 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2880 result = _bt_disconnect_le_device(&address, client_id);
2881 if (BLUETOOTH_ERROR_NONE == result) {
2882 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2884 _bt_convert_addr_type_to_string(addr, address.addr);
2886 /* Save the informations to invocation */
2887 _bt_save_invocation_context(context, result, sender,
2888 function_name, (gpointer)addr);
2890 g_array_append_vals(*out_param1, &address,
2891 sizeof(bluetooth_device_address_t));
2896 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2897 guint available_packets = 0;
2899 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2900 BT_DBG("LE batching available packets %u", available_packets);
2901 if (result == BLUETOOTH_ERROR_NONE) {
2902 g_array_append_vals(*out_param1, &available_packets,
2909 case BT_ENABLE_GATT_DATA_BATCHING: {
2910 bluetooth_device_address_t address = { {0} };
2911 int packet_threshold;
2914 __bt_service_get_parameters(in_param1,
2915 &address, sizeof(bluetooth_device_address_t));
2916 __bt_service_get_parameters(in_param2,
2917 &packet_threshold, sizeof(int));
2918 __bt_service_get_parameters(in_param3,
2919 &timeout, sizeof(int));
2920 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2925 case BT_DISABLE_GATT_DATA_BATCHING: {
2926 bluetooth_device_address_t address = { {0} };
2928 __bt_service_get_parameters(in_param1,
2929 &address, sizeof(bluetooth_device_address_t));
2930 result = _bt_gatt_disable_data_batching(&address);
2935 case BT_GATT_GET_PRIMARY_SERVICES: {
2938 sender = (char*)g_dbus_method_invocation_get_sender(context);
2939 bluetooth_device_address_t address = { {0} };
2941 __bt_service_get_parameters(in_param1, &address,
2942 sizeof(bluetooth_device_address_t));
2944 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2945 _bt_convert_addr_type_to_string(addr, address.addr);
2947 result = _bt_gatt_get_primary_services(addr);
2948 if (BLUETOOTH_ERROR_NONE == result) {
2949 _bt_save_invocation_context(context, result, sender,
2950 function_name, (gpointer)addr);
2956 case BT_GATT_GET_SERVICE_PROPERTIES: {
2957 bluetooth_gatt_client_svc_prop_info_t param;
2959 sender = (char*)g_dbus_method_invocation_get_sender(context);
2960 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2962 __bt_service_get_parameters(in_param1, ¶m,
2963 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2965 result = _bt_gatt_get_all_characteristic(¶m);
2966 if (BLUETOOTH_ERROR_NONE == result) {
2967 /* Save the informations to invocation */
2968 _bt_save_invocation_context(context, result, sender,
2970 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2974 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2975 bluetooth_gatt_client_char_prop_info_t param;
2977 sender = (char*)g_dbus_method_invocation_get_sender(context);
2978 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2980 __bt_service_get_parameters(in_param1, ¶m,
2981 sizeof(bluetooth_gatt_client_char_prop_info_t));
2983 result = _bt_gatt_get_all_characteristic_properties(¶m);
2984 if (BLUETOOTH_ERROR_NONE == result) {
2985 /* Save the informations to invocation */
2986 _bt_save_invocation_context(context, result, sender,
2988 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2992 /* Async: Remote Interaction */
2993 case BT_GATT_READ_CHARACTERISTIC: {
2994 bluetooth_gatt_client_char_prop_info_t param;
2996 sender = (char*)g_dbus_method_invocation_get_sender(context);
2997 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2999 __bt_service_get_parameters(in_param1, ¶m,
3000 sizeof(bluetooth_gatt_client_char_prop_info_t));
3002 result = _bt_gatt_read_characteristic_value(¶m);
3003 if (BLUETOOTH_ERROR_NONE == result) {
3004 /* Save the informations to invocation */
3005 _bt_save_invocation_context(context, result, sender,
3007 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3011 /* Async: Remote Interaction */
3012 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3013 bluetooth_gatt_client_desc_prop_info_t param;
3015 sender = (char*)g_dbus_method_invocation_get_sender(context);
3016 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3018 __bt_service_get_parameters(in_param1, ¶m,
3019 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3021 result = _bt_gatt_read_descriptor_value(¶m);
3022 if (BLUETOOTH_ERROR_NONE == result) {
3023 /* Save the informations to invocation */
3024 _bt_save_invocation_context(context, result, sender,
3026 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3030 /* Async: Remote Interaction */
3031 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3032 bluetooth_gatt_client_char_prop_info_t param;
3033 bluetooth_gatt_att_data_t data;
3034 bluetooth_gatt_write_type_e write_type;
3036 sender = (char*)g_dbus_method_invocation_get_sender(context);
3038 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3039 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3041 __bt_service_get_parameters(in_param1, ¶m,
3042 sizeof(bluetooth_gatt_client_char_prop_info_t));
3043 __bt_service_get_parameters(in_param2, &data,
3044 sizeof(bluetooth_gatt_att_data_t));
3045 __bt_service_get_parameters(in_param3, &write_type,
3046 sizeof(bluetooth_gatt_write_type_e));
3048 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3049 if (BLUETOOTH_ERROR_NONE == result) {
3050 /* Save the informations to invocation */
3051 _bt_save_invocation_context(context, result, sender,
3053 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3057 /* Async: Remote Interaction */
3058 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3059 bluetooth_gatt_client_desc_prop_info_t param;
3060 bluetooth_gatt_att_data_t data;
3061 bluetooth_gatt_write_type_e write_type;
3063 sender = (char*)g_dbus_method_invocation_get_sender(context);
3064 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3065 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3067 __bt_service_get_parameters(in_param1, ¶m,
3068 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3069 __bt_service_get_parameters(in_param2, &data,
3070 sizeof(bluetooth_gatt_att_data_t));
3071 __bt_service_get_parameters(in_param3, &write_type,
3072 sizeof(bluetooth_gatt_write_type_e));
3074 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3075 if (BLUETOOTH_ERROR_NONE == result) {
3076 /* Save the informations to invocation */
3077 _bt_save_invocation_context(context, result, sender,
3079 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3084 case BT_GATT_WATCH_CHARACTERISTIC: {
3085 bluetooth_gatt_client_char_prop_info_t param;
3090 gboolean is_indicate;
3093 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3095 sender = (char*)g_dbus_method_invocation_get_sender(context);
3097 __bt_service_get_parameters(in_param1, ¶m,
3098 sizeof(bluetooth_gatt_client_char_prop_info_t));
3099 __bt_service_get_parameters(in_param2, &client_id,
3101 __bt_service_get_parameters(in_param3, &is_notify,
3103 __bt_service_get_parameters(in_param4, &is_indicate,
3106 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3110 if (is_indicate == false) {
3111 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3112 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3113 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3115 GUnixFDList *fd_list = NULL;
3116 GError *error = NULL;
3118 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3119 /* Add socket fd to unix_fd_list */
3120 fd_list = g_unix_fd_list_new();
3121 g_unix_fd_list_append(fd_list, fd, &error);
3122 g_assert_no_error(error);
3124 _bt_service_method_return_with_unix_fd_list(
3125 context, *out_param1, result, fd_list);
3127 g_object_unref(fd_list);
3133 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3134 if (BLUETOOTH_ERROR_NONE == result) {
3135 /* Save the informations to invocation */
3136 _bt_save_invocation_context(context, result, sender, function_name,
3137 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3142 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3143 gboolean is_enabled;
3144 bluetooth_device_address_t address;
3146 sender = (char*)g_dbus_method_invocation_get_sender(context);
3148 __bt_service_get_parameters(in_param1,
3149 &address, sizeof(bluetooth_device_address_t));
3150 __bt_service_get_parameters(in_param2, &is_enabled,
3152 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3153 BT_INFO("Service changed indication from app [%s]", sender);
3157 case BT_LE_CONN_UPDATE: {
3158 char *sender = NULL;
3159 bluetooth_device_address_t local_address = { {0} };
3160 bluetooth_le_connection_param_t parameters = {0};
3162 sender = (char *)g_dbus_method_invocation_get_sender(context);
3164 __bt_service_get_parameters(in_param1, &local_address,
3165 sizeof(bluetooth_device_address_t));
3166 __bt_service_get_parameters(in_param2, ¶meters,
3167 sizeof(bluetooth_le_connection_param_t));
3169 result = _bt_le_connection_update(sender,
3171 parameters.interval_min,
3172 parameters.interval_max,
3174 parameters.timeout);
3178 case BT_START_LE_DISCOVERY: {
3182 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3184 sender = (char *)g_dbus_method_invocation_get_sender(context);
3186 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3187 BT_ERR("Fail to get the sender pid");
3189 result = _bt_start_le_scan(sender, uid, pid);
3190 if (result == BLUETOOTH_ERROR_NONE) {
3191 _bt_save_invocation_context(context, result, sender,
3192 function_name, NULL);
3194 BT_DBG("Remeber pid / uid for the scan operation");
3195 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3199 case BT_STOP_LE_DISCOVERY: {
3203 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3205 sender = (char *)g_dbus_method_invocation_get_sender(context);
3207 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3208 BT_ERR("Fail to get the sender pid");
3210 result = _bt_stop_le_scan(sender);
3211 if (result == BLUETOOTH_ERROR_NONE) {
3212 _bt_save_invocation_context(context, result, sender,
3213 function_name, NULL);
3216 BT_DBG("Remove pid / uid for the scan operation");
3217 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3221 case BT_IS_LE_DISCOVERYING: {
3222 gboolean le_discovering = FALSE;
3224 le_discovering = _bt_is_le_scanning();
3225 g_array_append_vals(*out_param1,
3226 &le_discovering, sizeof(gboolean));
3229 case BT_SET_SCAN_PARAMETERS: {
3230 bluetooth_le_scan_params_t scan_params;
3232 __bt_service_get_parameters(in_param1, &scan_params,
3233 sizeof(bluetooth_le_scan_params_t));
3235 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3236 scan_params.interval, scan_params.window,
3239 result = _bt_prepare_scan_parameters(&scan_params, 0);
3242 case BT_SET_SCAN_TYPE: {
3244 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3246 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3247 result = _bt_prepare_scan_parameters(NULL, scan_type);
3250 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3251 case BT_NETWORK_ACTIVATE:
3252 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3253 result = _bt_network_activate();
3255 case BT_NETWORK_DEACTIVATE:
3256 result = _bt_network_deactivate();
3258 case BT_NETWORK_CONNECT: {
3259 bluetooth_device_address_t address = { {0} };
3262 __bt_service_get_parameters(in_param1,
3263 &address, sizeof(bluetooth_device_address_t));
3264 __bt_service_get_parameters(in_param2,
3265 &role, sizeof(int));
3267 result = _bt_network_connect(request_id, role, &address);
3268 if (result != BLUETOOTH_ERROR_NONE) {
3269 g_array_append_vals(*out_param1, &address,
3270 sizeof(bluetooth_device_address_t));
3274 case BT_NETWORK_DISCONNECT: {
3275 bluetooth_device_address_t address = { {0} };
3277 __bt_service_get_parameters(in_param1,
3278 &address, sizeof(bluetooth_device_address_t));
3280 result = _bt_network_disconnect(request_id, &address);
3281 if (result != BLUETOOTH_ERROR_NONE) {
3282 g_array_append_vals(*out_param1, &address,
3283 sizeof(bluetooth_device_address_t));
3287 case BT_NETWORK_SERVER_DISCONNECT: {
3288 bluetooth_device_address_t address = { {0} };
3290 __bt_service_get_parameters(in_param1,
3291 &address, sizeof(bluetooth_device_address_t));
3293 result = _bt_network_server_disconnect(request_id, &address);
3294 if (result != BLUETOOTH_ERROR_NONE) {
3295 g_array_append_vals(*out_param1, &address,
3296 sizeof(bluetooth_device_address_t));
3302 #ifdef TIZEN_FEATURE_BT_IPSP
3303 case BT_LE_IPSP_INIT:
3304 result = _bt_initialize_ipsp();
3306 case BT_LE_IPSP_DEINIT:
3307 result = _bt_deinitialize_ipsp();
3309 case BT_LE_IPSP_CONNECT: {
3310 bluetooth_device_address_t address = { {0} };
3311 __bt_service_get_parameters(in_param1, &address,
3312 sizeof(bluetooth_device_address_t));
3313 result = _bt_connect_le_ipsp_device(&address);
3316 case BT_LE_IPSP_DISCONNECT: {
3317 bluetooth_device_address_t address = { {0} };
3318 __bt_service_get_parameters(in_param1, &address,
3319 sizeof(bluetooth_device_address_t));
3320 result = _bt_disconnect_le_ipsp_device(&address);
3324 case BT_IS_ADVERTISING: {
3325 gboolean advertising = FALSE;
3326 advertising = _bt_is_advertising();
3327 g_array_append_vals(*out_param1, &advertising,
3331 case BT_IS_LE_2M_PHY_SUPPORTED: {
3332 gboolean is_2m_phy_supported = FALSE;
3334 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3335 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3338 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3339 gboolean is_coded_phy_supported = FALSE;
3341 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3342 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3345 case BT_DISCONNECT_DEVICE: {
3346 bluetooth_device_address_t address = { {0} };
3348 __bt_service_get_parameters(in_param1,
3349 &address, sizeof(bluetooth_device_address_t));
3351 result = _bt_disconnect_device(&address);
3354 case BT_REGISTER_SCAN_FILTER: {
3355 bluetooth_le_scan_filter_t scan_filter;
3357 sender = (char*)g_dbus_method_invocation_get_sender(context);
3358 __bt_service_get_parameters(in_param1, &scan_filter,
3359 sizeof(bluetooth_le_scan_filter_t));
3361 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3362 scan_filter.added_features);
3364 result = _bt_register_scan_filter(sender, &scan_filter);
3370 result = _bt_mesh_init();
3373 case BT_MESH_DEINIT:
3374 result = _bt_mesh_deinit();
3377 case BT_MESH_NETWORK_CREATE: {
3378 bluetooth_mesh_node_t node;
3379 GSList *model_list = NULL;
3380 int total_models = 0;
3383 const char *network_name = NULL;
3384 bluetooth_mesh_network_t *network;
3386 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3387 sender = (char*)g_dbus_method_invocation_get_sender(context);
3389 __bt_service_get_parameters(in_param1,
3390 &node, sizeof(bluetooth_mesh_node_t));
3391 network_name = (const char *)g_variant_get_data(in_param2);
3392 BT_INFO("MESH: Network name [%s]", network_name);
3394 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3395 __bt_fill_garray_from_variant(in_param3, param3);
3397 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3398 for (i = 0; i < total_models; i++) {
3399 bluetooth_mesh_model_t *info = NULL;
3400 bluetooth_mesh_model_t *mod = NULL;
3402 info = &g_array_index(param3,
3403 bluetooth_mesh_model_t, i);
3405 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3408 model_list = g_slist_append(model_list,
3411 result = _bt_mesh_network_create(requester_unique_creds,
3412 sender, network_name, &node, model_list);
3414 /* Save invocation */
3415 if (result == BLUETOOTH_ERROR_NONE) {
3416 BT_INFO("Mesh: Save Invoation");
3417 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3419 /* Save Network name & UUID, Token will be received in event */
3420 _bt_mesh_util_convert_hex_to_string(
3421 (uint8_t *) node.uuid, 16,
3423 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3424 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3425 g_strlcpy(network->name.name, network_name,
3426 sizeof(network->name.name));
3427 g_strlcpy(network->app_cred,
3428 requester_unique_creds,
3429 sizeof(network->app_cred));
3430 sender = (char*)g_dbus_method_invocation_get_sender(context);
3431 _bt_save_invocation_context(context,
3433 function_name, (gpointer)network);
3435 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3436 BT_ERR("Mesh: Mesh Network creation schedule failed");
3437 g_slist_free_full(model_list, g_free);
3441 BT_INFO("Mesh: Cleanup");
3442 g_free((gpointer)requester_unique_creds);
3443 g_array_free(param3, TRUE);
3444 BT_INFO("Mesh: Cleanup Done");
3447 case BT_MESH_NETWORK_LOAD: {
3449 bluetooth_mesh_network_t *network;
3450 token = (char *)g_variant_get_data(in_param1);
3451 BT_INFO("MESH: Network Load: Token string [%s]", token);
3452 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3453 /* Save invocation */
3454 if (result == BLUETOOTH_ERROR_NONE) {
3455 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3456 g_strlcpy(network->token.token, token, strlen(token));
3457 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3459 sender = (char*)g_dbus_method_invocation_get_sender(context);
3460 _bt_save_invocation_context(context, result, sender,
3461 function_name, (gpointer)network);
3463 g_free((gpointer)requester_unique_creds);
3466 case BT_MESH_NETWORK_SCAN: {
3467 bluetooth_mesh_network_t network;
3468 bluetooth_mesh_scan_param_t param;
3469 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3470 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3472 __bt_service_get_parameters(in_param1,
3473 &network, sizeof(bluetooth_mesh_network_t));
3475 __bt_service_get_parameters(in_param2,
3476 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3478 result = _bt_mesh_network_scan(requester_unique_creds,
3479 sender, &network, ¶m);
3481 if (result != BLUETOOTH_ERROR_NONE) {
3482 g_array_append_vals(*out_param1,
3483 &network, sizeof(bluetooth_mesh_network_t));
3485 bluetooth_mesh_network_t *net = \
3486 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3488 sender = (char*)g_dbus_method_invocation_get_sender(context);
3489 _bt_save_invocation_context(context, result, sender,
3490 function_name, (gpointer)net);
3494 case BT_MESH_NETWORK_CANCEL_SCAN: {
3495 bluetooth_mesh_network_t network;
3496 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3498 __bt_service_get_parameters(in_param1,
3499 &network, sizeof(bluetooth_mesh_network_t));
3501 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3504 if (result != BLUETOOTH_ERROR_NONE)
3505 g_array_append_vals(*out_param1,
3506 &network, sizeof(bluetooth_mesh_network_t));
3509 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3510 bluetooth_mesh_network_t network;
3511 bluetooth_mesh_provisioner_caps_t caps;
3512 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3513 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3515 __bt_service_get_parameters(in_param1,
3516 &network, sizeof(bluetooth_mesh_network_t));
3518 __bt_service_get_parameters(in_param2,
3519 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3521 result = _bt_mesh_network_set_provisioner_caps(
3522 requester_unique_creds, sender, &network, &caps);
3526 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3527 bluetooth_mesh_provisioning_request_t req;
3528 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3530 __bt_service_get_parameters(in_param1,
3531 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3533 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3534 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3536 result = _bt_mesh_network_provision_device(
3537 requester_unique_creds, sender, &req);
3539 /* Save invocation */
3540 if (result != BLUETOOTH_ERROR_NONE) {
3541 g_array_append_vals(*out_param1, &req,
3542 sizeof(bluetooth_mesh_provisioning_request_t));
3544 bluetooth_mesh_provisioning_request_t *param = \
3545 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3547 sender = (char*)g_dbus_method_invocation_get_sender(context);
3548 _bt_save_invocation_context(context, result, sender,
3549 function_name, (gpointer)param);
3553 case BT_MESH_AUTHENTICATION_REPLY: {
3554 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3555 const char *auth_value = NULL;
3556 gboolean authentication_reply = FALSE;
3558 auth_value = g_variant_get_data(in_param2);
3559 __bt_service_get_parameters(in_param3,
3560 &authentication_reply, sizeof(gboolean));
3561 __bt_service_get_parameters(in_param1,
3562 &auth_type, sizeof(int));
3563 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3564 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3565 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3566 result = _bt_mesh_authentication_reply(auth_type,
3567 auth_value, authentication_reply);
3570 case BT_MESH_NETWORK_SET_NAME: {
3571 bluetooth_mesh_network_t network;
3572 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3574 __bt_service_get_parameters(in_param1,
3575 &network, sizeof(bluetooth_mesh_network_t));
3577 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3581 case BT_MESH_NETWORK_ADD_NETKEY: {
3582 bluetooth_mesh_network_t network;
3583 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3585 __bt_service_get_parameters(in_param1,
3586 &network, sizeof(bluetooth_mesh_network_t));
3588 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3591 if (result != BLUETOOTH_ERROR_NONE) {
3592 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3594 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3596 sender = (char*)g_dbus_method_invocation_get_sender(context);
3597 _bt_save_invocation_context(context, result, sender,
3598 function_name, (gpointer)net);
3602 case BT_MESH_NETWORK_DELETE_NETKEY: {
3603 bluetooth_mesh_network_t network;
3606 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3608 __bt_service_get_parameters(in_param1,
3609 &network, sizeof(bluetooth_mesh_network_t));
3610 __bt_service_get_parameters(in_param2,
3611 &index, sizeof(guint16));
3613 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3614 sender, &network, index);
3616 if (result != BLUETOOTH_ERROR_NONE) {
3617 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3619 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3621 sender = (char*)g_dbus_method_invocation_get_sender(context);
3622 _bt_save_invocation_context(context, result, sender,
3623 function_name, (gpointer)net);
3627 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3628 bluetooth_mesh_network_t network;
3631 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3633 __bt_service_get_parameters(in_param1,
3634 &network, sizeof(bluetooth_mesh_network_t));
3635 __bt_service_get_parameters(in_param2,
3636 &index, sizeof(guint16));
3638 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3639 sender, &network, index);
3641 if (result != BLUETOOTH_ERROR_NONE) {
3642 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3644 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3646 sender = (char*)g_dbus_method_invocation_get_sender(context);
3647 _bt_save_invocation_context(context, result, sender,
3648 function_name, (gpointer)net);
3652 case BT_MESH_NETWORK_ADD_APPKEY: {
3653 bluetooth_mesh_network_t network;
3656 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3658 __bt_service_get_parameters(in_param1,
3659 &network, sizeof(bluetooth_mesh_network_t));
3660 __bt_service_get_parameters(in_param2,
3661 &net_idx, sizeof(guint16));
3663 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3664 sender, &network, net_idx);
3666 if (result != BLUETOOTH_ERROR_NONE) {
3667 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3669 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3671 sender = (char*)g_dbus_method_invocation_get_sender(context);
3672 _bt_save_invocation_context(context, result, sender,
3673 function_name, (gpointer)net);
3677 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3678 bluetooth_mesh_network_t network;
3682 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3684 __bt_service_get_parameters(in_param1,
3685 &network, sizeof(bluetooth_mesh_network_t));
3686 __bt_service_get_parameters(in_param2,
3687 &net_idx, sizeof(guint16));
3688 __bt_service_get_parameters(in_param3,
3689 &app_idx, sizeof(guint16));
3691 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3692 sender, &network, net_idx, app_idx);
3694 if (result != BLUETOOTH_ERROR_NONE) {
3695 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3697 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3699 sender = (char*)g_dbus_method_invocation_get_sender(context);
3700 _bt_save_invocation_context(context, result, sender,
3701 function_name, (gpointer)net);
3705 case BT_MESH_NETWORK_DELETE_APPKEY: {
3706 bluetooth_mesh_network_t network;
3710 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3712 __bt_service_get_parameters(in_param1,
3713 &network, sizeof(bluetooth_mesh_network_t));
3714 __bt_service_get_parameters(in_param2,
3715 &net_idx, sizeof(guint16));
3716 __bt_service_get_parameters(in_param3,
3717 &app_idx, sizeof(guint16));
3719 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3720 sender, &network, net_idx, app_idx);
3722 if (result != BLUETOOTH_ERROR_NONE) {
3723 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3725 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3727 sender = (char*)g_dbus_method_invocation_get_sender(context);
3728 _bt_save_invocation_context(context, result, sender,
3729 function_name, (gpointer)net);
3733 case BT_MESH_NETWORK_GET_NETKEYS: {
3734 bluetooth_mesh_network_t network;
3735 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3736 __bt_service_get_parameters(in_param1,
3737 &network, sizeof(bluetooth_mesh_network_t));
3738 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3739 sender, &network, out_param1);
3742 case BT_MESH_NETWORK_GET_APPKEYS: {
3743 bluetooth_mesh_network_t network;
3746 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3747 __bt_service_get_parameters(in_param1,
3748 &network, sizeof(bluetooth_mesh_network_t));
3749 __bt_service_get_parameters(in_param2,
3750 &net_idx, sizeof(guint16));
3751 result = _bt_mesh_network_get_appkeys(
3752 requester_unique_creds, sender,
3753 &network, net_idx, out_param1);
3756 case BT_MESH_NETWORK_GET_NODES: {
3757 bluetooth_mesh_network_t network;
3758 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3759 __bt_service_get_parameters(in_param1,
3760 &network, sizeof(bluetooth_mesh_network_t));
3761 result = _bt_mesh_network_get_nodes(
3762 requester_unique_creds, sender,
3763 &network, out_param1);
3766 case BT_MESH_ELEMENT_GET_MODELS: {
3767 bluetooth_mesh_network_t network;
3771 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3772 __bt_service_get_parameters(in_param1,
3773 &network, sizeof(bluetooth_mesh_network_t));
3774 __bt_service_get_parameters(in_param2,
3775 &node_addr, sizeof(guint16));
3776 __bt_service_get_parameters(in_param3,
3777 &elem_idx, sizeof(int));
3778 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3779 &network, node_addr, elem_idx, out_param1);
3782 case BT_MESH_NODE_BROWSE: {
3783 bluetooth_mesh_node_discover_t req;
3784 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3786 __bt_service_get_parameters(in_param1,
3787 &req, sizeof(bluetooth_mesh_node_discover_t));
3789 result = _bt_mesh_browse_remote_node(
3790 requester_unique_creds, sender, &req);
3792 /* Save invocation */
3793 if (result != BLUETOOTH_ERROR_NONE) {
3794 g_array_append_vals(*out_param1, &req,
3795 sizeof(bluetooth_mesh_node_discover_t));
3797 bluetooth_mesh_node_discover_t *param = \
3798 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3800 sender = (char*)g_dbus_method_invocation_get_sender(context);
3801 _bt_save_invocation_context(context, result, sender,
3802 function_name, (gpointer)param);
3806 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3807 bluetooth_mesh_node_features_t req;
3808 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3810 __bt_service_get_parameters(in_param1,
3811 &req, sizeof(bluetooth_mesh_node_features_t));
3813 result = _bt_mesh_node_discover_vendor_features(
3814 requester_unique_creds, sender, &req);
3816 /* Save invocation */
3817 if (result != BLUETOOTH_ERROR_NONE) {
3818 g_array_append_vals(*out_param1,
3819 &req, sizeof(bluetooth_mesh_node_features_t));
3821 bluetooth_mesh_node_features_t *param = \
3822 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3824 sender = (char*)g_dbus_method_invocation_get_sender(context);
3825 _bt_save_invocation_context(context, result, sender,
3826 function_name, (gpointer)param);
3830 case BT_MESH_NODE_CONFIGURE_KEY: {
3831 bluetooth_mesh_key_configure_t req;
3833 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3835 __bt_service_get_parameters(in_param1,
3836 &req, sizeof(bluetooth_mesh_key_configure_t));
3838 result = _bt_mesh_node_configure_key(
3839 requester_unique_creds, sender, &req);
3841 /* Save invocation */
3842 if (result != BLUETOOTH_ERROR_NONE) {
3843 g_array_append_vals(*out_param1,
3844 &req, sizeof(bluetooth_mesh_key_configure_t));
3846 bluetooth_mesh_key_configure_t *param = \
3847 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3849 sender = (char*)g_dbus_method_invocation_get_sender(context);
3850 _bt_save_invocation_context(context, result, sender,
3851 function_name, (gpointer)param);
3855 case BT_MESH_NODE_TTL_EXECUTE: {
3856 bluetooth_mesh_node_ttl_info_t req;
3858 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3860 __bt_service_get_parameters(in_param1,
3861 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3863 result = _bt_mesh_ttl_execute_remote_node(
3864 requester_unique_creds, sender, &req);
3866 /* Save invocation */
3867 if (result != BLUETOOTH_ERROR_NONE) {
3868 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3870 bluetooth_mesh_node_ttl_info_t *param = \
3871 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3873 sender = (char*)g_dbus_method_invocation_get_sender(context);
3874 _bt_save_invocation_context(context, result, sender,
3875 function_name, (gpointer)param);
3879 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3880 bluetooth_mesh_model_configure_t req;
3882 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3884 __bt_service_get_parameters(in_param1,
3885 &req, sizeof(bluetooth_mesh_model_configure_t));
3887 result = _bt_mesh_node_model_appkey_execute(
3888 requester_unique_creds, sender, &req);
3890 /* Save invocation */
3891 if (result != BLUETOOTH_ERROR_NONE) {
3892 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3894 bluetooth_mesh_model_configure_t *param = \
3895 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3897 sender = (char*)g_dbus_method_invocation_get_sender(context);
3898 _bt_save_invocation_context(context, result, sender,
3899 function_name, (gpointer)param);
3903 case BT_MESH_NODE_GET_NETKEYS: {
3904 bluetooth_mesh_node_discover_t node;
3905 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3906 __bt_service_get_parameters(in_param1,
3907 &node, sizeof(bluetooth_mesh_node_discover_t));
3908 result = _bt_mesh_network_node_get_netkeys(
3909 requester_unique_creds, &node, out_param1);
3912 case BT_MESH_NODE_GET_APPKEYS: {
3913 bluetooth_mesh_node_discover_t node;
3914 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3915 __bt_service_get_parameters(in_param1,
3916 &node, sizeof(bluetooth_mesh_node_discover_t));
3917 result = _bt_mesh_network_node_get_appkeys(
3918 requester_unique_creds, sender, &node, out_param1);
3921 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3922 bluetooth_mesh_model_configure_t req;
3924 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3926 __bt_service_get_parameters(in_param1,
3927 &req, sizeof(bluetooth_mesh_model_configure_t));
3929 result = _bt_mesh_node_model_get_appkey_list(
3930 requester_unique_creds, sender, &req);
3932 /* Save invocation */
3933 if (result != BLUETOOTH_ERROR_NONE) {
3934 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3936 bluetooth_mesh_model_configure_t *param = \
3937 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3939 sender = (char*)g_dbus_method_invocation_get_sender(context);
3940 _bt_save_invocation_context(context, result, sender,
3941 function_name, (gpointer)param);
3945 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3946 bluetooth_mesh_model_configure_t req;
3948 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3950 __bt_service_get_parameters(in_param1,
3951 &req, sizeof(bluetooth_mesh_model_configure_t));
3953 result = _bt_mesh_node_model_get_subscription_list(
3954 requester_unique_creds, sender, &req);
3956 /* Save invocation */
3957 if (result != BLUETOOTH_ERROR_NONE) {
3958 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3960 bluetooth_mesh_model_configure_t *param = \
3961 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3963 sender = (char*)g_dbus_method_invocation_get_sender(context);
3964 _bt_save_invocation_context(context, result, sender,
3965 function_name, (gpointer)param);
3970 case BT_MESH_NETWORK_CREATE_GROUP: {
3971 bluetooth_mesh_network_t net;
3972 bluetooth_mesh_network_group_info_t res;
3973 gboolean is_virtual;
3976 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
3977 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
3979 __bt_service_get_parameters(in_param1,
3980 &net, sizeof(bluetooth_mesh_network_t));
3981 __bt_service_get_parameters(in_param2,
3982 &is_virtual, sizeof(gboolean));
3983 __bt_service_get_parameters(in_param3,
3984 &grp_addr, sizeof(guint16));
3986 result = _bt_mesh_network_create_group(
3987 requester_unique_creds, sender, &net,
3988 is_virtual, grp_addr, &res);
3990 if (result == BLUETOOTH_ERROR_NONE)
3991 g_array_append_vals(*out_param1, &res,
3992 sizeof(bluetooth_mesh_network_group_info_t));
3995 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
3996 bluetooth_mesh_model_configure_t req;
3998 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4000 __bt_service_get_parameters(in_param1,
4001 &req, sizeof(bluetooth_mesh_model_configure_t));
4003 result = _bt_mesh_model_configure_group_subscription(
4004 requester_unique_creds, sender, &req);
4006 /* Save invocation */
4007 if (result != BLUETOOTH_ERROR_NONE) {
4008 g_array_append_vals(*out_param1,
4009 &req, sizeof(bluetooth_mesh_model_configure_t));
4011 bluetooth_mesh_model_configure_t *param = \
4012 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4014 sender = (char*)g_dbus_method_invocation_get_sender(context);
4015 _bt_save_invocation_context(context, result, sender,
4016 function_name, (gpointer)param);
4020 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4021 bluetooth_mesh_model_configure_t req;
4023 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4025 __bt_service_get_parameters(in_param1,
4026 &req, sizeof(bluetooth_mesh_model_configure_t));
4028 result = _bt_mesh_model_configure_virtual_group_subscription(
4029 requester_unique_creds, sender, &req);
4031 /* Save invocation */
4032 if (result != BLUETOOTH_ERROR_NONE) {
4033 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4035 bluetooth_mesh_model_configure_t *param = \
4036 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4038 sender = (char*)g_dbus_method_invocation_get_sender(context);
4039 _bt_save_invocation_context(context, result, sender,
4040 function_name, (gpointer)param);
4044 case BT_MESH_MODEL_SET_PUBLICATION: {
4045 bluetooth_mesh_model_configure_t req;
4047 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4049 __bt_service_get_parameters(in_param1,
4050 &req, sizeof(bluetooth_mesh_model_configure_t));
4052 result = _bt_mesh_model_set_publication(
4053 requester_unique_creds, sender, &req);
4055 /* Save invocation */
4056 if (result != BLUETOOTH_ERROR_NONE) {
4057 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4059 bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4061 sender = (char*)g_dbus_method_invocation_get_sender(context);
4062 _bt_save_invocation_context(context, result, sender,
4063 function_name, (gpointer)param);
4067 case BT_MESH_MODEL_GET_PUBLICATION: {
4068 bluetooth_mesh_model_configure_t req;
4070 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4072 __bt_service_get_parameters(in_param1,
4073 &req, sizeof(bluetooth_mesh_model_configure_t));
4075 result = _bt_mesh_model_get_publication(
4076 requester_unique_creds, sender, &req);
4078 /* Save invocation */
4079 if (result != BLUETOOTH_ERROR_NONE) {
4080 g_array_append_vals(*out_param1,
4081 &req, sizeof(bluetooth_mesh_model_configure_t));
4083 bluetooth_mesh_model_configure_t *param = \
4084 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4086 sender = (char*)g_dbus_method_invocation_get_sender(context);
4087 _bt_save_invocation_context(context, result, sender,
4088 function_name, (gpointer)param);
4092 case BT_MESH_NETWORK_GET_GROUPS: {
4093 bluetooth_mesh_network_t network;
4094 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4095 __bt_service_get_parameters(in_param1,
4096 &network, sizeof(bluetooth_mesh_network_t));
4097 result = _bt_mesh_network_get_groups(
4098 requester_unique_creds, sender, &network, out_param1);
4102 BT_INFO("UnSupported function [%d]", function_name);
4103 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4109 #ifdef TIZEN_FEATURE_BT_OBEX
4110 /* Function definitions*/
4111 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4116 size = g_variant_get_size(var);
4118 data = (char *)g_variant_get_data(var);
4120 param = g_array_append_vals(param, data, size);
4126 int __bt_obexd_request(int function_name,
4129 GDBusMethodInvocation *context,
4130 GVariant *in_param1,
4131 GVariant *in_param2,
4132 GVariant *in_param3,
4133 GVariant *in_param4,
4134 GArray **out_param1)
4138 int result = BLUETOOTH_ERROR_NONE;
4140 BT_DBG("function_name : %x", function_name);
4142 switch (function_name) {
4143 case BT_OPP_PUSH_FILES: {
4144 BT_DBG("BT_OPP_PUSH_FILES");
4146 bluetooth_device_address_t address = { {0} };
4147 bt_file_path_t *path;
4152 __bt_service_get_parameters(in_param1, &address,
4153 sizeof(bluetooth_device_address_t));
4154 __bt_service_get_parameters(in_param3, &file_count,
4157 file_path = g_new0(char *, file_count + 1);
4159 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4160 __bt_fill_garray_from_variant(in_param2, param2);
4162 for (i = 0; i < file_count; i++) {
4163 path = &g_array_index(param2, bt_file_path_t, i);
4164 file_path[i] = g_strdup(path->path);
4166 BT_DBG("_bt_opp_client_push_files");
4167 result = _bt_opp_client_push_files(request_id, context,
4168 &address, file_path,
4171 for (i = 0; i < file_count; i++)
4172 g_free(file_path[i]);
4175 g_array_free(param2, TRUE);
4179 case BT_OPP_CANCEL_PUSH: {
4180 result = _bt_opp_client_cancel_push();
4184 case BT_OPP_IS_PUSHING_FILES: {
4185 gboolean is_sending = FALSE;
4187 result = _bt_opp_client_is_sending(&is_sending);
4189 g_array_append_vals(*out_param1, &is_sending,
4193 case BT_OPP_GET_TRANSFER_PROGRESS: {
4196 guint8 progress = 0;
4198 __bt_service_get_parameters(in_param1, &direction,
4200 __bt_service_get_parameters(in_param2, &transfer_id,
4203 result = _bt_opp_get_client_progress(&progress);
4205 result = _bt_opp_get_server_progress(transfer_id, &progress);
4207 g_array_append_vals(*out_param1, &progress,
4213 case BT_MAP_CREATE_SESSION: {
4214 BT_DBG("BT_MAP_CREATE_SESSION");
4215 char *address = (char *)g_variant_get_data(in_param1);
4216 char *session_id = NULL;
4217 result = _bt_create_session_sync(address, &session_id);
4218 if (result == BLUETOOTH_ERROR_NONE)
4219 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4223 case BT_MAP_DESTROY_SESSION: {
4224 BT_DBG("BT_MAP_DESTROY_SESSION");
4225 char* session_id = (char *)g_variant_get_data(in_param1);
4226 result = _bt_destroy_session_sync(session_id);
4227 if (result == BLUETOOTH_ERROR_NONE)
4228 BT_DBG("successfully destroyed session");
4232 case BT_MAP_SET_FOLDER: {
4233 BT_DBG("BT_MAP_SET_FOLDER");
4234 char *session_id = (char *)g_variant_get_data(in_param1);
4235 char *name = (char *)g_variant_get_data(in_param2);
4236 result = _bt_map_client_set_folder(session_id, name);
4240 case BT_MAP_LIST_FOLDERS: {
4241 BT_DBG("BT_MAP_LIST_FOLDERS");
4243 char* session_id = (char *)g_variant_get_data(in_param1);
4244 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4246 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4247 if (result == BLUETOOTH_ERROR_NONE)
4248 BT_DBG("_bt_map_client_list_folders succeed");
4253 case BT_MAP_LIST_FILTER_FIELDS: {
4254 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4256 char* session_id = (char *)g_variant_get_data(in_param1);
4258 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4259 if (result == BLUETOOTH_ERROR_NONE)
4260 BT_DBG("_bt_map_client_list_filter_fields succeed");
4265 case BT_MAP_LIST_MESSAGES: {
4266 BT_DBG("BT_MAP_LIST_MESSAGES");
4268 char* session_id = (char*)g_variant_get_data(in_param1);
4269 char* folder = (char*)g_variant_get_data(in_param2);
4270 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4272 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4273 if (result == BLUETOOTH_ERROR_NONE)
4274 BT_DBG("_bt_map_client_list_messages succeed");
4276 BT_DBG("_bt_map_client_list_messages failed");
4281 case BT_MAP_UPDATE_INBOX: {
4282 BT_DBG("BT_MAP_UPDATE_INBOX");
4283 char* session_id = (char *)g_variant_get_data(in_param1);
4284 result = _bt_map_client_update_inbox(session_id);
4288 case BT_MAP_PUSH_MESSAGE: {
4289 BT_DBG("BT_MAP_PUSH_MESSAGE");
4291 char* session_id = (char *)g_variant_get_data(in_param1);
4292 char* source_file = (char *)g_variant_get_data(in_param2);
4293 char* folder = (char *)g_variant_get_data(in_param3);
4294 char* args_serialized = (char *)g_variant_get_data(in_param4);
4296 result = _bt_map_client_push_message(
4297 request_id, context, session_id, source_file, folder, args_serialized);
4298 if (result == BLUETOOTH_ERROR_NONE)
4299 BT_DBG("_bt_map_client_push_message succeed");
4301 BT_ERR("_bt_map_client_push_message failed");
4306 case BT_MAP_GET_MESSAGE: {
4307 BT_DBG("BT_MAP_GET_MESSAGE");
4308 // TODO session currently is not used, but should be valid
4309 //char* session_id = (char *)g_variant_get_data(in_param1);
4310 char* message_object = (char *)g_variant_get_data(in_param2);
4311 char* target_file = (char *)g_variant_get_data(in_param3);
4312 bool attachment = false;
4313 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4315 result = _bt_map_client_get_message(request_id, context, message_object,
4316 target_file, attachment);
4317 if (result == BLUETOOTH_ERROR_NONE)
4318 BT_DBG("_bt_map_client_get_message succeed");
4323 case BT_OBEX_SERVER_ALLOCATE: {
4329 sender = (char *)g_dbus_method_invocation_get_sender(context);
4331 path = (char *)g_variant_get_data(in_param1);
4332 __bt_service_get_parameters(in_param2, &is_native,
4334 __bt_service_get_parameters(in_param3, &app_pid,
4337 result = _bt_obex_server_allocate(sender,
4338 path, app_pid, is_native);
4342 case BT_OBEX_SERVER_DEALLOCATE: {
4346 __bt_service_get_parameters(in_param1, &is_native,
4348 __bt_service_get_parameters(in_param2, &app_pid,
4351 result = _bt_obex_server_deallocate(app_pid, is_native);
4354 case BT_OBEX_SERVER_IS_ACTIVATED: {
4355 gboolean is_activated = FALSE;
4357 result = _bt_obex_server_is_activated(&is_activated);
4359 g_array_append_vals(*out_param1, &is_activated,
4364 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4365 result = _bt_obex_server_accept_connection(request_id);
4369 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4370 result = _bt_obex_server_reject_connection();
4374 case BT_OBEX_SERVER_ACCEPT_FILE: {
4377 file_name = (char *)g_variant_get_data(in_param1);
4379 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4383 case BT_OBEX_SERVER_REJECT_FILE: {
4384 result = _bt_obex_server_reject_authorize();
4388 case BT_OBEX_SERVER_SET_PATH: {
4390 char *destination_path;
4392 destination_path = (char *)g_variant_get_data(in_param1);
4393 __bt_service_get_parameters(in_param2, &is_native,
4396 result = _bt_obex_server_set_destination_path(destination_path,
4401 case BT_OBEX_SERVER_SET_ROOT: {
4404 root = (char *)g_variant_get_data(in_param1);
4406 result = _bt_obex_server_set_root(root);
4410 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4413 __bt_service_get_parameters(in_param1, &transfer_id,
4416 result = _bt_obex_server_cancel_transfer(transfer_id);
4420 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4421 result = _bt_obex_server_cancel_all_transfers();
4425 case BT_OBEX_SERVER_IS_RECEIVING: {
4426 gboolean is_receiving = FALSE;
4428 result = _bt_obex_server_is_receiving(&is_receiving);
4430 g_array_append_vals(*out_param1, &is_receiving,
4434 case BT_PBAP_CONNECT: {
4435 bluetooth_device_address_t address = { {0} };
4437 __bt_service_get_parameters(in_param1, &address,
4438 sizeof(bluetooth_device_address_t));
4440 result = _bt_pbap_connect(&address);
4443 case BT_PBAP_DISCONNECT: {
4444 bluetooth_device_address_t address = { {0} };
4446 __bt_service_get_parameters(in_param1, &address,
4447 sizeof(bluetooth_device_address_t));
4449 result = _bt_pbap_disconnect(&address);
4452 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4453 bluetooth_device_address_t address = { {0} };
4454 bt_pbap_folder_t folder = { 0, };
4456 __bt_service_get_parameters(in_param1, &address,
4457 sizeof(bluetooth_device_address_t));
4458 __bt_service_get_parameters(in_param2, &folder,
4459 sizeof(bt_pbap_folder_t));
4461 result = _bt_pbap_get_phonebook_size(&address,
4462 folder.addressbook, folder.folder_type);
4465 case BT_PBAP_GET_PHONEBOOK: {
4466 bluetooth_device_address_t address = { {0} };
4467 bt_pbap_folder_t folder = { 0, };
4468 bt_pbap_pull_parameters_t app_param = { 0, };
4470 __bt_service_get_parameters(in_param1, &address,
4471 sizeof(bluetooth_device_address_t));
4472 __bt_service_get_parameters(in_param2, &folder,
4473 sizeof(bt_pbap_folder_t));
4474 __bt_service_get_parameters(in_param3, &app_param,
4475 sizeof(bt_pbap_pull_parameters_t));
4477 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4478 folder.folder_type, &app_param);
4481 case BT_PBAP_GET_LIST: {
4482 bluetooth_device_address_t address = { {0} };
4483 bt_pbap_folder_t folder = { 0, };
4484 bt_pbap_list_parameters_t app_param = { 0, };
4486 __bt_service_get_parameters(in_param1, &address,
4487 sizeof(bluetooth_device_address_t));
4488 __bt_service_get_parameters(in_param2, &folder,
4489 sizeof(bt_pbap_folder_t));
4490 __bt_service_get_parameters(in_param3, &app_param,
4491 sizeof(bt_pbap_list_parameters_t));
4493 result = _bt_pbap_get_list(&address, folder.addressbook,
4494 folder.folder_type, &app_param);
4497 case BT_PBAP_PULL_VCARD: {
4498 bluetooth_device_address_t address = { {0} };
4499 bt_pbap_folder_t folder = { 0, };
4500 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4502 __bt_service_get_parameters(in_param1, &address,
4503 sizeof(bluetooth_device_address_t));
4504 __bt_service_get_parameters(in_param2, &folder,
4505 sizeof(bt_pbap_folder_t));
4506 __bt_service_get_parameters(in_param3, &app_param,
4507 sizeof(bt_pbap_pull_vcard_parameters_t));
4509 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4510 folder.folder_type, &app_param);
4513 case BT_PBAP_PHONEBOOK_SEARCH: {
4514 bluetooth_device_address_t address = { {0} };
4515 bt_pbap_folder_t folder = { 0, };
4516 bt_pbap_search_parameters_t app_param = { 0, };
4518 __bt_service_get_parameters(in_param1, &address,
4519 sizeof(bluetooth_device_address_t));
4520 __bt_service_get_parameters(in_param2, &folder,
4521 sizeof(bt_pbap_folder_t));
4522 __bt_service_get_parameters(in_param3, &app_param,
4523 sizeof(bt_pbap_search_parameters_t));
4525 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4526 folder.folder_type, &app_param);
4531 BT_ERR("Unknown function!");
4532 result = BLUETOOTH_ERROR_INTERNAL;
4541 int __bt_agent_request(int function_name,
4544 GDBusMethodInvocation *context,
4545 GVariant *in_param1,
4546 GVariant *in_param2,
4547 GVariant *in_param3,
4548 GVariant *in_param4,
4549 GArray **out_param1)
4552 switch (function_name) {
4553 case BT_SET_AUTHORIZATION: {
4560 sender = (char *)g_dbus_method_invocation_get_sender(context);
4561 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4562 uuid = (char *)g_variant_get_data(in_param2);
4563 path = (char *)g_variant_get_data(in_param3);
4564 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4566 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4569 case BT_UNSET_AUTHORIZATION: {
4573 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4574 uuid = (char *)g_variant_get_data(in_param2);
4576 result = _bt_unregister_osp_server_in_agent(type, uuid);
4580 BT_ERR("Unknown function!");
4581 result = BLUETOOTH_ERROR_INTERNAL;
4588 int __bt_core_request(int function_name,
4591 GDBusMethodInvocation *context,
4592 GVariant *in_param1)
4596 switch (function_name) {
4597 case BT_ENABLE_ADAPTER:
4600 _bt_set_adapter_request_state(TRUE);
4601 status = _bt_adapter_get_status();
4603 if (status == BT_ACTIVATING) {
4604 BT_DBG("Enabling in progress");
4605 result = BLUETOOTH_ERROR_IN_PROGRESS;
4606 } else if (status == BT_ACTIVATED) {
4607 BT_DBG("Already enabled");
4608 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4610 _bt_adapter_set_status(BT_ACTIVATING);
4611 result = BLUETOOTH_ERROR_NONE;
4616 case BT_DISABLE_ADAPTER:
4620 status = _bt_adapter_get_status();
4621 if (status == BT_DEACTIVATING) {
4622 BT_DBG("Disabling in progress");
4623 result = BLUETOOTH_ERROR_IN_PROGRESS;
4624 } else if (status == BT_DEACTIVATED) {
4625 BT_DBG("Already disabled");
4626 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4628 _bt_adapter_set_status(BT_DEACTIVATING);
4629 result = BLUETOOTH_ERROR_NONE;
4634 case BT_ENABLE_ADAPTER_LE:
4636 bt_le_status_t le_status;
4637 _bt_set_le_request_state(TRUE);
4638 le_status = _bt_adapter_get_le_status();
4639 if (le_status == BT_LE_ACTIVATING) {
4640 BT_DBG("Enabling in progress");
4641 result = BLUETOOTH_ERROR_IN_PROGRESS;
4642 } else if (le_status == BT_LE_ACTIVATED) {
4643 BT_DBG("Already enabled");
4644 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4646 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4647 result = BLUETOOTH_ERROR_NONE;
4652 case BT_DISABLE_ADAPTER_LE:
4654 bt_le_status_t le_status;
4656 le_status = _bt_adapter_get_le_status();
4657 if (le_status == BT_LE_DEACTIVATING) {
4658 BT_DBG("Disabling in progress");
4659 result = BLUETOOTH_ERROR_IN_PROGRESS;
4660 } else if (le_status == BT_LE_DEACTIVATED) {
4661 BT_DBG("Already disabled");
4662 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4664 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4665 result = BLUETOOTH_ERROR_NONE;
4671 BT_ERR("Unknown function!");
4672 result = BLUETOOTH_ERROR_INTERNAL;
4679 gboolean __bt_service_check_privilege(int function_name,
4681 const char *unique_name)
4684 gboolean result = TRUE;
4685 char *client_creds = NULL;
4686 char *user_creds = NULL;
4687 char *client_session = "";
4688 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4689 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4690 char err_msg[256] = {0, };
4692 retv_if(unique_name == NULL, FALSE);
4693 retv_if(bt_service_conn == NULL, FALSE);
4695 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4696 if (ret_val != CYNARA_API_SUCCESS) {
4697 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4698 BT_ERR("Fail to get default client method: %s", err_msg);
4702 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4703 if (ret_val != CYNARA_API_SUCCESS) {
4704 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4705 BT_ERR("Fail to get default user method: %s", err_msg);
4709 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4710 if (ret_val != CYNARA_API_SUCCESS) {
4711 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4712 BT_ERR("Fail to get client credential: %s", err_msg);
4716 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4717 if (ret_val != CYNARA_API_SUCCESS) {
4718 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4719 BT_ERR("Fail to get user credential: %s", err_msg);
4725 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4727 switch (function_name) {
4728 case BT_SET_LOCAL_NAME:
4729 case BT_START_DISCOVERY:
4730 case BT_START_CUSTOM_DISCOVERY:
4731 case BT_CANCEL_DISCOVERY:
4732 case BT_OOB_ADD_REMOTE_DATA:
4733 case BT_OOB_REMOVE_REMOTE_DATA:
4734 case BT_OOB_READ_LOCAL_DATA:
4735 case BT_SET_ADVERTISING:
4736 case BT_SET_CUSTOM_ADVERTISING:
4737 case BT_SET_ADVERTISING_PARAMETERS:
4738 case BT_START_LE_DISCOVERY:
4739 case BT_STOP_LE_DISCOVERY:
4740 case BT_SET_SCAN_PARAMETERS:
4741 case BT_SET_SCAN_TYPE:
4743 case BT_BOND_DEVICE:
4744 case BT_CANCEL_BONDING:
4745 case BT_UNBOND_DEVICE:
4747 case BT_SET_AUTHORIZATION:
4748 case BT_UNSET_AUTHORIZATION:
4749 case BT_SEARCH_SERVICE:
4751 case BT_RFCOMM_CLIENT_CONNECT:
4752 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4753 BT_PERMANENT_LOG("Connect socket");
4754 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4755 case BT_RFCOMM_SOCKET_DISCONNECT:
4756 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4757 BT_PERMANENT_LOG("Disconnect socket");
4758 case BT_RFCOMM_SOCKET_WRITE:
4759 case BT_RFCOMM_CREATE_SOCKET:
4760 case BT_RFCOMM_REMOVE_SOCKET:
4761 case BT_RFCOMM_SEND_RX_DETAILS:
4762 case BT_RFCOMM_SEND_TX_DETAILS:
4763 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4765 case BT_OPP_PUSH_FILES:
4766 case BT_OPP_CANCEL_PUSH:
4767 /* TODO: MAP? MAP functions, see above */
4769 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4770 case BT_OBEX_SERVER_REJECT_CONNECTION:
4771 case BT_OBEX_SERVER_ACCEPT_FILE:
4772 case BT_OBEX_SERVER_REJECT_FILE:
4773 case BT_OBEX_SERVER_SET_PATH:
4774 case BT_OBEX_SERVER_SET_ROOT:
4775 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4776 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4778 case BT_AUDIO_SELECT_ROLE:
4779 case BT_AUDIO_CONNECT:
4780 case BT_AUDIO_DISCONNECT:
4782 case BT_AG_DISCONNECT:
4784 case BT_AV_DISCONNECT:
4785 case BT_AV_SOURCE_CONNECT:
4786 case BT_AV_SOURCE_DISCONNECT:
4787 case BT_AVRCP_TARGET_CONNECT:
4788 case BT_AVRCP_TARGET_DISCONNECT:
4789 case BT_AVRCP_CONTROL_CONNECT:
4790 case BT_AVRCP_CONTROL_DISCONNECT:
4791 case BT_AVRCP_HANDLE_CONTROL:
4792 case BT_AVRCP_SET_TRACK_INFO:
4793 case BT_AVRCP_SET_PROPERTY:
4794 case BT_AVRCP_SET_PROPERTIES:
4795 case BT_AVRCP_CONTROL_SET_PROPERTY:
4797 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
4798 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4799 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4800 case BT_AUDIO_IS_AVC_ACTIVATED:
4804 case BT_HF_DISCONNECT:
4806 case BT_HID_CONNECT:
4807 case BT_HID_DISCONNECT:
4809 case BT_HID_DEVICE_ACTIVATE:
4810 case BT_HID_DEVICE_DEACTIVATE:
4811 case BT_HID_DEVICE_CONNECT:
4812 case BT_HID_DEVICE_DISCONNECT:
4813 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4814 case BT_HID_DEVICE_SEND_KEY_EVENT:
4815 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4816 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4819 case BT_DISCONNECT_LE:
4821 case BT_SET_ADVERTISING_DATA:
4822 case BT_SET_SCAN_RESPONSE_DATA:
4824 case BT_HDP_CONNECT:
4825 case BT_HDP_DISCONNECT:
4826 case BT_HDP_SEND_DATA:
4827 case BT_HDP_REGISTER_SINK_APP:
4828 case BT_HDP_UNREGISTER_SINK_APP:
4831 case BT_DPM_SET_ALLOW_BT_MODE:
4832 case BT_DPM_GET_ALLOW_BT_MODE:
4833 case BT_DPM_SET_DEVICE_RESTRITION:
4834 case BT_DPM_GET_DEVICE_RESTRITION:
4835 case BT_DPM_SET_UUID_RESTRITION:
4836 case BT_DPM_GET_UUID_RESTRITION:
4837 case BT_DPM_ADD_DEVICES_BLACKLIST:
4838 case BT_DPM_ADD_DEVICES_WHITELIST:
4839 case BT_DPM_ADD_UUIDS_BLACKLIST:
4840 case BT_DPM_ADD_UUIDS_WHITELIST:
4841 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4842 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4843 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4844 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4845 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4846 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4847 case BT_DPM_REMOVE_UUID_BLACKLIST:
4848 case BT_DPM_REMOVE_UUID_WHITELIST:
4849 case BT_DPM_GET_DEVICES_BLACKLIST:
4850 case BT_DPM_GET_DEVICES_WHITELIST:
4851 case BT_DPM_GET_UUIDS_BLACKLIST:
4852 case BT_DPM_GET_UUIDS_WHITELIST:
4853 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4854 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4855 case BT_DPM_SET_PAIRING_STATE:
4856 case BT_DPM_GET_PAIRING_STATE:
4857 case BT_DPM_SET_PROFILE_STATE:
4858 case BT_DPM_GET_PROFILE_STATE:
4859 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4860 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4861 case BT_DPM_SET_DISCOVERABLE_STATE:
4862 case BT_DPM_GET_DISCOVERABLE_STATE:
4863 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4864 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4865 case BT_DPM_SET_DATA_TRANSFER_STATE:
4866 case BT_DPM_GET_DATA_TRANSFER_STATE:
4868 case BT_NETWORK_ACTIVATE:
4869 case BT_NETWORK_DEACTIVATE:
4870 case BT_NETWORK_CONNECT:
4871 case BT_NETWORK_DISCONNECT:
4872 case BT_NETWORK_SERVER_DISCONNECT:
4874 case BT_GATT_GET_PRIMARY_SERVICES:
4875 #ifdef TIZEN_GATT_CLIENT
4876 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4877 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4878 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4880 case BT_GATT_DISCOVER_CHARACTERISTICS:
4881 case BT_GATT_SET_PROPERTY_REQUEST:
4882 case BT_GATT_READ_CHARACTERISTIC:
4883 #ifdef TIZEN_GATT_CLIENT
4884 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4885 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4886 case BT_GATT_ACQUIRE_WRITE:
4887 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4888 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4889 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4890 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4892 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4893 case BT_GATT_REGISTER_APPLICATION:
4894 case BT_GATT_REGISTER_SERVICE:
4895 case BT_GATT_SEND_RESPONSE:
4897 case BT_GATT_SERVER_REGISTER:
4898 case BT_GATT_SERVER_ADD_SERVICE:
4899 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4900 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4901 case BT_GATT_SERVER_START_SERVICE:
4902 case BT_GATT_SERVER_STOP_SERVICE:
4903 case BT_GATT_SERVER_DELETE_SERVICE:
4904 case BT_GATT_SERVER_SEND_RESPONSE:
4905 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
4906 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
4907 case BT_GATT_SERVER_SEND_INDICATION:
4908 case BT_GATT_SERVER_UPDATE_VALUE:
4909 case BT_GATT_SERVER_DEREGISTER:
4911 case BT_REQ_ATT_MTU:
4912 case BT_PBAP_CONNECT:
4913 case BT_PBAP_DISCONNECT:
4914 case BT_PBAP_GET_PHONEBOOK_SIZE:
4915 case BT_PBAP_GET_PHONEBOOK:
4916 case BT_PBAP_GET_LIST:
4917 case BT_PBAP_PULL_VCARD:
4918 case BT_PBAP_PHONEBOOK_SEARCH:
4920 case BT_RFCOMM_LISTEN_AND_ACCEPT:
4922 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4923 BT_PRIVILEGE_PUBLIC);
4925 BT_INFO("Client Credentials [%s]", client_creds);
4926 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4927 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
4931 /* Need to check mediastorage privilege */
4932 if (function_name == BT_PBAP_GET_PHONEBOOK ||
4933 function_name == BT_PBAP_PULL_VCARD) {
4934 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4935 MEDIASTORAGE_PRIVILEGE);
4937 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4938 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
4944 case BT_ENABLE_ADAPTER:
4945 case BT_DISABLE_ADAPTER:
4946 case BT_RESET_ADAPTER:
4947 case BT_RECOVER_ADAPTER:
4948 case BT_BATTERY_READ_DATA:
4949 case BT_ENABLE_ADAPTER_LE:
4950 case BT_DISABLE_ADAPTER_LE:
4951 case BT_SET_CONNECTABLE:
4952 case BT_SET_DISCOVERABLE_MODE:
4953 case BT_ADD_WHITE_LIST:
4954 case BT_REMOVE_WHITE_LIST:
4955 case BT_CLEAR_WHITE_LIST:
4956 case BT_SET_MANUFACTURER_DATA:
4958 case BT_CANCEL_SEARCH_SERVICE:
4959 case BT_ENABLE_RSSI:
4960 case BT_DISCONNECT_DEVICE:
4962 case BT_RFCOMM_ACCEPT_CONNECTION:
4963 case BT_RFCOMM_REJECT_CONNECTION:
4964 case BT_RFCOMM_LISTEN:
4966 case BT_HID_ENABLE_BARCODE_FEATURE:
4968 case BT_AVRCP_CONTROL_GET_PROPERTY:
4969 case BT_AVRCP_GET_TRACK_INFO:
4970 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
4971 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
4973 case BT_SET_CONTENT_PROTECT:
4974 case BT_BOND_DEVICE_BY_TYPE:
4975 case BT_SET_LE_PRIVACY:
4976 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
4977 case BT_LE_CONN_UPDATE:
4978 case BT_UPDATE_LE_CONNECTION_MODE:
4979 case BT_GET_DEVICE_IDA:
4980 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
4981 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
4982 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
4983 case BT_LE_SET_DATA_LENGTH:
4984 case BT_LE_OOB_READ_LOCAL_DATA:
4985 case BT_LE_OOB_ADD_REMOTE_DATA:
4987 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
4988 case BT_ENABLE_GATT_DATA_BATCHING:
4989 case BT_DISABLE_GATT_DATA_BATCHING:
4991 case BT_LE_IPSP_INIT:
4992 case BT_LE_IPSP_DEINIT:
4993 case BT_LE_IPSP_CONNECT:
4994 case BT_LE_IPSP_DISCONNECT:
4995 case BT_PXP_MONITOR_SET_PROPERTY:
4996 case BT_PXP_MONITOR_GET_PROPERTY:
4997 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
4998 case BT_PXP_REPORTER_REGISTER:
4999 case BT_PXP_REPORTER_UNREGISTER:
5000 case BT_PXP_REPORTER_GET_PROPERTY:
5003 case BT_TDS_PROVIDER_REGISTER:
5004 case BT_TDS_PROVIDER_UNREGISTER:
5005 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5006 case BT_TDS_PROVIDER_CREATE:
5007 case BT_TDS_PROVIDER_DESTROY:
5008 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5009 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5010 case BT_TDS_READ_TRANSPORT_DATA:
5011 case BT_TDS_ENABLE_CONTROL_POINT:
5012 case BT_TDS_ACTIVATE_CONTROL_POINT:
5015 case BT_OTP_SERVER_INIT:
5016 case BT_OTP_SERVER_DEINIT:
5017 case BT_OTP_READ_VALUE:
5018 case BT_OTP_ENABLE_NOTIFICATION:
5019 case BT_OTP_WRITE_VALUE:
5020 case BT_LE_OTC_CONNECT:
5021 case BT_LE_OTC_DISCONNECT:
5023 case BT_MAP_CREATE_SESSION:
5024 case BT_MAP_DESTROY_SESSION:
5025 case BT_MAP_SET_FOLDER:
5026 case BT_MAP_LIST_FOLDERS:
5027 case BT_MAP_LIST_FILTER_FIELDS:
5028 case BT_MAP_LIST_MESSAGES:
5029 case BT_MAP_UPDATE_INBOX:
5030 case BT_MAP_PUSH_MESSAGE:
5031 case BT_MAP_GET_MESSAGE:
5034 case BT_MESH_DEINIT:
5035 case BT_MESH_NETWORK_CREATE:
5036 case BT_MESH_NETWORK_LOAD:
5037 case BT_MESH_NETWORK_SCAN:
5038 case BT_MESH_NETWORK_CANCEL_SCAN:
5039 case BT_MESH_NETWORK_SET_CAPABILITIES:
5040 case BT_MESH_NETWORK_PROVISION_DEVICE:
5041 case BT_MESH_AUTHENTICATION_REPLY:
5042 case BT_MESH_NETWORK_SET_NAME:
5043 case BT_MESH_NETWORK_ADD_NETKEY:
5044 case BT_MESH_NETWORK_DELETE_NETKEY:
5045 case BT_MESH_NETWORK_UPDATE_NETKEY:
5046 case BT_MESH_NETWORK_ADD_APPKEY:
5047 case BT_MESH_NETWORK_DELETE_APPKEY:
5048 case BT_MESH_NETWORK_UPDATE_APPKEY:
5049 case BT_MESH_NETWORK_GET_NETKEYS:
5050 case BT_MESH_NETWORK_GET_APPKEYS:
5051 case BT_MESH_NETWORK_GET_NODES:
5052 case BT_MESH_ELEMENT_GET_MODELS:
5053 case BT_MESH_NODE_BROWSE:
5054 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5055 case BT_MESH_NODE_CONFIGURE_KEY:
5056 case BT_MESH_NODE_TTL_EXECUTE:
5057 case BT_MESH_NODE_GET_NETKEYS:
5058 case BT_MESH_NODE_GET_APPKEYS:
5059 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5060 case BT_MESH_MODEL_GET_APPKEY_LIST:
5061 case BT_MESH_NETWORK_CREATE_GROUP:
5062 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5063 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5064 case BT_MESH_MODEL_SET_PUBLICATION:
5065 case BT_MESH_MODEL_GET_PUBLICATION:
5066 case BT_MESH_NETWORK_GET_GROUPS:
5068 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5069 BT_PRIVILEGE_PLATFORM);
5071 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5072 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5077 case BT_CHECK_ADAPTER:
5080 case BT_GET_LOCAL_NAME:
5081 case BT_GET_LOCAL_ADDRESS:
5082 case BT_GET_LOCAL_VERSION:
5083 case BT_IS_SERVICE_USED:
5084 case BT_GET_DISCOVERABLE_MODE:
5085 case BT_GET_DISCOVERABLE_TIME:
5086 case BT_IS_DISCOVERYING:
5087 case BT_IS_LE_DISCOVERYING:
5088 case BT_IS_CONNECTABLE:
5089 case BT_GET_CONNECTABLE:
5090 case BT_GET_BONDED_DEVICES:
5091 case BT_GET_PROFILE_CONNECTED_DEVICES:
5092 case BT_GET_BONDED_DEVICE:
5093 case BT_PASSKEY_REPLY:
5094 case BT_PASSKEY_CONFIRMATION_REPLY:
5095 case BT_GET_IS_ALIAS_SET:
5096 case BT_IS_DEVICE_CONNECTED:
5097 case BT_GET_CONNECTED_LINK_TYPE:
5098 case BT_SET_PROFILE_TRUSTED:
5099 case BT_GET_PROFILE_TRUSTED:
5100 case BT_GET_SPEAKER_GAIN:
5101 case BT_SET_SPEAKER_GAIN:
5102 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5103 case BT_RFCOMM_IS_UUID_AVAILABLE:
5104 case BT_GET_ADVERTISING_DATA:
5105 case BT_GET_SCAN_RESPONSE_DATA:
5106 case BT_IS_ADVERTISING:
5107 case BT_IS_LE_2M_PHY_SUPPORTED:
5108 case BT_IS_LE_CODED_PHY_SUPPORTED:
5109 case BT_REGISTER_SCAN_FILTER:
5110 case BT_IS_SCAN_FILTER_SUPPORTED:
5111 case BT_GET_ATT_MTU:
5113 case BT_OBEX_SERVER_ALLOCATE:
5114 case BT_OBEX_SERVER_DEALLOCATE:
5115 case BT_OBEX_SERVER_IS_ACTIVATED:
5116 case BT_OPP_GET_TRANSFER_PROGRESS:
5117 /* Non-privilege control */
5120 BT_ERR("Unknown function!");
5125 if (client_creds && function_name >= BT_FUNC_MESH_BASE) {
5126 BT_INFO("MESH Function called creds [%s]", client_creds);
5127 requester_unique_creds = g_strdup(client_creds);
5131 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5139 GDBusNodeInfo *__bt_service_create_method_node_info
5140 (const gchar *introspection_data)
5143 GDBusNodeInfo *node_info = NULL;
5145 if (introspection_data == NULL) {
5146 BT_ERR("Introspection XML not present");
5150 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5153 BT_ERR("Unable to create node: %s", err->message);
5154 g_clear_error(&err);
5159 int __bt_service_register_object(GDBusConnection *conn,
5160 GDBusNodeInfo *node_info, gboolean reg)
5162 static guint service_id = 0;
5163 GError *error = NULL;
5166 if (node_info == NULL)
5169 service_id = g_dbus_connection_register_object(conn,
5171 node_info->interfaces[0],
5173 NULL, NULL, &error);
5174 if (service_id == 0)
5177 if (service_id > 0) {
5178 g_dbus_connection_unregister_object(conn,
5187 static void __name_owner_changed(GDBusConnection *connection,
5188 const gchar *sender_name,
5189 const gchar *object_path,
5190 const gchar *interface_name,
5191 const gchar *signal_name,
5192 GVariant *parameters,
5195 const char *name = NULL;
5196 const char *old_owner = NULL;
5197 const char *new_owner = NULL;
5199 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5200 if (*new_owner != '\0')
5203 _bt_check_hdp_app_termination(name);
5205 /* Advertising App Termination */
5206 _bt_check_adv_app_termination(name);
5208 /* Check if le_scanning app is terminated */
5209 _bt_check_le_scanner_app_termination(name);
5211 /* Check if RFCOMM app is terminated */
5212 _bt_rfcomm_check_termination(name);
5215 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5216 const gchar *name, gpointer user_data)
5218 GDBusNodeInfo *node_info = NULL;
5220 BT_INFO("bus acquired");
5222 ret_if(connection == NULL);
5224 node_info = __bt_service_create_method_node_info(
5225 bt_service_introspection_xml);
5226 ret_if(node_info == NULL);
5228 __bt_service_register_object(connection, node_info, TRUE);
5229 g_dbus_node_info_unref(node_info);
5231 bt_service_conn = connection;
5234 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5235 const gchar *name, gpointer user_data)
5237 BT_INFO("name acquired");
5238 name_acquired = TRUE;
5241 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5242 const gchar *name, gpointer user_data)
5244 BT_INFO("name lost");
5245 name_acquired = FALSE;
5248 gboolean _is_name_acquired(void)
5250 return name_acquired;
5253 void _bt_service_unref_connection(void)
5257 if (bt_service_conn) {
5258 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5259 g_object_unref(bt_service_conn);
5260 bt_service_conn = NULL;
5266 int _bt_service_register(void)
5268 GDBusConnection *conn;
5271 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5272 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5273 bt_service_conn = conn;
5275 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5277 G_BUS_NAME_OWNER_FLAGS_NONE,
5278 __bt_service_bus_acquired_handler,
5279 __bt_service_name_acquired_handler,
5280 __bt_service_name_lost_handler,
5282 BT_DBG("owner_id is [%d]", owner_id);
5286 /* Subscribe for name owner changed signal */
5287 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5288 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5289 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5290 __name_owner_changed, NULL, NULL);
5291 BT_INFO("owner_sig_id: %d", owner_sig_id);
5293 return BLUETOOTH_ERROR_NONE;
5296 if (bt_service_conn) {
5297 g_object_unref(bt_service_conn);
5298 bt_service_conn = NULL;
5301 return BLUETOOTH_ERROR_INTERNAL;
5304 void _bt_service_unregister(void)
5306 if (bt_service_conn) {
5307 sd_notify(0, "STOPPING=1");
5309 if (owner_sig_id > 0) {
5310 g_dbus_connection_signal_unsubscribe(
5311 bt_service_conn, owner_sig_id);
5316 g_bus_unown_name(owner_id);
5320 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5324 int _bt_service_cynara_init(void)
5327 char err_msg[256] = {0, };
5329 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5331 result = cynara_initialize(&p_cynara, conf);
5333 if (result != CYNARA_API_SUCCESS) {
5334 cynara_strerror(result, err_msg, sizeof(err_msg));
5335 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5336 return BLUETOOTH_ERROR_INTERNAL;
5339 return BLUETOOTH_ERROR_NONE;
5342 void _bt_service_cynara_deinit(void)
5345 char err_msg[256] = {0, };
5347 ret_if(p_cynara == NULL);
5349 result = cynara_finish(p_cynara);
5351 if (result != CYNARA_API_SUCCESS) {
5352 cynara_strerror(result, err_msg, sizeof(err_msg));
5353 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5361 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5362 GArray *out_param, int result)
5366 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5367 out_param->data, out_param->len, TRUE, NULL, NULL);
5369 g_dbus_method_invocation_return_value(invocation,
5370 g_variant_new("(iv)", result, out_var));
5373 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5374 GArray *out_param, int result, GUnixFDList *fd_list)
5378 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5379 out_param->data, out_param->len, TRUE, NULL, NULL);
5381 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5382 g_variant_new("(iv)", result, out_var), fd_list);