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>
29 #include "bluetooth-api.h"
30 #include "bluetooth-audio-api.h"
31 #include "bluetooth-gatt-server-api.h"
32 #include "bluetooth-mesh-api.h"
33 #include "bt-request-handler.h"
34 #include "bt-service-common.h"
35 #include "bt-service-util.h"
37 #include "bt-service-core-adapter.h"
38 #include "bt-service-core-adapter-le.h"
39 #include "bt-service-core-device.h"
41 #include "bt-service-audio-common.h"
42 #include "bt-service-avrcp-tg.h"
43 #include "bt-service-avrcp-ctrl.h"
44 #include "bt-service-gatt.h"
45 #include "bt-service-mesh-main.h"
46 #include "bt-service-mesh-util.h"
47 #include "bt-service-mesh-network.h"
48 #include "bt-service-mesh-config-client.h"
50 #ifdef TIZEN_FEATURE_BT_DPM
51 #include "bt-service-dpm.h"
53 #include "bt-service-hidhost.h"
54 #include "bt-service-rfcomm.h"
55 #include "bt-service-hdp.h"
58 #include "bt-service-obex-server.h"
59 #include "bt-service-opp-client.h"
60 #include "bt-service-map-client.h"
61 #include "bt-service-pbap.h"
62 #include "bt-service-oob.h"
64 #include "bt-service-battery-monitor.h"
66 #ifdef TIZEN_FEATURE_BT_PAN_NAP
67 #include "bt-service-network.h"
70 #ifdef TIZEN_FEATURE_BT_IPSP
71 #include "bt-service-ipsp.h"
73 /* For maintaining Application Sync API call requests */
74 GSList *invocation_list = NULL;
76 static GDBusConnection *bt_service_conn;
77 static guint owner_id = 0;
78 static guint owner_sig_id = 0;
79 static gboolean is_le_intended = FALSE;
81 static cynara *p_cynara;
82 static cynara_configuration *conf;
83 const char *requester_unique_creds = NULL;
85 static const gchar bt_service_introspection_xml[] =
86 "<node name='/org/projectx/bt_service'>"
87 " <interface name='org.projectx.bt'>"
88 " <method name='service_request'>"
89 /* Input Parameters */
90 " <arg type='i' name='service_type' direction='in' />"
91 " <arg type='i' name='service_function' direction='in' />"
92 " <arg type='i' name='request_type' direction='in' />"
93 " <arg type='ay' name='input_param1' direction='in' />"
94 " <arg type='ay' name='input_param2' direction='in' />"
95 " <arg type='ay' name='input_param3' direction='in' />"
96 " <arg type='ay' name='input_param4' direction='in' />"
97 " <arg type='ay' name='input_param5' direction='in' />"
98 /* Return Parameters */
99 " <arg type='i' name='output_param1' direction='out' />"
100 " <arg type='v' name='output_param2' direction='out' />"
102 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
103 " <method name='get_avc_mode'>"
105 " <arg type='u' name='avc_mode' direction='out' />"
111 static gboolean name_acquired = FALSE;
113 static char *current_sender_playing = NULL;
115 GDBusNodeInfo *node_info_g = NULL;
117 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
119 static void __bt_service_method(GDBusConnection *connection,
121 const gchar *object_path,
122 const gchar *interface_name,
123 const gchar *method_name,
124 GVariant *parameters,
125 GDBusMethodInvocation *invocation,
128 int __bt_bluez_request(int function_name,
131 GDBusMethodInvocation *context,
136 GArray **out_param1);
137 int __bt_obexd_request(int function_name,
140 GDBusMethodInvocation *context,
145 GArray **out_param1);
146 int __bt_agent_request(int function_name,
149 GDBusMethodInvocation *context,
154 GArray **out_param1);
155 int __bt_core_request(int function_name,
158 GDBusMethodInvocation *context,
159 GVariant *in_param1);
161 gboolean __bt_service_check_privilege(int function_name,
163 const char *unique_name);
165 /* Function definitions*/
166 GSList *_bt_get_invocation_list(void)
168 return invocation_list;
171 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
173 ret_if(NULL == req_info);
174 invocation_list = g_slist_remove(invocation_list, req_info);
175 g_free(req_info->sender);
176 g_free(req_info->user_data);
180 void _bt_set_le_intended_status(gboolean value)
182 is_le_intended = value;
185 static void __bt_service_get_parameters(GVariant *in_param,
186 void *value, int size)
189 buf = (void *)g_variant_get_data(in_param);
190 memcpy(value, buf, size);
193 static gboolean __bt_is_sync_function(int service_function)
195 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
196 if (service_function == BT_GET_LOCAL_ADDRESS
197 || service_function == BT_GET_LOCAL_NAME
198 || service_function == BT_GET_LOCAL_VERSION
199 || service_function == BT_GET_BONDED_DEVICES
200 || service_function == BT_GET_BONDED_DEVICE
201 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
202 || service_function == BT_GET_IS_ALIAS_SET
203 || service_function == BT_GET_CONNECTED_LINK_TYPE
204 || service_function == BT_IS_SERVICE_USED
205 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
206 || service_function == BT_RFCOMM_LISTEN
207 || service_function == BT_HDP_REGISTER_SINK_APP
208 || service_function == BT_HDP_UNREGISTER_SINK_APP
209 || service_function == BT_HDP_GET_FD
210 || service_function == BT_AVRCP_GET_TRACK_INFO
211 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
212 || service_function == BT_SET_ADVERTISING_DATA
213 || service_function == BT_SET_SCAN_RESPONSE_DATA
214 || service_function == BT_SET_ADVERTISING
215 || service_function == BT_SET_CUSTOM_ADVERTISING
216 || service_function == BT_GATT_SERVER_REGISTER
217 || service_function == BT_GATT_SERVER_ADD_SERVICE
218 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
219 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
220 || service_function == BT_GATT_SERVER_START_SERVICE
221 || service_function == BT_GATT_SERVER_STOP_SERVICE
222 || service_function == BT_GATT_SERVER_DELETE_SERVICE
223 || service_function == BT_START_LE_DISCOVERY
224 || service_function == BT_STOP_LE_DISCOVERY
225 || service_function == BT_GET_CONNECTABLE
226 #ifdef TIZEN_GATT_CLIENT
227 || service_function == BT_GATT_CLIENT_REGISTER
228 || service_function == BT_GATT_GET_PRIMARY_SERVICES
229 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
230 || service_function == BT_GATT_GET_INCLUDED_SERVICES
231 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
232 || service_function == BT_GATT_WATCH_CHARACTERISTIC
233 || service_function == BT_GATT_ACQUIRE_WRITE
235 || service_function == BT_AUDIO_SELECT_ROLE
237 || service_function == BT_MESH_NETWORK_CREATE
238 || service_function == BT_MESH_NETWORK_LOAD
239 || service_function == BT_MESH_NETWORK_SCAN
240 || service_function == BT_MESH_NETWORK_ADD_NETKEY
241 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
242 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
243 || service_function == BT_MESH_NETWORK_ADD_APPKEY
244 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
245 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
251 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
252 char *sender, int service_function,
253 gpointer invocation_data)
255 invocation_info_t *info;
256 info = g_malloc0(sizeof(invocation_info_t));
257 info->context = invocation;
258 info->result = result;
259 info->sender = g_strdup(sender);
260 info->service_function = service_function;
261 info->user_data = invocation_data;
262 invocation_list = g_slist_append(invocation_list, info);
266 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
269 char err_msg[256] = {0, };
271 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
273 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
274 if (ret != CYNARA_API_SUCCESS) {
275 cynara_strerror(ret, err_msg, sizeof(err_msg));
276 BT_ERR("Fail to get user credential: %s", err_msg);
278 return BLUETOOTH_ERROR_INTERNAL;
281 return BLUETOOTH_ERROR_NONE;
284 static int __bt_bm_request_data(_bt_battery_data_t *latest)
286 int ret = _bt_bm_read_data(latest);
287 if (ret == BLUETOOTH_ERROR_NONE) {
288 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
289 latest->session_start_time, latest->session_end_time,
290 latest->session_scan_time, latest->session_connected_time);
292 if (latest->atm_list == NULL) {
293 BT_DBG("No app data transaction for this session");
297 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
298 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
299 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
303 BT_ERR("Error encountered");
307 static void __bt_service_method(GDBusConnection *connection,
309 const gchar *object_path,
310 const gchar *interface_name,
311 const gchar *method_name,
312 GVariant *parameters,
313 GDBusMethodInvocation *invocation,
318 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
319 method_name, object_path, interface_name);
321 if (g_strcmp0(method_name, "service_request") == 0) {
323 int service_function;
325 GVariant *param1 = NULL;
326 GVariant *param2 = NULL;
327 GVariant *param3 = NULL;
328 GVariant *param4 = NULL;
329 GVariant *param5 = NULL;
330 GArray *out_param1 = NULL;
331 GVariant *out_var = NULL;
332 GVariant *temp = NULL;
336 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
337 &service_function, &request_type,
338 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
340 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
342 if (service_type == BT_CORE_SERVICE) {
343 BT_DBG("No need to check privilege from bt-core");
344 } else if (__bt_service_check_privilege(service_function,
345 service_type, (const char *)sender) == FALSE) {
346 BT_ERR("Client don't have the privilege to excute this function");
347 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
351 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
352 service_type, service_function);
353 switch (service_type) {
354 case BT_BLUEZ_SERVICE:
355 result = __bt_bluez_request(service_function,
356 request_type, request_id,
357 invocation, param1, param2,
358 param3, param4, &out_param1);
360 case BT_OBEX_SERVICE:
361 result = __bt_obexd_request(service_function,
362 request_type, request_id,
365 param4, &out_param1);
367 case BT_AGENT_SERVICE:
368 result = __bt_agent_request(service_function,
369 request_type, request_id,
372 param4, &out_param1);
374 case BT_CORE_SERVICE:
375 result = __bt_core_request(service_function,
376 request_type, request_id,
379 case BT_CHECK_PRIVILEGE:
380 result = BLUETOOTH_ERROR_NONE;
383 BT_ERR("Unknown service type");
384 result = BLUETOOTH_ERROR_INTERNAL;
388 if (result != BLUETOOTH_ERROR_NONE)
391 if (service_type == BT_CHECK_PRIVILEGE)
394 if (service_function == BT_OPP_PUSH_FILES)
397 if (request_type == BT_ASYNC_REQ ||
398 __bt_is_sync_function(service_function)) {
399 /* Do not send reply to bt-api over dbus,
400 Invocation context is already saved in service_function */
405 out_var = g_variant_new_from_data((const GVariantType *)"ay",
406 out_param1->data, out_param1->len,
409 temp = g_variant_new("(iv)", result, out_var);
410 g_dbus_method_invocation_return_value(invocation, temp);
411 g_array_free(out_param1, TRUE);
415 g_variant_unref(param1);
416 g_variant_unref(param2);
417 g_variant_unref(param3);
418 g_variant_unref(param4);
419 g_variant_unref(param5);
423 BT_ERR_C("Request is failed [%s] [0x%x]",
424 _bt_convert_error_to_string(result), result);
426 out_var = g_variant_new_from_data((const GVariantType *)"ay",
427 out_param1->data, out_param1->len,
430 temp = g_variant_new("(iv)", result, out_var);
431 g_dbus_method_invocation_return_value(invocation, temp);
433 g_array_free(out_param1, TRUE);
436 g_variant_unref(param1);
437 g_variant_unref(param2);
438 g_variant_unref(param3);
439 g_variant_unref(param4);
440 g_variant_unref(param5);
442 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
443 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
444 unsigned int mode = 0;
446 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
447 BT_ERR("Fail to get the avc mode");
449 BT_DBG("Absolute Volume Control mode: %d", mode);
451 g_dbus_method_invocation_return_value(invocation,
452 g_variant_new("(u)", mode));
461 static const GDBusInterfaceVTable method_table = {
468 int __bt_bluez_request(int function_name,
471 GDBusMethodInvocation *context,
478 int result = BLUETOOTH_ERROR_NONE;
481 switch (function_name) {
482 case BT_ENABLE_ADAPTER: {
483 result = _bt_enable_adapter();
484 _bt_adapter_start_enable_timer();
487 case BT_DISABLE_ADAPTER: {
488 result = _bt_disable_adapter();
491 case BT_RECOVER_ADAPTER:
492 result = _bt_recover_adapter();
494 case BT_RESET_ADAPTER:
495 result = _bt_reset_adapter();
497 case BT_BATTERY_READ_DATA: {
498 _bt_battery_data_t *data = NULL;
499 data = g_malloc0(sizeof(_bt_battery_data_t));
500 result = __bt_bm_request_data(data);
502 bt_battery_dbus_data_t dbus_data;
503 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
504 dbus_data.session_start_time = data->session_start_time;
505 dbus_data.session_end_time = data->session_end_time;
506 dbus_data.session_scan_time = data->session_scan_time;
507 dbus_data.session_connected_time = data->session_connected_time;
508 dbus_data.tx_time = data->tx_time;
509 dbus_data.rx_time = data->rx_time;
510 dbus_data.idle_time = data->idle_time;
512 /*Populating app data*/
514 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
515 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
516 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
519 dbus_data.num_app = n;
520 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
521 g_slist_free_full(data->atm_list, g_free);
526 case BT_CHECK_ADAPTER: {
527 int enabled = BT_ADAPTER_DISABLED;
528 result = _bt_check_adapter(&enabled);
530 g_array_append_vals(*out_param1, &enabled,
534 case BT_ENABLE_ADAPTER_LE:
535 _bt_set_le_intended_status(TRUE);
536 result = _bt_enable_adapter_le();
538 case BT_DISABLE_ADAPTER_LE:
539 _bt_set_le_intended_status(FALSE);
540 result = _bt_disable_adapter_le();
542 case BT_START_DISCOVERY: {
543 unsigned short max_response;
544 unsigned short discovery_duration;
545 unsigned int classOfDeviceMask;
548 __bt_service_get_parameters(in_param1,
549 &max_response, sizeof(unsigned short));
550 __bt_service_get_parameters(in_param2,
551 &discovery_duration, sizeof(unsigned short));
552 __bt_service_get_parameters(in_param3,
553 &classOfDeviceMask, sizeof(unsigned int));
554 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
556 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
558 if (result == BLUETOOTH_ERROR_NONE) {
561 sender = (char*)g_dbus_method_invocation_get_sender(context);
563 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
564 BT_ERR("Fail to get the sender pid");
566 BT_DBG("Remeber pid / uid for the scan operation");
567 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
572 case BT_START_CUSTOM_DISCOVERY: {
573 bt_discovery_role_type_t role;
575 __bt_service_get_parameters(in_param1,
576 &role, sizeof(bt_discovery_role_type_t));
577 result = _bt_start_custom_discovery(role);
581 case BT_CANCEL_DISCOVERY:
582 result = _bt_cancel_discovery();
584 case BT_IS_DISCOVERYING: {
585 gboolean discovering = FALSE;
586 discovering = _bt_is_discovering();
587 g_array_append_vals(*out_param1,
588 &discovering, sizeof(gboolean));
591 case BT_GET_LOCAL_ADDRESS: {
592 result = _bt_get_local_address();
594 /* Save invocation */
595 if (result == BLUETOOTH_ERROR_NONE) {
596 sender = (char*)g_dbus_method_invocation_get_sender(context);
597 _bt_save_invocation_context(context, result, sender,
598 function_name, NULL);
602 case BT_GET_LOCAL_VERSION: {
603 result = _bt_get_local_version();
605 /* Save invocation */
606 if (result == BLUETOOTH_ERROR_NONE) {
607 sender = (char*)g_dbus_method_invocation_get_sender(context);
608 _bt_save_invocation_context(context, result, sender,
609 function_name, NULL);
613 case BT_GET_LOCAL_NAME: {
614 result = _bt_get_local_name();
616 /* Save invocation */
617 if (result == BLUETOOTH_ERROR_NONE) {
618 sender = (char*)g_dbus_method_invocation_get_sender(context);
619 _bt_save_invocation_context(context, result, sender,
620 function_name, NULL);
624 case BT_SET_LOCAL_NAME: {
625 bluetooth_device_name_t local_name = { {0} };
626 __bt_service_get_parameters(in_param1,
627 &local_name, sizeof(bluetooth_device_name_t));
628 result = _bt_set_local_name(local_name.name);
631 case BT_GET_DISCOVERABLE_MODE: {
632 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
633 result = _bt_get_discoverable_mode(&discoverable_mode);
634 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
637 case BT_GET_DISCOVERABLE_TIME: {
640 result = _bt_get_timeout_value(&timeout);
641 g_array_append_vals(*out_param1, &timeout, sizeof(int));
644 case BT_SET_DISCOVERABLE_MODE: {
645 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
648 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
649 __bt_service_get_parameters(in_param2, &time, sizeof(int));
651 result = _bt_set_discoverable_mode(mode, time);
654 case BT_IS_CONNECTABLE: {
655 gboolean is_connectable = FALSE;
657 is_connectable = _bt_is_connectable();
658 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
661 case BT_GET_CONNECTABLE: {
662 result = _bt_get_connectable();
664 /* Save invocation */
665 if (result == BLUETOOTH_ERROR_NONE) {
666 sender = (char*)g_dbus_method_invocation_get_sender(context);
667 _bt_save_invocation_context(context, result, sender,
668 function_name, NULL);
672 case BT_SET_CONNECTABLE: {
673 gboolean is_connectable;
675 __bt_service_get_parameters(in_param1,
676 &is_connectable, sizeof(gboolean));
677 result = _bt_set_connectable(is_connectable);
680 case BT_IS_SERVICE_USED: {
683 uuid = (char *)g_variant_get_data(in_param1);
684 BT_INFO("UUID to be searched [%s]", uuid);
685 result = _bt_is_service_used();
687 /* Save invocation */
688 if (result == BLUETOOTH_ERROR_NONE) {
689 sender = (char*)g_dbus_method_invocation_get_sender(context);
690 _bt_save_invocation_context(context, result, sender,
691 function_name, g_strdup(uuid));
695 case BT_GET_BONDED_DEVICES: {
696 result = _bt_get_bonded_devices();
697 /* Save invocation */
698 if (result == BLUETOOTH_ERROR_NONE) {
699 sender = (char*)g_dbus_method_invocation_get_sender(context);
700 _bt_save_invocation_context(context, result, sender,
701 function_name, NULL);
705 case BT_GET_BONDED_DEVICE: {
706 bluetooth_device_address_t address = { {0} };
708 __bt_service_get_parameters(in_param1,
709 &address, sizeof(bluetooth_device_address_t));
711 result = _bt_get_bonded_device_info(&address);
712 /* Save invocation */
713 if (result == BLUETOOTH_ERROR_NONE) {
714 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
716 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
720 _bt_convert_addr_type_to_string(addr, address.addr);
721 sender = (char*)g_dbus_method_invocation_get_sender(context);
722 _bt_save_invocation_context(context, result, sender,
723 function_name, addr);
727 case BT_GET_PROFILE_CONNECTED_DEVICES: {
729 uuid = (char *)g_variant_get_data(in_param1);
730 result = _bt_get_profile_connected_devices(uuid);
732 /* Save invocation */
733 if (result == BLUETOOTH_ERROR_NONE) {
734 sender = (char *)g_dbus_method_invocation_get_sender(context);
735 _bt_save_invocation_context(context, result, sender,
736 function_name, NULL);
741 bluetooth_device_address_t address = { {0} };
742 const char *local_name;
744 __bt_service_get_parameters(in_param1,
745 &address, sizeof(bluetooth_device_address_t));
746 local_name = (const char *)g_variant_get_data(in_param2);
748 result = _bt_set_alias(&address, local_name);
751 case BT_BOND_DEVICE: {
752 bluetooth_device_address_t address = { {0} };
754 __bt_service_get_parameters(in_param1,
755 &address, sizeof(bluetooth_device_address_t));
756 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
758 /* Save invocation */
759 if (result == BLUETOOTH_ERROR_NONE) {
760 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
761 _bt_convert_addr_type_to_string(addr, address.addr);
762 sender = (char*)g_dbus_method_invocation_get_sender(context);
763 _bt_save_invocation_context(context, result, sender,
764 function_name, (gpointer)addr);
766 bluetooth_device_info_t dev_info;
768 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
769 memcpy(&dev_info.device_address, &address,
770 sizeof(bluetooth_device_address_t));
771 g_array_append_vals(*out_param1, &dev_info,
772 sizeof(bluetooth_device_info_t));
776 case BT_BOND_DEVICE_BY_TYPE: {
777 bluetooth_device_address_t address = { {0} };
778 unsigned short conn_type = 0;
780 __bt_service_get_parameters(in_param1,
781 &address, sizeof(bluetooth_device_address_t));
782 __bt_service_get_parameters(in_param2,
783 &conn_type, sizeof(unsigned short));
785 result = _bt_bond_device(&address, conn_type, out_param1);
786 /* Save invocation */
787 if (result == BLUETOOTH_ERROR_NONE) {
788 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
789 _bt_convert_addr_type_to_string(addr, address.addr);
790 sender = (char*)g_dbus_method_invocation_get_sender(context);
791 _bt_save_invocation_context(context, result, sender,
792 function_name, (gpointer)addr);
794 bluetooth_device_info_t dev_info;
796 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
797 memcpy(&dev_info.device_address, &address,
798 sizeof(bluetooth_device_address_t));
799 g_array_append_vals(*out_param1, &dev_info,
800 sizeof(bluetooth_device_info_t));
804 case BT_UNBOND_DEVICE: {
805 bluetooth_device_address_t address = { {0} };
807 __bt_service_get_parameters(in_param1,
808 &address, sizeof(bluetooth_device_address_t));
809 result = _bt_unbond_device(&address, out_param1);
811 /* Save invocation */
812 if (result == BLUETOOTH_ERROR_NONE) {
813 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
814 _bt_convert_addr_type_to_string(addr, address.addr);
815 sender = (char*)g_dbus_method_invocation_get_sender(context);
816 _bt_save_invocation_context(context, result, sender,
817 function_name, (gpointer)addr);
819 g_array_append_vals(*out_param1, &address,
820 sizeof(bluetooth_device_address_t));
824 case BT_CANCEL_BONDING:{
825 result = _bt_cancel_bonding();
828 case BT_SEARCH_SERVICE: {
829 bluetooth_device_address_t address = { {0} };
830 __bt_service_get_parameters(in_param1,
831 &address, sizeof(bluetooth_device_address_t));
832 result = _bt_search_device(&address);
833 /* Save invocation */
834 if (result == BLUETOOTH_ERROR_NONE) {
835 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
836 _bt_convert_addr_type_to_string(addr, address.addr);
837 sender = (char*)g_dbus_method_invocation_get_sender(context);
838 _bt_save_invocation_context(context, result, sender,
839 function_name, (gpointer)addr);
841 bt_sdp_info_t sdp_info;
843 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
844 memcpy(&sdp_info.device_addr, &address,
845 sizeof(bluetooth_device_address_t));
846 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
850 case BT_CANCEL_SEARCH_SERVICE: {
851 result = _bt_cancel_search_device();
854 case BT_SET_PASSKEY_NOTIFICATION: {
858 sender = (char *)g_dbus_method_invocation_get_sender(context);
859 __bt_service_get_parameters(in_param1,
860 &enable, sizeof(gboolean));
862 result = _bt_set_passkey_notification(sender, enable);
865 case BT_SET_PIN_CODE: {
866 bluetooth_device_address_t address = { {0} };
867 bluetooth_device_pin_code_t pin_code = { {0} };
869 __bt_service_get_parameters(in_param1,
870 &address, sizeof(bluetooth_device_address_t));
871 __bt_service_get_parameters(in_param2,
872 &pin_code, sizeof(bluetooth_device_pin_code_t));
874 result = _bt_set_pin_code(&address, &pin_code);
877 case BT_UNSET_PIN_CODE: {
878 bluetooth_device_address_t address = { {0} };
880 __bt_service_get_parameters(in_param1,
881 &address, sizeof(bluetooth_device_address_t));
883 result = _bt_unset_pin_code(&address);
886 case BT_PASSKEY_REPLY: {
887 const char *passkey = NULL;
888 gboolean authentication_reply = FALSE;
889 passkey = g_variant_get_data(in_param1);
890 __bt_service_get_parameters(in_param2,
891 &authentication_reply, sizeof(gboolean));
892 result = _bt_passkey_reply(passkey, authentication_reply);
895 case BT_PASSKEY_CONFIRMATION_REPLY: {
896 gboolean confirmation_reply = FALSE;
897 __bt_service_get_parameters(in_param1,
898 &confirmation_reply, sizeof(gboolean));
899 result = _bt_passkey_confirmation_reply(confirmation_reply);
902 case BT_GET_IS_ALIAS_SET: {
903 bluetooth_device_address_t address = { {0} };
905 __bt_service_get_parameters(in_param1,
906 &address, sizeof(bluetooth_device_address_t));
908 result = _bt_is_alias_set(&address);
909 if (result == BLUETOOTH_ERROR_NONE) {
910 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
912 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
916 _bt_convert_addr_type_to_string(addr, address.addr);
917 sender = (char*)g_dbus_method_invocation_get_sender(context);
918 _bt_save_invocation_context(context, result, sender,
919 function_name, addr);
923 case BT_SET_AUTHORIZATION: {
924 bluetooth_device_address_t address = { {0} };
926 __bt_service_get_parameters(in_param1,
927 &address, sizeof(bluetooth_device_address_t));
928 __bt_service_get_parameters(in_param2,
929 &authorize, sizeof(gboolean));
930 result = _bt_set_authorization(&address, authorize);
933 case BT_SET_LE_PRIVACY: {
934 gboolean set_privacy;
935 __bt_service_get_parameters(in_param1, &set_privacy,
937 result = _bt_set_le_privacy(set_privacy);
940 case BT_ADD_WHITE_LIST: {
941 bluetooth_device_address_t address = { {0} };
942 int address_type = 0;
944 __bt_service_get_parameters(in_param1,
945 &address, sizeof(bluetooth_device_address_t));
946 __bt_service_get_parameters(in_param2,
947 &address_type, sizeof(int));
948 result = _bt_set_white_list(&address, address_type, is_add);
951 case BT_REMOVE_WHITE_LIST: {
952 bluetooth_device_address_t address = { {0} };
953 int address_type = 0;
955 __bt_service_get_parameters(in_param1,
956 &address, sizeof(bluetooth_device_address_t));
957 __bt_service_get_parameters(in_param2,
958 &address_type, sizeof(int));
959 result = _bt_set_white_list(&address, address_type, is_add);
962 case BT_UPDATE_LE_CONNECTION_MODE: {
964 bluetooth_device_address_t remote_address = { { 0 } };
965 bluetooth_le_connection_param_t parameters = { 0 };
966 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
968 __bt_service_get_parameters(in_param1, &remote_address,
969 sizeof(bluetooth_device_address_t));
970 __bt_service_get_parameters(in_param2, &mode,
971 sizeof(bluetooth_le_connection_mode_t));
973 result = _bt_get_le_connection_parameter(mode, ¶meters);
974 if (result != BLUETOOTH_ERROR_NONE)
977 sender = (char *)g_dbus_method_invocation_get_sender(context);
979 result = _bt_le_connection_update(sender,
981 parameters.interval_min,
982 parameters.interval_max,
987 case BT_SET_MANUFACTURER_DATA: {
988 bluetooth_manufacturer_data_t m_data = { 0 };
989 __bt_service_get_parameters(in_param1,
990 &m_data, sizeof(bluetooth_manufacturer_data_t));
991 result = _bt_set_manufacturer_data(&m_data);
995 case BT_IS_DEVICE_CONNECTED: {
996 bluetooth_device_address_t address = { {0} };
997 gboolean connected = FALSE;
1000 __bt_service_get_parameters(in_param1,
1001 &address, sizeof(bluetooth_device_address_t));
1002 __bt_service_get_parameters(in_param2,
1003 &service_type, sizeof(int));
1005 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1006 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1007 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1009 connected = _bt_is_device_connected(&address, service_type);
1011 connected = _bt_is_device_connected(&address, service_type);
1013 BT_INFO("is_connected: %d", connected);
1014 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1017 case BT_GET_CONNECTED_LINK_TYPE: {
1018 bluetooth_device_address_t address = { {0} };
1020 __bt_service_get_parameters(in_param1,
1021 &address, sizeof(bluetooth_device_address_t));
1023 result = _bt_get_connected_link(&address);
1024 if (result == BLUETOOTH_ERROR_NONE) {
1025 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1027 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1031 _bt_convert_addr_type_to_string(addr, address.addr);
1032 sender = (char*)g_dbus_method_invocation_get_sender(context);
1033 _bt_save_invocation_context(context, result, sender,
1034 function_name, addr);
1038 case BT_IS_SCAN_FILTER_SUPPORTED:{
1039 int is_supported = 0;
1041 if (_bt_is_scan_filter_supported() == TRUE)
1044 g_array_append_vals(*out_param1,
1045 &is_supported, sizeof(int));
1049 case BT_ENABLE_RSSI: {
1050 bluetooth_device_address_t bd_addr;
1052 bt_rssi_threshold_t rssi_threshold;
1054 int in_range_threshold;
1057 BT_DBG("Enable RSSI");
1059 __bt_service_get_parameters(in_param1,
1060 &bd_addr, sizeof(bluetooth_device_address_t));
1061 __bt_service_get_parameters(in_param2,
1062 &link_type, sizeof(int));
1063 __bt_service_get_parameters(in_param3,
1064 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1066 low_threshold = rssi_threshold.low_threshold;
1067 in_range_threshold = rssi_threshold.in_range_threshold;
1068 high_threshold = rssi_threshold.high_threshold;
1070 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1071 in_range_threshold, high_threshold);
1076 bluetooth_device_address_t bd_addr;
1078 BT_DBG("Get RSSI Strength");
1080 __bt_service_get_parameters(in_param1,
1081 &bd_addr, sizeof(bluetooth_device_address_t));
1082 __bt_service_get_parameters(in_param2,
1083 &link_type, sizeof(int));
1085 result = _bt_get_rssi_strength(&bd_addr, link_type);
1088 case BT_SET_PROFILE_TRUSTED: {
1089 bluetooth_device_address_t bd_addr = { {0} };
1093 __bt_service_get_parameters(in_param1, &bd_addr,
1094 sizeof(bluetooth_device_address_t));
1095 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1096 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1098 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1101 case BT_GET_PROFILE_TRUSTED: {
1102 bluetooth_device_address_t bd_addr = { {0} };
1104 guint trusted_profile = 0;
1106 __bt_service_get_parameters(in_param1, &bd_addr,
1107 sizeof(bluetooth_device_address_t));
1108 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1110 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1111 BT_DBG("TRUST %d", trusted_profile);
1112 if (result == BLUETOOTH_ERROR_NONE) {
1113 g_array_append_vals(*out_param1, &trusted_profile,
1119 case BT_HID_CONNECT: {
1120 bluetooth_device_address_t address = { {0} };
1122 __bt_service_get_parameters(in_param1,
1123 &address, sizeof(bluetooth_device_address_t));
1125 result = _bt_hid_connect(&address);
1126 if (result != BLUETOOTH_ERROR_NONE) {
1127 g_array_append_vals(*out_param1, &address,
1128 sizeof(bluetooth_device_address_t));
1130 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1131 _bt_convert_addr_type_to_string(addr, address.addr);
1132 sender = (char*)g_dbus_method_invocation_get_sender(context);
1133 _bt_save_invocation_context(context, result, sender,
1134 function_name, (gpointer)addr);
1138 case BT_HID_DISCONNECT: {
1139 bluetooth_device_address_t address = { {0} };
1141 __bt_service_get_parameters(in_param1,
1142 &address, sizeof(bluetooth_device_address_t));
1144 result = _bt_hid_disconnect(&address);
1145 if (result != BLUETOOTH_ERROR_NONE) {
1146 g_array_append_vals(*out_param1, &address,
1147 sizeof(bluetooth_device_address_t));
1149 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1150 _bt_convert_addr_type_to_string(addr, address.addr);
1151 sender = (char*)g_dbus_method_invocation_get_sender(context);
1152 _bt_save_invocation_context(context, result, sender,
1153 function_name, (gpointer)addr);
1157 #ifdef TIZEN_FEATURE_BT_DPM
1158 case BT_DPM_SET_ALLOW_BT_MODE: {
1159 dpm_bt_allow_t value = DPM_BT_ERROR;
1161 __bt_service_get_parameters(in_param1, &value,
1164 result = _bt_dpm_set_allow_bluetooth_mode(value);
1167 case BT_DPM_GET_ALLOW_BT_MODE: {
1168 int value = DPM_BT_ERROR;
1170 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1171 g_array_append_vals(*out_param1, &value, sizeof(int));
1174 case BT_DPM_SET_DEVICE_RESTRITION: {
1175 dpm_status_t value = DPM_STATUS_ERROR;
1177 __bt_service_get_parameters(in_param1, &value,
1180 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1183 case BT_DPM_GET_DEVICE_RESTRITION: {
1184 int value = DPM_STATUS_ERROR;
1186 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1187 g_array_append_vals(*out_param1, &value, sizeof(int));
1190 case BT_DPM_SET_UUID_RESTRITION: {
1191 dpm_status_t value = DPM_STATUS_ERROR;
1193 __bt_service_get_parameters(in_param1, &value,
1196 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1199 case BT_DPM_GET_UUID_RESTRITION: {
1200 int value = DPM_STATUS_ERROR;
1202 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1203 g_array_append_vals(*out_param1, &value, sizeof(int));
1206 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1207 bluetooth_device_address_t address = { {0} };
1209 __bt_service_get_parameters(in_param1, &address,
1210 sizeof(bluetooth_device_address_t));
1212 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1215 case BT_DPM_ADD_DEVICES_WHITELIST: {
1216 bluetooth_device_address_t address = { {0} };
1218 __bt_service_get_parameters(in_param1, &address,
1219 sizeof(bluetooth_device_address_t));
1221 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1224 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1225 const char *uuid = NULL;
1227 uuid = g_variant_get_data(in_param1);
1229 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1232 case BT_DPM_ADD_UUIDS_WHITELIST: {
1233 const char *uuid = NULL;
1235 uuid = g_variant_get_data(in_param1);
1237 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1240 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1241 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1244 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1245 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1248 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1249 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1252 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1253 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1256 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1257 bluetooth_device_address_t address = { {0} };
1259 __bt_service_get_parameters(in_param1, &address,
1260 sizeof(bluetooth_device_address_t));
1262 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1265 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1266 bluetooth_device_address_t address = { {0} };
1268 __bt_service_get_parameters(in_param1, &address,
1269 sizeof(bluetooth_device_address_t));
1271 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1274 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1275 const char *uuid = NULL;
1277 uuid = g_variant_get_data(in_param1);
1279 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1282 case BT_DPM_REMOVE_UUID_WHITELIST: {
1283 const char *uuid = NULL;
1285 uuid = g_variant_get_data(in_param1);
1287 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1291 case BT_DPM_GET_DEVICES_BLACKLIST: {
1292 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1295 case BT_DPM_GET_DEVICES_WHITELIST: {
1296 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1299 case BT_DPM_GET_UUIDS_BLACKLIST: {
1300 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1303 case BT_DPM_GET_UUIDS_WHITELIST: {
1304 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1307 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1308 dpm_status_t value = DPM_STATUS_ERROR;
1310 __bt_service_get_parameters(in_param1, &value,
1313 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1317 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1318 int value = DPM_STATUS_ERROR;
1320 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1321 g_array_append_vals(*out_param1, &value, sizeof(int));
1324 case BT_DPM_SET_PAIRING_STATE: {
1325 dpm_status_t value = DPM_STATUS_ERROR;
1327 __bt_service_get_parameters(in_param1, &value,
1330 result = _bt_dpm_set_bluetooth_pairing_state(value);
1334 case BT_DPM_GET_PAIRING_STATE: {
1335 int value = DPM_STATUS_ERROR;
1337 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1338 g_array_append_vals(*out_param1, &value, sizeof(int));
1341 case BT_DPM_SET_PROFILE_STATE: {
1342 int value = DPM_STATUS_ERROR;
1343 int profile = DPM_PROFILE_NONE;
1345 __bt_service_get_parameters(in_param1, &profile,
1347 __bt_service_get_parameters(in_param2, &value,
1350 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1354 case BT_DPM_GET_PROFILE_STATE: {
1355 int value = DPM_STATUS_ERROR;
1356 int profile = DPM_PROFILE_NONE;
1358 __bt_service_get_parameters(in_param1, &profile,
1361 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1362 g_array_append_vals(*out_param1, &value, sizeof(int));
1365 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1366 int value = DPM_BT_ERROR;
1368 __bt_service_get_parameters(in_param1, &value,
1371 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1375 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1376 int value = DPM_STATUS_ERROR;
1378 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1379 g_array_append_vals(*out_param1, &value, sizeof(int));
1382 case BT_DPM_SET_DISCOVERABLE_STATE: {
1383 int value = DPM_STATUS_ERROR;
1385 __bt_service_get_parameters(in_param1, &value,
1388 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1392 case BT_DPM_GET_DISCOVERABLE_STATE: {
1393 int value = DPM_STATUS_ERROR;
1395 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1396 g_array_append_vals(*out_param1, &value, sizeof(int));
1399 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1400 int value = DPM_STATUS_ERROR;
1402 __bt_service_get_parameters(in_param1, &value,
1405 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1409 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1410 int value = DPM_STATUS_ERROR;
1412 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1413 g_array_append_vals(*out_param1, &value, sizeof(int));
1416 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1417 int value = DPM_STATUS_ERROR;
1419 __bt_service_get_parameters(in_param1, &value,
1422 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1426 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1427 int value = DPM_STATUS_ERROR;
1429 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1430 g_array_append_vals(*out_param1, &value, sizeof(int));
1434 case BT_RFCOMM_CLIENT_CONNECT: {
1435 bluetooth_device_address_t address = { {0} };
1439 __bt_service_get_parameters(in_param1,
1440 &address, sizeof(bluetooth_device_address_t));
1441 input_string = (char *)g_variant_get_data(in_param2);
1442 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1444 if (connect_type == BT_RFCOMM_UUID)
1445 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1447 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1449 if (result != BLUETOOTH_ERROR_NONE) {
1450 bluetooth_rfcomm_connection_t conn_info;
1452 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1453 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1454 if (connect_type == BT_RFCOMM_UUID)
1455 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1457 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1459 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1460 conn_info.socket_fd = -1;
1461 g_array_append_vals(*out_param1, &conn_info,
1462 sizeof(bluetooth_rfcomm_connection_t));
1464 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1465 _bt_convert_addr_type_to_string(addr, address.addr);
1466 sender = (char*)g_dbus_method_invocation_get_sender(context);
1467 _bt_save_invocation_context(context, result, sender, function_name, addr);
1471 case BT_RFCOMM_SOCKET_DISCONNECT: {
1473 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1474 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1476 result = BLUETOOTH_ERROR_NONE;
1479 case BT_RFCOMM_SOCKET_WRITE: {
1481 * This call to bt-service is only used for privilege check, so return
1482 * BLUETOOTH_ERROR_NONE from here.
1484 result = BLUETOOTH_ERROR_NONE;
1487 case BT_RFCOMM_CREATE_SOCKET: {
1489 * This call to bt-service is only used for privilege check, so return
1490 * BLUETOOTH_ERROR_NONE from here.
1492 result = BLUETOOTH_ERROR_NONE;
1495 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1499 sender = (char *)g_dbus_method_invocation_get_sender(context);
1500 uuid = (char *)g_variant_get_data(in_param1);
1502 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1504 result = BLUETOOTH_ERROR_NONE;
1505 _bt_save_invocation_context(context,
1506 result, sender, function_name, NULL);
1508 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1512 case BT_RFCOMM_LISTEN: {
1516 sender = (char *)g_dbus_method_invocation_get_sender(context);
1517 uuid = (char *)g_variant_get_data(in_param1);
1519 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1521 result = BLUETOOTH_ERROR_NONE;
1522 _bt_save_invocation_context(context,
1523 result, sender, function_name, NULL);
1525 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1529 case BT_RFCOMM_ACCEPT_CONNECTION: {
1532 address = (char *)g_variant_get_data(in_param1);
1533 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1536 case BT_RFCOMM_REJECT_CONNECTION: {
1539 address = (char *)g_variant_get_data(in_param1);
1540 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1543 case BT_RFCOMM_REMOVE_SOCKET: {
1545 * This call to bt-service is only used for privilege check, so return
1546 * BLUETOOTH_ERROR_NONE from here.
1548 result = BLUETOOTH_ERROR_NONE;
1551 case BT_RFCOMM_SEND_RX_DETAILS: {
1555 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1556 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1557 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1558 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1561 case BT_RFCOMM_SEND_TX_DETAILS: {
1565 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1566 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1567 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1568 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1571 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1572 gboolean connected = FALSE;
1574 int role = RFCOMM_ROLE_SERVER;
1576 sender = (char *)g_dbus_method_invocation_get_sender(context);
1578 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1579 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1580 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1582 if (connected == TRUE)
1583 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1585 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1589 case BT_AUDIO_SELECT_ROLE: {
1590 bluetooth_audio_role_t role;
1592 __bt_service_get_parameters(in_param1,
1593 &role, sizeof(bluetooth_audio_role_t));
1595 result = _bt_audio_select_role(role);
1596 if (result == BLUETOOTH_ERROR_NONE) {
1597 sender = (char*)g_dbus_method_invocation_get_sender(context);
1598 _bt_save_invocation_context(context, result, sender,
1599 function_name, NULL);
1603 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
1604 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1605 unsigned int volume = 0;
1607 __bt_service_get_parameters(in_param1,
1608 &volume, sizeof(unsigned int));
1610 result = _bt_audio_set_absolute_volume(volume);
1613 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1614 unsigned int volume = 0;
1616 result = _bt_audio_get_absolute_volume(&volume);
1617 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1620 case BT_AUDIO_IS_AVC_ACTIVATED: {
1623 result = _bt_audio_is_avc_activated(&activated);
1624 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1628 case BT_AV_CONNECT: {
1629 bluetooth_device_address_t address = { {0} };
1630 __bt_service_get_parameters(in_param1,
1631 &address, sizeof(bluetooth_device_address_t));
1633 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1635 if (result != BLUETOOTH_ERROR_NONE) {
1636 char addr[BT_ADDRESS_STRING_SIZE];
1637 _bt_convert_addr_type_to_string(addr, address.addr);
1638 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1640 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1641 _bt_convert_addr_type_to_string(addr, address.addr);
1642 sender = (char*)g_dbus_method_invocation_get_sender(context);
1643 _bt_save_invocation_context(context, result, sender,
1644 function_name, (gpointer)addr);
1648 case BT_AUDIO_CONNECT: {
1649 bluetooth_device_address_t address = { {0} };
1650 __bt_service_get_parameters(in_param1,
1651 &address, sizeof(bluetooth_device_address_t));
1653 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1655 if (result != BLUETOOTH_ERROR_NONE) {
1656 char addr[BT_ADDRESS_STRING_SIZE];
1657 _bt_convert_addr_type_to_string(addr, address.addr);
1658 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1660 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1661 _bt_convert_addr_type_to_string(addr, address.addr);
1662 sender = (char*)g_dbus_method_invocation_get_sender(context);
1663 _bt_save_invocation_context(context, result, sender,
1664 function_name, (gpointer)addr);
1668 case BT_AUDIO_DISCONNECT: {
1669 bluetooth_device_address_t address = { {0} };
1670 __bt_service_get_parameters(in_param1,
1671 &address, sizeof(bluetooth_device_address_t));
1673 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1675 if (result != BLUETOOTH_ERROR_NONE) {
1676 char addr[BT_ADDRESS_STRING_SIZE];
1677 _bt_convert_addr_type_to_string(addr, address.addr);
1678 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1680 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1681 _bt_convert_addr_type_to_string(addr, address.addr);
1682 sender = (char*)g_dbus_method_invocation_get_sender(context);
1683 _bt_save_invocation_context(context, result, sender,
1684 function_name, (gpointer)addr);
1688 case BT_AV_DISCONNECT: {
1689 bluetooth_device_address_t address = { {0} };
1690 __bt_service_get_parameters(in_param1,
1691 &address, sizeof(bluetooth_device_address_t));
1693 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1695 if (result != BLUETOOTH_ERROR_NONE) {
1696 char addr[BT_ADDRESS_STRING_SIZE];
1697 _bt_convert_addr_type_to_string(addr, address.addr);
1698 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1700 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1701 _bt_convert_addr_type_to_string(addr, address.addr);
1702 sender = (char*)g_dbus_method_invocation_get_sender(context);
1703 _bt_save_invocation_context(context, result, sender,
1704 function_name, (gpointer)addr);
1708 case BT_AG_CONNECT: {
1709 bluetooth_device_address_t address = { {0} };
1710 __bt_service_get_parameters(in_param1,
1711 &address, sizeof(bluetooth_device_address_t));
1713 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1715 if (result != BLUETOOTH_ERROR_NONE) {
1716 char addr[BT_ADDRESS_STRING_SIZE];
1717 _bt_convert_addr_type_to_string(addr, address.addr);
1718 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1720 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1721 _bt_convert_addr_type_to_string(addr, address.addr);
1722 sender = (char*)g_dbus_method_invocation_get_sender(context);
1723 _bt_save_invocation_context(context, result, sender,
1724 function_name, (gpointer)addr);
1728 case BT_AG_DISCONNECT: {
1729 bluetooth_device_address_t address = { {0} };
1731 __bt_service_get_parameters(in_param1,
1732 &address, sizeof(bluetooth_device_address_t));
1734 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1736 if (result != BLUETOOTH_ERROR_NONE) {
1737 char addr[BT_ADDRESS_STRING_SIZE];
1738 _bt_convert_addr_type_to_string(addr, address.addr);
1739 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1741 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1742 _bt_convert_addr_type_to_string(addr, address.addr);
1743 sender = (char*)g_dbus_method_invocation_get_sender(context);
1744 _bt_save_invocation_context(context, result, sender,
1745 function_name, (gpointer)addr);
1749 case BT_AV_SOURCE_CONNECT: {
1750 bluetooth_device_address_t address = { {0} };
1752 __bt_service_get_parameters(in_param1,
1753 &address, sizeof(bluetooth_device_address_t));
1755 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1756 if (result != BLUETOOTH_ERROR_NONE) {
1757 char addr[BT_ADDRESS_STRING_SIZE];
1758 _bt_convert_addr_type_to_string(addr, address.addr);
1759 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1761 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1762 _bt_convert_addr_type_to_string(addr, address.addr);
1763 sender = (char*)g_dbus_method_invocation_get_sender(context);
1764 _bt_save_invocation_context(context, result, sender,
1765 function_name, (gpointer)addr);
1769 case BT_AV_SOURCE_DISCONNECT: {
1770 bluetooth_device_address_t address = { {0} };
1772 __bt_service_get_parameters(in_param1,
1773 &address, sizeof(bluetooth_device_address_t));
1775 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1776 if (result != BLUETOOTH_ERROR_NONE) {
1777 char addr[BT_ADDRESS_STRING_SIZE];
1778 _bt_convert_addr_type_to_string(addr, address.addr);
1779 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1781 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1782 _bt_convert_addr_type_to_string(addr, address.addr);
1783 sender = (char*)g_dbus_method_invocation_get_sender(context);
1784 _bt_save_invocation_context(context, result, sender,
1785 function_name, (gpointer)addr);
1789 case BT_HF_CONNECT: {
1790 bluetooth_device_address_t address = { {0} };
1792 __bt_service_get_parameters(in_param1,
1793 &address, sizeof(bluetooth_device_address_t));
1795 result = _bt_hf_connect(&address);
1796 if (result != BLUETOOTH_ERROR_NONE) {
1797 char addr[BT_ADDRESS_STRING_SIZE];
1798 _bt_convert_addr_type_to_string(addr, address.addr);
1799 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1801 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1802 _bt_convert_addr_type_to_string(addr, address.addr);
1803 sender = (char*)g_dbus_method_invocation_get_sender(context);
1804 _bt_save_invocation_context(context, result, sender,
1805 function_name, (gpointer)addr);
1809 case BT_HF_DISCONNECT: {
1810 bluetooth_device_address_t address = { {0} };
1812 __bt_service_get_parameters(in_param1,
1813 &address, sizeof(bluetooth_device_address_t));
1815 result = _bt_hf_disconnect(&address);
1816 if (result != BLUETOOTH_ERROR_NONE) {
1817 char addr[BT_ADDRESS_STRING_SIZE];
1818 _bt_convert_addr_type_to_string(addr, address.addr);
1819 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1821 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1822 _bt_convert_addr_type_to_string(addr, address.addr);
1823 sender = (char*)g_dbus_method_invocation_get_sender(context);
1824 _bt_save_invocation_context(context, result, sender,
1825 function_name, (gpointer)addr);
1829 case BT_AVRCP_TARGET_CONNECT: {
1830 bluetooth_device_address_t address = { {0} };
1832 __bt_service_get_parameters(in_param1,
1833 &address, sizeof(bluetooth_device_address_t));
1835 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1836 if (result != BLUETOOTH_ERROR_NONE) {
1837 char addr[BT_ADDRESS_STRING_SIZE];
1838 _bt_convert_addr_type_to_string(addr, address.addr);
1839 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1841 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1842 _bt_convert_addr_type_to_string(addr, address.addr);
1843 sender = (char*)g_dbus_method_invocation_get_sender(context);
1844 _bt_save_invocation_context(context, result, sender,
1845 function_name, (gpointer)addr);
1849 case BT_AVRCP_TARGET_DISCONNECT: {
1850 bluetooth_device_address_t address = { {0} };
1852 __bt_service_get_parameters(in_param1,
1853 &address, sizeof(bluetooth_device_address_t));
1855 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1856 if (result != BLUETOOTH_ERROR_NONE) {
1857 char addr[BT_ADDRESS_STRING_SIZE];
1858 _bt_convert_addr_type_to_string(addr, address.addr);
1859 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1861 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1862 _bt_convert_addr_type_to_string(addr, address.addr);
1863 sender = (char*)g_dbus_method_invocation_get_sender(context);
1864 _bt_save_invocation_context(context, result, sender,
1865 function_name, (gpointer)addr);
1869 case BT_AVRCP_CONTROL_CONNECT: {
1870 bluetooth_device_address_t address = { {0} };
1872 __bt_service_get_parameters(in_param1,
1873 &address, sizeof(bluetooth_device_address_t));
1875 result = _bt_audio_connect(BT_AVRCP, &address);
1876 if (result != BLUETOOTH_ERROR_NONE) {
1877 char addr[BT_ADDRESS_STRING_SIZE];
1878 _bt_convert_addr_type_to_string(addr, address.addr);
1879 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1881 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1882 _bt_convert_addr_type_to_string(addr, address.addr);
1883 sender = (char*)g_dbus_method_invocation_get_sender(context);
1884 _bt_save_invocation_context(context, result, sender,
1885 function_name, (gpointer)addr);
1889 case BT_AVRCP_CONTROL_DISCONNECT: {
1890 bluetooth_device_address_t address = { {0} };
1892 __bt_service_get_parameters(in_param1,
1893 &address, sizeof(bluetooth_device_address_t));
1895 result = _bt_audio_disconnect(BT_AVRCP, &address);
1896 if (result != BLUETOOTH_ERROR_NONE) {
1897 char addr[BT_ADDRESS_STRING_SIZE];
1898 _bt_convert_addr_type_to_string(addr, address.addr);
1899 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1901 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1902 _bt_convert_addr_type_to_string(addr, address.addr);
1903 sender = (char*)g_dbus_method_invocation_get_sender(context);
1904 _bt_save_invocation_context(context, result, sender,
1905 function_name, (gpointer)addr);
1909 case BT_AVRCP_HANDLE_CONTROL: {
1911 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1912 result = _bt_avrcp_control_cmd(key_code);
1915 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1917 bluetooth_device_address_t address = { { 0 } };
1919 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1920 __bt_service_get_parameters(in_param2,
1921 &address, sizeof(bluetooth_device_address_t));
1923 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1926 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1930 __bt_service_get_parameters(in_param1,
1931 &type, sizeof(int));
1932 __bt_service_get_parameters(in_param2,
1933 &value, sizeof(unsigned int));
1935 result = _bt_avrcp_control_set_property(type, value);
1938 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1943 __bt_service_get_parameters(in_param1,
1944 &type, sizeof(int));
1945 __bt_service_get_parameters(in_param2,
1946 &value, sizeof(unsigned int));
1948 result = _bt_avrcp_transport_set_property(type, value);
1952 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1955 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1957 result = _bt_avrcp_control_get_property(type);
1958 /* Save invocation */
1959 if (result == BLUETOOTH_ERROR_NONE) {
1960 sender = (char*)g_dbus_method_invocation_get_sender(context);
1961 _bt_save_invocation_context(context, result, sender,
1962 function_name, g_memdup(&type, sizeof(int)));
1966 case BT_AVRCP_GET_TRACK_INFO: {
1967 result = _bt_avrcp_control_get_track_info();
1968 /* Save invocation */
1969 if (result == BLUETOOTH_ERROR_NONE) {
1970 sender = (char*)g_dbus_method_invocation_get_sender(context);
1971 _bt_save_invocation_context(context, result, sender,
1972 function_name, NULL);
1976 case BT_HDP_REGISTER_SINK_APP: {
1977 unsigned short data_type;
1978 bt_hdp_role_type_t role;
1979 bt_hdp_qos_type_t channel_type;
1980 int *app_id = g_new0(int, 1);
1982 __bt_service_get_parameters(in_param1,
1983 &data_type, sizeof(short));
1984 __bt_service_get_parameters(in_param2,
1985 &role, sizeof(bt_hdp_role_type_t));
1986 __bt_service_get_parameters(in_param3,
1987 &channel_type, sizeof(bt_hdp_qos_type_t));
1988 sender = (char*)g_dbus_method_invocation_get_sender(context);
1990 result = _bt_hdp_app_register(role,
1991 channel_type, data_type, sender, app_id);
1992 if (result != BLUETOOTH_ERROR_NONE) {
1993 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1996 _bt_save_invocation_context(context, result, sender,
1997 function_name, (gpointer)app_id);
2001 case BT_HDP_UNREGISTER_SINK_APP: {
2003 int *app_id = g_new0(int, 1);
2005 app_handle = (char *)g_variant_get_data(in_param1);
2006 sscanf(app_handle, "health_app_%d", app_id);
2007 result = _bt_hdp_app_unregister(*app_id);
2008 if (result != BLUETOOTH_ERROR_NONE) {
2011 sender = (char*)g_dbus_method_invocation_get_sender(context);
2012 _bt_save_invocation_context(context, result, sender,
2013 function_name, (gpointer)app_id);
2017 case BT_HDP_CONNECT: {
2021 bt_hdp_connected_t *conn_info = NULL;
2023 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2025 app_handle = (char *)g_variant_get_data(in_param1);
2026 conn_info->app_handle = app_handle;
2027 sscanf(app_handle, "health_app_%d", &app_id);
2029 __bt_service_get_parameters(in_param2,
2030 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2031 __bt_service_get_parameters(in_param3,
2032 &(conn_info->device_address),
2033 sizeof(bluetooth_device_address_t));
2035 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2036 conn_info->type, (int *)(&(conn_info->channel_id)));
2037 if (result != BLUETOOTH_ERROR_NONE) {
2038 g_array_append_vals(*out_param1, conn_info,
2039 sizeof(bt_hdp_connected_t));
2042 sender = (char*)g_dbus_method_invocation_get_sender(context);
2043 _bt_save_invocation_context(context, result, sender,
2044 function_name, (gpointer)conn_info);
2048 case BT_HDP_DISCONNECT: {
2049 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2051 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2053 __bt_service_get_parameters(in_param1,
2054 &(hdp_disconn_info->channel_id), sizeof(int));
2055 __bt_service_get_parameters(in_param2,
2056 &(hdp_disconn_info->device_address),
2057 sizeof(bluetooth_device_address_t));
2059 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2060 if (result != BLUETOOTH_ERROR_NONE) {
2061 g_array_append_vals(*out_param1, hdp_disconn_info,
2062 sizeof(bt_hdp_disconnected_t));
2063 g_free(hdp_disconn_info);
2065 sender = (char*)g_dbus_method_invocation_get_sender(context);
2066 _bt_save_invocation_context(context, result, sender,
2067 function_name, (gpointer)hdp_disconn_info);
2071 case BT_HDP_GET_FD: {
2072 int *channel_id = g_new0(int, 1);
2074 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2076 result = _bt_hdp_get_fd(*channel_id);
2077 if (result != BLUETOOTH_ERROR_NONE) {
2080 sender = (char*)g_dbus_method_invocation_get_sender(context);
2081 _bt_save_invocation_context(context, result, sender,
2082 function_name, (gpointer)channel_id);
2086 case BT_HDP_SEND_DATA: {
2088 * This call to bt-service is only used for privilege check, so return
2089 * BLUETOOTH_ERROR_NONE from here.
2091 result = BLUETOOTH_ERROR_NONE;
2094 case BT_OOB_READ_LOCAL_DATA: { //208
2095 bt_oob_data_t local_oob_data;
2097 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2098 result = _bt_oob_read_local_data(&local_oob_data);
2100 g_array_append_vals(*out_param1, &local_oob_data,
2101 sizeof(bt_oob_data_t));
2105 case BT_OOB_ADD_REMOTE_DATA: { //209
2106 bluetooth_device_address_t address = { {0} };
2107 unsigned short address_type;
2108 bt_oob_data_t remote_oob_data;
2110 __bt_service_get_parameters(in_param1,
2111 &address, sizeof(bluetooth_device_address_t));
2112 __bt_service_get_parameters(in_param2,
2113 &address_type, sizeof(unsigned short));
2114 __bt_service_get_parameters(in_param3,
2115 &remote_oob_data, sizeof(bt_oob_data_t));
2117 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2121 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2122 bluetooth_device_address_t address = { {0} };
2124 __bt_service_get_parameters(in_param1,
2125 &address, sizeof(bluetooth_device_address_t));
2127 result = _bt_oob_remove_remote_data(&address);
2131 case BT_LE_OOB_READ_LOCAL_DATA: {
2132 bt_oob_data_t local_oob_data;
2133 bt_oob_data_t *local_oob_cache_data;
2135 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2136 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2137 g_array_append_vals(*out_param1, local_oob_cache_data,
2138 sizeof(bt_oob_data_t));
2139 return BLUETOOTH_ERROR_NONE;
2142 /* We should modify this logic in later */
2143 if (_bt_is_le_static_random_address_enabled() == false) {
2144 /* Seperate BT & LE address */
2145 _bt_set_le_static_random_address(TRUE);
2148 result = _bt_le_oob_read_local_data(&local_oob_data);
2149 _bt_le_oob_set_local_cache_data(&local_oob_data);
2151 g_array_append_vals(*out_param1, &local_oob_data,
2152 sizeof(bt_oob_data_t));
2156 case BT_LE_OOB_ADD_REMOTE_DATA: {
2157 bluetooth_device_address_t address = { {0} };
2158 unsigned short address_type;
2159 bt_oob_data_t remote_oob_data;
2161 __bt_service_get_parameters(in_param1,
2162 &address, sizeof(bluetooth_device_address_t));
2163 __bt_service_get_parameters(in_param2,
2164 &address_type, sizeof(unsigned short));
2165 __bt_service_get_parameters(in_param3,
2166 &remote_oob_data, sizeof(bt_oob_data_t));
2168 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2172 case BT_AVRCP_SET_TRACK_INFO: {
2173 media_metadata_t data;
2174 media_metadata_attributes_t meta_data;
2176 memset(&data, 0x00, sizeof(media_metadata_t));
2177 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2179 __bt_service_get_parameters(in_param1,
2180 &data, sizeof(media_metadata_t));
2182 meta_data.title = g_strdup(data.title);
2183 meta_data.artist = g_strdup(data.artist);
2184 meta_data.album = g_strdup(data.album);
2185 meta_data.genre = g_strdup(data.genre);
2186 meta_data.total_tracks = data.total_tracks;
2187 meta_data.number = data.number;
2188 meta_data.duration = (int64_t) data.duration;
2190 result = _bt_avrcp_set_track_info(&meta_data);
2192 g_free((gpointer)meta_data.title);
2193 g_free((gpointer)meta_data.artist);
2194 g_free((gpointer)meta_data.album);
2195 g_free((gpointer)meta_data.genre);
2199 case BT_AVRCP_SET_PROPERTY: {
2203 sender = (char *)g_dbus_method_invocation_get_sender(context);
2205 __bt_service_get_parameters(in_param1,
2206 &type, sizeof(int));
2207 __bt_service_get_parameters(in_param2,
2208 &value, sizeof(unsigned int));
2210 if (value == STATUS_PLAYING) {
2211 if (current_sender_playing)
2212 g_free(current_sender_playing);
2213 current_sender_playing = g_strdup(sender);
2215 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2216 current_sender_playing == NULL) {
2217 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2219 BT_INFO("Current Player and this sender (%s) are different", sender);
2220 result = BLUETOOTH_ERROR_NONE;
2223 result = _bt_avrcp_set_property(type, value);
2227 case BT_AVRCP_SET_PROPERTIES: {
2228 media_player_settings_t properties;
2230 memset(&properties, 0x00, sizeof(media_player_settings_t));
2231 __bt_service_get_parameters(in_param1,
2232 &properties, sizeof(media_player_settings_t));
2234 result = _bt_avrcp_set_properties(&properties);
2238 case BT_SET_ADVERTISING_DATA: {
2241 bluetooth_advertising_data_t adv = { {0} };
2243 gboolean use_reserved_slot = FALSE;
2245 app = (char *)g_dbus_method_invocation_get_sender(context);
2246 adv_handle = g_malloc0(sizeof(int));
2248 __bt_service_get_parameters(in_param1,
2249 adv_handle, sizeof(int));
2250 __bt_service_get_parameters(in_param3,
2251 &length, sizeof(int));
2252 __bt_service_get_parameters(in_param2,
2254 __bt_service_get_parameters(in_param4,
2255 &use_reserved_slot, sizeof(gboolean));
2256 result = _bt_set_advertising_data(app, *adv_handle,
2257 &adv, length, use_reserved_slot);
2258 if (result != BLUETOOTH_ERROR_NONE) {
2259 BT_ERR("Set Advertising data failed!!");
2262 _bt_save_invocation_context(context, result, app,
2263 function_name, (gpointer)adv_handle);
2267 case BT_SET_SCAN_RESPONSE_DATA: {
2270 bluetooth_scan_resp_data_t rsp = { {0} };
2272 gboolean use_reserved_slot = FALSE;
2274 app = (char *)g_dbus_method_invocation_get_sender(context);
2275 adv_handle = g_malloc0(sizeof(int));
2277 __bt_service_get_parameters(in_param1,
2278 adv_handle, sizeof(int));
2279 __bt_service_get_parameters(in_param3,
2280 &length, sizeof(int));
2281 __bt_service_get_parameters(in_param2,
2283 __bt_service_get_parameters(in_param4,
2284 &use_reserved_slot, sizeof(gboolean));
2286 result = _bt_set_scan_response_data(app, *adv_handle,
2287 &rsp, length, use_reserved_slot);
2289 if (result != BLUETOOTH_ERROR_NONE) {
2290 BT_ERR("Set Scan Response Data failed!!");
2293 _bt_save_invocation_context(context, result, app,
2294 function_name, (gpointer)adv_handle);
2298 case BT_SET_ADVERTISING: {
2301 gboolean enable = FALSE;
2302 gboolean use_reserved_slot = FALSE;
2304 adv_handle = g_malloc0(sizeof(int));
2305 __bt_service_get_parameters(in_param1,
2306 adv_handle, sizeof(int));
2307 __bt_service_get_parameters(in_param2,
2308 &enable, sizeof(gboolean));
2309 __bt_service_get_parameters(in_param3,
2310 &use_reserved_slot, sizeof(gboolean));
2312 app = (char *)g_dbus_method_invocation_get_sender(context);
2314 result = _bt_set_advertising(app, *adv_handle,
2315 enable, use_reserved_slot);
2316 if (result != BLUETOOTH_ERROR_NONE) {
2317 BT_ERR("Start Advertising failed!!");
2320 _bt_save_invocation_context(context, result, app,
2321 function_name, (gpointer)adv_handle);
2325 case BT_SET_CUSTOM_ADVERTISING: {
2328 gboolean enable = FALSE;
2329 bluetooth_advertising_params_t adv_params;
2330 gboolean use_reserved_slot = FALSE;
2332 app = (char *)g_dbus_method_invocation_get_sender(context);
2333 adv_handle = g_malloc0(sizeof(int));
2335 __bt_service_get_parameters(in_param1, adv_handle,
2337 __bt_service_get_parameters(in_param2, &enable,
2339 __bt_service_get_parameters(in_param3, &adv_params,
2340 sizeof(bluetooth_advertising_params_t));
2341 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2344 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2345 adv_params.interval_min, adv_params.interval_max,
2346 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2347 result = _bt_set_custom_advertising(app, *adv_handle,
2348 enable, &adv_params, use_reserved_slot);
2349 if (result != BLUETOOTH_ERROR_NONE) {
2350 BT_ERR("Start Custom Advertising failed!!");
2353 _bt_save_invocation_context(context, result, app,
2354 function_name, (gpointer)adv_handle);
2358 case BT_GET_SCAN_RESPONSE_DATA: {
2359 bluetooth_scan_resp_data_t rsp = { {0} };
2363 app = (char *)g_dbus_method_invocation_get_sender(context);
2365 __bt_service_get_parameters(in_param1, &adv_handle,
2368 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2369 if (result == BLUETOOTH_ERROR_NONE)
2370 g_array_append_vals(*out_param1, rsp.data, length);
2374 case BT_GET_ADVERTISING_DATA: {
2375 bluetooth_advertising_data_t adv = { {0} };
2379 app = (char *)g_dbus_method_invocation_get_sender(context);
2381 __bt_service_get_parameters(in_param1, &adv_handle,
2384 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2385 if (result == BLUETOOTH_ERROR_NONE)
2386 g_array_append_vals(*out_param1, adv.data, length);
2390 case BT_GATT_REGISTER_APPLICATION: {
2391 BT_DBG("Register GATT application:Unhandled!!");
2394 case BT_GATT_SERVER_REGISTER: {
2395 BT_DBG("GATT Server instance initialization");
2398 app = (char *)g_dbus_method_invocation_get_sender(context);
2399 BT_DBG("GATT Server Unique Name [%s]", app);
2401 /* No ADV handle: Set 0 */
2402 result = _bt_register_server_instance(app, 0);
2404 if (result != BLUETOOTH_ERROR_NONE) {
2405 BT_ERR("GATT Server registration failed. result %d", result);
2407 _bt_save_invocation_context(context, result, app,
2408 function_name, NULL);
2412 case BT_GATT_SERVER_DEREGISTER: {
2414 app = (char*)g_dbus_method_invocation_get_sender(context);
2416 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2419 case BT_GATT_SERVER_ADD_SERVICE: {
2420 BT_DBG("GATT Server Add Service");
2426 int *tmp_inst_id = NULL;
2428 app = (char *)g_dbus_method_invocation_get_sender(context);
2430 __bt_service_get_parameters(in_param1, &service_type,
2432 __bt_service_get_parameters(in_param2, &num_handles,
2434 svc_uuid = (char *)g_variant_get_data(in_param3);
2435 __bt_service_get_parameters(in_param4, &instance_id,
2438 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2439 if (result != BLUETOOTH_ERROR_NONE) {
2440 BT_ERR("GATT Server Add Service failed!!");
2442 tmp_inst_id = g_malloc0(sizeof(int));
2443 *tmp_inst_id = instance_id;
2444 _bt_save_invocation_context(context, result, app,
2445 function_name, (gpointer)tmp_inst_id);
2449 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2450 BT_DBG("GATT Server Add Characteristic");
2453 int *tmp_inst_id = NULL;
2454 bluetooth_gatt_server_attribute_params_t param;
2455 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2457 app = (char*)g_dbus_method_invocation_get_sender(context);
2459 __bt_service_get_parameters(in_param1, ¶m,
2460 sizeof(bluetooth_gatt_server_attribute_params_t));
2461 char_uuid = (char *)g_variant_get_data(in_param2);
2463 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2464 if (result != BLUETOOTH_ERROR_NONE) {
2465 BT_ERR("GATT Server Add Service failed!!");
2467 tmp_inst_id = g_malloc0(sizeof(int));
2468 *tmp_inst_id = param.instance_id;
2470 _bt_save_invocation_context(context, result, app,
2471 function_name, (gpointer)tmp_inst_id);
2475 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2476 BT_DBG("GATT Server Add Descriptor");
2480 bt_gatt_permission_t perm;
2482 int *tmp_inst_id = NULL;
2483 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2485 app = (char *)g_dbus_method_invocation_get_sender(context);
2487 __bt_service_get_parameters(in_param1, &service_handle,
2489 __bt_service_get_parameters(in_param2, &instance_id,
2491 desc_uuid = (char *)g_variant_get_data(in_param4);
2492 __bt_service_get_parameters(in_param3, &perm,
2493 sizeof(bt_gatt_permission_t));
2495 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2496 if (result != BLUETOOTH_ERROR_NONE) {
2497 BT_ERR("GATT Server Add Service failed!!");
2499 tmp_inst_id = g_malloc0(sizeof(int));
2500 *tmp_inst_id = instance_id;
2501 _bt_save_invocation_context(context, result, app,
2502 function_name, (gpointer)tmp_inst_id);
2506 case BT_GATT_SERVER_START_SERVICE: {
2511 int *tmp_inst_id = NULL;
2512 app = (char*)g_dbus_method_invocation_get_sender(context);
2514 __bt_service_get_parameters(in_param1, &service_handle,
2516 __bt_service_get_parameters(in_param2, &instance_id,
2519 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2521 if (BLUETOOTH_ERROR_NONE == result) {
2522 tmp_inst_id = g_malloc0(sizeof(int));
2523 *tmp_inst_id = instance_id;
2524 _bt_save_invocation_context(context, result, app,
2525 function_name, (gpointer)tmp_inst_id);
2529 case BT_GATT_SERVER_STOP_SERVICE: {
2533 int *tmp_inst_id = NULL;
2534 app = (char*)g_dbus_method_invocation_get_sender(context);
2536 __bt_service_get_parameters(in_param1, &service_handle,
2538 __bt_service_get_parameters(in_param2, &instance_id,
2541 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2543 if (BLUETOOTH_ERROR_NONE == result) {
2544 tmp_inst_id = g_malloc0(sizeof(int));
2545 *tmp_inst_id = instance_id;
2546 _bt_save_invocation_context(context, result, app,
2547 function_name, (gpointer)tmp_inst_id);
2551 case BT_GATT_SERVER_DELETE_SERVICE: {
2554 int *tmp_inst_id = NULL;
2556 app = (char*)g_dbus_method_invocation_get_sender(context);
2558 __bt_service_get_parameters(in_param1, &service_handle,
2560 __bt_service_get_parameters(in_param2, &instance_id,
2563 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2565 if (BLUETOOTH_ERROR_NONE == result) {
2566 tmp_inst_id = g_malloc0(sizeof(int));
2567 *tmp_inst_id = instance_id;
2568 _bt_save_invocation_context(context, result, app,
2569 function_name, (gpointer)tmp_inst_id);
2573 case BT_GATT_SERVER_SEND_RESPONSE: {
2574 bluetooth_gatt_server_response_params_t param;
2575 bluetooth_gatt_att_data_t data;
2578 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2579 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2581 app = (char*)g_dbus_method_invocation_get_sender(context);
2583 __bt_service_get_parameters(in_param1, &data,
2584 sizeof(bluetooth_gatt_att_data_t));
2585 __bt_service_get_parameters(in_param2, ¶m,
2586 sizeof(bluetooth_gatt_server_response_params_t));
2588 result = _bt_gatt_server_send_response(app, &data, ¶m);
2592 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2594 bluetooth_gatt_server_acquire_response_params_t param;
2597 msg = g_dbus_method_invocation_get_message(context);
2598 GUnixFDList *fd_list;
2603 fd_list = g_dbus_message_get_unix_fd_list(msg);
2605 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2607 app = (char*)g_dbus_method_invocation_get_sender(context);
2609 __bt_service_get_parameters(in_param1, ¶m,
2610 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2612 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2613 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2614 fd = fd_list_array[0];
2617 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2621 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2623 bluetooth_gatt_server_acquire_response_params_t param;
2626 msg = g_dbus_method_invocation_get_message(context);
2627 GUnixFDList *fd_list;
2632 fd_list = g_dbus_message_get_unix_fd_list(msg);
2634 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2636 app = (char*)g_dbus_method_invocation_get_sender(context);
2638 __bt_service_get_parameters(in_param1, ¶m,
2639 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2641 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2642 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2643 fd = fd_list_array[0];
2646 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2650 case BT_GATT_SERVER_SEND_INDICATION: {
2651 bluetooth_gatt_server_indication_params_t param;
2652 bluetooth_gatt_att_data_t data;
2653 bluetooth_device_address_t address;
2656 app = (char*)g_dbus_method_invocation_get_sender(context);
2658 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2659 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2660 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2662 __bt_service_get_parameters(in_param1, &data,
2663 sizeof(bluetooth_gatt_att_data_t));
2664 __bt_service_get_parameters(in_param2, ¶m,
2665 sizeof(bluetooth_gatt_server_indication_params_t));
2666 __bt_service_get_parameters(in_param3, &address,
2667 sizeof(bluetooth_device_address_t));
2669 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2673 case BT_GATT_SERVER_UPDATE_VALUE: {
2674 bluetooth_gatt_server_update_value_t param;
2678 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2680 app = (char*)g_dbus_method_invocation_get_sender(context);
2682 __bt_service_get_parameters(in_param1, &instance_id,
2684 __bt_service_get_parameters(in_param2, ¶m,
2685 sizeof(bluetooth_gatt_server_update_value_t));
2687 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2690 case BT_GET_ATT_MTU: {
2691 bluetooth_device_address_t address = { {0} };
2692 unsigned int mtu = 0;
2694 __bt_service_get_parameters(in_param1,
2695 &address, sizeof(bluetooth_device_address_t));
2696 result = _bt_get_att_mtu(&address, &mtu);
2697 BT_DBG("MTU: %d", mtu);
2699 if (result == BLUETOOTH_ERROR_NONE) {
2700 g_array_append_vals(*out_param1, &mtu,
2701 sizeof(unsigned int));
2705 case BT_REQ_ATT_MTU: {
2706 bluetooth_device_address_t address = { {0} };
2710 sender = (char*)g_dbus_method_invocation_get_sender(context);
2712 __bt_service_get_parameters(in_param1,
2713 &address, sizeof(bluetooth_device_address_t));
2714 __bt_service_get_parameters(in_param2,
2715 &mtu, sizeof(unsigned int));
2716 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2717 result = _bt_request_att_mtu(&address, mtu);
2718 if (BLUETOOTH_ERROR_NONE == result) {
2719 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2721 _bt_convert_addr_type_to_string(addr, address.addr);
2723 /* Save the informations to invocation */
2724 _bt_save_invocation_context(context, result, sender,
2725 function_name, (gpointer)addr);
2727 g_array_append_vals(*out_param1, &address,
2728 sizeof(bluetooth_device_address_t));
2732 case BT_GET_DEVICE_IDA: {
2733 bluetooth_device_address_t address = { {0} };
2734 bluetooth_device_address_t id_addr = { {0} };
2736 __bt_service_get_parameters(in_param1,
2737 &address, sizeof(bluetooth_device_address_t));
2739 result = _bt_device_get_ida(&address, &id_addr);
2741 if (result == BLUETOOTH_ERROR_NONE) {
2742 g_array_append_vals(*out_param1, &id_addr,
2743 sizeof(bluetooth_device_address_t));
2747 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2750 __bt_service_get_parameters(in_param1, &is_enable,
2753 result = _bt_set_le_static_random_address(is_enable);
2757 #ifdef TIZEN_GATT_CLIENT
2759 case BT_GATT_CLIENT_REGISTER: {
2760 bluetooth_device_address_t address = { {0} };
2763 sender = (char*)g_dbus_method_invocation_get_sender(context);
2765 __bt_service_get_parameters(in_param1,
2766 &address, sizeof(bluetooth_device_address_t));
2768 result = _bt_register_gatt_client_instance(sender, &address);
2769 if (BLUETOOTH_ERROR_NONE == result) {
2770 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2772 _bt_convert_addr_type_to_string(addr, address.addr);
2774 /* Save the informations to invocation */
2775 _bt_save_invocation_context(context, result, sender,
2776 function_name, (gpointer)addr);
2781 case BT_GATT_CLIENT_UNREGISTER: {
2784 sender = (char*)g_dbus_method_invocation_get_sender(context);
2785 __bt_service_get_parameters(in_param1,
2786 &client_id, sizeof(int));
2788 result = _bt_unregister_gatt_client_instance(sender, client_id);
2792 /* Async: Remote Interaction */
2793 case BT_GATT_ACQUIRE_WRITE: {
2797 bluetooth_gatt_client_char_prop_info_t param;
2799 sender = (char*)g_dbus_method_invocation_get_sender(context);
2801 __bt_service_get_parameters(in_param1, ¶m,
2802 sizeof(bluetooth_gatt_client_char_prop_info_t));
2805 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2807 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2809 if (BLUETOOTH_ERROR_NONE == result)
2810 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2812 BT_ERR("GATT Client: gatt acquire write failed");
2816 GUnixFDList *fd_list = NULL;
2817 GError *error = NULL;
2819 /* Add socket fd to unix_fd_list */
2820 fd_list = g_unix_fd_list_new();
2821 g_unix_fd_list_append(fd_list, fd, &error);
2822 g_assert_no_error(error);
2824 _bt_service_method_return_with_unix_fd_list(
2825 context, *out_param1, result, fd_list);
2828 g_object_unref(fd_list);
2832 /* Async: Remote Interaction */
2833 case BT_CONNECT_LE: {
2834 bluetooth_device_address_t address = { {0} };
2835 gboolean auto_connect;
2839 sender = (char*)g_dbus_method_invocation_get_sender(context);
2841 __bt_service_get_parameters(in_param1,
2842 &address, sizeof(bluetooth_device_address_t));
2843 __bt_service_get_parameters(in_param2,
2844 &auto_connect, sizeof(gboolean));
2845 __bt_service_get_parameters(in_param3,
2846 &client_id, sizeof(int));
2848 BT_DBG("GATT Client: client_id[%d]", client_id);
2849 result = _bt_connect_le_device(&address, auto_connect, client_id);
2850 if (BLUETOOTH_ERROR_NONE == result) {
2851 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2852 _bt_convert_addr_type_to_string(addr, address.addr);
2854 /* Save the informations to invocation */
2855 _bt_save_invocation_context(context, result, sender,
2856 function_name, (gpointer)addr);
2859 _bt_handle_invocation_context(function_name, (void *)addr);
2861 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2862 g_array_append_vals(*out_param1, &address,
2863 sizeof(bluetooth_device_address_t));
2867 /* Async: Remote Interaction */
2868 case BT_DISCONNECT_LE: {
2869 bluetooth_device_address_t address = { {0} };
2873 sender = (char*)g_dbus_method_invocation_get_sender(context);
2875 __bt_service_get_parameters(in_param1,
2876 &address, sizeof(bluetooth_device_address_t));
2877 __bt_service_get_parameters(in_param2,
2878 &client_id, sizeof(int));
2880 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2881 result = _bt_disconnect_le_device(&address, client_id);
2882 if (BLUETOOTH_ERROR_NONE == result) {
2883 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2885 _bt_convert_addr_type_to_string(addr, address.addr);
2887 /* Save the informations to invocation */
2888 _bt_save_invocation_context(context, result, sender,
2889 function_name, (gpointer)addr);
2891 g_array_append_vals(*out_param1, &address,
2892 sizeof(bluetooth_device_address_t));
2897 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2898 guint available_packets = 0;
2900 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2901 BT_DBG("LE batching available packets %u", available_packets);
2902 if (result == BLUETOOTH_ERROR_NONE) {
2903 g_array_append_vals(*out_param1, &available_packets,
2910 case BT_ENABLE_GATT_DATA_BATCHING: {
2911 bluetooth_device_address_t address = { {0} };
2912 int packet_threshold;
2915 __bt_service_get_parameters(in_param1,
2916 &address, sizeof(bluetooth_device_address_t));
2917 __bt_service_get_parameters(in_param2,
2918 &packet_threshold, sizeof(int));
2919 __bt_service_get_parameters(in_param3,
2920 &timeout, sizeof(int));
2921 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2926 case BT_DISABLE_GATT_DATA_BATCHING: {
2927 bluetooth_device_address_t address = { {0} };
2929 __bt_service_get_parameters(in_param1,
2930 &address, sizeof(bluetooth_device_address_t));
2931 result = _bt_gatt_disable_data_batching(&address);
2936 case BT_GATT_GET_PRIMARY_SERVICES: {
2939 sender = (char*)g_dbus_method_invocation_get_sender(context);
2940 bluetooth_device_address_t address = { {0} };
2942 __bt_service_get_parameters(in_param1, &address,
2943 sizeof(bluetooth_device_address_t));
2945 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2946 _bt_convert_addr_type_to_string(addr, address.addr);
2948 result = _bt_gatt_get_primary_services(addr);
2949 if (BLUETOOTH_ERROR_NONE == result) {
2950 _bt_save_invocation_context(context, result, sender,
2951 function_name, (gpointer)addr);
2957 case BT_GATT_GET_SERVICE_PROPERTIES: {
2958 bluetooth_gatt_client_svc_prop_info_t param;
2960 sender = (char*)g_dbus_method_invocation_get_sender(context);
2961 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2963 __bt_service_get_parameters(in_param1, ¶m,
2964 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2966 result = _bt_gatt_get_all_characteristic(¶m);
2967 if (BLUETOOTH_ERROR_NONE == result) {
2968 /* Save the informations to invocation */
2969 _bt_save_invocation_context(context, result, sender,
2971 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2975 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2976 bluetooth_gatt_client_char_prop_info_t param;
2978 sender = (char*)g_dbus_method_invocation_get_sender(context);
2979 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2981 __bt_service_get_parameters(in_param1, ¶m,
2982 sizeof(bluetooth_gatt_client_char_prop_info_t));
2984 result = _bt_gatt_get_all_characteristic_properties(¶m);
2985 if (BLUETOOTH_ERROR_NONE == result) {
2986 /* Save the informations to invocation */
2987 _bt_save_invocation_context(context, result, sender,
2989 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2993 /* Async: Remote Interaction */
2994 case BT_GATT_READ_CHARACTERISTIC: {
2995 bluetooth_gatt_client_char_prop_info_t param;
2997 sender = (char*)g_dbus_method_invocation_get_sender(context);
2998 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3000 __bt_service_get_parameters(in_param1, ¶m,
3001 sizeof(bluetooth_gatt_client_char_prop_info_t));
3003 result = _bt_gatt_read_characteristic_value(¶m);
3004 if (BLUETOOTH_ERROR_NONE == result) {
3005 /* Save the informations to invocation */
3006 _bt_save_invocation_context(context, result, sender,
3008 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3012 /* Async: Remote Interaction */
3013 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3014 bluetooth_gatt_client_desc_prop_info_t param;
3016 sender = (char*)g_dbus_method_invocation_get_sender(context);
3017 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3019 __bt_service_get_parameters(in_param1, ¶m,
3020 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3022 result = _bt_gatt_read_descriptor_value(¶m);
3023 if (BLUETOOTH_ERROR_NONE == result) {
3024 /* Save the informations to invocation */
3025 _bt_save_invocation_context(context, result, sender,
3027 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3031 /* Async: Remote Interaction */
3032 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3033 bluetooth_gatt_client_char_prop_info_t param;
3034 bluetooth_gatt_att_data_t data;
3035 bluetooth_gatt_write_type_e write_type;
3037 sender = (char*)g_dbus_method_invocation_get_sender(context);
3039 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3040 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3042 __bt_service_get_parameters(in_param1, ¶m,
3043 sizeof(bluetooth_gatt_client_char_prop_info_t));
3044 __bt_service_get_parameters(in_param2, &data,
3045 sizeof(bluetooth_gatt_att_data_t));
3046 __bt_service_get_parameters(in_param3, &write_type,
3047 sizeof(bluetooth_gatt_write_type_e));
3049 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3050 if (BLUETOOTH_ERROR_NONE == result) {
3051 /* Save the informations to invocation */
3052 _bt_save_invocation_context(context, result, sender,
3054 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3058 /* Async: Remote Interaction */
3059 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3060 bluetooth_gatt_client_desc_prop_info_t param;
3061 bluetooth_gatt_att_data_t data;
3062 bluetooth_gatt_write_type_e write_type;
3064 sender = (char*)g_dbus_method_invocation_get_sender(context);
3065 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3066 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3068 __bt_service_get_parameters(in_param1, ¶m,
3069 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3070 __bt_service_get_parameters(in_param2, &data,
3071 sizeof(bluetooth_gatt_att_data_t));
3072 __bt_service_get_parameters(in_param3, &write_type,
3073 sizeof(bluetooth_gatt_write_type_e));
3075 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3076 if (BLUETOOTH_ERROR_NONE == result) {
3077 /* Save the informations to invocation */
3078 _bt_save_invocation_context(context, result, sender,
3080 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3085 case BT_GATT_WATCH_CHARACTERISTIC: {
3086 bluetooth_gatt_client_char_prop_info_t param;
3091 gboolean is_indicate;
3094 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3096 sender = (char*)g_dbus_method_invocation_get_sender(context);
3098 __bt_service_get_parameters(in_param1, ¶m,
3099 sizeof(bluetooth_gatt_client_char_prop_info_t));
3100 __bt_service_get_parameters(in_param2, &client_id,
3102 __bt_service_get_parameters(in_param3, &is_notify,
3104 __bt_service_get_parameters(in_param4, &is_indicate,
3107 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3111 if (is_indicate == false) {
3112 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3113 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3114 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3116 GUnixFDList *fd_list = NULL;
3117 GError *error = NULL;
3119 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3120 /* Add socket fd to unix_fd_list */
3121 fd_list = g_unix_fd_list_new();
3122 g_unix_fd_list_append(fd_list, fd, &error);
3123 g_assert_no_error(error);
3125 _bt_service_method_return_with_unix_fd_list(
3126 context, *out_param1, result, fd_list);
3128 g_object_unref(fd_list);
3134 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3135 if (BLUETOOTH_ERROR_NONE == result) {
3136 /* Save the informations to invocation */
3137 _bt_save_invocation_context(context, result, sender, function_name,
3138 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3143 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3144 gboolean is_enabled;
3145 bluetooth_device_address_t address;
3147 sender = (char*)g_dbus_method_invocation_get_sender(context);
3149 __bt_service_get_parameters(in_param1,
3150 &address, sizeof(bluetooth_device_address_t));
3151 __bt_service_get_parameters(in_param2, &is_enabled,
3153 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3154 BT_INFO("Service changed indication from app [%s]", sender);
3158 case BT_LE_CONN_UPDATE: {
3159 char *sender = NULL;
3160 bluetooth_device_address_t local_address = { {0} };
3161 bluetooth_le_connection_param_t parameters = {0};
3163 sender = (char *)g_dbus_method_invocation_get_sender(context);
3165 __bt_service_get_parameters(in_param1, &local_address,
3166 sizeof(bluetooth_device_address_t));
3167 __bt_service_get_parameters(in_param2, ¶meters,
3168 sizeof(bluetooth_le_connection_param_t));
3170 result = _bt_le_connection_update(sender,
3172 parameters.interval_min,
3173 parameters.interval_max,
3175 parameters.timeout);
3179 case BT_START_LE_DISCOVERY: {
3183 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3185 sender = (char *)g_dbus_method_invocation_get_sender(context);
3187 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3188 BT_ERR("Fail to get the sender pid");
3190 result = _bt_start_le_scan(sender, uid, pid);
3191 if (result == BLUETOOTH_ERROR_NONE) {
3192 _bt_save_invocation_context(context, result, sender,
3193 function_name, NULL);
3195 BT_DBG("Remeber pid / uid for the scan operation");
3196 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3200 case BT_STOP_LE_DISCOVERY: {
3204 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3206 sender = (char *)g_dbus_method_invocation_get_sender(context);
3208 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3209 BT_ERR("Fail to get the sender pid");
3211 result = _bt_stop_le_scan(sender);
3212 if (result == BLUETOOTH_ERROR_NONE) {
3213 _bt_save_invocation_context(context, result, sender,
3214 function_name, NULL);
3217 BT_DBG("Remove pid / uid for the scan operation");
3218 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3222 case BT_IS_LE_DISCOVERYING: {
3223 gboolean le_discovering = FALSE;
3225 le_discovering = _bt_is_le_scanning();
3226 g_array_append_vals(*out_param1,
3227 &le_discovering, sizeof(gboolean));
3230 case BT_SET_SCAN_PARAMETERS: {
3231 bluetooth_le_scan_params_t scan_params;
3233 __bt_service_get_parameters(in_param1, &scan_params,
3234 sizeof(bluetooth_le_scan_params_t));
3236 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3237 scan_params.interval, scan_params.window,
3240 result = _bt_prepare_scan_parameters(&scan_params, 0);
3243 case BT_SET_SCAN_TYPE: {
3245 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3247 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3248 result = _bt_prepare_scan_parameters(NULL, scan_type);
3251 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3252 case BT_NETWORK_ACTIVATE:
3253 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3254 result = _bt_network_activate();
3256 case BT_NETWORK_DEACTIVATE:
3257 result = _bt_network_deactivate();
3259 case BT_NETWORK_CONNECT: {
3260 bluetooth_device_address_t address = { {0} };
3263 __bt_service_get_parameters(in_param1,
3264 &address, sizeof(bluetooth_device_address_t));
3265 __bt_service_get_parameters(in_param2,
3266 &role, sizeof(int));
3268 result = _bt_network_connect(request_id, role, &address);
3269 if (result != BLUETOOTH_ERROR_NONE) {
3270 g_array_append_vals(*out_param1, &address,
3271 sizeof(bluetooth_device_address_t));
3275 case BT_NETWORK_DISCONNECT: {
3276 bluetooth_device_address_t address = { {0} };
3278 __bt_service_get_parameters(in_param1,
3279 &address, sizeof(bluetooth_device_address_t));
3281 result = _bt_network_disconnect(request_id, &address);
3282 if (result != BLUETOOTH_ERROR_NONE) {
3283 g_array_append_vals(*out_param1, &address,
3284 sizeof(bluetooth_device_address_t));
3288 case BT_NETWORK_SERVER_DISCONNECT: {
3289 bluetooth_device_address_t address = { {0} };
3291 __bt_service_get_parameters(in_param1,
3292 &address, sizeof(bluetooth_device_address_t));
3294 result = _bt_network_server_disconnect(request_id, &address);
3295 if (result != BLUETOOTH_ERROR_NONE) {
3296 g_array_append_vals(*out_param1, &address,
3297 sizeof(bluetooth_device_address_t));
3303 #ifdef TIZEN_FEATURE_BT_IPSP
3304 case BT_LE_IPSP_INIT:
3305 result = _bt_initialize_ipsp();
3307 case BT_LE_IPSP_DEINIT:
3308 result = _bt_deinitialize_ipsp();
3310 case BT_LE_IPSP_CONNECT: {
3311 bluetooth_device_address_t address = { {0} };
3312 __bt_service_get_parameters(in_param1, &address,
3313 sizeof(bluetooth_device_address_t));
3314 result = _bt_connect_le_ipsp_device(&address);
3317 case BT_LE_IPSP_DISCONNECT: {
3318 bluetooth_device_address_t address = { {0} };
3319 __bt_service_get_parameters(in_param1, &address,
3320 sizeof(bluetooth_device_address_t));
3321 result = _bt_disconnect_le_ipsp_device(&address);
3325 case BT_IS_ADVERTISING: {
3326 gboolean advertising = FALSE;
3327 advertising = _bt_is_advertising();
3328 g_array_append_vals(*out_param1, &advertising,
3332 case BT_IS_LE_2M_PHY_SUPPORTED: {
3333 gboolean is_2m_phy_supported = FALSE;
3335 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3336 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3339 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3340 gboolean is_coded_phy_supported = FALSE;
3342 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3343 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3346 case BT_DISCONNECT_DEVICE: {
3347 bluetooth_device_address_t address = { {0} };
3349 __bt_service_get_parameters(in_param1,
3350 &address, sizeof(bluetooth_device_address_t));
3352 result = _bt_disconnect_device(&address);
3355 case BT_REGISTER_SCAN_FILTER: {
3356 bluetooth_le_scan_filter_t scan_filter;
3358 sender = (char*)g_dbus_method_invocation_get_sender(context);
3359 __bt_service_get_parameters(in_param1, &scan_filter,
3360 sizeof(bluetooth_le_scan_filter_t));
3362 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3363 scan_filter.added_features);
3365 result = _bt_register_scan_filter(sender, &scan_filter);
3371 result = _bt_mesh_init();
3374 case BT_MESH_DEINIT:
3375 result = _bt_mesh_deinit();
3378 case BT_MESH_NETWORK_CREATE: {
3379 bluetooth_mesh_node_t node;
3380 GSList *model_list = NULL;
3381 int total_models = 0;
3384 const char *network_name = NULL;
3385 bluetooth_mesh_network_t *network;
3387 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3388 sender = (char*)g_dbus_method_invocation_get_sender(context);
3390 __bt_service_get_parameters(in_param1,
3391 &node, sizeof(bluetooth_mesh_node_t));
3392 network_name = (const char *)g_variant_get_data(in_param2);
3393 BT_INFO("MESH: Network name [%s]", network_name);
3395 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3396 __bt_fill_garray_from_variant(in_param3, param3);
3398 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3399 for (i = 0; i < total_models; i++) {
3400 bluetooth_mesh_model_t *info = NULL;
3401 bluetooth_mesh_model_t *mod = NULL;
3403 info = &g_array_index(param3,
3404 bluetooth_mesh_model_t, i);
3406 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3409 model_list = g_slist_append(model_list,
3412 result = _bt_mesh_network_create(requester_unique_creds,
3413 sender, network_name, &node, model_list);
3415 /* Save invocation */
3416 if (result == BLUETOOTH_ERROR_NONE) {
3417 BT_INFO("Mesh: Save Invoation");
3418 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3420 /* Save Network name & UUID, Token will be received in event */
3421 _bt_mesh_util_convert_hex_to_string(
3422 (uint8_t *) node.uuid, 16,
3424 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3425 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3426 g_strlcpy(network->name.name, network_name,
3427 sizeof(network->name.name));
3428 g_strlcpy(network->app_cred,
3429 requester_unique_creds,
3430 sizeof(network->app_cred));
3431 sender = (char*)g_dbus_method_invocation_get_sender(context);
3432 _bt_save_invocation_context(context,
3434 function_name, (gpointer)network);
3436 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3437 BT_ERR("Mesh: Mesh Network creation schedule failed");
3438 g_slist_free_full(model_list, g_free);
3442 BT_INFO("Mesh: Cleanup");
3443 g_free((gpointer)requester_unique_creds);
3444 g_array_free(param3, TRUE);
3445 BT_INFO("Mesh: Cleanup Done");
3448 case BT_MESH_NETWORK_LOAD: {
3450 bluetooth_mesh_network_t *network;
3451 token = (char *)g_variant_get_data(in_param1);
3452 BT_INFO("MESH: Network Load: Token string [%s]", token);
3453 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3454 /* Save invocation */
3455 if (result == BLUETOOTH_ERROR_NONE) {
3456 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3457 g_strlcpy(network->token.token, token, strlen(token));
3458 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3460 sender = (char*)g_dbus_method_invocation_get_sender(context);
3461 _bt_save_invocation_context(context, result, sender,
3462 function_name, (gpointer)network);
3464 g_free((gpointer)requester_unique_creds);
3467 case BT_MESH_NETWORK_SCAN: {
3468 bluetooth_mesh_network_t network;
3469 bluetooth_mesh_scan_param_t param;
3470 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3471 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3473 __bt_service_get_parameters(in_param1,
3474 &network, sizeof(bluetooth_mesh_network_t));
3476 __bt_service_get_parameters(in_param2,
3477 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3479 result = _bt_mesh_network_scan(requester_unique_creds,
3480 sender, &network, ¶m);
3482 if (result != BLUETOOTH_ERROR_NONE) {
3483 g_array_append_vals(*out_param1,
3484 &network, sizeof(bluetooth_mesh_network_t));
3486 bluetooth_mesh_network_t *net = \
3487 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3489 sender = (char*)g_dbus_method_invocation_get_sender(context);
3490 _bt_save_invocation_context(context, result, sender,
3491 function_name, (gpointer)net);
3495 case BT_MESH_NETWORK_CANCEL_SCAN: {
3496 bluetooth_mesh_network_t network;
3497 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3499 __bt_service_get_parameters(in_param1,
3500 &network, sizeof(bluetooth_mesh_network_t));
3502 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3505 if (result != BLUETOOTH_ERROR_NONE)
3506 g_array_append_vals(*out_param1,
3507 &network, sizeof(bluetooth_mesh_network_t));
3510 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3511 bluetooth_mesh_network_t network;
3512 bluetooth_mesh_provisioner_caps_t caps;
3513 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3514 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3516 __bt_service_get_parameters(in_param1,
3517 &network, sizeof(bluetooth_mesh_network_t));
3519 __bt_service_get_parameters(in_param2,
3520 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3522 result = _bt_mesh_network_set_provisioner_caps(
3523 requester_unique_creds, sender, &network, &caps);
3527 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3528 bluetooth_mesh_provisioning_request_t req;
3529 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3531 __bt_service_get_parameters(in_param1,
3532 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3534 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3535 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3537 result = _bt_mesh_network_provision_device(
3538 requester_unique_creds, sender, &req);
3540 /* Save invocation */
3541 if (result != BLUETOOTH_ERROR_NONE) {
3542 g_array_append_vals(*out_param1, &req,
3543 sizeof(bluetooth_mesh_provisioning_request_t));
3545 bluetooth_mesh_provisioning_request_t *param = \
3546 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3548 sender = (char*)g_dbus_method_invocation_get_sender(context);
3549 _bt_save_invocation_context(context, result, sender,
3550 function_name, (gpointer)param);
3554 case BT_MESH_AUTHENTICATION_REPLY: {
3555 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3556 const char *auth_value = NULL;
3557 gboolean authentication_reply = FALSE;
3559 auth_value = g_variant_get_data(in_param2);
3560 __bt_service_get_parameters(in_param3,
3561 &authentication_reply, sizeof(gboolean));
3562 __bt_service_get_parameters(in_param1,
3563 &auth_type, sizeof(int));
3564 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3565 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3566 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3567 result = _bt_mesh_authentication_reply(auth_type,
3568 auth_value, authentication_reply);
3571 case BT_MESH_NETWORK_SET_NAME: {
3572 bluetooth_mesh_network_t network;
3573 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3575 __bt_service_get_parameters(in_param1,
3576 &network, sizeof(bluetooth_mesh_network_t));
3578 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3582 case BT_MESH_NETWORK_ADD_NETKEY: {
3583 bluetooth_mesh_network_t network;
3584 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3586 __bt_service_get_parameters(in_param1,
3587 &network, sizeof(bluetooth_mesh_network_t));
3589 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3592 if (result != BLUETOOTH_ERROR_NONE) {
3593 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3595 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3597 sender = (char*)g_dbus_method_invocation_get_sender(context);
3598 _bt_save_invocation_context(context, result, sender,
3599 function_name, (gpointer)net);
3603 case BT_MESH_NETWORK_DELETE_NETKEY: {
3604 bluetooth_mesh_network_t network;
3607 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3609 __bt_service_get_parameters(in_param1,
3610 &network, sizeof(bluetooth_mesh_network_t));
3611 __bt_service_get_parameters(in_param2,
3612 &index, sizeof(guint16));
3614 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3615 sender, &network, index);
3617 if (result != BLUETOOTH_ERROR_NONE) {
3618 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3620 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3622 sender = (char*)g_dbus_method_invocation_get_sender(context);
3623 _bt_save_invocation_context(context, result, sender,
3624 function_name, (gpointer)net);
3628 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3629 bluetooth_mesh_network_t network;
3632 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3634 __bt_service_get_parameters(in_param1,
3635 &network, sizeof(bluetooth_mesh_network_t));
3636 __bt_service_get_parameters(in_param2,
3637 &index, sizeof(guint16));
3639 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3640 sender, &network, index);
3642 if (result != BLUETOOTH_ERROR_NONE) {
3643 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3645 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3647 sender = (char*)g_dbus_method_invocation_get_sender(context);
3648 _bt_save_invocation_context(context, result, sender,
3649 function_name, (gpointer)net);
3653 case BT_MESH_NETWORK_ADD_APPKEY: {
3654 bluetooth_mesh_network_t network;
3657 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3659 __bt_service_get_parameters(in_param1,
3660 &network, sizeof(bluetooth_mesh_network_t));
3661 __bt_service_get_parameters(in_param2,
3662 &net_idx, sizeof(guint16));
3664 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3665 sender, &network, net_idx);
3667 if (result != BLUETOOTH_ERROR_NONE) {
3668 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3670 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3672 sender = (char*)g_dbus_method_invocation_get_sender(context);
3673 _bt_save_invocation_context(context, result, sender,
3674 function_name, (gpointer)net);
3678 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3679 bluetooth_mesh_network_t network;
3683 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3685 __bt_service_get_parameters(in_param1,
3686 &network, sizeof(bluetooth_mesh_network_t));
3687 __bt_service_get_parameters(in_param2,
3688 &net_idx, sizeof(guint16));
3689 __bt_service_get_parameters(in_param3,
3690 &app_idx, sizeof(guint16));
3692 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3693 sender, &network, net_idx, app_idx);
3695 if (result != BLUETOOTH_ERROR_NONE) {
3696 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3698 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3700 sender = (char*)g_dbus_method_invocation_get_sender(context);
3701 _bt_save_invocation_context(context, result, sender,
3702 function_name, (gpointer)net);
3706 case BT_MESH_NETWORK_DELETE_APPKEY: {
3707 bluetooth_mesh_network_t network;
3711 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3713 __bt_service_get_parameters(in_param1,
3714 &network, sizeof(bluetooth_mesh_network_t));
3715 __bt_service_get_parameters(in_param2,
3716 &net_idx, sizeof(guint16));
3717 __bt_service_get_parameters(in_param3,
3718 &app_idx, sizeof(guint16));
3720 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3721 sender, &network, net_idx, app_idx);
3723 if (result != BLUETOOTH_ERROR_NONE) {
3724 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3726 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3728 sender = (char*)g_dbus_method_invocation_get_sender(context);
3729 _bt_save_invocation_context(context, result, sender,
3730 function_name, (gpointer)net);
3734 case BT_MESH_NETWORK_GET_NETKEYS: {
3735 bluetooth_mesh_network_t network;
3736 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3737 __bt_service_get_parameters(in_param1,
3738 &network, sizeof(bluetooth_mesh_network_t));
3739 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3740 sender, &network, out_param1);
3743 case BT_MESH_NETWORK_GET_APPKEYS: {
3744 bluetooth_mesh_network_t network;
3747 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3748 __bt_service_get_parameters(in_param1,
3749 &network, sizeof(bluetooth_mesh_network_t));
3750 __bt_service_get_parameters(in_param2,
3751 &net_idx, sizeof(guint16));
3752 result = _bt_mesh_network_get_appkeys(
3753 requester_unique_creds, sender,
3754 &network, net_idx, out_param1);
3757 case BT_MESH_NETWORK_GET_NODES: {
3758 bluetooth_mesh_network_t network;
3759 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3760 __bt_service_get_parameters(in_param1,
3761 &network, sizeof(bluetooth_mesh_network_t));
3762 result = _bt_mesh_network_get_nodes(
3763 requester_unique_creds, sender,
3764 &network, out_param1);
3767 case BT_MESH_ELEMENT_GET_MODELS: {
3768 bluetooth_mesh_network_t network;
3772 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3773 __bt_service_get_parameters(in_param1,
3774 &network, sizeof(bluetooth_mesh_network_t));
3775 __bt_service_get_parameters(in_param2,
3776 &node_addr, sizeof(guint16));
3777 __bt_service_get_parameters(in_param3,
3778 &elem_idx, sizeof(int));
3779 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3780 &network, node_addr, elem_idx, out_param1);
3783 case BT_MESH_NODE_BROWSE: {
3784 bluetooth_mesh_node_discover_t req;
3785 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3787 __bt_service_get_parameters(in_param1,
3788 &req, sizeof(bluetooth_mesh_node_discover_t));
3790 result = _bt_mesh_browse_remote_node(
3791 requester_unique_creds, sender, &req);
3793 /* Save invocation */
3794 if (result != BLUETOOTH_ERROR_NONE) {
3795 g_array_append_vals(*out_param1, &req,
3796 sizeof(bluetooth_mesh_node_discover_t));
3798 bluetooth_mesh_node_discover_t *param = \
3799 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3801 sender = (char*)g_dbus_method_invocation_get_sender(context);
3802 _bt_save_invocation_context(context, result, sender,
3803 function_name, (gpointer)param);
3807 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3808 bluetooth_mesh_node_features_t req;
3809 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3811 __bt_service_get_parameters(in_param1,
3812 &req, sizeof(bluetooth_mesh_node_features_t));
3814 result = _bt_mesh_node_discover_vendor_features(
3815 requester_unique_creds, sender, &req);
3817 /* Save invocation */
3818 if (result != BLUETOOTH_ERROR_NONE) {
3819 g_array_append_vals(*out_param1,
3820 &req, sizeof(bluetooth_mesh_node_features_t));
3822 bluetooth_mesh_node_features_t *param = \
3823 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3825 sender = (char*)g_dbus_method_invocation_get_sender(context);
3826 _bt_save_invocation_context(context, result, sender,
3827 function_name, (gpointer)param);
3831 case BT_MESH_NODE_CONFIGURE_KEY: {
3832 bluetooth_mesh_key_configure_t req;
3834 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3836 __bt_service_get_parameters(in_param1,
3837 &req, sizeof(bluetooth_mesh_key_configure_t));
3839 result = _bt_mesh_node_configure_key(
3840 requester_unique_creds, sender, &req);
3842 /* Save invocation */
3843 if (result != BLUETOOTH_ERROR_NONE) {
3844 g_array_append_vals(*out_param1,
3845 &req, sizeof(bluetooth_mesh_key_configure_t));
3847 bluetooth_mesh_key_configure_t *param = \
3848 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3850 sender = (char*)g_dbus_method_invocation_get_sender(context);
3851 _bt_save_invocation_context(context, result, sender,
3852 function_name, (gpointer)param);
3856 case BT_MESH_NODE_TTL_EXECUTE: {
3857 bluetooth_mesh_node_ttl_info_t req;
3859 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3861 __bt_service_get_parameters(in_param1,
3862 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3864 result = _bt_mesh_ttl_execute_remote_node(
3865 requester_unique_creds, sender, &req);
3867 /* Save invocation */
3868 if (result != BLUETOOTH_ERROR_NONE) {
3869 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3871 bluetooth_mesh_node_ttl_info_t *param = \
3872 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3874 sender = (char*)g_dbus_method_invocation_get_sender(context);
3875 _bt_save_invocation_context(context, result, sender,
3876 function_name, (gpointer)param);
3880 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3881 bluetooth_mesh_model_configure_t req;
3883 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3885 __bt_service_get_parameters(in_param1,
3886 &req, sizeof(bluetooth_mesh_model_configure_t));
3888 result = _bt_mesh_node_model_appkey_execute(
3889 requester_unique_creds, sender, &req);
3891 /* Save invocation */
3892 if (result != BLUETOOTH_ERROR_NONE) {
3893 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3895 bluetooth_mesh_model_configure_t *param = \
3896 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3898 sender = (char*)g_dbus_method_invocation_get_sender(context);
3899 _bt_save_invocation_context(context, result, sender,
3900 function_name, (gpointer)param);
3904 case BT_MESH_NODE_GET_NETKEYS: {
3905 bluetooth_mesh_node_discover_t node;
3906 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3907 __bt_service_get_parameters(in_param1,
3908 &node, sizeof(bluetooth_mesh_node_discover_t));
3909 result = _bt_mesh_network_node_get_netkeys(
3910 requester_unique_creds, &node, out_param1);
3913 case BT_MESH_NODE_GET_APPKEYS: {
3914 bluetooth_mesh_node_discover_t node;
3915 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3916 __bt_service_get_parameters(in_param1,
3917 &node, sizeof(bluetooth_mesh_node_discover_t));
3918 result = _bt_mesh_network_node_get_appkeys(
3919 requester_unique_creds, sender, &node, out_param1);
3922 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3923 bluetooth_mesh_model_configure_t req;
3925 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3927 __bt_service_get_parameters(in_param1,
3928 &req, sizeof(bluetooth_mesh_model_configure_t));
3930 result = _bt_mesh_node_model_get_appkey_list(
3931 requester_unique_creds, sender, &req);
3933 /* Save invocation */
3934 if (result != BLUETOOTH_ERROR_NONE) {
3935 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3937 bluetooth_mesh_model_configure_t *param = \
3938 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3940 sender = (char*)g_dbus_method_invocation_get_sender(context);
3941 _bt_save_invocation_context(context, result, sender,
3942 function_name, (gpointer)param);
3946 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3947 bluetooth_mesh_model_configure_t req;
3949 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3951 __bt_service_get_parameters(in_param1,
3952 &req, sizeof(bluetooth_mesh_model_configure_t));
3954 result = _bt_mesh_node_model_get_subscription_list(
3955 requester_unique_creds, sender, &req);
3957 /* Save invocation */
3958 if (result != BLUETOOTH_ERROR_NONE) {
3959 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3961 bluetooth_mesh_model_configure_t *param = \
3962 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3964 sender = (char*)g_dbus_method_invocation_get_sender(context);
3965 _bt_save_invocation_context(context, result, sender,
3966 function_name, (gpointer)param);
3971 case BT_MESH_NETWORK_CREATE_GROUP: {
3972 bluetooth_mesh_network_t net;
3973 bluetooth_mesh_network_group_info_t res;
3974 gboolean is_virtual;
3977 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
3978 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
3980 __bt_service_get_parameters(in_param1,
3981 &net, sizeof(bluetooth_mesh_network_t));
3982 __bt_service_get_parameters(in_param2,
3983 &is_virtual, sizeof(gboolean));
3984 __bt_service_get_parameters(in_param3,
3985 &grp_addr, sizeof(guint16));
3987 result = _bt_mesh_network_create_group(
3988 requester_unique_creds, sender, &net,
3989 is_virtual, grp_addr, &res);
3991 if (result == BLUETOOTH_ERROR_NONE)
3992 g_array_append_vals(*out_param1, &res,
3993 sizeof(bluetooth_mesh_network_group_info_t));
3996 case BT_MESH_NETWORK_REMOVE_GROUP: {
3997 bluetooth_mesh_network_t net;
3998 bluetooth_mesh_network_group_info_t req;
4000 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4001 memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4003 __bt_service_get_parameters(in_param1,
4004 &net, sizeof(bluetooth_mesh_network_t));
4005 __bt_service_get_parameters(in_param2,
4006 &req, sizeof(bluetooth_mesh_network_group_info_t));
4008 result = _bt_mesh_network_remove_group(
4009 requester_unique_creds, sender, &net, &req);
4013 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
4014 bluetooth_mesh_model_configure_t req;
4016 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4018 __bt_service_get_parameters(in_param1,
4019 &req, sizeof(bluetooth_mesh_model_configure_t));
4021 result = _bt_mesh_model_configure_group_subscription(
4022 requester_unique_creds, sender, &req);
4024 /* Save invocation */
4025 if (result != BLUETOOTH_ERROR_NONE) {
4026 g_array_append_vals(*out_param1,
4027 &req, sizeof(bluetooth_mesh_model_configure_t));
4029 bluetooth_mesh_model_configure_t *param = \
4030 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4032 sender = (char*)g_dbus_method_invocation_get_sender(context);
4033 _bt_save_invocation_context(context, result, sender,
4034 function_name, (gpointer)param);
4038 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4039 bluetooth_mesh_model_configure_t req;
4041 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4043 __bt_service_get_parameters(in_param1,
4044 &req, sizeof(bluetooth_mesh_model_configure_t));
4046 result = _bt_mesh_model_configure_virtual_group_subscription(
4047 requester_unique_creds, sender, &req);
4049 /* Save invocation */
4050 if (result != BLUETOOTH_ERROR_NONE) {
4051 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4053 bluetooth_mesh_model_configure_t *param = \
4054 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4056 sender = (char*)g_dbus_method_invocation_get_sender(context);
4057 _bt_save_invocation_context(context, result, sender,
4058 function_name, (gpointer)param);
4062 case BT_MESH_MODEL_SET_PUBLICATION: {
4063 bluetooth_mesh_model_configure_t req;
4065 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4067 __bt_service_get_parameters(in_param1,
4068 &req, sizeof(bluetooth_mesh_model_configure_t));
4070 result = _bt_mesh_model_set_publication(
4071 requester_unique_creds, sender, &req);
4073 /* Save invocation */
4074 if (result != BLUETOOTH_ERROR_NONE) {
4075 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4077 bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4079 sender = (char*)g_dbus_method_invocation_get_sender(context);
4080 _bt_save_invocation_context(context, result, sender,
4081 function_name, (gpointer)param);
4085 case BT_MESH_MODEL_GET_PUBLICATION: {
4086 bluetooth_mesh_model_configure_t req;
4088 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4090 __bt_service_get_parameters(in_param1,
4091 &req, sizeof(bluetooth_mesh_model_configure_t));
4093 result = _bt_mesh_model_get_publication(
4094 requester_unique_creds, sender, &req);
4096 /* Save invocation */
4097 if (result != BLUETOOTH_ERROR_NONE) {
4098 g_array_append_vals(*out_param1,
4099 &req, sizeof(bluetooth_mesh_model_configure_t));
4101 bluetooth_mesh_model_configure_t *param = \
4102 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4104 sender = (char*)g_dbus_method_invocation_get_sender(context);
4105 _bt_save_invocation_context(context, result, sender,
4106 function_name, (gpointer)param);
4110 case BT_MESH_NETWORK_GET_GROUPS: {
4111 bluetooth_mesh_network_t network;
4112 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4113 __bt_service_get_parameters(in_param1,
4114 &network, sizeof(bluetooth_mesh_network_t));
4115 BT_INFO("Mesh: Request:: Get Groups");
4116 result = _bt_mesh_network_get_groups(
4117 requester_unique_creds, sender, &network, out_param1);
4121 BT_INFO("UnSupported function [%d]", function_name);
4122 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4128 #ifdef TIZEN_FEATURE_BT_OBEX
4129 /* Function definitions*/
4130 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4135 size = g_variant_get_size(var);
4137 data = (char *)g_variant_get_data(var);
4139 param = g_array_append_vals(param, data, size);
4145 int __bt_obexd_request(int function_name,
4148 GDBusMethodInvocation *context,
4149 GVariant *in_param1,
4150 GVariant *in_param2,
4151 GVariant *in_param3,
4152 GVariant *in_param4,
4153 GArray **out_param1)
4157 int result = BLUETOOTH_ERROR_NONE;
4159 BT_DBG("function_name : %x", function_name);
4161 switch (function_name) {
4162 case BT_OPP_PUSH_FILES: {
4163 BT_DBG("BT_OPP_PUSH_FILES");
4165 bluetooth_device_address_t address = { {0} };
4166 bt_file_path_t *path;
4171 __bt_service_get_parameters(in_param1, &address,
4172 sizeof(bluetooth_device_address_t));
4173 __bt_service_get_parameters(in_param3, &file_count,
4176 file_path = g_new0(char *, file_count + 1);
4178 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4179 __bt_fill_garray_from_variant(in_param2, param2);
4181 for (i = 0; i < file_count; i++) {
4182 path = &g_array_index(param2, bt_file_path_t, i);
4183 file_path[i] = g_strdup(path->path);
4185 BT_DBG("_bt_opp_client_push_files");
4186 result = _bt_opp_client_push_files(request_id, context,
4187 &address, file_path,
4190 for (i = 0; i < file_count; i++)
4191 g_free(file_path[i]);
4194 g_array_free(param2, TRUE);
4198 case BT_OPP_CANCEL_PUSH: {
4199 result = _bt_opp_client_cancel_push();
4203 case BT_OPP_IS_PUSHING_FILES: {
4204 gboolean is_sending = FALSE;
4206 result = _bt_opp_client_is_sending(&is_sending);
4208 g_array_append_vals(*out_param1, &is_sending,
4212 case BT_OPP_GET_TRANSFER_PROGRESS: {
4215 guint8 progress = 0;
4217 __bt_service_get_parameters(in_param1, &direction,
4219 __bt_service_get_parameters(in_param2, &transfer_id,
4222 result = _bt_opp_get_client_progress(&progress);
4224 result = _bt_opp_get_server_progress(transfer_id, &progress);
4226 g_array_append_vals(*out_param1, &progress,
4232 case BT_MAP_CREATE_SESSION: {
4233 BT_DBG("BT_MAP_CREATE_SESSION");
4234 char *address = (char *)g_variant_get_data(in_param1);
4235 char *session_id = NULL;
4236 result = _bt_create_session_sync(address, &session_id);
4237 if (result == BLUETOOTH_ERROR_NONE)
4238 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4242 case BT_MAP_DESTROY_SESSION: {
4243 BT_DBG("BT_MAP_DESTROY_SESSION");
4244 char* session_id = (char *)g_variant_get_data(in_param1);
4245 result = _bt_destroy_session_sync(session_id);
4246 if (result == BLUETOOTH_ERROR_NONE)
4247 BT_DBG("successfully destroyed session");
4251 case BT_MAP_SET_FOLDER: {
4252 BT_DBG("BT_MAP_SET_FOLDER");
4253 char *session_id = (char *)g_variant_get_data(in_param1);
4254 char *name = (char *)g_variant_get_data(in_param2);
4255 result = _bt_map_client_set_folder(session_id, name);
4259 case BT_MAP_LIST_FOLDERS: {
4260 BT_DBG("BT_MAP_LIST_FOLDERS");
4262 char* session_id = (char *)g_variant_get_data(in_param1);
4263 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4265 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4266 if (result == BLUETOOTH_ERROR_NONE)
4267 BT_DBG("_bt_map_client_list_folders succeed");
4272 case BT_MAP_LIST_FILTER_FIELDS: {
4273 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4275 char* session_id = (char *)g_variant_get_data(in_param1);
4277 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4278 if (result == BLUETOOTH_ERROR_NONE)
4279 BT_DBG("_bt_map_client_list_filter_fields succeed");
4284 case BT_MAP_LIST_MESSAGES: {
4285 BT_DBG("BT_MAP_LIST_MESSAGES");
4287 char* session_id = (char*)g_variant_get_data(in_param1);
4288 char* folder = (char*)g_variant_get_data(in_param2);
4289 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4291 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4292 if (result == BLUETOOTH_ERROR_NONE)
4293 BT_DBG("_bt_map_client_list_messages succeed");
4295 BT_DBG("_bt_map_client_list_messages failed");
4300 case BT_MAP_UPDATE_INBOX: {
4301 BT_DBG("BT_MAP_UPDATE_INBOX");
4302 char* session_id = (char *)g_variant_get_data(in_param1);
4303 result = _bt_map_client_update_inbox(session_id);
4307 case BT_MAP_PUSH_MESSAGE: {
4308 BT_DBG("BT_MAP_PUSH_MESSAGE");
4310 char* session_id = (char *)g_variant_get_data(in_param1);
4311 char* source_file = (char *)g_variant_get_data(in_param2);
4312 char* folder = (char *)g_variant_get_data(in_param3);
4313 char* args_serialized = (char *)g_variant_get_data(in_param4);
4315 result = _bt_map_client_push_message(
4316 request_id, context, session_id, source_file, folder, args_serialized);
4317 if (result == BLUETOOTH_ERROR_NONE)
4318 BT_DBG("_bt_map_client_push_message succeed");
4320 BT_ERR("_bt_map_client_push_message failed");
4325 case BT_MAP_GET_MESSAGE: {
4326 BT_DBG("BT_MAP_GET_MESSAGE");
4327 // TODO session currently is not used, but should be valid
4328 //char* session_id = (char *)g_variant_get_data(in_param1);
4329 char* message_object = (char *)g_variant_get_data(in_param2);
4330 char* target_file = (char *)g_variant_get_data(in_param3);
4331 bool attachment = false;
4332 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4334 result = _bt_map_client_get_message(request_id, context, message_object,
4335 target_file, attachment);
4336 if (result == BLUETOOTH_ERROR_NONE)
4337 BT_DBG("_bt_map_client_get_message succeed");
4342 case BT_OBEX_SERVER_ALLOCATE: {
4348 sender = (char *)g_dbus_method_invocation_get_sender(context);
4350 path = (char *)g_variant_get_data(in_param1);
4351 __bt_service_get_parameters(in_param2, &is_native,
4353 __bt_service_get_parameters(in_param3, &app_pid,
4356 result = _bt_obex_server_allocate(sender,
4357 path, app_pid, is_native);
4361 case BT_OBEX_SERVER_DEALLOCATE: {
4365 __bt_service_get_parameters(in_param1, &is_native,
4367 __bt_service_get_parameters(in_param2, &app_pid,
4370 result = _bt_obex_server_deallocate(app_pid, is_native);
4373 case BT_OBEX_SERVER_IS_ACTIVATED: {
4374 gboolean is_activated = FALSE;
4376 result = _bt_obex_server_is_activated(&is_activated);
4378 g_array_append_vals(*out_param1, &is_activated,
4383 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4384 result = _bt_obex_server_accept_connection(request_id);
4388 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4389 result = _bt_obex_server_reject_connection();
4393 case BT_OBEX_SERVER_ACCEPT_FILE: {
4396 file_name = (char *)g_variant_get_data(in_param1);
4398 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4402 case BT_OBEX_SERVER_REJECT_FILE: {
4403 result = _bt_obex_server_reject_authorize();
4407 case BT_OBEX_SERVER_SET_PATH: {
4409 char *destination_path;
4411 destination_path = (char *)g_variant_get_data(in_param1);
4412 __bt_service_get_parameters(in_param2, &is_native,
4415 result = _bt_obex_server_set_destination_path(destination_path,
4420 case BT_OBEX_SERVER_SET_ROOT: {
4423 root = (char *)g_variant_get_data(in_param1);
4425 result = _bt_obex_server_set_root(root);
4429 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4432 __bt_service_get_parameters(in_param1, &transfer_id,
4435 result = _bt_obex_server_cancel_transfer(transfer_id);
4439 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4440 result = _bt_obex_server_cancel_all_transfers();
4444 case BT_OBEX_SERVER_IS_RECEIVING: {
4445 gboolean is_receiving = FALSE;
4447 result = _bt_obex_server_is_receiving(&is_receiving);
4449 g_array_append_vals(*out_param1, &is_receiving,
4453 case BT_PBAP_CONNECT: {
4454 bluetooth_device_address_t address = { {0} };
4456 __bt_service_get_parameters(in_param1, &address,
4457 sizeof(bluetooth_device_address_t));
4459 result = _bt_pbap_connect(&address);
4462 case BT_PBAP_DISCONNECT: {
4463 bluetooth_device_address_t address = { {0} };
4465 __bt_service_get_parameters(in_param1, &address,
4466 sizeof(bluetooth_device_address_t));
4468 result = _bt_pbap_disconnect(&address);
4471 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4472 bluetooth_device_address_t address = { {0} };
4473 bt_pbap_folder_t folder = { 0, };
4475 __bt_service_get_parameters(in_param1, &address,
4476 sizeof(bluetooth_device_address_t));
4477 __bt_service_get_parameters(in_param2, &folder,
4478 sizeof(bt_pbap_folder_t));
4480 result = _bt_pbap_get_phonebook_size(&address,
4481 folder.addressbook, folder.folder_type);
4484 case BT_PBAP_GET_PHONEBOOK: {
4485 bluetooth_device_address_t address = { {0} };
4486 bt_pbap_folder_t folder = { 0, };
4487 bt_pbap_pull_parameters_t app_param = { 0, };
4489 __bt_service_get_parameters(in_param1, &address,
4490 sizeof(bluetooth_device_address_t));
4491 __bt_service_get_parameters(in_param2, &folder,
4492 sizeof(bt_pbap_folder_t));
4493 __bt_service_get_parameters(in_param3, &app_param,
4494 sizeof(bt_pbap_pull_parameters_t));
4496 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4497 folder.folder_type, &app_param);
4500 case BT_PBAP_GET_LIST: {
4501 bluetooth_device_address_t address = { {0} };
4502 bt_pbap_folder_t folder = { 0, };
4503 bt_pbap_list_parameters_t app_param = { 0, };
4505 __bt_service_get_parameters(in_param1, &address,
4506 sizeof(bluetooth_device_address_t));
4507 __bt_service_get_parameters(in_param2, &folder,
4508 sizeof(bt_pbap_folder_t));
4509 __bt_service_get_parameters(in_param3, &app_param,
4510 sizeof(bt_pbap_list_parameters_t));
4512 result = _bt_pbap_get_list(&address, folder.addressbook,
4513 folder.folder_type, &app_param);
4516 case BT_PBAP_PULL_VCARD: {
4517 bluetooth_device_address_t address = { {0} };
4518 bt_pbap_folder_t folder = { 0, };
4519 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4521 __bt_service_get_parameters(in_param1, &address,
4522 sizeof(bluetooth_device_address_t));
4523 __bt_service_get_parameters(in_param2, &folder,
4524 sizeof(bt_pbap_folder_t));
4525 __bt_service_get_parameters(in_param3, &app_param,
4526 sizeof(bt_pbap_pull_vcard_parameters_t));
4528 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4529 folder.folder_type, &app_param);
4532 case BT_PBAP_PHONEBOOK_SEARCH: {
4533 bluetooth_device_address_t address = { {0} };
4534 bt_pbap_folder_t folder = { 0, };
4535 bt_pbap_search_parameters_t app_param = { 0, };
4537 __bt_service_get_parameters(in_param1, &address,
4538 sizeof(bluetooth_device_address_t));
4539 __bt_service_get_parameters(in_param2, &folder,
4540 sizeof(bt_pbap_folder_t));
4541 __bt_service_get_parameters(in_param3, &app_param,
4542 sizeof(bt_pbap_search_parameters_t));
4544 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4545 folder.folder_type, &app_param);
4550 BT_ERR("Unknown function!");
4551 result = BLUETOOTH_ERROR_INTERNAL;
4560 int __bt_agent_request(int function_name,
4563 GDBusMethodInvocation *context,
4564 GVariant *in_param1,
4565 GVariant *in_param2,
4566 GVariant *in_param3,
4567 GVariant *in_param4,
4568 GArray **out_param1)
4571 switch (function_name) {
4572 case BT_SET_AUTHORIZATION: {
4579 sender = (char *)g_dbus_method_invocation_get_sender(context);
4580 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4581 uuid = (char *)g_variant_get_data(in_param2);
4582 path = (char *)g_variant_get_data(in_param3);
4583 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4585 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4588 case BT_UNSET_AUTHORIZATION: {
4592 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4593 uuid = (char *)g_variant_get_data(in_param2);
4595 result = _bt_unregister_osp_server_in_agent(type, uuid);
4599 BT_ERR("Unknown function!");
4600 result = BLUETOOTH_ERROR_INTERNAL;
4607 int __bt_core_request(int function_name,
4610 GDBusMethodInvocation *context,
4611 GVariant *in_param1)
4615 switch (function_name) {
4616 case BT_ENABLE_ADAPTER:
4619 _bt_set_adapter_request_state(TRUE);
4620 status = _bt_adapter_get_status();
4622 if (status == BT_ACTIVATING) {
4623 BT_DBG("Enabling in progress");
4624 result = BLUETOOTH_ERROR_IN_PROGRESS;
4625 } else if (status == BT_ACTIVATED) {
4626 BT_DBG("Already enabled");
4627 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4629 _bt_adapter_set_status(BT_ACTIVATING);
4630 result = BLUETOOTH_ERROR_NONE;
4635 case BT_DISABLE_ADAPTER:
4639 status = _bt_adapter_get_status();
4640 if (status == BT_DEACTIVATING) {
4641 BT_DBG("Disabling in progress");
4642 result = BLUETOOTH_ERROR_IN_PROGRESS;
4643 } else if (status == BT_DEACTIVATED) {
4644 BT_DBG("Already disabled");
4645 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4647 _bt_adapter_set_status(BT_DEACTIVATING);
4648 result = BLUETOOTH_ERROR_NONE;
4653 case BT_ENABLE_ADAPTER_LE:
4655 bt_le_status_t le_status;
4656 _bt_set_le_request_state(TRUE);
4657 le_status = _bt_adapter_get_le_status();
4658 if (le_status == BT_LE_ACTIVATING) {
4659 BT_DBG("Enabling in progress");
4660 result = BLUETOOTH_ERROR_IN_PROGRESS;
4661 } else if (le_status == BT_LE_ACTIVATED) {
4662 BT_DBG("Already enabled");
4663 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4665 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4666 result = BLUETOOTH_ERROR_NONE;
4671 case BT_DISABLE_ADAPTER_LE:
4673 bt_le_status_t le_status;
4675 le_status = _bt_adapter_get_le_status();
4676 if (le_status == BT_LE_DEACTIVATING) {
4677 BT_DBG("Disabling in progress");
4678 result = BLUETOOTH_ERROR_IN_PROGRESS;
4679 } else if (le_status == BT_LE_DEACTIVATED) {
4680 BT_DBG("Already disabled");
4681 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4683 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4684 result = BLUETOOTH_ERROR_NONE;
4690 BT_ERR("Unknown function!");
4691 result = BLUETOOTH_ERROR_INTERNAL;
4698 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
4703 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
4704 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
4706 ret = __bt_service_get_sender_pid(unique_name, &pid);
4707 if (ret != BLUETOOTH_ERROR_NONE) {
4708 BT_ERR("Fail to get the sender pid");
4712 ret = aul_app_get_appid_bypid(pid, app_id, len);
4713 if (ret != AUL_R_OK) {
4714 BT_ERR("app_id not found");
4715 return BLUETOOTH_ERROR_NOT_SUPPORT;
4717 BT_DBG("Sender app_id: %s", app_id);
4719 return BLUETOOTH_ERROR_NONE;
4722 gboolean __bt_service_check_privilege(int function_name,
4724 const char *unique_name)
4727 gboolean result = TRUE;
4728 char *client_creds = NULL;
4729 char *user_creds = NULL;
4730 char *client_session = "";
4731 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4732 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4733 char err_msg[256] = {0, };
4735 retv_if(unique_name == NULL, FALSE);
4736 retv_if(bt_service_conn == NULL, FALSE);
4738 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4739 if (ret_val != CYNARA_API_SUCCESS) {
4740 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4741 BT_ERR("Fail to get default client method: %s", err_msg);
4745 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4746 if (ret_val != CYNARA_API_SUCCESS) {
4747 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4748 BT_ERR("Fail to get default user method: %s", err_msg);
4752 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4753 if (ret_val != CYNARA_API_SUCCESS) {
4754 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4755 BT_ERR("Fail to get client credential: %s", err_msg);
4759 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4760 if (ret_val != CYNARA_API_SUCCESS) {
4761 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4762 BT_ERR("Fail to get user credential: %s", err_msg);
4768 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4770 switch (function_name) {
4771 case BT_SET_LOCAL_NAME:
4772 case BT_START_DISCOVERY:
4773 case BT_START_CUSTOM_DISCOVERY:
4774 case BT_CANCEL_DISCOVERY:
4775 case BT_OOB_ADD_REMOTE_DATA:
4776 case BT_OOB_REMOVE_REMOTE_DATA:
4777 case BT_OOB_READ_LOCAL_DATA:
4778 case BT_SET_ADVERTISING:
4779 case BT_SET_CUSTOM_ADVERTISING:
4780 case BT_SET_ADVERTISING_PARAMETERS:
4781 case BT_START_LE_DISCOVERY:
4782 case BT_STOP_LE_DISCOVERY:
4783 case BT_SET_SCAN_PARAMETERS:
4784 case BT_SET_SCAN_TYPE:
4786 case BT_BOND_DEVICE:
4787 case BT_CANCEL_BONDING:
4788 case BT_UNBOND_DEVICE:
4790 case BT_SET_AUTHORIZATION:
4791 case BT_UNSET_AUTHORIZATION:
4792 case BT_SEARCH_SERVICE:
4794 case BT_RFCOMM_CLIENT_CONNECT:
4795 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4796 BT_PERMANENT_LOG("Connect socket");
4797 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4798 case BT_RFCOMM_SOCKET_DISCONNECT:
4799 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4800 BT_PERMANENT_LOG("Disconnect socket");
4801 case BT_RFCOMM_SOCKET_WRITE:
4802 case BT_RFCOMM_CREATE_SOCKET:
4803 case BT_RFCOMM_REMOVE_SOCKET:
4804 case BT_RFCOMM_SEND_RX_DETAILS:
4805 case BT_RFCOMM_SEND_TX_DETAILS:
4806 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4808 case BT_OPP_PUSH_FILES:
4809 case BT_OPP_CANCEL_PUSH:
4810 /* TODO: MAP? MAP functions, see above */
4812 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4813 case BT_OBEX_SERVER_REJECT_CONNECTION:
4814 case BT_OBEX_SERVER_ACCEPT_FILE:
4815 case BT_OBEX_SERVER_REJECT_FILE:
4816 case BT_OBEX_SERVER_SET_PATH:
4817 case BT_OBEX_SERVER_SET_ROOT:
4818 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4819 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4821 case BT_AUDIO_SELECT_ROLE:
4822 case BT_AUDIO_CONNECT:
4823 case BT_AUDIO_DISCONNECT:
4825 case BT_AG_DISCONNECT:
4827 case BT_AV_DISCONNECT:
4828 case BT_AV_SOURCE_CONNECT:
4829 case BT_AV_SOURCE_DISCONNECT:
4830 case BT_AVRCP_TARGET_CONNECT:
4831 case BT_AVRCP_TARGET_DISCONNECT:
4832 case BT_AVRCP_CONTROL_CONNECT:
4833 case BT_AVRCP_CONTROL_DISCONNECT:
4834 case BT_AVRCP_HANDLE_CONTROL:
4835 case BT_AVRCP_SET_TRACK_INFO:
4836 case BT_AVRCP_SET_PROPERTY:
4837 case BT_AVRCP_SET_PROPERTIES:
4838 case BT_AVRCP_CONTROL_SET_PROPERTY:
4840 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
4841 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4842 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4843 case BT_AUDIO_IS_AVC_ACTIVATED:
4847 case BT_HF_DISCONNECT:
4849 case BT_HID_CONNECT:
4850 case BT_HID_DISCONNECT:
4852 case BT_HID_DEVICE_ACTIVATE:
4853 case BT_HID_DEVICE_DEACTIVATE:
4854 case BT_HID_DEVICE_CONNECT:
4855 case BT_HID_DEVICE_DISCONNECT:
4856 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4857 case BT_HID_DEVICE_SEND_KEY_EVENT:
4858 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4859 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4862 case BT_DISCONNECT_LE:
4864 case BT_SET_ADVERTISING_DATA:
4865 case BT_SET_SCAN_RESPONSE_DATA:
4867 case BT_HDP_CONNECT:
4868 case BT_HDP_DISCONNECT:
4869 case BT_HDP_SEND_DATA:
4870 case BT_HDP_REGISTER_SINK_APP:
4871 case BT_HDP_UNREGISTER_SINK_APP:
4874 case BT_DPM_SET_ALLOW_BT_MODE:
4875 case BT_DPM_GET_ALLOW_BT_MODE:
4876 case BT_DPM_SET_DEVICE_RESTRITION:
4877 case BT_DPM_GET_DEVICE_RESTRITION:
4878 case BT_DPM_SET_UUID_RESTRITION:
4879 case BT_DPM_GET_UUID_RESTRITION:
4880 case BT_DPM_ADD_DEVICES_BLACKLIST:
4881 case BT_DPM_ADD_DEVICES_WHITELIST:
4882 case BT_DPM_ADD_UUIDS_BLACKLIST:
4883 case BT_DPM_ADD_UUIDS_WHITELIST:
4884 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4885 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4886 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4887 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4888 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4889 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4890 case BT_DPM_REMOVE_UUID_BLACKLIST:
4891 case BT_DPM_REMOVE_UUID_WHITELIST:
4892 case BT_DPM_GET_DEVICES_BLACKLIST:
4893 case BT_DPM_GET_DEVICES_WHITELIST:
4894 case BT_DPM_GET_UUIDS_BLACKLIST:
4895 case BT_DPM_GET_UUIDS_WHITELIST:
4896 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4897 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4898 case BT_DPM_SET_PAIRING_STATE:
4899 case BT_DPM_GET_PAIRING_STATE:
4900 case BT_DPM_SET_PROFILE_STATE:
4901 case BT_DPM_GET_PROFILE_STATE:
4902 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4903 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4904 case BT_DPM_SET_DISCOVERABLE_STATE:
4905 case BT_DPM_GET_DISCOVERABLE_STATE:
4906 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4907 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4908 case BT_DPM_SET_DATA_TRANSFER_STATE:
4909 case BT_DPM_GET_DATA_TRANSFER_STATE:
4911 case BT_NETWORK_ACTIVATE:
4912 case BT_NETWORK_DEACTIVATE:
4913 case BT_NETWORK_CONNECT:
4914 case BT_NETWORK_DISCONNECT:
4915 case BT_NETWORK_SERVER_DISCONNECT:
4917 case BT_GATT_GET_PRIMARY_SERVICES:
4918 #ifdef TIZEN_GATT_CLIENT
4919 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4920 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4921 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4923 case BT_GATT_DISCOVER_CHARACTERISTICS:
4924 case BT_GATT_SET_PROPERTY_REQUEST:
4925 case BT_GATT_READ_CHARACTERISTIC:
4926 #ifdef TIZEN_GATT_CLIENT
4927 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4928 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4929 case BT_GATT_ACQUIRE_WRITE:
4930 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4931 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4932 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4933 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4935 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4936 case BT_GATT_REGISTER_APPLICATION:
4937 case BT_GATT_REGISTER_SERVICE:
4938 case BT_GATT_SEND_RESPONSE:
4940 case BT_GATT_SERVER_REGISTER:
4941 case BT_GATT_SERVER_ADD_SERVICE:
4942 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4943 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4944 case BT_GATT_SERVER_START_SERVICE:
4945 case BT_GATT_SERVER_STOP_SERVICE:
4946 case BT_GATT_SERVER_DELETE_SERVICE:
4947 case BT_GATT_SERVER_SEND_RESPONSE:
4948 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
4949 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
4950 case BT_GATT_SERVER_SEND_INDICATION:
4951 case BT_GATT_SERVER_UPDATE_VALUE:
4952 case BT_GATT_SERVER_DEREGISTER:
4954 case BT_REQ_ATT_MTU:
4955 case BT_PBAP_CONNECT:
4956 case BT_PBAP_DISCONNECT:
4957 case BT_PBAP_GET_PHONEBOOK_SIZE:
4958 case BT_PBAP_GET_PHONEBOOK:
4959 case BT_PBAP_GET_LIST:
4960 case BT_PBAP_PULL_VCARD:
4961 case BT_PBAP_PHONEBOOK_SEARCH:
4963 case BT_RFCOMM_LISTEN_AND_ACCEPT:
4965 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4966 BT_PRIVILEGE_PUBLIC);
4968 BT_INFO("Client Credentials [%s]", client_creds);
4969 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4970 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
4974 /* Need to check mediastorage privilege */
4975 if (function_name == BT_PBAP_GET_PHONEBOOK ||
4976 function_name == BT_PBAP_PULL_VCARD) {
4977 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4978 MEDIASTORAGE_PRIVILEGE);
4980 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4981 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
4987 case BT_ENABLE_ADAPTER:
4988 case BT_DISABLE_ADAPTER:
4989 case BT_RESET_ADAPTER:
4990 case BT_RECOVER_ADAPTER:
4991 case BT_BATTERY_READ_DATA:
4992 case BT_ENABLE_ADAPTER_LE:
4993 case BT_DISABLE_ADAPTER_LE:
4994 case BT_SET_CONNECTABLE:
4995 case BT_SET_DISCOVERABLE_MODE:
4996 case BT_ADD_WHITE_LIST:
4997 case BT_REMOVE_WHITE_LIST:
4998 case BT_CLEAR_WHITE_LIST:
4999 case BT_SET_MANUFACTURER_DATA:
5001 case BT_CANCEL_SEARCH_SERVICE:
5002 case BT_ENABLE_RSSI:
5003 case BT_DISCONNECT_DEVICE:
5005 case BT_RFCOMM_ACCEPT_CONNECTION:
5006 case BT_RFCOMM_REJECT_CONNECTION:
5007 case BT_RFCOMM_LISTEN:
5009 case BT_HID_ENABLE_BARCODE_FEATURE:
5011 case BT_AVRCP_CONTROL_GET_PROPERTY:
5012 case BT_AVRCP_GET_TRACK_INFO:
5013 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5014 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5016 case BT_SET_CONTENT_PROTECT:
5017 case BT_BOND_DEVICE_BY_TYPE:
5018 case BT_SET_LE_PRIVACY:
5019 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5020 case BT_LE_CONN_UPDATE:
5021 case BT_UPDATE_LE_CONNECTION_MODE:
5022 case BT_GET_DEVICE_IDA:
5023 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5024 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5025 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5026 case BT_LE_SET_DATA_LENGTH:
5027 case BT_LE_OOB_READ_LOCAL_DATA:
5028 case BT_LE_OOB_ADD_REMOTE_DATA:
5030 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5031 case BT_ENABLE_GATT_DATA_BATCHING:
5032 case BT_DISABLE_GATT_DATA_BATCHING:
5034 case BT_LE_IPSP_INIT:
5035 case BT_LE_IPSP_DEINIT:
5036 case BT_LE_IPSP_CONNECT:
5037 case BT_LE_IPSP_DISCONNECT:
5038 case BT_PXP_MONITOR_SET_PROPERTY:
5039 case BT_PXP_MONITOR_GET_PROPERTY:
5040 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5041 case BT_PXP_REPORTER_REGISTER:
5042 case BT_PXP_REPORTER_UNREGISTER:
5043 case BT_PXP_REPORTER_GET_PROPERTY:
5046 case BT_TDS_PROVIDER_REGISTER:
5047 case BT_TDS_PROVIDER_UNREGISTER:
5048 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5049 case BT_TDS_PROVIDER_CREATE:
5050 case BT_TDS_PROVIDER_DESTROY:
5051 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5052 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5053 case BT_TDS_READ_TRANSPORT_DATA:
5054 case BT_TDS_ENABLE_CONTROL_POINT:
5055 case BT_TDS_ACTIVATE_CONTROL_POINT:
5058 case BT_OTP_SERVER_INIT:
5059 case BT_OTP_SERVER_DEINIT:
5060 case BT_OTP_READ_VALUE:
5061 case BT_OTP_ENABLE_NOTIFICATION:
5062 case BT_OTP_WRITE_VALUE:
5063 case BT_LE_OTC_CONNECT:
5064 case BT_LE_OTC_DISCONNECT:
5066 case BT_MAP_CREATE_SESSION:
5067 case BT_MAP_DESTROY_SESSION:
5068 case BT_MAP_SET_FOLDER:
5069 case BT_MAP_LIST_FOLDERS:
5070 case BT_MAP_LIST_FILTER_FIELDS:
5071 case BT_MAP_LIST_MESSAGES:
5072 case BT_MAP_UPDATE_INBOX:
5073 case BT_MAP_PUSH_MESSAGE:
5074 case BT_MAP_GET_MESSAGE:
5077 case BT_MESH_DEINIT:
5078 case BT_MESH_NETWORK_CREATE:
5079 case BT_MESH_NETWORK_LOAD:
5080 case BT_MESH_NETWORK_SCAN:
5081 case BT_MESH_NETWORK_CANCEL_SCAN:
5082 case BT_MESH_NETWORK_SET_CAPABILITIES:
5083 case BT_MESH_NETWORK_PROVISION_DEVICE:
5084 case BT_MESH_AUTHENTICATION_REPLY:
5085 case BT_MESH_NETWORK_SET_NAME:
5086 case BT_MESH_NETWORK_ADD_NETKEY:
5087 case BT_MESH_NETWORK_DELETE_NETKEY:
5088 case BT_MESH_NETWORK_UPDATE_NETKEY:
5089 case BT_MESH_NETWORK_ADD_APPKEY:
5090 case BT_MESH_NETWORK_DELETE_APPKEY:
5091 case BT_MESH_NETWORK_UPDATE_APPKEY:
5092 case BT_MESH_NETWORK_GET_NETKEYS:
5093 case BT_MESH_NETWORK_GET_APPKEYS:
5094 case BT_MESH_NETWORK_GET_NODES:
5095 case BT_MESH_ELEMENT_GET_MODELS:
5096 case BT_MESH_NODE_BROWSE:
5097 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5098 case BT_MESH_NODE_CONFIGURE_KEY:
5099 case BT_MESH_NODE_TTL_EXECUTE:
5100 case BT_MESH_NODE_GET_NETKEYS:
5101 case BT_MESH_NODE_GET_APPKEYS:
5102 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5103 case BT_MESH_MODEL_GET_APPKEY_LIST:
5104 case BT_MESH_NETWORK_CREATE_GROUP:
5105 case BT_MESH_NETWORK_REMOVE_GROUP:
5106 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5107 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5108 case BT_MESH_MODEL_SET_PUBLICATION:
5109 case BT_MESH_MODEL_GET_PUBLICATION:
5110 case BT_MESH_NETWORK_GET_GROUPS:
5112 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5113 BT_PRIVILEGE_PLATFORM);
5115 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5116 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5121 case BT_CHECK_ADAPTER:
5124 case BT_GET_LOCAL_NAME:
5125 case BT_GET_LOCAL_ADDRESS:
5126 case BT_GET_LOCAL_VERSION:
5127 case BT_IS_SERVICE_USED:
5128 case BT_GET_DISCOVERABLE_MODE:
5129 case BT_GET_DISCOVERABLE_TIME:
5130 case BT_IS_DISCOVERYING:
5131 case BT_IS_LE_DISCOVERYING:
5132 case BT_IS_CONNECTABLE:
5133 case BT_GET_CONNECTABLE:
5134 case BT_GET_BONDED_DEVICES:
5135 case BT_GET_PROFILE_CONNECTED_DEVICES:
5136 case BT_GET_BONDED_DEVICE:
5137 case BT_PASSKEY_REPLY:
5138 case BT_PASSKEY_CONFIRMATION_REPLY:
5139 case BT_GET_IS_ALIAS_SET:
5140 case BT_IS_DEVICE_CONNECTED:
5141 case BT_GET_CONNECTED_LINK_TYPE:
5142 case BT_SET_PROFILE_TRUSTED:
5143 case BT_GET_PROFILE_TRUSTED:
5144 case BT_GET_SPEAKER_GAIN:
5145 case BT_SET_SPEAKER_GAIN:
5146 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5147 case BT_RFCOMM_IS_UUID_AVAILABLE:
5148 case BT_GET_ADVERTISING_DATA:
5149 case BT_GET_SCAN_RESPONSE_DATA:
5150 case BT_IS_ADVERTISING:
5151 case BT_IS_LE_2M_PHY_SUPPORTED:
5152 case BT_IS_LE_CODED_PHY_SUPPORTED:
5153 case BT_REGISTER_SCAN_FILTER:
5154 case BT_IS_SCAN_FILTER_SUPPORTED:
5155 case BT_GET_ATT_MTU:
5157 case BT_OBEX_SERVER_ALLOCATE:
5158 case BT_OBEX_SERVER_DEALLOCATE:
5159 case BT_OBEX_SERVER_IS_ACTIVATED:
5160 case BT_OPP_GET_TRANSFER_PROGRESS:
5161 /* Non-privilege control */
5164 BT_ERR("Unknown function!");
5169 if (function_name >= BT_FUNC_MESH_BASE) {
5170 BT_INFO("MESH Function called");
5171 char app_id[256] = { 0, };
5173 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5174 app_id, sizeof(app_id))) {
5175 requester_unique_creds = g_strdup(app_id);
5177 BT_DBG("Requester app_id not found, use client creds");
5178 requester_unique_creds = g_strdup(client_creds);
5180 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5182 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5194 GDBusNodeInfo *__bt_service_create_method_node_info
5195 (const gchar *introspection_data)
5198 GDBusNodeInfo *node_info = NULL;
5200 if (introspection_data == NULL) {
5201 BT_ERR("Introspection XML not present");
5205 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5208 BT_ERR("Unable to create node: %s", err->message);
5209 g_clear_error(&err);
5214 int __bt_service_register_object(GDBusConnection *conn,
5215 GDBusNodeInfo *node_info, gboolean reg)
5217 static guint service_id = 0;
5218 GError *error = NULL;
5221 if (node_info == NULL)
5224 service_id = g_dbus_connection_register_object(conn,
5226 node_info->interfaces[0],
5228 NULL, NULL, &error);
5229 if (service_id == 0)
5232 if (service_id > 0) {
5233 g_dbus_connection_unregister_object(conn,
5242 static void __name_owner_changed(GDBusConnection *connection,
5243 const gchar *sender_name,
5244 const gchar *object_path,
5245 const gchar *interface_name,
5246 const gchar *signal_name,
5247 GVariant *parameters,
5250 const char *name = NULL;
5251 const char *old_owner = NULL;
5252 const char *new_owner = NULL;
5254 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5255 if (*new_owner != '\0')
5258 _bt_check_hdp_app_termination(name);
5260 /* Advertising App Termination */
5261 _bt_check_adv_app_termination(name);
5263 /* Check if le_scanning app is terminated */
5264 _bt_check_le_scanner_app_termination(name);
5266 /* Check if RFCOMM app is terminated */
5267 _bt_rfcomm_check_termination(name);
5270 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5271 const gchar *name, gpointer user_data)
5273 GDBusNodeInfo *node_info = NULL;
5275 BT_INFO("bus acquired");
5277 ret_if(connection == NULL);
5279 node_info = __bt_service_create_method_node_info(
5280 bt_service_introspection_xml);
5281 ret_if(node_info == NULL);
5283 __bt_service_register_object(connection, node_info, TRUE);
5284 g_dbus_node_info_unref(node_info);
5286 bt_service_conn = connection;
5289 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5290 const gchar *name, gpointer user_data)
5292 BT_INFO("name acquired");
5293 name_acquired = TRUE;
5296 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5297 const gchar *name, gpointer user_data)
5299 BT_INFO("name lost");
5300 name_acquired = FALSE;
5303 gboolean _is_name_acquired(void)
5305 return name_acquired;
5308 void _bt_service_unref_connection(void)
5312 if (bt_service_conn) {
5313 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5314 g_object_unref(bt_service_conn);
5315 bt_service_conn = NULL;
5321 int _bt_service_register(void)
5323 GDBusConnection *conn;
5326 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5327 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5328 bt_service_conn = conn;
5330 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5332 G_BUS_NAME_OWNER_FLAGS_NONE,
5333 __bt_service_bus_acquired_handler,
5334 __bt_service_name_acquired_handler,
5335 __bt_service_name_lost_handler,
5337 BT_DBG("owner_id is [%d]", owner_id);
5341 /* Subscribe for name owner changed signal */
5342 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5343 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5344 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5345 __name_owner_changed, NULL, NULL);
5346 BT_INFO("owner_sig_id: %d", owner_sig_id);
5348 return BLUETOOTH_ERROR_NONE;
5351 if (bt_service_conn) {
5352 g_object_unref(bt_service_conn);
5353 bt_service_conn = NULL;
5356 return BLUETOOTH_ERROR_INTERNAL;
5359 void _bt_service_unregister(void)
5361 if (bt_service_conn) {
5362 sd_notify(0, "STOPPING=1");
5364 if (owner_sig_id > 0) {
5365 g_dbus_connection_signal_unsubscribe(
5366 bt_service_conn, owner_sig_id);
5371 g_bus_unown_name(owner_id);
5375 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5379 int _bt_service_cynara_init(void)
5382 char err_msg[256] = {0, };
5384 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5386 result = cynara_initialize(&p_cynara, conf);
5388 if (result != CYNARA_API_SUCCESS) {
5389 cynara_strerror(result, err_msg, sizeof(err_msg));
5390 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5391 return BLUETOOTH_ERROR_INTERNAL;
5394 return BLUETOOTH_ERROR_NONE;
5397 void _bt_service_cynara_deinit(void)
5400 char err_msg[256] = {0, };
5402 ret_if(p_cynara == NULL);
5404 result = cynara_finish(p_cynara);
5406 if (result != CYNARA_API_SUCCESS) {
5407 cynara_strerror(result, err_msg, sizeof(err_msg));
5408 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5416 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5417 GArray *out_param, int result)
5421 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5422 out_param->data, out_param->len, TRUE, NULL, NULL);
5424 g_dbus_method_invocation_return_value(invocation,
5425 g_variant_new("(iv)", result, out_var));
5428 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5429 GArray *out_param, int result, GUnixFDList *fd_list)
5433 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5434 out_param->data, out_param->len, TRUE, NULL, NULL);
5436 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5437 g_variant_new("(iv)", result, out_var), fd_list);