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"
49 #include "bt-service-mesh-model.h"
51 #ifdef TIZEN_FEATURE_BT_DPM
52 #include "bt-service-dpm.h"
54 #include "bt-service-hidhost.h"
55 #include "bt-service-rfcomm.h"
56 #include "bt-service-hdp.h"
59 #include "bt-service-obex-server.h"
60 #include "bt-service-opp-client.h"
61 #include "bt-service-map-client.h"
62 #include "bt-service-pbap.h"
63 #include "bt-service-oob.h"
65 #include "bt-service-battery-monitor.h"
67 #ifdef TIZEN_FEATURE_BT_PAN_NAP
68 #include "bt-service-network.h"
71 #ifdef TIZEN_FEATURE_BT_IPSP
72 #include "bt-service-ipsp.h"
74 /* For maintaining Application Sync API call requests */
75 GSList *invocation_list = NULL;
77 static GDBusConnection *bt_service_conn;
78 static guint owner_id = 0;
79 static guint owner_sig_id = 0;
80 static gboolean is_le_intended = FALSE;
82 static cynara *p_cynara;
83 static cynara_configuration *conf;
84 const char *requester_unique_creds = NULL;
86 static const gchar bt_service_introspection_xml[] =
87 "<node name='/org/projectx/bt_service'>"
88 " <interface name='org.projectx.bt'>"
89 " <method name='service_request'>"
90 /* Input Parameters */
91 " <arg type='i' name='service_type' direction='in' />"
92 " <arg type='i' name='service_function' direction='in' />"
93 " <arg type='i' name='request_type' direction='in' />"
94 " <arg type='ay' name='input_param1' direction='in' />"
95 " <arg type='ay' name='input_param2' direction='in' />"
96 " <arg type='ay' name='input_param3' direction='in' />"
97 " <arg type='ay' name='input_param4' direction='in' />"
98 " <arg type='ay' name='input_param5' direction='in' />"
99 /* Return Parameters */
100 " <arg type='i' name='output_param1' direction='out' />"
101 " <arg type='v' name='output_param2' direction='out' />"
103 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
104 " <method name='get_avc_mode'>"
106 " <arg type='u' name='avc_mode' direction='out' />"
112 static gboolean name_acquired = FALSE;
114 static char *current_sender_playing = NULL;
116 GDBusNodeInfo *node_info_g = NULL;
118 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
120 static void __bt_service_method(GDBusConnection *connection,
122 const gchar *object_path,
123 const gchar *interface_name,
124 const gchar *method_name,
125 GVariant *parameters,
126 GDBusMethodInvocation *invocation,
129 int __bt_bluez_request(int function_name,
132 GDBusMethodInvocation *context,
137 GArray **out_param1);
138 int __bt_obexd_request(int function_name,
141 GDBusMethodInvocation *context,
146 GArray **out_param1);
147 int __bt_agent_request(int function_name,
150 GDBusMethodInvocation *context,
155 GArray **out_param1);
156 int __bt_core_request(int function_name,
159 GDBusMethodInvocation *context,
160 GVariant *in_param1);
162 gboolean __bt_service_check_privilege(int function_name,
164 const char *unique_name);
166 /* Function definitions*/
167 GSList *_bt_get_invocation_list(void)
169 return invocation_list;
172 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
174 ret_if(NULL == req_info);
175 invocation_list = g_slist_remove(invocation_list, req_info);
176 g_free(req_info->sender);
177 g_free(req_info->user_data);
181 void _bt_set_le_intended_status(gboolean value)
183 is_le_intended = value;
186 static void __bt_service_get_parameters(GVariant *in_param,
187 void *value, int size)
190 buf = (void *)g_variant_get_data(in_param);
191 memcpy(value, buf, size);
194 static gboolean __bt_is_sync_function(int service_function)
196 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
197 if (service_function == BT_GET_LOCAL_ADDRESS
198 || service_function == BT_GET_LOCAL_NAME
199 || service_function == BT_GET_LOCAL_VERSION
200 || service_function == BT_GET_BONDED_DEVICES
201 || service_function == BT_GET_BONDED_DEVICE
202 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
203 || service_function == BT_GET_IS_ALIAS_SET
204 || service_function == BT_GET_CONNECTED_LINK_TYPE
205 || service_function == BT_IS_SERVICE_USED
206 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
207 || service_function == BT_RFCOMM_LISTEN
208 || service_function == BT_HDP_REGISTER_SINK_APP
209 || service_function == BT_HDP_UNREGISTER_SINK_APP
210 || service_function == BT_HDP_GET_FD
211 || service_function == BT_AVRCP_GET_TRACK_INFO
212 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
213 || service_function == BT_SET_ADVERTISING_DATA
214 || service_function == BT_SET_SCAN_RESPONSE_DATA
215 || service_function == BT_SET_ADVERTISING
216 || service_function == BT_SET_CUSTOM_ADVERTISING
217 || service_function == BT_GATT_SERVER_REGISTER
218 || service_function == BT_GATT_SERVER_ADD_SERVICE
219 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
220 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
221 || service_function == BT_GATT_SERVER_START_SERVICE
222 || service_function == BT_GATT_SERVER_STOP_SERVICE
223 || service_function == BT_GATT_SERVER_DELETE_SERVICE
224 || service_function == BT_START_LE_DISCOVERY
225 || service_function == BT_STOP_LE_DISCOVERY
226 || service_function == BT_GET_CONNECTABLE
227 #ifdef TIZEN_GATT_CLIENT
228 || service_function == BT_GATT_CLIENT_REGISTER
229 || service_function == BT_GATT_GET_PRIMARY_SERVICES
230 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
231 || service_function == BT_GATT_GET_INCLUDED_SERVICES
232 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
233 || service_function == BT_GATT_WATCH_CHARACTERISTIC
234 || service_function == BT_GATT_ACQUIRE_WRITE
236 || service_function == BT_AUDIO_SELECT_ROLE
238 || service_function == BT_MESH_NETWORK_CREATE
239 || service_function == BT_MESH_NETWORK_LOAD
240 || service_function == BT_MESH_NETWORK_SCAN
241 || service_function == BT_MESH_NETWORK_ADD_NETKEY
242 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
243 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
244 || service_function == BT_MESH_NETWORK_ADD_APPKEY
245 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
246 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
252 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
253 char *sender, int service_function,
254 gpointer invocation_data)
256 invocation_info_t *info;
257 info = g_malloc0(sizeof(invocation_info_t));
258 info->context = invocation;
259 info->result = result;
260 info->sender = g_strdup(sender);
261 info->service_function = service_function;
262 info->user_data = invocation_data;
263 invocation_list = g_slist_append(invocation_list, info);
267 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
270 char err_msg[256] = {0, };
272 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
274 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
275 if (ret != CYNARA_API_SUCCESS) {
276 cynara_strerror(ret, err_msg, sizeof(err_msg));
277 BT_ERR("Fail to get user credential: %s", err_msg);
279 return BLUETOOTH_ERROR_INTERNAL;
282 return BLUETOOTH_ERROR_NONE;
285 static int __bt_bm_request_data(_bt_battery_data_t *latest)
287 int ret = _bt_bm_read_data(latest);
288 if (ret == BLUETOOTH_ERROR_NONE) {
289 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
290 latest->session_start_time, latest->session_end_time,
291 latest->session_scan_time, latest->session_connected_time);
293 if (latest->atm_list == NULL) {
294 BT_DBG("No app data transaction for this session");
298 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
299 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
300 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
304 BT_ERR("Error encountered");
308 static void __bt_service_method(GDBusConnection *connection,
310 const gchar *object_path,
311 const gchar *interface_name,
312 const gchar *method_name,
313 GVariant *parameters,
314 GDBusMethodInvocation *invocation,
319 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
320 method_name, object_path, interface_name);
322 if (g_strcmp0(method_name, "service_request") == 0) {
324 int service_function;
326 GVariant *param1 = NULL;
327 GVariant *param2 = NULL;
328 GVariant *param3 = NULL;
329 GVariant *param4 = NULL;
330 GVariant *param5 = NULL;
331 GArray *out_param1 = NULL;
332 GVariant *out_var = NULL;
333 GVariant *temp = NULL;
337 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
338 &service_function, &request_type,
339 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
341 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
343 if (service_type == BT_CORE_SERVICE) {
344 BT_DBG("No need to check privilege from bt-core");
345 } else if (__bt_service_check_privilege(service_function,
346 service_type, (const char *)sender) == FALSE) {
347 BT_ERR("Client don't have the privilege to excute this function");
348 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
352 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
353 service_type, service_function);
354 switch (service_type) {
355 case BT_BLUEZ_SERVICE:
356 result = __bt_bluez_request(service_function,
357 request_type, request_id,
358 invocation, param1, param2,
359 param3, param4, &out_param1);
361 case BT_OBEX_SERVICE:
362 result = __bt_obexd_request(service_function,
363 request_type, request_id,
366 param4, &out_param1);
368 case BT_AGENT_SERVICE:
369 result = __bt_agent_request(service_function,
370 request_type, request_id,
373 param4, &out_param1);
375 case BT_CORE_SERVICE:
376 result = __bt_core_request(service_function,
377 request_type, request_id,
380 case BT_CHECK_PRIVILEGE:
381 result = BLUETOOTH_ERROR_NONE;
384 BT_ERR("Unknown service type");
385 result = BLUETOOTH_ERROR_INTERNAL;
389 if (result != BLUETOOTH_ERROR_NONE)
392 if (service_type == BT_CHECK_PRIVILEGE)
395 if (service_function == BT_OPP_PUSH_FILES)
398 if (request_type == BT_ASYNC_REQ ||
399 __bt_is_sync_function(service_function)) {
400 /* Do not send reply to bt-api over dbus,
401 Invocation context is already saved in service_function */
406 out_var = g_variant_new_from_data((const GVariantType *)"ay",
407 out_param1->data, out_param1->len,
410 temp = g_variant_new("(iv)", result, out_var);
411 g_dbus_method_invocation_return_value(invocation, temp);
412 g_array_free(out_param1, TRUE);
416 g_variant_unref(param1);
417 g_variant_unref(param2);
418 g_variant_unref(param3);
419 g_variant_unref(param4);
420 g_variant_unref(param5);
424 BT_ERR_C("Request is failed [%s] [0x%x]",
425 _bt_convert_error_to_string(result), result);
427 out_var = g_variant_new_from_data((const GVariantType *)"ay",
428 out_param1->data, out_param1->len,
431 temp = g_variant_new("(iv)", result, out_var);
432 g_dbus_method_invocation_return_value(invocation, temp);
434 g_array_free(out_param1, TRUE);
437 g_variant_unref(param1);
438 g_variant_unref(param2);
439 g_variant_unref(param3);
440 g_variant_unref(param4);
441 g_variant_unref(param5);
443 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
444 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
445 unsigned int mode = 0;
447 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
448 BT_ERR("Fail to get the avc mode");
450 BT_DBG("Absolute Volume Control mode: %d", mode);
452 g_dbus_method_invocation_return_value(invocation,
453 g_variant_new("(u)", mode));
462 static const GDBusInterfaceVTable method_table = {
469 int __bt_bluez_request(int function_name,
472 GDBusMethodInvocation *context,
479 int result = BLUETOOTH_ERROR_NONE;
482 switch (function_name) {
483 case BT_ENABLE_ADAPTER: {
484 result = _bt_enable_adapter();
485 _bt_adapter_start_enable_timer();
488 case BT_DISABLE_ADAPTER: {
489 result = _bt_disable_adapter();
492 case BT_RECOVER_ADAPTER:
493 result = _bt_recover_adapter();
495 case BT_RESET_ADAPTER:
496 result = _bt_reset_adapter();
498 case BT_BATTERY_READ_DATA: {
499 _bt_battery_data_t *data = NULL;
500 data = g_malloc0(sizeof(_bt_battery_data_t));
501 result = __bt_bm_request_data(data);
503 bt_battery_dbus_data_t dbus_data;
504 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
505 dbus_data.session_start_time = data->session_start_time;
506 dbus_data.session_end_time = data->session_end_time;
507 dbus_data.session_scan_time = data->session_scan_time;
508 dbus_data.session_connected_time = data->session_connected_time;
509 dbus_data.tx_time = data->tx_time;
510 dbus_data.rx_time = data->rx_time;
511 dbus_data.idle_time = data->idle_time;
513 /*Populating app data*/
515 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
516 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
517 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
520 dbus_data.num_app = n;
521 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
522 g_slist_free_full(data->atm_list, g_free);
527 case BT_CHECK_ADAPTER: {
528 int enabled = BT_ADAPTER_DISABLED;
529 result = _bt_check_adapter(&enabled);
531 g_array_append_vals(*out_param1, &enabled,
535 case BT_ENABLE_ADAPTER_LE:
536 _bt_set_le_intended_status(TRUE);
537 result = _bt_enable_adapter_le();
539 case BT_DISABLE_ADAPTER_LE:
540 _bt_set_le_intended_status(FALSE);
541 result = _bt_disable_adapter_le();
543 case BT_START_DISCOVERY: {
544 unsigned short max_response;
545 unsigned short discovery_duration;
546 unsigned int classOfDeviceMask;
549 __bt_service_get_parameters(in_param1,
550 &max_response, sizeof(unsigned short));
551 __bt_service_get_parameters(in_param2,
552 &discovery_duration, sizeof(unsigned short));
553 __bt_service_get_parameters(in_param3,
554 &classOfDeviceMask, sizeof(unsigned int));
555 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
557 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
559 if (result == BLUETOOTH_ERROR_NONE) {
562 sender = (char*)g_dbus_method_invocation_get_sender(context);
564 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
565 BT_ERR("Fail to get the sender pid");
567 BT_DBG("Remeber pid / uid for the scan operation");
568 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
573 case BT_START_CUSTOM_DISCOVERY: {
574 bt_discovery_role_type_t role;
576 __bt_service_get_parameters(in_param1,
577 &role, sizeof(bt_discovery_role_type_t));
578 result = _bt_start_custom_discovery(role);
582 case BT_CANCEL_DISCOVERY:
583 result = _bt_cancel_discovery();
585 case BT_IS_DISCOVERYING: {
586 gboolean discovering = FALSE;
587 discovering = _bt_is_discovering();
588 g_array_append_vals(*out_param1,
589 &discovering, sizeof(gboolean));
592 case BT_GET_LOCAL_ADDRESS: {
593 result = _bt_get_local_address();
595 /* Save invocation */
596 if (result == BLUETOOTH_ERROR_NONE) {
597 sender = (char*)g_dbus_method_invocation_get_sender(context);
598 _bt_save_invocation_context(context, result, sender,
599 function_name, NULL);
603 case BT_GET_LOCAL_VERSION: {
604 result = _bt_get_local_version();
606 /* Save invocation */
607 if (result == BLUETOOTH_ERROR_NONE) {
608 sender = (char*)g_dbus_method_invocation_get_sender(context);
609 _bt_save_invocation_context(context, result, sender,
610 function_name, NULL);
614 case BT_GET_LOCAL_NAME: {
615 result = _bt_get_local_name();
617 /* Save invocation */
618 if (result == BLUETOOTH_ERROR_NONE) {
619 sender = (char*)g_dbus_method_invocation_get_sender(context);
620 _bt_save_invocation_context(context, result, sender,
621 function_name, NULL);
625 case BT_SET_LOCAL_NAME: {
626 bluetooth_device_name_t local_name = { {0} };
627 __bt_service_get_parameters(in_param1,
628 &local_name, sizeof(bluetooth_device_name_t));
629 result = _bt_set_local_name(local_name.name);
632 case BT_GET_DISCOVERABLE_MODE: {
633 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
634 result = _bt_get_discoverable_mode(&discoverable_mode);
635 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
638 case BT_GET_DISCOVERABLE_TIME: {
641 result = _bt_get_timeout_value(&timeout);
642 g_array_append_vals(*out_param1, &timeout, sizeof(int));
645 case BT_SET_DISCOVERABLE_MODE: {
646 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
649 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
650 __bt_service_get_parameters(in_param2, &time, sizeof(int));
652 result = _bt_set_discoverable_mode(mode, time);
655 case BT_IS_CONNECTABLE: {
656 gboolean is_connectable = FALSE;
658 is_connectable = _bt_is_connectable();
659 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
662 case BT_GET_CONNECTABLE: {
663 result = _bt_get_connectable();
665 /* Save invocation */
666 if (result == BLUETOOTH_ERROR_NONE) {
667 sender = (char*)g_dbus_method_invocation_get_sender(context);
668 _bt_save_invocation_context(context, result, sender,
669 function_name, NULL);
673 case BT_SET_CONNECTABLE: {
674 gboolean is_connectable;
676 __bt_service_get_parameters(in_param1,
677 &is_connectable, sizeof(gboolean));
678 result = _bt_set_connectable(is_connectable);
681 case BT_IS_SERVICE_USED: {
684 uuid = (char *)g_variant_get_data(in_param1);
685 BT_INFO("UUID to be searched [%s]", uuid);
686 result = _bt_is_service_used();
688 /* Save invocation */
689 if (result == BLUETOOTH_ERROR_NONE) {
690 sender = (char*)g_dbus_method_invocation_get_sender(context);
691 _bt_save_invocation_context(context, result, sender,
692 function_name, g_strdup(uuid));
696 case BT_GET_BONDED_DEVICES: {
697 result = _bt_get_bonded_devices();
698 /* Save invocation */
699 if (result == BLUETOOTH_ERROR_NONE) {
700 sender = (char*)g_dbus_method_invocation_get_sender(context);
701 _bt_save_invocation_context(context, result, sender,
702 function_name, NULL);
706 case BT_GET_BONDED_DEVICE: {
707 bluetooth_device_address_t address = { {0} };
709 __bt_service_get_parameters(in_param1,
710 &address, sizeof(bluetooth_device_address_t));
712 result = _bt_get_bonded_device_info(&address);
713 /* Save invocation */
714 if (result == BLUETOOTH_ERROR_NONE) {
715 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
717 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
721 _bt_convert_addr_type_to_string(addr, address.addr);
722 sender = (char*)g_dbus_method_invocation_get_sender(context);
723 _bt_save_invocation_context(context, result, sender,
724 function_name, addr);
728 case BT_GET_PROFILE_CONNECTED_DEVICES: {
730 uuid = (char *)g_variant_get_data(in_param1);
731 result = _bt_get_profile_connected_devices(uuid);
733 /* Save invocation */
734 if (result == BLUETOOTH_ERROR_NONE) {
735 sender = (char *)g_dbus_method_invocation_get_sender(context);
736 _bt_save_invocation_context(context, result, sender,
737 function_name, NULL);
742 bluetooth_device_address_t address = { {0} };
743 const char *local_name;
745 __bt_service_get_parameters(in_param1,
746 &address, sizeof(bluetooth_device_address_t));
747 local_name = (const char *)g_variant_get_data(in_param2);
749 result = _bt_set_alias(&address, local_name);
752 case BT_BOND_DEVICE: {
753 bluetooth_device_address_t address = { {0} };
755 __bt_service_get_parameters(in_param1,
756 &address, sizeof(bluetooth_device_address_t));
757 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
759 /* Save invocation */
760 if (result == BLUETOOTH_ERROR_NONE) {
761 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
762 _bt_convert_addr_type_to_string(addr, address.addr);
763 sender = (char*)g_dbus_method_invocation_get_sender(context);
764 _bt_save_invocation_context(context, result, sender,
765 function_name, (gpointer)addr);
767 bluetooth_device_info_t dev_info;
769 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
770 memcpy(&dev_info.device_address, &address,
771 sizeof(bluetooth_device_address_t));
772 g_array_append_vals(*out_param1, &dev_info,
773 sizeof(bluetooth_device_info_t));
777 case BT_BOND_DEVICE_BY_TYPE: {
778 bluetooth_device_address_t address = { {0} };
779 unsigned short conn_type = 0;
781 __bt_service_get_parameters(in_param1,
782 &address, sizeof(bluetooth_device_address_t));
783 __bt_service_get_parameters(in_param2,
784 &conn_type, sizeof(unsigned short));
786 result = _bt_bond_device(&address, conn_type, out_param1);
787 /* Save invocation */
788 if (result == BLUETOOTH_ERROR_NONE) {
789 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
790 _bt_convert_addr_type_to_string(addr, address.addr);
791 sender = (char*)g_dbus_method_invocation_get_sender(context);
792 _bt_save_invocation_context(context, result, sender,
793 function_name, (gpointer)addr);
795 bluetooth_device_info_t dev_info;
797 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
798 memcpy(&dev_info.device_address, &address,
799 sizeof(bluetooth_device_address_t));
800 g_array_append_vals(*out_param1, &dev_info,
801 sizeof(bluetooth_device_info_t));
805 case BT_UNBOND_DEVICE: {
806 bluetooth_device_address_t address = { {0} };
808 __bt_service_get_parameters(in_param1,
809 &address, sizeof(bluetooth_device_address_t));
810 result = _bt_unbond_device(&address, out_param1);
812 /* Save invocation */
813 if (result == BLUETOOTH_ERROR_NONE) {
814 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
815 _bt_convert_addr_type_to_string(addr, address.addr);
816 sender = (char*)g_dbus_method_invocation_get_sender(context);
817 _bt_save_invocation_context(context, result, sender,
818 function_name, (gpointer)addr);
820 g_array_append_vals(*out_param1, &address,
821 sizeof(bluetooth_device_address_t));
825 case BT_CANCEL_BONDING:{
826 result = _bt_cancel_bonding();
829 case BT_SEARCH_SERVICE: {
830 bluetooth_device_address_t address = { {0} };
831 __bt_service_get_parameters(in_param1,
832 &address, sizeof(bluetooth_device_address_t));
833 result = _bt_search_device(&address);
834 /* Save invocation */
835 if (result == BLUETOOTH_ERROR_NONE) {
836 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
837 _bt_convert_addr_type_to_string(addr, address.addr);
838 sender = (char*)g_dbus_method_invocation_get_sender(context);
839 _bt_save_invocation_context(context, result, sender,
840 function_name, (gpointer)addr);
842 bt_sdp_info_t sdp_info;
844 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
845 memcpy(&sdp_info.device_addr, &address,
846 sizeof(bluetooth_device_address_t));
847 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
851 case BT_CANCEL_SEARCH_SERVICE: {
852 result = _bt_cancel_search_device();
855 case BT_SET_PASSKEY_NOTIFICATION: {
859 sender = (char *)g_dbus_method_invocation_get_sender(context);
860 __bt_service_get_parameters(in_param1,
861 &enable, sizeof(gboolean));
863 result = _bt_set_passkey_notification(sender, enable);
866 case BT_SET_PIN_CODE: {
867 bluetooth_device_address_t address = { {0} };
868 bluetooth_device_pin_code_t pin_code = { {0} };
870 __bt_service_get_parameters(in_param1,
871 &address, sizeof(bluetooth_device_address_t));
872 __bt_service_get_parameters(in_param2,
873 &pin_code, sizeof(bluetooth_device_pin_code_t));
875 result = _bt_set_pin_code(&address, &pin_code);
878 case BT_UNSET_PIN_CODE: {
879 bluetooth_device_address_t address = { {0} };
881 __bt_service_get_parameters(in_param1,
882 &address, sizeof(bluetooth_device_address_t));
884 result = _bt_unset_pin_code(&address);
887 case BT_PASSKEY_REPLY: {
888 const char *passkey = NULL;
889 gboolean authentication_reply = FALSE;
890 passkey = g_variant_get_data(in_param1);
891 __bt_service_get_parameters(in_param2,
892 &authentication_reply, sizeof(gboolean));
893 result = _bt_passkey_reply(passkey, authentication_reply);
896 case BT_PASSKEY_CONFIRMATION_REPLY: {
897 gboolean confirmation_reply = FALSE;
898 __bt_service_get_parameters(in_param1,
899 &confirmation_reply, sizeof(gboolean));
900 result = _bt_passkey_confirmation_reply(confirmation_reply);
903 case BT_GET_IS_ALIAS_SET: {
904 bluetooth_device_address_t address = { {0} };
906 __bt_service_get_parameters(in_param1,
907 &address, sizeof(bluetooth_device_address_t));
909 result = _bt_is_alias_set(&address);
910 if (result == BLUETOOTH_ERROR_NONE) {
911 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
913 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
917 _bt_convert_addr_type_to_string(addr, address.addr);
918 sender = (char*)g_dbus_method_invocation_get_sender(context);
919 _bt_save_invocation_context(context, result, sender,
920 function_name, addr);
924 case BT_SET_AUTHORIZATION: {
925 bluetooth_device_address_t address = { {0} };
927 __bt_service_get_parameters(in_param1,
928 &address, sizeof(bluetooth_device_address_t));
929 __bt_service_get_parameters(in_param2,
930 &authorize, sizeof(gboolean));
931 result = _bt_set_authorization(&address, authorize);
934 case BT_SET_LE_PRIVACY: {
935 gboolean set_privacy;
936 __bt_service_get_parameters(in_param1, &set_privacy,
938 result = _bt_set_le_privacy(set_privacy);
941 case BT_ADD_WHITE_LIST: {
942 bluetooth_device_address_t address = { {0} };
943 int address_type = 0;
945 __bt_service_get_parameters(in_param1,
946 &address, sizeof(bluetooth_device_address_t));
947 __bt_service_get_parameters(in_param2,
948 &address_type, sizeof(int));
949 result = _bt_set_white_list(&address, address_type, is_add);
952 case BT_REMOVE_WHITE_LIST: {
953 bluetooth_device_address_t address = { {0} };
954 int address_type = 0;
956 __bt_service_get_parameters(in_param1,
957 &address, sizeof(bluetooth_device_address_t));
958 __bt_service_get_parameters(in_param2,
959 &address_type, sizeof(int));
960 result = _bt_set_white_list(&address, address_type, is_add);
963 case BT_UPDATE_LE_CONNECTION_MODE: {
965 bluetooth_device_address_t remote_address = { { 0 } };
966 bluetooth_le_connection_param_t parameters = { 0 };
967 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
969 __bt_service_get_parameters(in_param1, &remote_address,
970 sizeof(bluetooth_device_address_t));
971 __bt_service_get_parameters(in_param2, &mode,
972 sizeof(bluetooth_le_connection_mode_t));
974 result = _bt_get_le_connection_parameter(mode, ¶meters);
975 if (result != BLUETOOTH_ERROR_NONE)
978 sender = (char *)g_dbus_method_invocation_get_sender(context);
980 result = _bt_le_connection_update(sender,
982 parameters.interval_min,
983 parameters.interval_max,
988 case BT_SET_MANUFACTURER_DATA: {
989 bluetooth_manufacturer_data_t m_data = { 0 };
990 __bt_service_get_parameters(in_param1,
991 &m_data, sizeof(bluetooth_manufacturer_data_t));
992 result = _bt_set_manufacturer_data(&m_data);
996 case BT_IS_DEVICE_CONNECTED: {
997 bluetooth_device_address_t address = { {0} };
998 gboolean connected = FALSE;
1001 __bt_service_get_parameters(in_param1,
1002 &address, sizeof(bluetooth_device_address_t));
1003 __bt_service_get_parameters(in_param2,
1004 &service_type, sizeof(int));
1006 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1007 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1008 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1010 connected = _bt_is_device_connected(&address, service_type);
1012 connected = _bt_is_device_connected(&address, service_type);
1014 BT_INFO("is_connected: %d", connected);
1015 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1018 case BT_GET_CONNECTED_LINK_TYPE: {
1019 bluetooth_device_address_t address = { {0} };
1021 __bt_service_get_parameters(in_param1,
1022 &address, sizeof(bluetooth_device_address_t));
1024 result = _bt_get_connected_link(&address);
1025 if (result == BLUETOOTH_ERROR_NONE) {
1026 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1028 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1032 _bt_convert_addr_type_to_string(addr, address.addr);
1033 sender = (char*)g_dbus_method_invocation_get_sender(context);
1034 _bt_save_invocation_context(context, result, sender,
1035 function_name, addr);
1039 case BT_IS_SCAN_FILTER_SUPPORTED:{
1040 int is_supported = 0;
1042 if (_bt_is_scan_filter_supported() == TRUE)
1045 g_array_append_vals(*out_param1,
1046 &is_supported, sizeof(int));
1050 case BT_ENABLE_RSSI: {
1051 bluetooth_device_address_t bd_addr;
1053 bt_rssi_threshold_t rssi_threshold;
1055 int in_range_threshold;
1058 BT_DBG("Enable RSSI");
1060 __bt_service_get_parameters(in_param1,
1061 &bd_addr, sizeof(bluetooth_device_address_t));
1062 __bt_service_get_parameters(in_param2,
1063 &link_type, sizeof(int));
1064 __bt_service_get_parameters(in_param3,
1065 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1067 low_threshold = rssi_threshold.low_threshold;
1068 in_range_threshold = rssi_threshold.in_range_threshold;
1069 high_threshold = rssi_threshold.high_threshold;
1071 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1072 in_range_threshold, high_threshold);
1077 bluetooth_device_address_t bd_addr;
1079 BT_DBG("Get RSSI Strength");
1081 __bt_service_get_parameters(in_param1,
1082 &bd_addr, sizeof(bluetooth_device_address_t));
1083 __bt_service_get_parameters(in_param2,
1084 &link_type, sizeof(int));
1086 result = _bt_get_rssi_strength(&bd_addr, link_type);
1089 case BT_SET_PROFILE_TRUSTED: {
1090 bluetooth_device_address_t bd_addr = { {0} };
1094 __bt_service_get_parameters(in_param1, &bd_addr,
1095 sizeof(bluetooth_device_address_t));
1096 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1097 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1099 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1102 case BT_GET_PROFILE_TRUSTED: {
1103 bluetooth_device_address_t bd_addr = { {0} };
1105 guint trusted_profile = 0;
1107 __bt_service_get_parameters(in_param1, &bd_addr,
1108 sizeof(bluetooth_device_address_t));
1109 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1111 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1112 BT_DBG("TRUST %d", trusted_profile);
1113 if (result == BLUETOOTH_ERROR_NONE) {
1114 g_array_append_vals(*out_param1, &trusted_profile,
1120 case BT_HID_CONNECT: {
1121 bluetooth_device_address_t address = { {0} };
1123 __bt_service_get_parameters(in_param1,
1124 &address, sizeof(bluetooth_device_address_t));
1126 result = _bt_hid_connect(&address);
1127 if (result != BLUETOOTH_ERROR_NONE) {
1128 g_array_append_vals(*out_param1, &address,
1129 sizeof(bluetooth_device_address_t));
1131 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1132 _bt_convert_addr_type_to_string(addr, address.addr);
1133 sender = (char*)g_dbus_method_invocation_get_sender(context);
1134 _bt_save_invocation_context(context, result, sender,
1135 function_name, (gpointer)addr);
1139 case BT_HID_DISCONNECT: {
1140 bluetooth_device_address_t address = { {0} };
1142 __bt_service_get_parameters(in_param1,
1143 &address, sizeof(bluetooth_device_address_t));
1145 result = _bt_hid_disconnect(&address);
1146 if (result != BLUETOOTH_ERROR_NONE) {
1147 g_array_append_vals(*out_param1, &address,
1148 sizeof(bluetooth_device_address_t));
1150 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1151 _bt_convert_addr_type_to_string(addr, address.addr);
1152 sender = (char*)g_dbus_method_invocation_get_sender(context);
1153 _bt_save_invocation_context(context, result, sender,
1154 function_name, (gpointer)addr);
1158 #ifdef TIZEN_FEATURE_BT_DPM
1159 case BT_DPM_SET_ALLOW_BT_MODE: {
1160 dpm_bt_allow_t value = DPM_BT_ERROR;
1162 __bt_service_get_parameters(in_param1, &value,
1165 result = _bt_dpm_set_allow_bluetooth_mode(value);
1168 case BT_DPM_GET_ALLOW_BT_MODE: {
1169 int value = DPM_BT_ERROR;
1171 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1172 g_array_append_vals(*out_param1, &value, sizeof(int));
1175 case BT_DPM_SET_DEVICE_RESTRITION: {
1176 dpm_status_t value = DPM_STATUS_ERROR;
1178 __bt_service_get_parameters(in_param1, &value,
1181 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1184 case BT_DPM_GET_DEVICE_RESTRITION: {
1185 int value = DPM_STATUS_ERROR;
1187 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1188 g_array_append_vals(*out_param1, &value, sizeof(int));
1191 case BT_DPM_SET_UUID_RESTRITION: {
1192 dpm_status_t value = DPM_STATUS_ERROR;
1194 __bt_service_get_parameters(in_param1, &value,
1197 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1200 case BT_DPM_GET_UUID_RESTRITION: {
1201 int value = DPM_STATUS_ERROR;
1203 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1204 g_array_append_vals(*out_param1, &value, sizeof(int));
1207 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1208 bluetooth_device_address_t address = { {0} };
1210 __bt_service_get_parameters(in_param1, &address,
1211 sizeof(bluetooth_device_address_t));
1213 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1216 case BT_DPM_ADD_DEVICES_WHITELIST: {
1217 bluetooth_device_address_t address = { {0} };
1219 __bt_service_get_parameters(in_param1, &address,
1220 sizeof(bluetooth_device_address_t));
1222 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1225 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1226 const char *uuid = NULL;
1228 uuid = g_variant_get_data(in_param1);
1230 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1233 case BT_DPM_ADD_UUIDS_WHITELIST: {
1234 const char *uuid = NULL;
1236 uuid = g_variant_get_data(in_param1);
1238 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1241 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1242 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1245 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1246 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1249 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1250 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1253 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1254 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1257 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1258 bluetooth_device_address_t address = { {0} };
1260 __bt_service_get_parameters(in_param1, &address,
1261 sizeof(bluetooth_device_address_t));
1263 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1266 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1267 bluetooth_device_address_t address = { {0} };
1269 __bt_service_get_parameters(in_param1, &address,
1270 sizeof(bluetooth_device_address_t));
1272 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1275 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1276 const char *uuid = NULL;
1278 uuid = g_variant_get_data(in_param1);
1280 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1283 case BT_DPM_REMOVE_UUID_WHITELIST: {
1284 const char *uuid = NULL;
1286 uuid = g_variant_get_data(in_param1);
1288 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1292 case BT_DPM_GET_DEVICES_BLACKLIST: {
1293 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1296 case BT_DPM_GET_DEVICES_WHITELIST: {
1297 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1300 case BT_DPM_GET_UUIDS_BLACKLIST: {
1301 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1304 case BT_DPM_GET_UUIDS_WHITELIST: {
1305 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1308 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1309 dpm_status_t value = DPM_STATUS_ERROR;
1311 __bt_service_get_parameters(in_param1, &value,
1314 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1318 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1319 int value = DPM_STATUS_ERROR;
1321 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1322 g_array_append_vals(*out_param1, &value, sizeof(int));
1325 case BT_DPM_SET_PAIRING_STATE: {
1326 dpm_status_t value = DPM_STATUS_ERROR;
1328 __bt_service_get_parameters(in_param1, &value,
1331 result = _bt_dpm_set_bluetooth_pairing_state(value);
1335 case BT_DPM_GET_PAIRING_STATE: {
1336 int value = DPM_STATUS_ERROR;
1338 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1339 g_array_append_vals(*out_param1, &value, sizeof(int));
1342 case BT_DPM_SET_PROFILE_STATE: {
1343 int value = DPM_STATUS_ERROR;
1344 int profile = DPM_PROFILE_NONE;
1346 __bt_service_get_parameters(in_param1, &profile,
1348 __bt_service_get_parameters(in_param2, &value,
1351 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1355 case BT_DPM_GET_PROFILE_STATE: {
1356 int value = DPM_STATUS_ERROR;
1357 int profile = DPM_PROFILE_NONE;
1359 __bt_service_get_parameters(in_param1, &profile,
1362 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1363 g_array_append_vals(*out_param1, &value, sizeof(int));
1366 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1367 int value = DPM_BT_ERROR;
1369 __bt_service_get_parameters(in_param1, &value,
1372 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1376 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1377 int value = DPM_STATUS_ERROR;
1379 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1380 g_array_append_vals(*out_param1, &value, sizeof(int));
1383 case BT_DPM_SET_DISCOVERABLE_STATE: {
1384 int value = DPM_STATUS_ERROR;
1386 __bt_service_get_parameters(in_param1, &value,
1389 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1393 case BT_DPM_GET_DISCOVERABLE_STATE: {
1394 int value = DPM_STATUS_ERROR;
1396 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1397 g_array_append_vals(*out_param1, &value, sizeof(int));
1400 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1401 int value = DPM_STATUS_ERROR;
1403 __bt_service_get_parameters(in_param1, &value,
1406 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1410 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1411 int value = DPM_STATUS_ERROR;
1413 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1414 g_array_append_vals(*out_param1, &value, sizeof(int));
1417 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1418 int value = DPM_STATUS_ERROR;
1420 __bt_service_get_parameters(in_param1, &value,
1423 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1427 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1428 int value = DPM_STATUS_ERROR;
1430 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1431 g_array_append_vals(*out_param1, &value, sizeof(int));
1435 case BT_RFCOMM_CLIENT_CONNECT: {
1436 bluetooth_device_address_t address = { {0} };
1440 __bt_service_get_parameters(in_param1,
1441 &address, sizeof(bluetooth_device_address_t));
1442 input_string = (char *)g_variant_get_data(in_param2);
1443 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1445 if (connect_type == BT_RFCOMM_UUID)
1446 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1448 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1450 if (result != BLUETOOTH_ERROR_NONE) {
1451 bluetooth_rfcomm_connection_t conn_info;
1453 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1454 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1455 if (connect_type == BT_RFCOMM_UUID)
1456 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1458 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1460 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1461 conn_info.socket_fd = -1;
1462 g_array_append_vals(*out_param1, &conn_info,
1463 sizeof(bluetooth_rfcomm_connection_t));
1465 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1466 _bt_convert_addr_type_to_string(addr, address.addr);
1467 sender = (char*)g_dbus_method_invocation_get_sender(context);
1468 _bt_save_invocation_context(context, result, sender, function_name, addr);
1472 case BT_RFCOMM_SOCKET_DISCONNECT: {
1474 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1475 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1477 result = BLUETOOTH_ERROR_NONE;
1480 case BT_RFCOMM_SOCKET_WRITE: {
1482 * This call to bt-service is only used for privilege check, so return
1483 * BLUETOOTH_ERROR_NONE from here.
1485 result = BLUETOOTH_ERROR_NONE;
1488 case BT_RFCOMM_CREATE_SOCKET: {
1490 * This call to bt-service is only used for privilege check, so return
1491 * BLUETOOTH_ERROR_NONE from here.
1493 result = BLUETOOTH_ERROR_NONE;
1496 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1500 sender = (char *)g_dbus_method_invocation_get_sender(context);
1501 uuid = (char *)g_variant_get_data(in_param1);
1503 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1505 result = BLUETOOTH_ERROR_NONE;
1506 _bt_save_invocation_context(context,
1507 result, sender, function_name, NULL);
1509 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1513 case BT_RFCOMM_LISTEN: {
1517 sender = (char *)g_dbus_method_invocation_get_sender(context);
1518 uuid = (char *)g_variant_get_data(in_param1);
1520 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1522 result = BLUETOOTH_ERROR_NONE;
1523 _bt_save_invocation_context(context,
1524 result, sender, function_name, NULL);
1526 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1530 case BT_RFCOMM_ACCEPT_CONNECTION: {
1533 address = (char *)g_variant_get_data(in_param1);
1534 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1537 case BT_RFCOMM_REJECT_CONNECTION: {
1540 address = (char *)g_variant_get_data(in_param1);
1541 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1544 case BT_RFCOMM_REMOVE_SOCKET: {
1546 * This call to bt-service is only used for privilege check, so return
1547 * BLUETOOTH_ERROR_NONE from here.
1549 result = BLUETOOTH_ERROR_NONE;
1552 case BT_RFCOMM_SEND_RX_DETAILS: {
1556 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1557 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1558 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1559 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1562 case BT_RFCOMM_SEND_TX_DETAILS: {
1566 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1567 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1568 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1569 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1572 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1573 gboolean connected = FALSE;
1575 int role = RFCOMM_ROLE_SERVER;
1577 sender = (char *)g_dbus_method_invocation_get_sender(context);
1579 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1580 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1581 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1583 if (connected == TRUE)
1584 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1586 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1590 case BT_AUDIO_SELECT_ROLE: {
1591 bluetooth_audio_role_t role;
1593 __bt_service_get_parameters(in_param1,
1594 &role, sizeof(bluetooth_audio_role_t));
1596 result = _bt_audio_select_role(role);
1597 if (result == BLUETOOTH_ERROR_NONE) {
1598 sender = (char*)g_dbus_method_invocation_get_sender(context);
1599 _bt_save_invocation_context(context, result, sender,
1600 function_name, NULL);
1604 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
1605 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1606 unsigned int volume = 0;
1608 __bt_service_get_parameters(in_param1,
1609 &volume, sizeof(unsigned int));
1611 result = _bt_audio_set_absolute_volume(volume);
1614 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1615 unsigned int volume = 0;
1617 result = _bt_audio_get_absolute_volume(&volume);
1618 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1621 case BT_AUDIO_IS_AVC_ACTIVATED: {
1624 result = _bt_audio_is_avc_activated(&activated);
1625 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1629 case BT_AV_CONNECT: {
1630 bluetooth_device_address_t address = { {0} };
1631 __bt_service_get_parameters(in_param1,
1632 &address, sizeof(bluetooth_device_address_t));
1634 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1636 if (result != BLUETOOTH_ERROR_NONE) {
1637 char addr[BT_ADDRESS_STRING_SIZE];
1638 _bt_convert_addr_type_to_string(addr, address.addr);
1639 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1641 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1642 _bt_convert_addr_type_to_string(addr, address.addr);
1643 sender = (char*)g_dbus_method_invocation_get_sender(context);
1644 _bt_save_invocation_context(context, result, sender,
1645 function_name, (gpointer)addr);
1649 case BT_AUDIO_CONNECT: {
1650 bluetooth_device_address_t address = { {0} };
1651 __bt_service_get_parameters(in_param1,
1652 &address, sizeof(bluetooth_device_address_t));
1654 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1656 if (result != BLUETOOTH_ERROR_NONE) {
1657 char addr[BT_ADDRESS_STRING_SIZE];
1658 _bt_convert_addr_type_to_string(addr, address.addr);
1659 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1661 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1662 _bt_convert_addr_type_to_string(addr, address.addr);
1663 sender = (char*)g_dbus_method_invocation_get_sender(context);
1664 _bt_save_invocation_context(context, result, sender,
1665 function_name, (gpointer)addr);
1669 case BT_AUDIO_DISCONNECT: {
1670 bluetooth_device_address_t address = { {0} };
1671 __bt_service_get_parameters(in_param1,
1672 &address, sizeof(bluetooth_device_address_t));
1674 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1676 if (result != BLUETOOTH_ERROR_NONE) {
1677 char addr[BT_ADDRESS_STRING_SIZE];
1678 _bt_convert_addr_type_to_string(addr, address.addr);
1679 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1681 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1682 _bt_convert_addr_type_to_string(addr, address.addr);
1683 sender = (char*)g_dbus_method_invocation_get_sender(context);
1684 _bt_save_invocation_context(context, result, sender,
1685 function_name, (gpointer)addr);
1689 case BT_AV_DISCONNECT: {
1690 bluetooth_device_address_t address = { {0} };
1691 __bt_service_get_parameters(in_param1,
1692 &address, sizeof(bluetooth_device_address_t));
1694 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1696 if (result != BLUETOOTH_ERROR_NONE) {
1697 char addr[BT_ADDRESS_STRING_SIZE];
1698 _bt_convert_addr_type_to_string(addr, address.addr);
1699 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1701 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1702 _bt_convert_addr_type_to_string(addr, address.addr);
1703 sender = (char*)g_dbus_method_invocation_get_sender(context);
1704 _bt_save_invocation_context(context, result, sender,
1705 function_name, (gpointer)addr);
1709 case BT_AG_CONNECT: {
1710 bluetooth_device_address_t address = { {0} };
1711 __bt_service_get_parameters(in_param1,
1712 &address, sizeof(bluetooth_device_address_t));
1714 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1716 if (result != BLUETOOTH_ERROR_NONE) {
1717 char addr[BT_ADDRESS_STRING_SIZE];
1718 _bt_convert_addr_type_to_string(addr, address.addr);
1719 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1721 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1722 _bt_convert_addr_type_to_string(addr, address.addr);
1723 sender = (char*)g_dbus_method_invocation_get_sender(context);
1724 _bt_save_invocation_context(context, result, sender,
1725 function_name, (gpointer)addr);
1729 case BT_AG_DISCONNECT: {
1730 bluetooth_device_address_t address = { {0} };
1732 __bt_service_get_parameters(in_param1,
1733 &address, sizeof(bluetooth_device_address_t));
1735 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1737 if (result != BLUETOOTH_ERROR_NONE) {
1738 char addr[BT_ADDRESS_STRING_SIZE];
1739 _bt_convert_addr_type_to_string(addr, address.addr);
1740 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1742 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1743 _bt_convert_addr_type_to_string(addr, address.addr);
1744 sender = (char*)g_dbus_method_invocation_get_sender(context);
1745 _bt_save_invocation_context(context, result, sender,
1746 function_name, (gpointer)addr);
1750 case BT_AV_SOURCE_CONNECT: {
1751 bluetooth_device_address_t address = { {0} };
1753 __bt_service_get_parameters(in_param1,
1754 &address, sizeof(bluetooth_device_address_t));
1756 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1757 if (result != BLUETOOTH_ERROR_NONE) {
1758 char addr[BT_ADDRESS_STRING_SIZE];
1759 _bt_convert_addr_type_to_string(addr, address.addr);
1760 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1762 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1763 _bt_convert_addr_type_to_string(addr, address.addr);
1764 sender = (char*)g_dbus_method_invocation_get_sender(context);
1765 _bt_save_invocation_context(context, result, sender,
1766 function_name, (gpointer)addr);
1770 case BT_AV_SOURCE_DISCONNECT: {
1771 bluetooth_device_address_t address = { {0} };
1773 __bt_service_get_parameters(in_param1,
1774 &address, sizeof(bluetooth_device_address_t));
1776 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1777 if (result != BLUETOOTH_ERROR_NONE) {
1778 char addr[BT_ADDRESS_STRING_SIZE];
1779 _bt_convert_addr_type_to_string(addr, address.addr);
1780 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1782 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1783 _bt_convert_addr_type_to_string(addr, address.addr);
1784 sender = (char*)g_dbus_method_invocation_get_sender(context);
1785 _bt_save_invocation_context(context, result, sender,
1786 function_name, (gpointer)addr);
1790 case BT_HF_CONNECT: {
1791 bluetooth_device_address_t address = { {0} };
1793 __bt_service_get_parameters(in_param1,
1794 &address, sizeof(bluetooth_device_address_t));
1796 result = _bt_hf_connect(&address);
1797 if (result != BLUETOOTH_ERROR_NONE) {
1798 char addr[BT_ADDRESS_STRING_SIZE];
1799 _bt_convert_addr_type_to_string(addr, address.addr);
1800 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1802 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1803 _bt_convert_addr_type_to_string(addr, address.addr);
1804 sender = (char*)g_dbus_method_invocation_get_sender(context);
1805 _bt_save_invocation_context(context, result, sender,
1806 function_name, (gpointer)addr);
1810 case BT_HF_DISCONNECT: {
1811 bluetooth_device_address_t address = { {0} };
1813 __bt_service_get_parameters(in_param1,
1814 &address, sizeof(bluetooth_device_address_t));
1816 result = _bt_hf_disconnect(&address);
1817 if (result != BLUETOOTH_ERROR_NONE) {
1818 char addr[BT_ADDRESS_STRING_SIZE];
1819 _bt_convert_addr_type_to_string(addr, address.addr);
1820 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1822 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1823 _bt_convert_addr_type_to_string(addr, address.addr);
1824 sender = (char*)g_dbus_method_invocation_get_sender(context);
1825 _bt_save_invocation_context(context, result, sender,
1826 function_name, (gpointer)addr);
1830 case BT_AVRCP_TARGET_CONNECT: {
1831 bluetooth_device_address_t address = { {0} };
1833 __bt_service_get_parameters(in_param1,
1834 &address, sizeof(bluetooth_device_address_t));
1836 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1837 if (result != BLUETOOTH_ERROR_NONE) {
1838 char addr[BT_ADDRESS_STRING_SIZE];
1839 _bt_convert_addr_type_to_string(addr, address.addr);
1840 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1842 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1843 _bt_convert_addr_type_to_string(addr, address.addr);
1844 sender = (char*)g_dbus_method_invocation_get_sender(context);
1845 _bt_save_invocation_context(context, result, sender,
1846 function_name, (gpointer)addr);
1850 case BT_AVRCP_TARGET_DISCONNECT: {
1851 bluetooth_device_address_t address = { {0} };
1853 __bt_service_get_parameters(in_param1,
1854 &address, sizeof(bluetooth_device_address_t));
1856 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1857 if (result != BLUETOOTH_ERROR_NONE) {
1858 char addr[BT_ADDRESS_STRING_SIZE];
1859 _bt_convert_addr_type_to_string(addr, address.addr);
1860 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1862 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1863 _bt_convert_addr_type_to_string(addr, address.addr);
1864 sender = (char*)g_dbus_method_invocation_get_sender(context);
1865 _bt_save_invocation_context(context, result, sender,
1866 function_name, (gpointer)addr);
1870 case BT_AVRCP_CONTROL_CONNECT: {
1871 bluetooth_device_address_t address = { {0} };
1873 __bt_service_get_parameters(in_param1,
1874 &address, sizeof(bluetooth_device_address_t));
1876 result = _bt_audio_connect(BT_AVRCP, &address);
1877 if (result != BLUETOOTH_ERROR_NONE) {
1878 char addr[BT_ADDRESS_STRING_SIZE];
1879 _bt_convert_addr_type_to_string(addr, address.addr);
1880 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1882 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1883 _bt_convert_addr_type_to_string(addr, address.addr);
1884 sender = (char*)g_dbus_method_invocation_get_sender(context);
1885 _bt_save_invocation_context(context, result, sender,
1886 function_name, (gpointer)addr);
1890 case BT_AVRCP_CONTROL_DISCONNECT: {
1891 bluetooth_device_address_t address = { {0} };
1893 __bt_service_get_parameters(in_param1,
1894 &address, sizeof(bluetooth_device_address_t));
1896 result = _bt_audio_disconnect(BT_AVRCP, &address);
1897 if (result != BLUETOOTH_ERROR_NONE) {
1898 char addr[BT_ADDRESS_STRING_SIZE];
1899 _bt_convert_addr_type_to_string(addr, address.addr);
1900 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1902 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1903 _bt_convert_addr_type_to_string(addr, address.addr);
1904 sender = (char*)g_dbus_method_invocation_get_sender(context);
1905 _bt_save_invocation_context(context, result, sender,
1906 function_name, (gpointer)addr);
1910 case BT_AVRCP_HANDLE_CONTROL: {
1912 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1913 result = _bt_avrcp_control_cmd(key_code);
1916 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1918 bluetooth_device_address_t address = { { 0 } };
1920 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1921 __bt_service_get_parameters(in_param2,
1922 &address, sizeof(bluetooth_device_address_t));
1924 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1927 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1931 __bt_service_get_parameters(in_param1,
1932 &type, sizeof(int));
1933 __bt_service_get_parameters(in_param2,
1934 &value, sizeof(unsigned int));
1936 result = _bt_avrcp_control_set_property(type, value);
1939 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1944 __bt_service_get_parameters(in_param1,
1945 &type, sizeof(int));
1946 __bt_service_get_parameters(in_param2,
1947 &value, sizeof(unsigned int));
1949 result = _bt_avrcp_transport_set_property(type, value);
1953 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1956 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1958 result = _bt_avrcp_control_get_property(type);
1959 /* Save invocation */
1960 if (result == BLUETOOTH_ERROR_NONE) {
1961 sender = (char*)g_dbus_method_invocation_get_sender(context);
1962 _bt_save_invocation_context(context, result, sender,
1963 function_name, g_memdup(&type, sizeof(int)));
1967 case BT_AVRCP_GET_TRACK_INFO: {
1968 result = _bt_avrcp_control_get_track_info();
1969 /* Save invocation */
1970 if (result == BLUETOOTH_ERROR_NONE) {
1971 sender = (char*)g_dbus_method_invocation_get_sender(context);
1972 _bt_save_invocation_context(context, result, sender,
1973 function_name, NULL);
1977 case BT_HDP_REGISTER_SINK_APP: {
1978 unsigned short data_type;
1979 bt_hdp_role_type_t role;
1980 bt_hdp_qos_type_t channel_type;
1981 int *app_id = g_new0(int, 1);
1983 __bt_service_get_parameters(in_param1,
1984 &data_type, sizeof(short));
1985 __bt_service_get_parameters(in_param2,
1986 &role, sizeof(bt_hdp_role_type_t));
1987 __bt_service_get_parameters(in_param3,
1988 &channel_type, sizeof(bt_hdp_qos_type_t));
1989 sender = (char*)g_dbus_method_invocation_get_sender(context);
1991 result = _bt_hdp_app_register(role,
1992 channel_type, data_type, sender, app_id);
1993 if (result != BLUETOOTH_ERROR_NONE) {
1994 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1997 _bt_save_invocation_context(context, result, sender,
1998 function_name, (gpointer)app_id);
2002 case BT_HDP_UNREGISTER_SINK_APP: {
2004 int *app_id = g_new0(int, 1);
2006 app_handle = (char *)g_variant_get_data(in_param1);
2007 sscanf(app_handle, "health_app_%d", app_id);
2008 result = _bt_hdp_app_unregister(*app_id);
2009 if (result != BLUETOOTH_ERROR_NONE) {
2012 sender = (char*)g_dbus_method_invocation_get_sender(context);
2013 _bt_save_invocation_context(context, result, sender,
2014 function_name, (gpointer)app_id);
2018 case BT_HDP_CONNECT: {
2022 bt_hdp_connected_t *conn_info = NULL;
2024 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2026 app_handle = (char *)g_variant_get_data(in_param1);
2027 conn_info->app_handle = app_handle;
2028 sscanf(app_handle, "health_app_%d", &app_id);
2030 __bt_service_get_parameters(in_param2,
2031 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2032 __bt_service_get_parameters(in_param3,
2033 &(conn_info->device_address),
2034 sizeof(bluetooth_device_address_t));
2036 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2037 conn_info->type, (int *)(&(conn_info->channel_id)));
2038 if (result != BLUETOOTH_ERROR_NONE) {
2039 g_array_append_vals(*out_param1, conn_info,
2040 sizeof(bt_hdp_connected_t));
2043 sender = (char*)g_dbus_method_invocation_get_sender(context);
2044 _bt_save_invocation_context(context, result, sender,
2045 function_name, (gpointer)conn_info);
2049 case BT_HDP_DISCONNECT: {
2050 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2052 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2054 __bt_service_get_parameters(in_param1,
2055 &(hdp_disconn_info->channel_id), sizeof(int));
2056 __bt_service_get_parameters(in_param2,
2057 &(hdp_disconn_info->device_address),
2058 sizeof(bluetooth_device_address_t));
2060 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2061 if (result != BLUETOOTH_ERROR_NONE) {
2062 g_array_append_vals(*out_param1, hdp_disconn_info,
2063 sizeof(bt_hdp_disconnected_t));
2064 g_free(hdp_disconn_info);
2066 sender = (char*)g_dbus_method_invocation_get_sender(context);
2067 _bt_save_invocation_context(context, result, sender,
2068 function_name, (gpointer)hdp_disconn_info);
2072 case BT_HDP_GET_FD: {
2073 int *channel_id = g_new0(int, 1);
2075 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2077 result = _bt_hdp_get_fd(*channel_id);
2078 if (result != BLUETOOTH_ERROR_NONE) {
2081 sender = (char*)g_dbus_method_invocation_get_sender(context);
2082 _bt_save_invocation_context(context, result, sender,
2083 function_name, (gpointer)channel_id);
2087 case BT_HDP_SEND_DATA: {
2089 * This call to bt-service is only used for privilege check, so return
2090 * BLUETOOTH_ERROR_NONE from here.
2092 result = BLUETOOTH_ERROR_NONE;
2095 case BT_OOB_READ_LOCAL_DATA: { //208
2096 bt_oob_data_t local_oob_data;
2098 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2099 result = _bt_oob_read_local_data(&local_oob_data);
2101 g_array_append_vals(*out_param1, &local_oob_data,
2102 sizeof(bt_oob_data_t));
2106 case BT_OOB_ADD_REMOTE_DATA: { //209
2107 bluetooth_device_address_t address = { {0} };
2108 unsigned short address_type;
2109 bt_oob_data_t remote_oob_data;
2111 __bt_service_get_parameters(in_param1,
2112 &address, sizeof(bluetooth_device_address_t));
2113 __bt_service_get_parameters(in_param2,
2114 &address_type, sizeof(unsigned short));
2115 __bt_service_get_parameters(in_param3,
2116 &remote_oob_data, sizeof(bt_oob_data_t));
2118 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2122 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2123 bluetooth_device_address_t address = { {0} };
2125 __bt_service_get_parameters(in_param1,
2126 &address, sizeof(bluetooth_device_address_t));
2128 result = _bt_oob_remove_remote_data(&address);
2132 case BT_LE_OOB_READ_LOCAL_DATA: {
2133 bt_oob_data_t local_oob_data;
2134 bt_oob_data_t *local_oob_cache_data;
2136 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2137 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2138 g_array_append_vals(*out_param1, local_oob_cache_data,
2139 sizeof(bt_oob_data_t));
2140 return BLUETOOTH_ERROR_NONE;
2143 /* We should modify this logic in later */
2144 if (_bt_is_le_static_random_address_enabled() == false) {
2145 /* Seperate BT & LE address */
2146 _bt_set_le_static_random_address(TRUE);
2149 result = _bt_le_oob_read_local_data(&local_oob_data);
2150 _bt_le_oob_set_local_cache_data(&local_oob_data);
2152 g_array_append_vals(*out_param1, &local_oob_data,
2153 sizeof(bt_oob_data_t));
2157 case BT_LE_OOB_ADD_REMOTE_DATA: {
2158 bluetooth_device_address_t address = { {0} };
2159 unsigned short address_type;
2160 bt_oob_data_t remote_oob_data;
2162 __bt_service_get_parameters(in_param1,
2163 &address, sizeof(bluetooth_device_address_t));
2164 __bt_service_get_parameters(in_param2,
2165 &address_type, sizeof(unsigned short));
2166 __bt_service_get_parameters(in_param3,
2167 &remote_oob_data, sizeof(bt_oob_data_t));
2169 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2173 case BT_AVRCP_SET_TRACK_INFO: {
2174 media_metadata_t data;
2175 media_metadata_attributes_t meta_data;
2177 memset(&data, 0x00, sizeof(media_metadata_t));
2178 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2180 __bt_service_get_parameters(in_param1,
2181 &data, sizeof(media_metadata_t));
2183 meta_data.title = g_strdup(data.title);
2184 meta_data.artist = g_strdup(data.artist);
2185 meta_data.album = g_strdup(data.album);
2186 meta_data.genre = g_strdup(data.genre);
2187 meta_data.total_tracks = data.total_tracks;
2188 meta_data.number = data.number;
2189 meta_data.duration = (int64_t) data.duration;
2191 result = _bt_avrcp_set_track_info(&meta_data);
2193 g_free((gpointer)meta_data.title);
2194 g_free((gpointer)meta_data.artist);
2195 g_free((gpointer)meta_data.album);
2196 g_free((gpointer)meta_data.genre);
2200 case BT_AVRCP_SET_PROPERTY: {
2204 sender = (char *)g_dbus_method_invocation_get_sender(context);
2206 __bt_service_get_parameters(in_param1,
2207 &type, sizeof(int));
2208 __bt_service_get_parameters(in_param2,
2209 &value, sizeof(unsigned int));
2211 if (value == STATUS_PLAYING) {
2212 if (current_sender_playing)
2213 g_free(current_sender_playing);
2214 current_sender_playing = g_strdup(sender);
2216 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2217 current_sender_playing == NULL) {
2218 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2220 BT_INFO("Current Player and this sender (%s) are different", sender);
2221 result = BLUETOOTH_ERROR_NONE;
2224 result = _bt_avrcp_set_property(type, value);
2228 case BT_AVRCP_SET_PROPERTIES: {
2229 media_player_settings_t properties;
2231 memset(&properties, 0x00, sizeof(media_player_settings_t));
2232 __bt_service_get_parameters(in_param1,
2233 &properties, sizeof(media_player_settings_t));
2235 result = _bt_avrcp_set_properties(&properties);
2239 case BT_SET_ADVERTISING_DATA: {
2242 bluetooth_advertising_data_t adv = { {0} };
2244 gboolean use_reserved_slot = FALSE;
2246 app = (char *)g_dbus_method_invocation_get_sender(context);
2247 adv_handle = g_malloc0(sizeof(int));
2249 __bt_service_get_parameters(in_param1,
2250 adv_handle, sizeof(int));
2251 __bt_service_get_parameters(in_param3,
2252 &length, sizeof(int));
2253 __bt_service_get_parameters(in_param2,
2255 __bt_service_get_parameters(in_param4,
2256 &use_reserved_slot, sizeof(gboolean));
2257 result = _bt_set_advertising_data(app, *adv_handle,
2258 &adv, length, use_reserved_slot);
2259 if (result != BLUETOOTH_ERROR_NONE) {
2260 BT_ERR("Set Advertising data failed!!");
2263 _bt_save_invocation_context(context, result, app,
2264 function_name, (gpointer)adv_handle);
2268 case BT_SET_SCAN_RESPONSE_DATA: {
2271 bluetooth_scan_resp_data_t rsp = { {0} };
2273 gboolean use_reserved_slot = FALSE;
2275 app = (char *)g_dbus_method_invocation_get_sender(context);
2276 adv_handle = g_malloc0(sizeof(int));
2278 __bt_service_get_parameters(in_param1,
2279 adv_handle, sizeof(int));
2280 __bt_service_get_parameters(in_param3,
2281 &length, sizeof(int));
2282 __bt_service_get_parameters(in_param2,
2284 __bt_service_get_parameters(in_param4,
2285 &use_reserved_slot, sizeof(gboolean));
2287 result = _bt_set_scan_response_data(app, *adv_handle,
2288 &rsp, length, use_reserved_slot);
2290 if (result != BLUETOOTH_ERROR_NONE) {
2291 BT_ERR("Set Scan Response Data failed!!");
2294 _bt_save_invocation_context(context, result, app,
2295 function_name, (gpointer)adv_handle);
2299 case BT_SET_ADVERTISING: {
2302 gboolean enable = FALSE;
2303 gboolean use_reserved_slot = FALSE;
2305 adv_handle = g_malloc0(sizeof(int));
2306 __bt_service_get_parameters(in_param1,
2307 adv_handle, sizeof(int));
2308 __bt_service_get_parameters(in_param2,
2309 &enable, sizeof(gboolean));
2310 __bt_service_get_parameters(in_param3,
2311 &use_reserved_slot, sizeof(gboolean));
2313 app = (char *)g_dbus_method_invocation_get_sender(context);
2315 result = _bt_set_advertising(app, *adv_handle,
2316 enable, use_reserved_slot);
2317 if (result != BLUETOOTH_ERROR_NONE) {
2318 BT_ERR("Start Advertising failed!!");
2321 _bt_save_invocation_context(context, result, app,
2322 function_name, (gpointer)adv_handle);
2326 case BT_SET_CUSTOM_ADVERTISING: {
2329 gboolean enable = FALSE;
2330 bluetooth_advertising_params_t adv_params;
2331 gboolean use_reserved_slot = FALSE;
2333 app = (char *)g_dbus_method_invocation_get_sender(context);
2334 adv_handle = g_malloc0(sizeof(int));
2336 __bt_service_get_parameters(in_param1, adv_handle,
2338 __bt_service_get_parameters(in_param2, &enable,
2340 __bt_service_get_parameters(in_param3, &adv_params,
2341 sizeof(bluetooth_advertising_params_t));
2342 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2345 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2346 adv_params.interval_min, adv_params.interval_max,
2347 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2348 result = _bt_set_custom_advertising(app, *adv_handle,
2349 enable, &adv_params, use_reserved_slot);
2350 if (result != BLUETOOTH_ERROR_NONE) {
2351 BT_ERR("Start Custom Advertising failed!!");
2354 _bt_save_invocation_context(context, result, app,
2355 function_name, (gpointer)adv_handle);
2359 case BT_GET_SCAN_RESPONSE_DATA: {
2360 bluetooth_scan_resp_data_t rsp = { {0} };
2364 app = (char *)g_dbus_method_invocation_get_sender(context);
2366 __bt_service_get_parameters(in_param1, &adv_handle,
2369 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2370 if (result == BLUETOOTH_ERROR_NONE)
2371 g_array_append_vals(*out_param1, rsp.data, length);
2375 case BT_GET_ADVERTISING_DATA: {
2376 bluetooth_advertising_data_t adv = { {0} };
2380 app = (char *)g_dbus_method_invocation_get_sender(context);
2382 __bt_service_get_parameters(in_param1, &adv_handle,
2385 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2386 if (result == BLUETOOTH_ERROR_NONE)
2387 g_array_append_vals(*out_param1, adv.data, length);
2391 case BT_GATT_REGISTER_APPLICATION: {
2392 BT_DBG("Register GATT application:Unhandled!!");
2395 case BT_GATT_SERVER_REGISTER: {
2396 BT_DBG("GATT Server instance initialization");
2399 app = (char *)g_dbus_method_invocation_get_sender(context);
2400 BT_DBG("GATT Server Unique Name [%s]", app);
2402 /* No ADV handle: Set 0 */
2403 result = _bt_register_server_instance(app, 0);
2405 if (result != BLUETOOTH_ERROR_NONE) {
2406 BT_ERR("GATT Server registration failed. result %d", result);
2408 _bt_save_invocation_context(context, result, app,
2409 function_name, NULL);
2413 case BT_GATT_SERVER_DEREGISTER: {
2415 app = (char*)g_dbus_method_invocation_get_sender(context);
2417 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2420 case BT_GATT_SERVER_ADD_SERVICE: {
2421 BT_DBG("GATT Server Add Service");
2427 int *tmp_inst_id = NULL;
2429 app = (char *)g_dbus_method_invocation_get_sender(context);
2431 __bt_service_get_parameters(in_param1, &service_type,
2433 __bt_service_get_parameters(in_param2, &num_handles,
2435 svc_uuid = (char *)g_variant_get_data(in_param3);
2436 __bt_service_get_parameters(in_param4, &instance_id,
2439 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2440 if (result != BLUETOOTH_ERROR_NONE) {
2441 BT_ERR("GATT Server Add Service failed!!");
2443 tmp_inst_id = g_malloc0(sizeof(int));
2444 *tmp_inst_id = instance_id;
2445 _bt_save_invocation_context(context, result, app,
2446 function_name, (gpointer)tmp_inst_id);
2450 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2451 BT_DBG("GATT Server Add Characteristic");
2454 int *tmp_inst_id = NULL;
2455 bluetooth_gatt_server_attribute_params_t param;
2456 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2458 app = (char*)g_dbus_method_invocation_get_sender(context);
2460 __bt_service_get_parameters(in_param1, ¶m,
2461 sizeof(bluetooth_gatt_server_attribute_params_t));
2462 char_uuid = (char *)g_variant_get_data(in_param2);
2464 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2465 if (result != BLUETOOTH_ERROR_NONE) {
2466 BT_ERR("GATT Server Add Service failed!!");
2468 tmp_inst_id = g_malloc0(sizeof(int));
2469 *tmp_inst_id = param.instance_id;
2471 _bt_save_invocation_context(context, result, app,
2472 function_name, (gpointer)tmp_inst_id);
2476 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2477 BT_DBG("GATT Server Add Descriptor");
2481 bt_gatt_permission_t perm;
2483 int *tmp_inst_id = NULL;
2484 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2486 app = (char *)g_dbus_method_invocation_get_sender(context);
2488 __bt_service_get_parameters(in_param1, &service_handle,
2490 __bt_service_get_parameters(in_param2, &instance_id,
2492 desc_uuid = (char *)g_variant_get_data(in_param4);
2493 __bt_service_get_parameters(in_param3, &perm,
2494 sizeof(bt_gatt_permission_t));
2496 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2497 if (result != BLUETOOTH_ERROR_NONE) {
2498 BT_ERR("GATT Server Add Service failed!!");
2500 tmp_inst_id = g_malloc0(sizeof(int));
2501 *tmp_inst_id = instance_id;
2502 _bt_save_invocation_context(context, result, app,
2503 function_name, (gpointer)tmp_inst_id);
2507 case BT_GATT_SERVER_START_SERVICE: {
2512 int *tmp_inst_id = NULL;
2513 app = (char*)g_dbus_method_invocation_get_sender(context);
2515 __bt_service_get_parameters(in_param1, &service_handle,
2517 __bt_service_get_parameters(in_param2, &instance_id,
2520 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2522 if (BLUETOOTH_ERROR_NONE == result) {
2523 tmp_inst_id = g_malloc0(sizeof(int));
2524 *tmp_inst_id = instance_id;
2525 _bt_save_invocation_context(context, result, app,
2526 function_name, (gpointer)tmp_inst_id);
2530 case BT_GATT_SERVER_STOP_SERVICE: {
2534 int *tmp_inst_id = NULL;
2535 app = (char*)g_dbus_method_invocation_get_sender(context);
2537 __bt_service_get_parameters(in_param1, &service_handle,
2539 __bt_service_get_parameters(in_param2, &instance_id,
2542 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2544 if (BLUETOOTH_ERROR_NONE == result) {
2545 tmp_inst_id = g_malloc0(sizeof(int));
2546 *tmp_inst_id = instance_id;
2547 _bt_save_invocation_context(context, result, app,
2548 function_name, (gpointer)tmp_inst_id);
2552 case BT_GATT_SERVER_DELETE_SERVICE: {
2555 int *tmp_inst_id = NULL;
2557 app = (char*)g_dbus_method_invocation_get_sender(context);
2559 __bt_service_get_parameters(in_param1, &service_handle,
2561 __bt_service_get_parameters(in_param2, &instance_id,
2564 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2566 if (BLUETOOTH_ERROR_NONE == result) {
2567 tmp_inst_id = g_malloc0(sizeof(int));
2568 *tmp_inst_id = instance_id;
2569 _bt_save_invocation_context(context, result, app,
2570 function_name, (gpointer)tmp_inst_id);
2574 case BT_GATT_SERVER_SEND_RESPONSE: {
2575 bluetooth_gatt_server_response_params_t param;
2576 bluetooth_gatt_att_data_t data;
2579 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2580 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2582 app = (char*)g_dbus_method_invocation_get_sender(context);
2584 __bt_service_get_parameters(in_param1, &data,
2585 sizeof(bluetooth_gatt_att_data_t));
2586 __bt_service_get_parameters(in_param2, ¶m,
2587 sizeof(bluetooth_gatt_server_response_params_t));
2589 result = _bt_gatt_server_send_response(app, &data, ¶m);
2593 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2595 bluetooth_gatt_server_acquire_response_params_t param;
2598 msg = g_dbus_method_invocation_get_message(context);
2599 GUnixFDList *fd_list;
2604 fd_list = g_dbus_message_get_unix_fd_list(msg);
2606 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2608 app = (char*)g_dbus_method_invocation_get_sender(context);
2610 __bt_service_get_parameters(in_param1, ¶m,
2611 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2613 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2614 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2615 fd = fd_list_array[0];
2618 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2622 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2624 bluetooth_gatt_server_acquire_response_params_t param;
2627 msg = g_dbus_method_invocation_get_message(context);
2628 GUnixFDList *fd_list;
2633 fd_list = g_dbus_message_get_unix_fd_list(msg);
2635 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2637 app = (char*)g_dbus_method_invocation_get_sender(context);
2639 __bt_service_get_parameters(in_param1, ¶m,
2640 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2642 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2643 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2644 fd = fd_list_array[0];
2647 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2651 case BT_GATT_SERVER_SEND_INDICATION: {
2652 bluetooth_gatt_server_indication_params_t param;
2653 bluetooth_gatt_att_data_t data;
2654 bluetooth_device_address_t address;
2657 app = (char*)g_dbus_method_invocation_get_sender(context);
2659 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2660 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2661 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2663 __bt_service_get_parameters(in_param1, &data,
2664 sizeof(bluetooth_gatt_att_data_t));
2665 __bt_service_get_parameters(in_param2, ¶m,
2666 sizeof(bluetooth_gatt_server_indication_params_t));
2667 __bt_service_get_parameters(in_param3, &address,
2668 sizeof(bluetooth_device_address_t));
2670 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2674 case BT_GATT_SERVER_UPDATE_VALUE: {
2675 bluetooth_gatt_server_update_value_t param;
2679 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2681 app = (char*)g_dbus_method_invocation_get_sender(context);
2683 __bt_service_get_parameters(in_param1, &instance_id,
2685 __bt_service_get_parameters(in_param2, ¶m,
2686 sizeof(bluetooth_gatt_server_update_value_t));
2688 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2691 case BT_GET_ATT_MTU: {
2692 bluetooth_device_address_t address = { {0} };
2693 unsigned int mtu = 0;
2695 __bt_service_get_parameters(in_param1,
2696 &address, sizeof(bluetooth_device_address_t));
2697 result = _bt_get_att_mtu(&address, &mtu);
2698 BT_DBG("MTU: %d", mtu);
2700 if (result == BLUETOOTH_ERROR_NONE) {
2701 g_array_append_vals(*out_param1, &mtu,
2702 sizeof(unsigned int));
2706 case BT_REQ_ATT_MTU: {
2707 bluetooth_device_address_t address = { {0} };
2711 sender = (char*)g_dbus_method_invocation_get_sender(context);
2713 __bt_service_get_parameters(in_param1,
2714 &address, sizeof(bluetooth_device_address_t));
2715 __bt_service_get_parameters(in_param2,
2716 &mtu, sizeof(unsigned int));
2717 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2718 result = _bt_request_att_mtu(&address, mtu);
2719 if (BLUETOOTH_ERROR_NONE == result) {
2720 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2722 _bt_convert_addr_type_to_string(addr, address.addr);
2724 /* Save the informations to invocation */
2725 _bt_save_invocation_context(context, result, sender,
2726 function_name, (gpointer)addr);
2728 g_array_append_vals(*out_param1, &address,
2729 sizeof(bluetooth_device_address_t));
2733 case BT_GET_DEVICE_IDA: {
2734 bluetooth_device_address_t address = { {0} };
2735 bluetooth_device_address_t id_addr = { {0} };
2737 __bt_service_get_parameters(in_param1,
2738 &address, sizeof(bluetooth_device_address_t));
2740 result = _bt_device_get_ida(&address, &id_addr);
2742 if (result == BLUETOOTH_ERROR_NONE) {
2743 g_array_append_vals(*out_param1, &id_addr,
2744 sizeof(bluetooth_device_address_t));
2748 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2751 __bt_service_get_parameters(in_param1, &is_enable,
2754 result = _bt_set_le_static_random_address(is_enable);
2758 #ifdef TIZEN_GATT_CLIENT
2760 case BT_GATT_CLIENT_REGISTER: {
2761 bluetooth_device_address_t address = { {0} };
2764 sender = (char*)g_dbus_method_invocation_get_sender(context);
2766 __bt_service_get_parameters(in_param1,
2767 &address, sizeof(bluetooth_device_address_t));
2769 result = _bt_register_gatt_client_instance(sender, &address);
2770 if (BLUETOOTH_ERROR_NONE == result) {
2771 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2773 _bt_convert_addr_type_to_string(addr, address.addr);
2775 /* Save the informations to invocation */
2776 _bt_save_invocation_context(context, result, sender,
2777 function_name, (gpointer)addr);
2782 case BT_GATT_CLIENT_UNREGISTER: {
2785 sender = (char*)g_dbus_method_invocation_get_sender(context);
2786 __bt_service_get_parameters(in_param1,
2787 &client_id, sizeof(int));
2789 result = _bt_unregister_gatt_client_instance(sender, client_id);
2793 /* Async: Remote Interaction */
2794 case BT_GATT_ACQUIRE_WRITE: {
2798 bluetooth_gatt_client_char_prop_info_t param;
2800 sender = (char*)g_dbus_method_invocation_get_sender(context);
2802 __bt_service_get_parameters(in_param1, ¶m,
2803 sizeof(bluetooth_gatt_client_char_prop_info_t));
2806 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2808 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2810 if (BLUETOOTH_ERROR_NONE == result)
2811 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2813 BT_ERR("GATT Client: gatt acquire write failed");
2817 GUnixFDList *fd_list = NULL;
2818 GError *error = NULL;
2820 /* Add socket fd to unix_fd_list */
2821 fd_list = g_unix_fd_list_new();
2822 g_unix_fd_list_append(fd_list, fd, &error);
2823 g_assert_no_error(error);
2825 _bt_service_method_return_with_unix_fd_list(
2826 context, *out_param1, result, fd_list);
2829 g_object_unref(fd_list);
2833 /* Async: Remote Interaction */
2834 case BT_CONNECT_LE: {
2835 bluetooth_device_address_t address = { {0} };
2836 gboolean auto_connect;
2840 sender = (char*)g_dbus_method_invocation_get_sender(context);
2842 __bt_service_get_parameters(in_param1,
2843 &address, sizeof(bluetooth_device_address_t));
2844 __bt_service_get_parameters(in_param2,
2845 &auto_connect, sizeof(gboolean));
2846 __bt_service_get_parameters(in_param3,
2847 &client_id, sizeof(int));
2849 BT_DBG("GATT Client: client_id[%d]", client_id);
2850 result = _bt_connect_le_device(&address, auto_connect, client_id);
2851 if (BLUETOOTH_ERROR_NONE == result) {
2852 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2853 _bt_convert_addr_type_to_string(addr, address.addr);
2855 /* Save the informations to invocation */
2856 _bt_save_invocation_context(context, result, sender,
2857 function_name, (gpointer)addr);
2860 _bt_handle_invocation_context(function_name, (void *)addr);
2862 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2863 g_array_append_vals(*out_param1, &address,
2864 sizeof(bluetooth_device_address_t));
2868 /* Async: Remote Interaction */
2869 case BT_DISCONNECT_LE: {
2870 bluetooth_device_address_t address = { {0} };
2874 sender = (char*)g_dbus_method_invocation_get_sender(context);
2876 __bt_service_get_parameters(in_param1,
2877 &address, sizeof(bluetooth_device_address_t));
2878 __bt_service_get_parameters(in_param2,
2879 &client_id, sizeof(int));
2881 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2882 result = _bt_disconnect_le_device(&address, client_id);
2883 if (BLUETOOTH_ERROR_NONE == result) {
2884 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2886 _bt_convert_addr_type_to_string(addr, address.addr);
2888 /* Save the informations to invocation */
2889 _bt_save_invocation_context(context, result, sender,
2890 function_name, (gpointer)addr);
2892 g_array_append_vals(*out_param1, &address,
2893 sizeof(bluetooth_device_address_t));
2898 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2899 guint available_packets = 0;
2901 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2902 BT_DBG("LE batching available packets %u", available_packets);
2903 if (result == BLUETOOTH_ERROR_NONE) {
2904 g_array_append_vals(*out_param1, &available_packets,
2911 case BT_ENABLE_GATT_DATA_BATCHING: {
2912 bluetooth_device_address_t address = { {0} };
2913 int packet_threshold;
2916 __bt_service_get_parameters(in_param1,
2917 &address, sizeof(bluetooth_device_address_t));
2918 __bt_service_get_parameters(in_param2,
2919 &packet_threshold, sizeof(int));
2920 __bt_service_get_parameters(in_param3,
2921 &timeout, sizeof(int));
2922 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2927 case BT_DISABLE_GATT_DATA_BATCHING: {
2928 bluetooth_device_address_t address = { {0} };
2930 __bt_service_get_parameters(in_param1,
2931 &address, sizeof(bluetooth_device_address_t));
2932 result = _bt_gatt_disable_data_batching(&address);
2937 case BT_GATT_GET_PRIMARY_SERVICES: {
2940 sender = (char*)g_dbus_method_invocation_get_sender(context);
2941 bluetooth_device_address_t address = { {0} };
2943 __bt_service_get_parameters(in_param1, &address,
2944 sizeof(bluetooth_device_address_t));
2946 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2947 _bt_convert_addr_type_to_string(addr, address.addr);
2949 result = _bt_gatt_get_primary_services(addr);
2950 if (BLUETOOTH_ERROR_NONE == result) {
2951 _bt_save_invocation_context(context, result, sender,
2952 function_name, (gpointer)addr);
2958 case BT_GATT_GET_SERVICE_PROPERTIES: {
2959 bluetooth_gatt_client_svc_prop_info_t param;
2961 sender = (char*)g_dbus_method_invocation_get_sender(context);
2962 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2964 __bt_service_get_parameters(in_param1, ¶m,
2965 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2967 result = _bt_gatt_get_all_characteristic(¶m);
2968 if (BLUETOOTH_ERROR_NONE == result) {
2969 /* Save the informations to invocation */
2970 _bt_save_invocation_context(context, result, sender,
2972 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2976 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2977 bluetooth_gatt_client_char_prop_info_t param;
2979 sender = (char*)g_dbus_method_invocation_get_sender(context);
2980 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2982 __bt_service_get_parameters(in_param1, ¶m,
2983 sizeof(bluetooth_gatt_client_char_prop_info_t));
2985 result = _bt_gatt_get_all_characteristic_properties(¶m);
2986 if (BLUETOOTH_ERROR_NONE == result) {
2987 /* Save the informations to invocation */
2988 _bt_save_invocation_context(context, result, sender,
2990 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2994 /* Async: Remote Interaction */
2995 case BT_GATT_READ_CHARACTERISTIC: {
2996 bluetooth_gatt_client_char_prop_info_t param;
2998 sender = (char*)g_dbus_method_invocation_get_sender(context);
2999 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3001 __bt_service_get_parameters(in_param1, ¶m,
3002 sizeof(bluetooth_gatt_client_char_prop_info_t));
3004 result = _bt_gatt_read_characteristic_value(¶m);
3005 if (BLUETOOTH_ERROR_NONE == result) {
3006 /* Save the informations to invocation */
3007 _bt_save_invocation_context(context, result, sender,
3009 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3013 /* Async: Remote Interaction */
3014 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3015 bluetooth_gatt_client_desc_prop_info_t param;
3017 sender = (char*)g_dbus_method_invocation_get_sender(context);
3018 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3020 __bt_service_get_parameters(in_param1, ¶m,
3021 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3023 result = _bt_gatt_read_descriptor_value(¶m);
3024 if (BLUETOOTH_ERROR_NONE == result) {
3025 /* Save the informations to invocation */
3026 _bt_save_invocation_context(context, result, sender,
3028 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3032 /* Async: Remote Interaction */
3033 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3034 bluetooth_gatt_client_char_prop_info_t param;
3035 bluetooth_gatt_att_data_t data;
3036 bluetooth_gatt_write_type_e write_type;
3038 sender = (char*)g_dbus_method_invocation_get_sender(context);
3040 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3041 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3043 __bt_service_get_parameters(in_param1, ¶m,
3044 sizeof(bluetooth_gatt_client_char_prop_info_t));
3045 __bt_service_get_parameters(in_param2, &data,
3046 sizeof(bluetooth_gatt_att_data_t));
3047 __bt_service_get_parameters(in_param3, &write_type,
3048 sizeof(bluetooth_gatt_write_type_e));
3050 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3051 if (BLUETOOTH_ERROR_NONE == result) {
3052 /* Save the informations to invocation */
3053 _bt_save_invocation_context(context, result, sender,
3055 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3059 /* Async: Remote Interaction */
3060 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3061 bluetooth_gatt_client_desc_prop_info_t param;
3062 bluetooth_gatt_att_data_t data;
3063 bluetooth_gatt_write_type_e write_type;
3065 sender = (char*)g_dbus_method_invocation_get_sender(context);
3066 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3067 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3069 __bt_service_get_parameters(in_param1, ¶m,
3070 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3071 __bt_service_get_parameters(in_param2, &data,
3072 sizeof(bluetooth_gatt_att_data_t));
3073 __bt_service_get_parameters(in_param3, &write_type,
3074 sizeof(bluetooth_gatt_write_type_e));
3076 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3077 if (BLUETOOTH_ERROR_NONE == result) {
3078 /* Save the informations to invocation */
3079 _bt_save_invocation_context(context, result, sender,
3081 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3086 case BT_GATT_WATCH_CHARACTERISTIC: {
3087 bluetooth_gatt_client_char_prop_info_t param;
3092 gboolean is_indicate;
3095 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3097 sender = (char*)g_dbus_method_invocation_get_sender(context);
3099 __bt_service_get_parameters(in_param1, ¶m,
3100 sizeof(bluetooth_gatt_client_char_prop_info_t));
3101 __bt_service_get_parameters(in_param2, &client_id,
3103 __bt_service_get_parameters(in_param3, &is_notify,
3105 __bt_service_get_parameters(in_param4, &is_indicate,
3108 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3112 if (is_indicate == false) {
3113 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3114 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3115 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3117 GUnixFDList *fd_list = NULL;
3118 GError *error = NULL;
3120 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3121 /* Add socket fd to unix_fd_list */
3122 fd_list = g_unix_fd_list_new();
3123 g_unix_fd_list_append(fd_list, fd, &error);
3124 g_assert_no_error(error);
3126 _bt_service_method_return_with_unix_fd_list(
3127 context, *out_param1, result, fd_list);
3129 g_object_unref(fd_list);
3135 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3136 if (BLUETOOTH_ERROR_NONE == result) {
3137 /* Save the informations to invocation */
3138 _bt_save_invocation_context(context, result, sender, function_name,
3139 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3144 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3145 gboolean is_enabled;
3146 bluetooth_device_address_t address;
3148 sender = (char*)g_dbus_method_invocation_get_sender(context);
3150 __bt_service_get_parameters(in_param1,
3151 &address, sizeof(bluetooth_device_address_t));
3152 __bt_service_get_parameters(in_param2, &is_enabled,
3154 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3155 BT_INFO("Service changed indication from app [%s]", sender);
3159 case BT_LE_CONN_UPDATE: {
3160 char *sender = NULL;
3161 bluetooth_device_address_t local_address = { {0} };
3162 bluetooth_le_connection_param_t parameters = {0};
3164 sender = (char *)g_dbus_method_invocation_get_sender(context);
3166 __bt_service_get_parameters(in_param1, &local_address,
3167 sizeof(bluetooth_device_address_t));
3168 __bt_service_get_parameters(in_param2, ¶meters,
3169 sizeof(bluetooth_le_connection_param_t));
3171 result = _bt_le_connection_update(sender,
3173 parameters.interval_min,
3174 parameters.interval_max,
3176 parameters.timeout);
3180 case BT_START_LE_DISCOVERY: {
3184 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3186 sender = (char *)g_dbus_method_invocation_get_sender(context);
3188 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3189 BT_ERR("Fail to get the sender pid");
3191 result = _bt_start_le_scan(sender, uid, pid);
3192 if (result == BLUETOOTH_ERROR_NONE) {
3193 _bt_save_invocation_context(context, result, sender,
3194 function_name, NULL);
3196 BT_DBG("Remeber pid / uid for the scan operation");
3197 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3201 case BT_STOP_LE_DISCOVERY: {
3205 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3207 sender = (char *)g_dbus_method_invocation_get_sender(context);
3209 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3210 BT_ERR("Fail to get the sender pid");
3212 result = _bt_stop_le_scan(sender);
3213 if (result == BLUETOOTH_ERROR_NONE) {
3214 _bt_save_invocation_context(context, result, sender,
3215 function_name, NULL);
3218 BT_DBG("Remove pid / uid for the scan operation");
3219 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3223 case BT_IS_LE_DISCOVERYING: {
3224 gboolean le_discovering = FALSE;
3226 le_discovering = _bt_is_le_scanning();
3227 g_array_append_vals(*out_param1,
3228 &le_discovering, sizeof(gboolean));
3231 case BT_SET_SCAN_PARAMETERS: {
3232 bluetooth_le_scan_params_t scan_params;
3234 __bt_service_get_parameters(in_param1, &scan_params,
3235 sizeof(bluetooth_le_scan_params_t));
3237 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3238 scan_params.interval, scan_params.window,
3241 result = _bt_prepare_scan_parameters(&scan_params, 0);
3244 case BT_SET_SCAN_TYPE: {
3246 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3248 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3249 result = _bt_prepare_scan_parameters(NULL, scan_type);
3252 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3253 case BT_NETWORK_ACTIVATE:
3254 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3255 result = _bt_network_activate();
3257 case BT_NETWORK_DEACTIVATE:
3258 result = _bt_network_deactivate();
3260 case BT_NETWORK_CONNECT: {
3261 bluetooth_device_address_t address = { {0} };
3264 __bt_service_get_parameters(in_param1,
3265 &address, sizeof(bluetooth_device_address_t));
3266 __bt_service_get_parameters(in_param2,
3267 &role, sizeof(int));
3269 result = _bt_network_connect(request_id, role, &address);
3270 if (result != BLUETOOTH_ERROR_NONE) {
3271 g_array_append_vals(*out_param1, &address,
3272 sizeof(bluetooth_device_address_t));
3276 case BT_NETWORK_DISCONNECT: {
3277 bluetooth_device_address_t address = { {0} };
3279 __bt_service_get_parameters(in_param1,
3280 &address, sizeof(bluetooth_device_address_t));
3282 result = _bt_network_disconnect(request_id, &address);
3283 if (result != BLUETOOTH_ERROR_NONE) {
3284 g_array_append_vals(*out_param1, &address,
3285 sizeof(bluetooth_device_address_t));
3289 case BT_NETWORK_SERVER_DISCONNECT: {
3290 bluetooth_device_address_t address = { {0} };
3292 __bt_service_get_parameters(in_param1,
3293 &address, sizeof(bluetooth_device_address_t));
3295 result = _bt_network_server_disconnect(request_id, &address);
3296 if (result != BLUETOOTH_ERROR_NONE) {
3297 g_array_append_vals(*out_param1, &address,
3298 sizeof(bluetooth_device_address_t));
3304 #ifdef TIZEN_FEATURE_BT_IPSP
3305 case BT_LE_IPSP_INIT:
3306 result = _bt_initialize_ipsp();
3308 case BT_LE_IPSP_DEINIT:
3309 result = _bt_deinitialize_ipsp();
3311 case BT_LE_IPSP_CONNECT: {
3312 bluetooth_device_address_t address = { {0} };
3313 __bt_service_get_parameters(in_param1, &address,
3314 sizeof(bluetooth_device_address_t));
3315 result = _bt_connect_le_ipsp_device(&address);
3318 case BT_LE_IPSP_DISCONNECT: {
3319 bluetooth_device_address_t address = { {0} };
3320 __bt_service_get_parameters(in_param1, &address,
3321 sizeof(bluetooth_device_address_t));
3322 result = _bt_disconnect_le_ipsp_device(&address);
3326 case BT_IS_ADVERTISING: {
3327 gboolean advertising = FALSE;
3328 advertising = _bt_is_advertising();
3329 g_array_append_vals(*out_param1, &advertising,
3333 case BT_IS_LE_2M_PHY_SUPPORTED: {
3334 gboolean is_2m_phy_supported = FALSE;
3336 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3337 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3340 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3341 gboolean is_coded_phy_supported = FALSE;
3343 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3344 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3347 case BT_DISCONNECT_DEVICE: {
3348 bluetooth_device_address_t address = { {0} };
3350 __bt_service_get_parameters(in_param1,
3351 &address, sizeof(bluetooth_device_address_t));
3353 result = _bt_disconnect_device(&address);
3356 case BT_REGISTER_SCAN_FILTER: {
3357 bluetooth_le_scan_filter_t scan_filter;
3359 sender = (char*)g_dbus_method_invocation_get_sender(context);
3360 __bt_service_get_parameters(in_param1, &scan_filter,
3361 sizeof(bluetooth_le_scan_filter_t));
3363 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3364 scan_filter.added_features);
3366 result = _bt_register_scan_filter(sender, &scan_filter);
3372 result = _bt_mesh_init();
3375 case BT_MESH_DEINIT:
3376 result = _bt_mesh_deinit();
3379 case BT_MESH_NETWORK_CREATE: {
3380 bluetooth_mesh_node_t node;
3381 GSList *model_list = NULL;
3382 int total_models = 0;
3385 const char *network_name = NULL;
3386 bluetooth_mesh_network_t *network;
3388 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3389 sender = (char*)g_dbus_method_invocation_get_sender(context);
3391 __bt_service_get_parameters(in_param1,
3392 &node, sizeof(bluetooth_mesh_node_t));
3393 network_name = (const char *)g_variant_get_data(in_param2);
3394 BT_INFO("MESH: Network name [%s]", network_name);
3396 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3397 __bt_fill_garray_from_variant(in_param3, param3);
3399 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3400 for (i = 0; i < total_models; i++) {
3401 bluetooth_mesh_model_t *info = NULL;
3402 bluetooth_mesh_model_t *mod = NULL;
3404 info = &g_array_index(param3,
3405 bluetooth_mesh_model_t, i);
3407 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3410 model_list = g_slist_append(model_list,
3413 result = _bt_mesh_network_create(requester_unique_creds,
3414 sender, network_name, &node, model_list);
3416 /* Save invocation */
3417 if (result == BLUETOOTH_ERROR_NONE) {
3418 BT_INFO("Mesh: Save Invoation");
3419 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3421 /* Save Network name & UUID, Token will be received in event */
3422 _bt_mesh_util_convert_hex_to_string(
3423 (uint8_t *) node.uuid, 16,
3425 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3426 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3427 g_strlcpy(network->name.name, network_name,
3428 sizeof(network->name.name));
3429 g_strlcpy(network->app_cred,
3430 requester_unique_creds,
3431 sizeof(network->app_cred));
3432 sender = (char*)g_dbus_method_invocation_get_sender(context);
3433 _bt_save_invocation_context(context,
3435 function_name, (gpointer)network);
3437 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3438 BT_ERR("Mesh: Mesh Network creation schedule failed");
3439 g_slist_free_full(model_list, g_free);
3443 BT_INFO("Mesh: Cleanup");
3444 g_free((gpointer)requester_unique_creds);
3445 g_array_free(param3, TRUE);
3446 BT_INFO("Mesh: Cleanup Done");
3449 case BT_MESH_NETWORK_LOAD: {
3451 bluetooth_mesh_network_t *network;
3452 token = (char *)g_variant_get_data(in_param1);
3453 BT_INFO("MESH: Network Load: Token string [%s]", token);
3454 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3455 /* Save invocation */
3456 if (result == BLUETOOTH_ERROR_NONE) {
3457 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3458 g_strlcpy(network->token.token, token, strlen(token));
3459 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3461 sender = (char*)g_dbus_method_invocation_get_sender(context);
3462 _bt_save_invocation_context(context, result, sender,
3463 function_name, (gpointer)network);
3465 g_free((gpointer)requester_unique_creds);
3468 case BT_MESH_NETWORK_SCAN: {
3469 bluetooth_mesh_network_t network;
3470 bluetooth_mesh_scan_param_t param;
3471 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3472 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3474 __bt_service_get_parameters(in_param1,
3475 &network, sizeof(bluetooth_mesh_network_t));
3477 __bt_service_get_parameters(in_param2,
3478 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3480 result = _bt_mesh_network_scan(requester_unique_creds,
3481 sender, &network, ¶m);
3483 if (result != BLUETOOTH_ERROR_NONE) {
3484 g_array_append_vals(*out_param1,
3485 &network, sizeof(bluetooth_mesh_network_t));
3487 bluetooth_mesh_network_t *net = \
3488 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3490 sender = (char*)g_dbus_method_invocation_get_sender(context);
3491 _bt_save_invocation_context(context, result, sender,
3492 function_name, (gpointer)net);
3496 case BT_MESH_NETWORK_CANCEL_SCAN: {
3497 bluetooth_mesh_network_t network;
3498 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3500 __bt_service_get_parameters(in_param1,
3501 &network, sizeof(bluetooth_mesh_network_t));
3503 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3506 if (result != BLUETOOTH_ERROR_NONE)
3507 g_array_append_vals(*out_param1,
3508 &network, sizeof(bluetooth_mesh_network_t));
3511 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3512 bluetooth_mesh_network_t network;
3513 bluetooth_mesh_provisioner_caps_t caps;
3514 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3515 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3517 __bt_service_get_parameters(in_param1,
3518 &network, sizeof(bluetooth_mesh_network_t));
3520 __bt_service_get_parameters(in_param2,
3521 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3523 result = _bt_mesh_network_set_provisioner_caps(
3524 requester_unique_creds, sender, &network, &caps);
3528 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3529 bluetooth_mesh_provisioning_request_t req;
3530 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3532 __bt_service_get_parameters(in_param1,
3533 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3535 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3536 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3538 result = _bt_mesh_network_provision_device(
3539 requester_unique_creds, sender, &req);
3541 /* Save invocation */
3542 if (result != BLUETOOTH_ERROR_NONE) {
3543 g_array_append_vals(*out_param1, &req,
3544 sizeof(bluetooth_mesh_provisioning_request_t));
3546 bluetooth_mesh_provisioning_request_t *param = \
3547 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3549 sender = (char*)g_dbus_method_invocation_get_sender(context);
3550 _bt_save_invocation_context(context, result, sender,
3551 function_name, (gpointer)param);
3555 case BT_MESH_AUTHENTICATION_REPLY: {
3556 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3557 const char *auth_value = NULL;
3558 gboolean authentication_reply = FALSE;
3560 auth_value = g_variant_get_data(in_param2);
3561 __bt_service_get_parameters(in_param3,
3562 &authentication_reply, sizeof(gboolean));
3563 __bt_service_get_parameters(in_param1,
3564 &auth_type, sizeof(int));
3565 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3566 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3567 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3568 result = _bt_mesh_authentication_reply(auth_type,
3569 auth_value, authentication_reply);
3572 case BT_MESH_NETWORK_SET_NAME: {
3573 bluetooth_mesh_network_t network;
3574 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3576 __bt_service_get_parameters(in_param1,
3577 &network, sizeof(bluetooth_mesh_network_t));
3579 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3583 case BT_MESH_NETWORK_ADD_NETKEY: {
3584 bluetooth_mesh_network_t network;
3585 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3587 __bt_service_get_parameters(in_param1,
3588 &network, sizeof(bluetooth_mesh_network_t));
3590 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3593 if (result != BLUETOOTH_ERROR_NONE) {
3594 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3596 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3598 sender = (char*)g_dbus_method_invocation_get_sender(context);
3599 _bt_save_invocation_context(context, result, sender,
3600 function_name, (gpointer)net);
3604 case BT_MESH_NETWORK_DELETE_NETKEY: {
3605 bluetooth_mesh_network_t network;
3608 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3610 __bt_service_get_parameters(in_param1,
3611 &network, sizeof(bluetooth_mesh_network_t));
3612 __bt_service_get_parameters(in_param2,
3613 &index, sizeof(guint16));
3615 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3616 sender, &network, index);
3618 if (result != BLUETOOTH_ERROR_NONE) {
3619 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3621 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3623 sender = (char*)g_dbus_method_invocation_get_sender(context);
3624 _bt_save_invocation_context(context, result, sender,
3625 function_name, (gpointer)net);
3629 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3630 bluetooth_mesh_network_t network;
3633 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3635 __bt_service_get_parameters(in_param1,
3636 &network, sizeof(bluetooth_mesh_network_t));
3637 __bt_service_get_parameters(in_param2,
3638 &index, sizeof(guint16));
3640 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3641 sender, &network, index);
3643 if (result != BLUETOOTH_ERROR_NONE) {
3644 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3646 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3648 sender = (char*)g_dbus_method_invocation_get_sender(context);
3649 _bt_save_invocation_context(context, result, sender,
3650 function_name, (gpointer)net);
3654 case BT_MESH_NETWORK_ADD_APPKEY: {
3655 bluetooth_mesh_network_t network;
3658 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3660 __bt_service_get_parameters(in_param1,
3661 &network, sizeof(bluetooth_mesh_network_t));
3662 __bt_service_get_parameters(in_param2,
3663 &net_idx, sizeof(guint16));
3665 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3666 sender, &network, net_idx);
3668 if (result != BLUETOOTH_ERROR_NONE) {
3669 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3671 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3673 sender = (char*)g_dbus_method_invocation_get_sender(context);
3674 _bt_save_invocation_context(context, result, sender,
3675 function_name, (gpointer)net);
3679 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3680 bluetooth_mesh_network_t network;
3684 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3686 __bt_service_get_parameters(in_param1,
3687 &network, sizeof(bluetooth_mesh_network_t));
3688 __bt_service_get_parameters(in_param2,
3689 &net_idx, sizeof(guint16));
3690 __bt_service_get_parameters(in_param3,
3691 &app_idx, sizeof(guint16));
3693 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3694 sender, &network, net_idx, app_idx);
3696 if (result != BLUETOOTH_ERROR_NONE) {
3697 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3699 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3701 sender = (char*)g_dbus_method_invocation_get_sender(context);
3702 _bt_save_invocation_context(context, result, sender,
3703 function_name, (gpointer)net);
3707 case BT_MESH_NETWORK_DELETE_APPKEY: {
3708 bluetooth_mesh_network_t network;
3712 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3714 __bt_service_get_parameters(in_param1,
3715 &network, sizeof(bluetooth_mesh_network_t));
3716 __bt_service_get_parameters(in_param2,
3717 &net_idx, sizeof(guint16));
3718 __bt_service_get_parameters(in_param3,
3719 &app_idx, sizeof(guint16));
3721 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3722 sender, &network, net_idx, app_idx);
3724 if (result != BLUETOOTH_ERROR_NONE) {
3725 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3727 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3729 sender = (char*)g_dbus_method_invocation_get_sender(context);
3730 _bt_save_invocation_context(context, result, sender,
3731 function_name, (gpointer)net);
3735 case BT_MESH_NETWORK_GET_NETKEYS: {
3736 bluetooth_mesh_network_t network;
3737 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3738 __bt_service_get_parameters(in_param1,
3739 &network, sizeof(bluetooth_mesh_network_t));
3740 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3741 sender, &network, out_param1);
3744 case BT_MESH_NETWORK_GET_APPKEYS: {
3745 bluetooth_mesh_network_t network;
3748 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3749 __bt_service_get_parameters(in_param1,
3750 &network, sizeof(bluetooth_mesh_network_t));
3751 __bt_service_get_parameters(in_param2,
3752 &net_idx, sizeof(guint16));
3753 result = _bt_mesh_network_get_appkeys(
3754 requester_unique_creds, sender,
3755 &network, net_idx, out_param1);
3758 case BT_MESH_NETWORK_GET_NODES: {
3759 bluetooth_mesh_network_t network;
3760 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3761 __bt_service_get_parameters(in_param1,
3762 &network, sizeof(bluetooth_mesh_network_t));
3763 result = _bt_mesh_network_get_nodes(
3764 requester_unique_creds, sender,
3765 &network, out_param1);
3768 case BT_MESH_ELEMENT_GET_MODELS: {
3769 bluetooth_mesh_network_t network;
3773 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3774 __bt_service_get_parameters(in_param1,
3775 &network, sizeof(bluetooth_mesh_network_t));
3776 __bt_service_get_parameters(in_param2,
3777 &node_addr, sizeof(guint16));
3778 __bt_service_get_parameters(in_param3,
3779 &elem_idx, sizeof(int));
3780 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3781 &network, node_addr, elem_idx, out_param1);
3784 case BT_MESH_NODE_BROWSE: {
3785 bluetooth_mesh_node_discover_t req;
3786 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3788 __bt_service_get_parameters(in_param1,
3789 &req, sizeof(bluetooth_mesh_node_discover_t));
3791 result = _bt_mesh_browse_remote_node(
3792 requester_unique_creds, sender, &req);
3794 /* Save invocation */
3795 if (result != BLUETOOTH_ERROR_NONE) {
3796 g_array_append_vals(*out_param1, &req,
3797 sizeof(bluetooth_mesh_node_discover_t));
3799 bluetooth_mesh_node_discover_t *param = \
3800 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3802 sender = (char*)g_dbus_method_invocation_get_sender(context);
3803 _bt_save_invocation_context(context, result, sender,
3804 function_name, (gpointer)param);
3808 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3809 bluetooth_mesh_node_features_t req;
3810 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3812 __bt_service_get_parameters(in_param1,
3813 &req, sizeof(bluetooth_mesh_node_features_t));
3815 result = _bt_mesh_node_discover_vendor_features(
3816 requester_unique_creds, sender, &req);
3818 /* Save invocation */
3819 if (result != BLUETOOTH_ERROR_NONE) {
3820 g_array_append_vals(*out_param1,
3821 &req, sizeof(bluetooth_mesh_node_features_t));
3823 bluetooth_mesh_node_features_t *param = \
3824 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3826 sender = (char*)g_dbus_method_invocation_get_sender(context);
3827 _bt_save_invocation_context(context, result, sender,
3828 function_name, (gpointer)param);
3832 case BT_MESH_NODE_CONFIGURE_KEY: {
3833 bluetooth_mesh_key_configure_t req;
3835 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3837 __bt_service_get_parameters(in_param1,
3838 &req, sizeof(bluetooth_mesh_key_configure_t));
3840 result = _bt_mesh_node_configure_key(
3841 requester_unique_creds, sender, &req);
3843 /* Save invocation */
3844 if (result != BLUETOOTH_ERROR_NONE) {
3845 g_array_append_vals(*out_param1,
3846 &req, sizeof(bluetooth_mesh_key_configure_t));
3848 bluetooth_mesh_key_configure_t *param = \
3849 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3851 sender = (char*)g_dbus_method_invocation_get_sender(context);
3852 _bt_save_invocation_context(context, result, sender,
3853 function_name, (gpointer)param);
3857 case BT_MESH_NODE_TTL_EXECUTE: {
3858 bluetooth_mesh_node_ttl_info_t req;
3860 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3862 __bt_service_get_parameters(in_param1,
3863 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3865 result = _bt_mesh_ttl_execute_remote_node(
3866 requester_unique_creds, sender, &req);
3868 /* Save invocation */
3869 if (result != BLUETOOTH_ERROR_NONE) {
3870 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3872 bluetooth_mesh_node_ttl_info_t *param = \
3873 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3875 sender = (char*)g_dbus_method_invocation_get_sender(context);
3876 _bt_save_invocation_context(context, result, sender,
3877 function_name, (gpointer)param);
3881 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3882 bluetooth_mesh_model_configure_t req;
3884 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3886 __bt_service_get_parameters(in_param1,
3887 &req, sizeof(bluetooth_mesh_model_configure_t));
3889 result = _bt_mesh_node_model_appkey_execute(
3890 requester_unique_creds, sender, &req);
3892 /* Save invocation */
3893 if (result != BLUETOOTH_ERROR_NONE) {
3894 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3896 bluetooth_mesh_model_configure_t *param = \
3897 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3899 sender = (char*)g_dbus_method_invocation_get_sender(context);
3900 _bt_save_invocation_context(context, result, sender,
3901 function_name, (gpointer)param);
3905 case BT_MESH_MODEL_EXECUTE_MSG: {
3906 bluetooth_mesh_model_msg_t req;
3908 memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
3910 __bt_service_get_parameters(in_param1,
3911 &req, sizeof(bluetooth_mesh_model_msg_t));
3913 result = _bt_mesh_model_execute_msg(
3914 requester_unique_creds, sender, &req);
3916 /* Save invocation */
3917 if (result != BLUETOOTH_ERROR_NONE) {
3918 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
3920 bluetooth_mesh_model_msg_t *param = \
3921 g_memdup(&req, sizeof(bluetooth_mesh_model_msg_t));
3923 sender = (char*)g_dbus_method_invocation_get_sender(context);
3924 _bt_save_invocation_context(context, result, sender,
3925 function_name, (gpointer)param);
3929 case BT_MESH_NODE_GET_NETKEYS: {
3930 bluetooth_mesh_node_discover_t node;
3931 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3932 __bt_service_get_parameters(in_param1,
3933 &node, sizeof(bluetooth_mesh_node_discover_t));
3934 result = _bt_mesh_network_node_get_netkeys(
3935 requester_unique_creds, &node, out_param1);
3938 case BT_MESH_NODE_GET_APPKEYS: {
3939 bluetooth_mesh_node_discover_t node;
3940 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3941 __bt_service_get_parameters(in_param1,
3942 &node, sizeof(bluetooth_mesh_node_discover_t));
3943 result = _bt_mesh_network_node_get_appkeys(
3944 requester_unique_creds, sender, &node, out_param1);
3947 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3948 bluetooth_mesh_model_configure_t req;
3950 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3952 __bt_service_get_parameters(in_param1,
3953 &req, sizeof(bluetooth_mesh_model_configure_t));
3955 result = _bt_mesh_node_model_get_appkey_list(
3956 requester_unique_creds, sender, &req);
3958 /* Save invocation */
3959 if (result != BLUETOOTH_ERROR_NONE) {
3960 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3962 bluetooth_mesh_model_configure_t *param = \
3963 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3965 sender = (char*)g_dbus_method_invocation_get_sender(context);
3966 _bt_save_invocation_context(context, result, sender,
3967 function_name, (gpointer)param);
3971 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3972 bluetooth_mesh_model_configure_t req;
3974 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3976 __bt_service_get_parameters(in_param1,
3977 &req, sizeof(bluetooth_mesh_model_configure_t));
3979 result = _bt_mesh_node_model_get_subscription_list(
3980 requester_unique_creds, sender, &req);
3982 /* Save invocation */
3983 if (result != BLUETOOTH_ERROR_NONE) {
3984 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3986 bluetooth_mesh_model_configure_t *param = \
3987 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3989 sender = (char*)g_dbus_method_invocation_get_sender(context);
3990 _bt_save_invocation_context(context, result, sender,
3991 function_name, (gpointer)param);
3996 case BT_MESH_NETWORK_CREATE_GROUP: {
3997 bluetooth_mesh_network_t net;
3998 bluetooth_mesh_network_group_info_t res;
3999 gboolean is_virtual;
4002 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4003 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4005 __bt_service_get_parameters(in_param1,
4006 &net, sizeof(bluetooth_mesh_network_t));
4007 __bt_service_get_parameters(in_param2,
4008 &is_virtual, sizeof(gboolean));
4009 __bt_service_get_parameters(in_param3,
4010 &grp_addr, sizeof(guint16));
4012 result = _bt_mesh_network_create_group(
4013 requester_unique_creds, sender, &net,
4014 is_virtual, grp_addr, &res);
4016 if (result == BLUETOOTH_ERROR_NONE)
4017 g_array_append_vals(*out_param1, &res,
4018 sizeof(bluetooth_mesh_network_group_info_t));
4021 case BT_MESH_NETWORK_REMOVE_GROUP: {
4022 bluetooth_mesh_network_t net;
4023 bluetooth_mesh_network_group_info_t req;
4025 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4026 memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4028 __bt_service_get_parameters(in_param1,
4029 &net, sizeof(bluetooth_mesh_network_t));
4030 __bt_service_get_parameters(in_param2,
4031 &req, sizeof(bluetooth_mesh_network_group_info_t));
4033 result = _bt_mesh_network_remove_group(
4034 requester_unique_creds, sender, &net, &req);
4038 case BT_MESH_MODEL_CONFIG_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_group_subscription(
4047 requester_unique_creds, sender, &req);
4049 /* Save invocation */
4050 if (result != BLUETOOTH_ERROR_NONE) {
4051 g_array_append_vals(*out_param1,
4052 &req, sizeof(bluetooth_mesh_model_configure_t));
4054 bluetooth_mesh_model_configure_t *param = \
4055 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4057 sender = (char*)g_dbus_method_invocation_get_sender(context);
4058 _bt_save_invocation_context(context, result, sender,
4059 function_name, (gpointer)param);
4063 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4064 bluetooth_mesh_model_configure_t req;
4066 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4068 __bt_service_get_parameters(in_param1,
4069 &req, sizeof(bluetooth_mesh_model_configure_t));
4071 result = _bt_mesh_model_configure_virtual_group_subscription(
4072 requester_unique_creds, sender, &req);
4074 /* Save invocation */
4075 if (result != BLUETOOTH_ERROR_NONE) {
4076 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4078 bluetooth_mesh_model_configure_t *param = \
4079 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4081 sender = (char*)g_dbus_method_invocation_get_sender(context);
4082 _bt_save_invocation_context(context, result, sender,
4083 function_name, (gpointer)param);
4087 case BT_MESH_MODEL_SET_PUBLICATION: {
4088 bluetooth_mesh_model_configure_t req;
4090 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4092 __bt_service_get_parameters(in_param1,
4093 &req, sizeof(bluetooth_mesh_model_configure_t));
4095 result = _bt_mesh_model_set_publication(
4096 requester_unique_creds, sender, &req);
4098 /* Save invocation */
4099 if (result != BLUETOOTH_ERROR_NONE) {
4100 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4102 bluetooth_mesh_model_configure_t *param = 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_MODEL_GET_PUBLICATION: {
4111 bluetooth_mesh_model_configure_t req;
4113 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4115 __bt_service_get_parameters(in_param1,
4116 &req, sizeof(bluetooth_mesh_model_configure_t));
4118 result = _bt_mesh_model_get_publication(
4119 requester_unique_creds, sender, &req);
4121 /* Save invocation */
4122 if (result != BLUETOOTH_ERROR_NONE) {
4123 g_array_append_vals(*out_param1,
4124 &req, sizeof(bluetooth_mesh_model_configure_t));
4126 bluetooth_mesh_model_configure_t *param = \
4127 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4129 sender = (char*)g_dbus_method_invocation_get_sender(context);
4130 _bt_save_invocation_context(context, result, sender,
4131 function_name, (gpointer)param);
4135 case BT_MESH_NETWORK_GET_GROUPS: {
4136 bluetooth_mesh_network_t network;
4137 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4138 __bt_service_get_parameters(in_param1,
4139 &network, sizeof(bluetooth_mesh_network_t));
4140 BT_INFO("Mesh: Request:: Get Groups");
4141 result = _bt_mesh_network_get_groups(
4142 requester_unique_creds, sender, &network, out_param1);
4146 BT_INFO("UnSupported function [%d]", function_name);
4147 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4153 #ifdef TIZEN_FEATURE_BT_OBEX
4154 /* Function definitions*/
4155 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4160 size = g_variant_get_size(var);
4162 data = (char *)g_variant_get_data(var);
4164 param = g_array_append_vals(param, data, size);
4170 int __bt_obexd_request(int function_name,
4173 GDBusMethodInvocation *context,
4174 GVariant *in_param1,
4175 GVariant *in_param2,
4176 GVariant *in_param3,
4177 GVariant *in_param4,
4178 GArray **out_param1)
4182 int result = BLUETOOTH_ERROR_NONE;
4184 BT_DBG("function_name : %x", function_name);
4186 switch (function_name) {
4187 case BT_OPP_PUSH_FILES: {
4188 BT_DBG("BT_OPP_PUSH_FILES");
4190 bluetooth_device_address_t address = { {0} };
4191 bt_file_path_t *path;
4196 __bt_service_get_parameters(in_param1, &address,
4197 sizeof(bluetooth_device_address_t));
4198 __bt_service_get_parameters(in_param3, &file_count,
4201 file_path = g_new0(char *, file_count + 1);
4203 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4204 __bt_fill_garray_from_variant(in_param2, param2);
4206 for (i = 0; i < file_count; i++) {
4207 path = &g_array_index(param2, bt_file_path_t, i);
4208 file_path[i] = g_strdup(path->path);
4210 BT_DBG("_bt_opp_client_push_files");
4211 result = _bt_opp_client_push_files(request_id, context,
4212 &address, file_path,
4215 for (i = 0; i < file_count; i++)
4216 g_free(file_path[i]);
4219 g_array_free(param2, TRUE);
4223 case BT_OPP_CANCEL_PUSH: {
4224 result = _bt_opp_client_cancel_push();
4228 case BT_OPP_IS_PUSHING_FILES: {
4229 gboolean is_sending = FALSE;
4231 result = _bt_opp_client_is_sending(&is_sending);
4233 g_array_append_vals(*out_param1, &is_sending,
4237 case BT_OPP_GET_TRANSFER_PROGRESS: {
4240 guint8 progress = 0;
4242 __bt_service_get_parameters(in_param1, &direction,
4244 __bt_service_get_parameters(in_param2, &transfer_id,
4247 result = _bt_opp_get_client_progress(&progress);
4249 result = _bt_opp_get_server_progress(transfer_id, &progress);
4251 g_array_append_vals(*out_param1, &progress,
4257 case BT_MAP_CREATE_SESSION: {
4258 BT_DBG("BT_MAP_CREATE_SESSION");
4259 char *address = (char *)g_variant_get_data(in_param1);
4260 char *session_id = NULL;
4261 result = _bt_create_session_sync(address, &session_id);
4262 if (result == BLUETOOTH_ERROR_NONE)
4263 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4267 case BT_MAP_DESTROY_SESSION: {
4268 BT_DBG("BT_MAP_DESTROY_SESSION");
4269 char* session_id = (char *)g_variant_get_data(in_param1);
4270 result = _bt_destroy_session_sync(session_id);
4271 if (result == BLUETOOTH_ERROR_NONE)
4272 BT_DBG("successfully destroyed session");
4276 case BT_MAP_SET_FOLDER: {
4277 BT_DBG("BT_MAP_SET_FOLDER");
4278 char *session_id = (char *)g_variant_get_data(in_param1);
4279 char *name = (char *)g_variant_get_data(in_param2);
4280 result = _bt_map_client_set_folder(session_id, name);
4284 case BT_MAP_LIST_FOLDERS: {
4285 BT_DBG("BT_MAP_LIST_FOLDERS");
4287 char* session_id = (char *)g_variant_get_data(in_param1);
4288 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4290 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4291 if (result == BLUETOOTH_ERROR_NONE)
4292 BT_DBG("_bt_map_client_list_folders succeed");
4297 case BT_MAP_LIST_FILTER_FIELDS: {
4298 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4300 char* session_id = (char *)g_variant_get_data(in_param1);
4302 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4303 if (result == BLUETOOTH_ERROR_NONE)
4304 BT_DBG("_bt_map_client_list_filter_fields succeed");
4309 case BT_MAP_LIST_MESSAGES: {
4310 BT_DBG("BT_MAP_LIST_MESSAGES");
4312 char* session_id = (char*)g_variant_get_data(in_param1);
4313 char* folder = (char*)g_variant_get_data(in_param2);
4314 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4316 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4317 if (result == BLUETOOTH_ERROR_NONE)
4318 BT_DBG("_bt_map_client_list_messages succeed");
4320 BT_DBG("_bt_map_client_list_messages failed");
4325 case BT_MAP_UPDATE_INBOX: {
4326 BT_DBG("BT_MAP_UPDATE_INBOX");
4327 char* session_id = (char *)g_variant_get_data(in_param1);
4328 result = _bt_map_client_update_inbox(session_id);
4332 case BT_MAP_PUSH_MESSAGE: {
4333 BT_DBG("BT_MAP_PUSH_MESSAGE");
4335 char* session_id = (char *)g_variant_get_data(in_param1);
4336 char* source_file = (char *)g_variant_get_data(in_param2);
4337 char* folder = (char *)g_variant_get_data(in_param3);
4338 char* args_serialized = (char *)g_variant_get_data(in_param4);
4340 result = _bt_map_client_push_message(
4341 request_id, context, session_id, source_file, folder, args_serialized);
4342 if (result == BLUETOOTH_ERROR_NONE)
4343 BT_DBG("_bt_map_client_push_message succeed");
4345 BT_ERR("_bt_map_client_push_message failed");
4350 case BT_MAP_GET_MESSAGE: {
4351 BT_DBG("BT_MAP_GET_MESSAGE");
4352 // TODO session currently is not used, but should be valid
4353 //char* session_id = (char *)g_variant_get_data(in_param1);
4354 char* message_object = (char *)g_variant_get_data(in_param2);
4355 char* target_file = (char *)g_variant_get_data(in_param3);
4356 bool attachment = false;
4357 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4359 result = _bt_map_client_get_message(request_id, context, message_object,
4360 target_file, attachment);
4361 if (result == BLUETOOTH_ERROR_NONE)
4362 BT_DBG("_bt_map_client_get_message succeed");
4367 case BT_OBEX_SERVER_ALLOCATE: {
4373 sender = (char *)g_dbus_method_invocation_get_sender(context);
4375 path = (char *)g_variant_get_data(in_param1);
4376 __bt_service_get_parameters(in_param2, &is_native,
4378 __bt_service_get_parameters(in_param3, &app_pid,
4381 result = _bt_obex_server_allocate(sender,
4382 path, app_pid, is_native);
4386 case BT_OBEX_SERVER_DEALLOCATE: {
4390 __bt_service_get_parameters(in_param1, &is_native,
4392 __bt_service_get_parameters(in_param2, &app_pid,
4395 result = _bt_obex_server_deallocate(app_pid, is_native);
4398 case BT_OBEX_SERVER_IS_ACTIVATED: {
4399 gboolean is_activated = FALSE;
4401 result = _bt_obex_server_is_activated(&is_activated);
4403 g_array_append_vals(*out_param1, &is_activated,
4408 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4409 result = _bt_obex_server_accept_connection(request_id);
4413 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4414 result = _bt_obex_server_reject_connection();
4418 case BT_OBEX_SERVER_ACCEPT_FILE: {
4421 file_name = (char *)g_variant_get_data(in_param1);
4423 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4427 case BT_OBEX_SERVER_REJECT_FILE: {
4428 result = _bt_obex_server_reject_authorize();
4432 case BT_OBEX_SERVER_SET_PATH: {
4434 char *destination_path;
4436 destination_path = (char *)g_variant_get_data(in_param1);
4437 __bt_service_get_parameters(in_param2, &is_native,
4440 result = _bt_obex_server_set_destination_path(destination_path,
4445 case BT_OBEX_SERVER_SET_ROOT: {
4448 root = (char *)g_variant_get_data(in_param1);
4450 result = _bt_obex_server_set_root(root);
4454 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4457 __bt_service_get_parameters(in_param1, &transfer_id,
4460 result = _bt_obex_server_cancel_transfer(transfer_id);
4464 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4465 result = _bt_obex_server_cancel_all_transfers();
4469 case BT_OBEX_SERVER_IS_RECEIVING: {
4470 gboolean is_receiving = FALSE;
4472 result = _bt_obex_server_is_receiving(&is_receiving);
4474 g_array_append_vals(*out_param1, &is_receiving,
4478 case BT_PBAP_CONNECT: {
4479 bluetooth_device_address_t address = { {0} };
4481 __bt_service_get_parameters(in_param1, &address,
4482 sizeof(bluetooth_device_address_t));
4484 result = _bt_pbap_connect(&address);
4487 case BT_PBAP_DISCONNECT: {
4488 bluetooth_device_address_t address = { {0} };
4490 __bt_service_get_parameters(in_param1, &address,
4491 sizeof(bluetooth_device_address_t));
4493 result = _bt_pbap_disconnect(&address);
4496 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4497 bluetooth_device_address_t address = { {0} };
4498 bt_pbap_folder_t folder = { 0, };
4500 __bt_service_get_parameters(in_param1, &address,
4501 sizeof(bluetooth_device_address_t));
4502 __bt_service_get_parameters(in_param2, &folder,
4503 sizeof(bt_pbap_folder_t));
4505 result = _bt_pbap_get_phonebook_size(&address,
4506 folder.addressbook, folder.folder_type);
4509 case BT_PBAP_GET_PHONEBOOK: {
4510 bluetooth_device_address_t address = { {0} };
4511 bt_pbap_folder_t folder = { 0, };
4512 bt_pbap_pull_parameters_t app_param = { 0, };
4514 __bt_service_get_parameters(in_param1, &address,
4515 sizeof(bluetooth_device_address_t));
4516 __bt_service_get_parameters(in_param2, &folder,
4517 sizeof(bt_pbap_folder_t));
4518 __bt_service_get_parameters(in_param3, &app_param,
4519 sizeof(bt_pbap_pull_parameters_t));
4521 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4522 folder.folder_type, &app_param);
4525 case BT_PBAP_GET_LIST: {
4526 bluetooth_device_address_t address = { {0} };
4527 bt_pbap_folder_t folder = { 0, };
4528 bt_pbap_list_parameters_t app_param = { 0, };
4530 __bt_service_get_parameters(in_param1, &address,
4531 sizeof(bluetooth_device_address_t));
4532 __bt_service_get_parameters(in_param2, &folder,
4533 sizeof(bt_pbap_folder_t));
4534 __bt_service_get_parameters(in_param3, &app_param,
4535 sizeof(bt_pbap_list_parameters_t));
4537 result = _bt_pbap_get_list(&address, folder.addressbook,
4538 folder.folder_type, &app_param);
4541 case BT_PBAP_PULL_VCARD: {
4542 bluetooth_device_address_t address = { {0} };
4543 bt_pbap_folder_t folder = { 0, };
4544 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4546 __bt_service_get_parameters(in_param1, &address,
4547 sizeof(bluetooth_device_address_t));
4548 __bt_service_get_parameters(in_param2, &folder,
4549 sizeof(bt_pbap_folder_t));
4550 __bt_service_get_parameters(in_param3, &app_param,
4551 sizeof(bt_pbap_pull_vcard_parameters_t));
4553 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4554 folder.folder_type, &app_param);
4557 case BT_PBAP_PHONEBOOK_SEARCH: {
4558 bluetooth_device_address_t address = { {0} };
4559 bt_pbap_folder_t folder = { 0, };
4560 bt_pbap_search_parameters_t app_param = { 0, };
4562 __bt_service_get_parameters(in_param1, &address,
4563 sizeof(bluetooth_device_address_t));
4564 __bt_service_get_parameters(in_param2, &folder,
4565 sizeof(bt_pbap_folder_t));
4566 __bt_service_get_parameters(in_param3, &app_param,
4567 sizeof(bt_pbap_search_parameters_t));
4569 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4570 folder.folder_type, &app_param);
4575 BT_ERR("Unknown function!");
4576 result = BLUETOOTH_ERROR_INTERNAL;
4585 int __bt_agent_request(int function_name,
4588 GDBusMethodInvocation *context,
4589 GVariant *in_param1,
4590 GVariant *in_param2,
4591 GVariant *in_param3,
4592 GVariant *in_param4,
4593 GArray **out_param1)
4596 switch (function_name) {
4597 case BT_SET_AUTHORIZATION: {
4604 sender = (char *)g_dbus_method_invocation_get_sender(context);
4605 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4606 uuid = (char *)g_variant_get_data(in_param2);
4607 path = (char *)g_variant_get_data(in_param3);
4608 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4610 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4613 case BT_UNSET_AUTHORIZATION: {
4617 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4618 uuid = (char *)g_variant_get_data(in_param2);
4620 result = _bt_unregister_osp_server_in_agent(type, uuid);
4624 BT_ERR("Unknown function!");
4625 result = BLUETOOTH_ERROR_INTERNAL;
4632 int __bt_core_request(int function_name,
4635 GDBusMethodInvocation *context,
4636 GVariant *in_param1)
4640 switch (function_name) {
4641 case BT_ENABLE_ADAPTER:
4644 _bt_set_adapter_request_state(TRUE);
4645 status = _bt_adapter_get_status();
4647 if (status == BT_ACTIVATING) {
4648 BT_DBG("Enabling in progress");
4649 result = BLUETOOTH_ERROR_IN_PROGRESS;
4650 } else if (status == BT_ACTIVATED) {
4651 BT_DBG("Already enabled");
4652 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4654 _bt_adapter_set_status(BT_ACTIVATING);
4655 result = BLUETOOTH_ERROR_NONE;
4660 case BT_DISABLE_ADAPTER:
4664 status = _bt_adapter_get_status();
4665 if (status == BT_DEACTIVATING) {
4666 BT_DBG("Disabling in progress");
4667 result = BLUETOOTH_ERROR_IN_PROGRESS;
4668 } else if (status == BT_DEACTIVATED) {
4669 BT_DBG("Already disabled");
4670 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4672 _bt_adapter_set_status(BT_DEACTIVATING);
4673 result = BLUETOOTH_ERROR_NONE;
4678 case BT_ENABLE_ADAPTER_LE:
4680 bt_le_status_t le_status;
4681 _bt_set_le_request_state(TRUE);
4682 le_status = _bt_adapter_get_le_status();
4683 if (le_status == BT_LE_ACTIVATING) {
4684 BT_DBG("Enabling in progress");
4685 result = BLUETOOTH_ERROR_IN_PROGRESS;
4686 } else if (le_status == BT_LE_ACTIVATED) {
4687 BT_DBG("Already enabled");
4688 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4690 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4691 result = BLUETOOTH_ERROR_NONE;
4696 case BT_DISABLE_ADAPTER_LE:
4698 bt_le_status_t le_status;
4700 le_status = _bt_adapter_get_le_status();
4701 if (le_status == BT_LE_DEACTIVATING) {
4702 BT_DBG("Disabling in progress");
4703 result = BLUETOOTH_ERROR_IN_PROGRESS;
4704 } else if (le_status == BT_LE_DEACTIVATED) {
4705 BT_DBG("Already disabled");
4706 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4708 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4709 result = BLUETOOTH_ERROR_NONE;
4715 BT_ERR("Unknown function!");
4716 result = BLUETOOTH_ERROR_INTERNAL;
4723 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
4728 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
4729 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
4731 ret = __bt_service_get_sender_pid(unique_name, &pid);
4732 if (ret != BLUETOOTH_ERROR_NONE) {
4733 BT_ERR("Fail to get the sender pid");
4737 ret = aul_app_get_appid_bypid(pid, app_id, len);
4738 if (ret != AUL_R_OK) {
4739 BT_ERR("app_id not found");
4740 return BLUETOOTH_ERROR_NOT_SUPPORT;
4742 BT_DBG("Sender app_id: %s", app_id);
4744 return BLUETOOTH_ERROR_NONE;
4747 gboolean __bt_service_check_privilege(int function_name,
4749 const char *unique_name)
4752 gboolean result = TRUE;
4753 char *client_creds = NULL;
4754 char *user_creds = NULL;
4755 char *client_session = "";
4756 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4757 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4758 char err_msg[256] = {0, };
4760 retv_if(unique_name == NULL, FALSE);
4761 retv_if(bt_service_conn == NULL, FALSE);
4763 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4764 if (ret_val != CYNARA_API_SUCCESS) {
4765 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4766 BT_ERR("Fail to get default client method: %s", err_msg);
4770 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4771 if (ret_val != CYNARA_API_SUCCESS) {
4772 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4773 BT_ERR("Fail to get default user method: %s", err_msg);
4777 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4778 if (ret_val != CYNARA_API_SUCCESS) {
4779 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4780 BT_ERR("Fail to get client credential: %s", err_msg);
4784 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4785 if (ret_val != CYNARA_API_SUCCESS) {
4786 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4787 BT_ERR("Fail to get user credential: %s", err_msg);
4793 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4795 switch (function_name) {
4796 case BT_SET_LOCAL_NAME:
4797 case BT_START_DISCOVERY:
4798 case BT_START_CUSTOM_DISCOVERY:
4799 case BT_CANCEL_DISCOVERY:
4800 case BT_OOB_ADD_REMOTE_DATA:
4801 case BT_OOB_REMOVE_REMOTE_DATA:
4802 case BT_OOB_READ_LOCAL_DATA:
4803 case BT_SET_ADVERTISING:
4804 case BT_SET_CUSTOM_ADVERTISING:
4805 case BT_SET_ADVERTISING_PARAMETERS:
4806 case BT_START_LE_DISCOVERY:
4807 case BT_STOP_LE_DISCOVERY:
4808 case BT_SET_SCAN_PARAMETERS:
4809 case BT_SET_SCAN_TYPE:
4811 case BT_BOND_DEVICE:
4812 case BT_CANCEL_BONDING:
4813 case BT_UNBOND_DEVICE:
4815 case BT_SET_AUTHORIZATION:
4816 case BT_UNSET_AUTHORIZATION:
4817 case BT_SEARCH_SERVICE:
4819 case BT_RFCOMM_CLIENT_CONNECT:
4820 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4821 BT_PERMANENT_LOG("Connect socket");
4822 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4823 case BT_RFCOMM_SOCKET_DISCONNECT:
4824 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4825 BT_PERMANENT_LOG("Disconnect socket");
4826 case BT_RFCOMM_SOCKET_WRITE:
4827 case BT_RFCOMM_CREATE_SOCKET:
4828 case BT_RFCOMM_REMOVE_SOCKET:
4829 case BT_RFCOMM_SEND_RX_DETAILS:
4830 case BT_RFCOMM_SEND_TX_DETAILS:
4831 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4833 case BT_OPP_PUSH_FILES:
4834 case BT_OPP_CANCEL_PUSH:
4835 /* TODO: MAP? MAP functions, see above */
4837 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4838 case BT_OBEX_SERVER_REJECT_CONNECTION:
4839 case BT_OBEX_SERVER_ACCEPT_FILE:
4840 case BT_OBEX_SERVER_REJECT_FILE:
4841 case BT_OBEX_SERVER_SET_PATH:
4842 case BT_OBEX_SERVER_SET_ROOT:
4843 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4844 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4846 case BT_AUDIO_SELECT_ROLE:
4847 case BT_AUDIO_CONNECT:
4848 case BT_AUDIO_DISCONNECT:
4850 case BT_AG_DISCONNECT:
4852 case BT_AV_DISCONNECT:
4853 case BT_AV_SOURCE_CONNECT:
4854 case BT_AV_SOURCE_DISCONNECT:
4855 case BT_AVRCP_TARGET_CONNECT:
4856 case BT_AVRCP_TARGET_DISCONNECT:
4857 case BT_AVRCP_CONTROL_CONNECT:
4858 case BT_AVRCP_CONTROL_DISCONNECT:
4859 case BT_AVRCP_HANDLE_CONTROL:
4860 case BT_AVRCP_SET_TRACK_INFO:
4861 case BT_AVRCP_SET_PROPERTY:
4862 case BT_AVRCP_SET_PROPERTIES:
4863 case BT_AVRCP_CONTROL_SET_PROPERTY:
4865 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
4866 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4867 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4868 case BT_AUDIO_IS_AVC_ACTIVATED:
4872 case BT_HF_DISCONNECT:
4874 case BT_HID_CONNECT:
4875 case BT_HID_DISCONNECT:
4877 case BT_HID_DEVICE_ACTIVATE:
4878 case BT_HID_DEVICE_DEACTIVATE:
4879 case BT_HID_DEVICE_CONNECT:
4880 case BT_HID_DEVICE_DISCONNECT:
4881 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4882 case BT_HID_DEVICE_SEND_KEY_EVENT:
4883 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4884 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4887 case BT_DISCONNECT_LE:
4889 case BT_SET_ADVERTISING_DATA:
4890 case BT_SET_SCAN_RESPONSE_DATA:
4892 case BT_HDP_CONNECT:
4893 case BT_HDP_DISCONNECT:
4894 case BT_HDP_SEND_DATA:
4895 case BT_HDP_REGISTER_SINK_APP:
4896 case BT_HDP_UNREGISTER_SINK_APP:
4899 case BT_DPM_SET_ALLOW_BT_MODE:
4900 case BT_DPM_GET_ALLOW_BT_MODE:
4901 case BT_DPM_SET_DEVICE_RESTRITION:
4902 case BT_DPM_GET_DEVICE_RESTRITION:
4903 case BT_DPM_SET_UUID_RESTRITION:
4904 case BT_DPM_GET_UUID_RESTRITION:
4905 case BT_DPM_ADD_DEVICES_BLACKLIST:
4906 case BT_DPM_ADD_DEVICES_WHITELIST:
4907 case BT_DPM_ADD_UUIDS_BLACKLIST:
4908 case BT_DPM_ADD_UUIDS_WHITELIST:
4909 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4910 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4911 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4912 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4913 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4914 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4915 case BT_DPM_REMOVE_UUID_BLACKLIST:
4916 case BT_DPM_REMOVE_UUID_WHITELIST:
4917 case BT_DPM_GET_DEVICES_BLACKLIST:
4918 case BT_DPM_GET_DEVICES_WHITELIST:
4919 case BT_DPM_GET_UUIDS_BLACKLIST:
4920 case BT_DPM_GET_UUIDS_WHITELIST:
4921 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4922 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4923 case BT_DPM_SET_PAIRING_STATE:
4924 case BT_DPM_GET_PAIRING_STATE:
4925 case BT_DPM_SET_PROFILE_STATE:
4926 case BT_DPM_GET_PROFILE_STATE:
4927 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4928 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4929 case BT_DPM_SET_DISCOVERABLE_STATE:
4930 case BT_DPM_GET_DISCOVERABLE_STATE:
4931 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4932 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4933 case BT_DPM_SET_DATA_TRANSFER_STATE:
4934 case BT_DPM_GET_DATA_TRANSFER_STATE:
4936 case BT_NETWORK_ACTIVATE:
4937 case BT_NETWORK_DEACTIVATE:
4938 case BT_NETWORK_CONNECT:
4939 case BT_NETWORK_DISCONNECT:
4940 case BT_NETWORK_SERVER_DISCONNECT:
4942 case BT_GATT_GET_PRIMARY_SERVICES:
4943 #ifdef TIZEN_GATT_CLIENT
4944 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4945 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4946 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4948 case BT_GATT_DISCOVER_CHARACTERISTICS:
4949 case BT_GATT_SET_PROPERTY_REQUEST:
4950 case BT_GATT_READ_CHARACTERISTIC:
4951 #ifdef TIZEN_GATT_CLIENT
4952 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4953 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4954 case BT_GATT_ACQUIRE_WRITE:
4955 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4956 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4957 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4958 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4960 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4961 case BT_GATT_REGISTER_APPLICATION:
4962 case BT_GATT_REGISTER_SERVICE:
4963 case BT_GATT_SEND_RESPONSE:
4965 case BT_GATT_SERVER_REGISTER:
4966 case BT_GATT_SERVER_ADD_SERVICE:
4967 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4968 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4969 case BT_GATT_SERVER_START_SERVICE:
4970 case BT_GATT_SERVER_STOP_SERVICE:
4971 case BT_GATT_SERVER_DELETE_SERVICE:
4972 case BT_GATT_SERVER_SEND_RESPONSE:
4973 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
4974 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
4975 case BT_GATT_SERVER_SEND_INDICATION:
4976 case BT_GATT_SERVER_UPDATE_VALUE:
4977 case BT_GATT_SERVER_DEREGISTER:
4979 case BT_REQ_ATT_MTU:
4980 case BT_PBAP_CONNECT:
4981 case BT_PBAP_DISCONNECT:
4982 case BT_PBAP_GET_PHONEBOOK_SIZE:
4983 case BT_PBAP_GET_PHONEBOOK:
4984 case BT_PBAP_GET_LIST:
4985 case BT_PBAP_PULL_VCARD:
4986 case BT_PBAP_PHONEBOOK_SEARCH:
4988 case BT_RFCOMM_LISTEN_AND_ACCEPT:
4990 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4991 BT_PRIVILEGE_PUBLIC);
4993 BT_INFO("Client Credentials [%s]", client_creds);
4994 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4995 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
4999 /* Need to check mediastorage privilege */
5000 if (function_name == BT_PBAP_GET_PHONEBOOK ||
5001 function_name == BT_PBAP_PULL_VCARD) {
5002 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5003 MEDIASTORAGE_PRIVILEGE);
5005 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5006 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
5012 case BT_ENABLE_ADAPTER:
5013 case BT_DISABLE_ADAPTER:
5014 case BT_RESET_ADAPTER:
5015 case BT_RECOVER_ADAPTER:
5016 case BT_BATTERY_READ_DATA:
5017 case BT_ENABLE_ADAPTER_LE:
5018 case BT_DISABLE_ADAPTER_LE:
5019 case BT_SET_CONNECTABLE:
5020 case BT_SET_DISCOVERABLE_MODE:
5021 case BT_ADD_WHITE_LIST:
5022 case BT_REMOVE_WHITE_LIST:
5023 case BT_CLEAR_WHITE_LIST:
5024 case BT_SET_MANUFACTURER_DATA:
5026 case BT_CANCEL_SEARCH_SERVICE:
5027 case BT_ENABLE_RSSI:
5028 case BT_DISCONNECT_DEVICE:
5030 case BT_RFCOMM_ACCEPT_CONNECTION:
5031 case BT_RFCOMM_REJECT_CONNECTION:
5032 case BT_RFCOMM_LISTEN:
5034 case BT_HID_ENABLE_BARCODE_FEATURE:
5036 case BT_AVRCP_CONTROL_GET_PROPERTY:
5037 case BT_AVRCP_GET_TRACK_INFO:
5038 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5039 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5041 case BT_SET_CONTENT_PROTECT:
5042 case BT_BOND_DEVICE_BY_TYPE:
5043 case BT_SET_LE_PRIVACY:
5044 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5045 case BT_LE_CONN_UPDATE:
5046 case BT_UPDATE_LE_CONNECTION_MODE:
5047 case BT_GET_DEVICE_IDA:
5048 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5049 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5050 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5051 case BT_LE_SET_DATA_LENGTH:
5052 case BT_LE_OOB_READ_LOCAL_DATA:
5053 case BT_LE_OOB_ADD_REMOTE_DATA:
5055 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5056 case BT_ENABLE_GATT_DATA_BATCHING:
5057 case BT_DISABLE_GATT_DATA_BATCHING:
5059 case BT_LE_IPSP_INIT:
5060 case BT_LE_IPSP_DEINIT:
5061 case BT_LE_IPSP_CONNECT:
5062 case BT_LE_IPSP_DISCONNECT:
5063 case BT_PXP_MONITOR_SET_PROPERTY:
5064 case BT_PXP_MONITOR_GET_PROPERTY:
5065 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5066 case BT_PXP_REPORTER_REGISTER:
5067 case BT_PXP_REPORTER_UNREGISTER:
5068 case BT_PXP_REPORTER_GET_PROPERTY:
5071 case BT_TDS_PROVIDER_REGISTER:
5072 case BT_TDS_PROVIDER_UNREGISTER:
5073 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5074 case BT_TDS_PROVIDER_CREATE:
5075 case BT_TDS_PROVIDER_DESTROY:
5076 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5077 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5078 case BT_TDS_READ_TRANSPORT_DATA:
5079 case BT_TDS_ENABLE_CONTROL_POINT:
5080 case BT_TDS_ACTIVATE_CONTROL_POINT:
5083 case BT_OTP_SERVER_INIT:
5084 case BT_OTP_SERVER_DEINIT:
5085 case BT_OTP_READ_VALUE:
5086 case BT_OTP_ENABLE_NOTIFICATION:
5087 case BT_OTP_WRITE_VALUE:
5088 case BT_LE_OTC_CONNECT:
5089 case BT_LE_OTC_DISCONNECT:
5091 case BT_MAP_CREATE_SESSION:
5092 case BT_MAP_DESTROY_SESSION:
5093 case BT_MAP_SET_FOLDER:
5094 case BT_MAP_LIST_FOLDERS:
5095 case BT_MAP_LIST_FILTER_FIELDS:
5096 case BT_MAP_LIST_MESSAGES:
5097 case BT_MAP_UPDATE_INBOX:
5098 case BT_MAP_PUSH_MESSAGE:
5099 case BT_MAP_GET_MESSAGE:
5102 case BT_MESH_DEINIT:
5103 case BT_MESH_NETWORK_CREATE:
5104 case BT_MESH_NETWORK_LOAD:
5105 case BT_MESH_NETWORK_SCAN:
5106 case BT_MESH_NETWORK_CANCEL_SCAN:
5107 case BT_MESH_NETWORK_SET_CAPABILITIES:
5108 case BT_MESH_NETWORK_PROVISION_DEVICE:
5109 case BT_MESH_AUTHENTICATION_REPLY:
5110 case BT_MESH_NETWORK_SET_NAME:
5111 case BT_MESH_NETWORK_ADD_NETKEY:
5112 case BT_MESH_NETWORK_DELETE_NETKEY:
5113 case BT_MESH_NETWORK_UPDATE_NETKEY:
5114 case BT_MESH_NETWORK_ADD_APPKEY:
5115 case BT_MESH_NETWORK_DELETE_APPKEY:
5116 case BT_MESH_NETWORK_UPDATE_APPKEY:
5117 case BT_MESH_NETWORK_GET_NETKEYS:
5118 case BT_MESH_NETWORK_GET_APPKEYS:
5119 case BT_MESH_NETWORK_GET_NODES:
5120 case BT_MESH_ELEMENT_GET_MODELS:
5121 case BT_MESH_NODE_BROWSE:
5122 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5123 case BT_MESH_NODE_CONFIGURE_KEY:
5124 case BT_MESH_NODE_TTL_EXECUTE:
5125 case BT_MESH_NODE_GET_NETKEYS:
5126 case BT_MESH_NODE_GET_APPKEYS:
5127 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5128 case BT_MESH_MODEL_GET_APPKEY_LIST:
5129 case BT_MESH_MODEL_EXECUTE_MSG:
5130 case BT_MESH_NETWORK_CREATE_GROUP:
5131 case BT_MESH_NETWORK_REMOVE_GROUP:
5132 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5133 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5134 case BT_MESH_MODEL_SET_PUBLICATION:
5135 case BT_MESH_MODEL_GET_PUBLICATION:
5136 case BT_MESH_NETWORK_GET_GROUPS:
5138 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5139 BT_PRIVILEGE_PLATFORM);
5141 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5142 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5147 case BT_CHECK_ADAPTER:
5150 case BT_GET_LOCAL_NAME:
5151 case BT_GET_LOCAL_ADDRESS:
5152 case BT_GET_LOCAL_VERSION:
5153 case BT_IS_SERVICE_USED:
5154 case BT_GET_DISCOVERABLE_MODE:
5155 case BT_GET_DISCOVERABLE_TIME:
5156 case BT_IS_DISCOVERYING:
5157 case BT_IS_LE_DISCOVERYING:
5158 case BT_IS_CONNECTABLE:
5159 case BT_GET_CONNECTABLE:
5160 case BT_GET_BONDED_DEVICES:
5161 case BT_GET_PROFILE_CONNECTED_DEVICES:
5162 case BT_GET_BONDED_DEVICE:
5163 case BT_PASSKEY_REPLY:
5164 case BT_PASSKEY_CONFIRMATION_REPLY:
5165 case BT_GET_IS_ALIAS_SET:
5166 case BT_IS_DEVICE_CONNECTED:
5167 case BT_GET_CONNECTED_LINK_TYPE:
5168 case BT_SET_PROFILE_TRUSTED:
5169 case BT_GET_PROFILE_TRUSTED:
5170 case BT_GET_SPEAKER_GAIN:
5171 case BT_SET_SPEAKER_GAIN:
5172 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5173 case BT_RFCOMM_IS_UUID_AVAILABLE:
5174 case BT_GET_ADVERTISING_DATA:
5175 case BT_GET_SCAN_RESPONSE_DATA:
5176 case BT_IS_ADVERTISING:
5177 case BT_IS_LE_2M_PHY_SUPPORTED:
5178 case BT_IS_LE_CODED_PHY_SUPPORTED:
5179 case BT_REGISTER_SCAN_FILTER:
5180 case BT_IS_SCAN_FILTER_SUPPORTED:
5181 case BT_GET_ATT_MTU:
5183 case BT_OBEX_SERVER_ALLOCATE:
5184 case BT_OBEX_SERVER_DEALLOCATE:
5185 case BT_OBEX_SERVER_IS_ACTIVATED:
5186 case BT_OPP_GET_TRANSFER_PROGRESS:
5187 /* Non-privilege control */
5190 BT_ERR("Unknown function!");
5195 if (function_name >= BT_FUNC_MESH_BASE) {
5196 BT_INFO("MESH Function called");
5197 char app_id[256] = { 0, };
5199 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5200 app_id, sizeof(app_id))) {
5201 requester_unique_creds = g_strdup(app_id);
5203 BT_DBG("Requester app_id not found, use client creds");
5204 requester_unique_creds = g_strdup(client_creds);
5206 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5208 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5220 GDBusNodeInfo *__bt_service_create_method_node_info
5221 (const gchar *introspection_data)
5224 GDBusNodeInfo *node_info = NULL;
5226 if (introspection_data == NULL) {
5227 BT_ERR("Introspection XML not present");
5231 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5234 BT_ERR("Unable to create node: %s", err->message);
5235 g_clear_error(&err);
5240 int __bt_service_register_object(GDBusConnection *conn,
5241 GDBusNodeInfo *node_info, gboolean reg)
5243 static guint service_id = 0;
5244 GError *error = NULL;
5247 if (node_info == NULL)
5250 service_id = g_dbus_connection_register_object(conn,
5252 node_info->interfaces[0],
5254 NULL, NULL, &error);
5255 if (service_id == 0)
5258 if (service_id > 0) {
5259 g_dbus_connection_unregister_object(conn,
5268 static void __name_owner_changed(GDBusConnection *connection,
5269 const gchar *sender_name,
5270 const gchar *object_path,
5271 const gchar *interface_name,
5272 const gchar *signal_name,
5273 GVariant *parameters,
5276 const char *name = NULL;
5277 const char *old_owner = NULL;
5278 const char *new_owner = NULL;
5280 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5281 if (*new_owner != '\0')
5284 _bt_check_hdp_app_termination(name);
5286 /* Advertising App Termination */
5287 _bt_check_adv_app_termination(name);
5289 /* Check if le_scanning app is terminated */
5290 _bt_check_le_scanner_app_termination(name);
5292 /* Check if RFCOMM app is terminated */
5293 _bt_rfcomm_check_termination(name);
5296 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5297 const gchar *name, gpointer user_data)
5299 GDBusNodeInfo *node_info = NULL;
5301 BT_INFO("bus acquired");
5303 ret_if(connection == NULL);
5305 node_info = __bt_service_create_method_node_info(
5306 bt_service_introspection_xml);
5307 ret_if(node_info == NULL);
5309 __bt_service_register_object(connection, node_info, TRUE);
5310 g_dbus_node_info_unref(node_info);
5312 bt_service_conn = connection;
5315 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5316 const gchar *name, gpointer user_data)
5318 BT_INFO("name acquired");
5319 name_acquired = TRUE;
5322 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5323 const gchar *name, gpointer user_data)
5325 BT_INFO("name lost");
5326 name_acquired = FALSE;
5329 gboolean _is_name_acquired(void)
5331 return name_acquired;
5334 void _bt_service_unref_connection(void)
5338 if (bt_service_conn) {
5339 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5340 g_object_unref(bt_service_conn);
5341 bt_service_conn = NULL;
5347 int _bt_service_register(void)
5349 GDBusConnection *conn;
5352 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5353 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5354 bt_service_conn = conn;
5356 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5358 G_BUS_NAME_OWNER_FLAGS_NONE,
5359 __bt_service_bus_acquired_handler,
5360 __bt_service_name_acquired_handler,
5361 __bt_service_name_lost_handler,
5363 BT_DBG("owner_id is [%d]", owner_id);
5367 /* Subscribe for name owner changed signal */
5368 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5369 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5370 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5371 __name_owner_changed, NULL, NULL);
5372 BT_INFO("owner_sig_id: %d", owner_sig_id);
5374 return BLUETOOTH_ERROR_NONE;
5377 if (bt_service_conn) {
5378 g_object_unref(bt_service_conn);
5379 bt_service_conn = NULL;
5382 return BLUETOOTH_ERROR_INTERNAL;
5385 void _bt_service_unregister(void)
5387 if (bt_service_conn) {
5388 sd_notify(0, "STOPPING=1");
5390 if (owner_sig_id > 0) {
5391 g_dbus_connection_signal_unsubscribe(
5392 bt_service_conn, owner_sig_id);
5397 g_bus_unown_name(owner_id);
5401 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5405 int _bt_service_cynara_init(void)
5408 char err_msg[256] = {0, };
5410 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5412 result = cynara_initialize(&p_cynara, conf);
5414 if (result != CYNARA_API_SUCCESS) {
5415 cynara_strerror(result, err_msg, sizeof(err_msg));
5416 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5417 return BLUETOOTH_ERROR_INTERNAL;
5420 return BLUETOOTH_ERROR_NONE;
5423 void _bt_service_cynara_deinit(void)
5426 char err_msg[256] = {0, };
5428 ret_if(p_cynara == NULL);
5430 result = cynara_finish(p_cynara);
5432 if (result != CYNARA_API_SUCCESS) {
5433 cynara_strerror(result, err_msg, sizeof(err_msg));
5434 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5442 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5443 GArray *out_param, int result)
5447 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5448 out_param->data, out_param->len, TRUE, NULL, NULL);
5450 g_dbus_method_invocation_return_value(invocation,
5451 g_variant_new("(iv)", result, out_var));
5454 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5455 GArray *out_param, int result, GUnixFDList *fd_list)
5459 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5460 out_param->data, out_param->len, TRUE, NULL, NULL);
5462 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5463 g_variant_new("(iv)", result, out_var), fd_list);