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 static 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 static 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_DESTROY
240 || service_function == BT_MESH_NETWORK_LOAD
241 || service_function == BT_MESH_NETWORK_SCAN
242 || service_function == BT_MESH_NETWORK_ADD_NETKEY
243 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
244 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
245 || service_function == BT_MESH_NETWORK_ADD_APPKEY
246 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
247 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
253 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
254 char *sender, int service_function,
255 gpointer invocation_data)
257 invocation_info_t *info;
258 info = g_malloc0(sizeof(invocation_info_t));
259 info->context = invocation;
260 info->result = result;
261 info->sender = g_strdup(sender);
262 info->service_function = service_function;
263 info->user_data = invocation_data;
264 invocation_list = g_slist_append(invocation_list, info);
268 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
271 char err_msg[256] = {0, };
273 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
275 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
276 if (ret != CYNARA_API_SUCCESS) {
277 cynara_strerror(ret, err_msg, sizeof(err_msg));
278 BT_ERR("Fail to get user credential: %s", err_msg);
280 return BLUETOOTH_ERROR_INTERNAL;
283 return BLUETOOTH_ERROR_NONE;
286 static int __bt_bm_request_data(_bt_battery_data_t *latest)
288 int ret = _bt_bm_read_data(latest);
289 if (ret == BLUETOOTH_ERROR_NONE) {
290 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
291 latest->session_start_time, latest->session_end_time,
292 latest->session_scan_time, latest->session_connected_time);
294 if (latest->atm_list == NULL) {
295 BT_DBG("No app data transaction for this session");
299 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
300 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
301 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
305 BT_ERR("Error encountered");
309 static void __bt_service_method(GDBusConnection *connection,
311 const gchar *object_path,
312 const gchar *interface_name,
313 const gchar *method_name,
314 GVariant *parameters,
315 GDBusMethodInvocation *invocation,
320 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
321 method_name, object_path, interface_name);
323 if (g_strcmp0(method_name, "service_request") == 0) {
325 int service_function;
327 GVariant *param1 = NULL;
328 GVariant *param2 = NULL;
329 GVariant *param3 = NULL;
330 GVariant *param4 = NULL;
331 GVariant *param5 = NULL;
332 GArray *out_param1 = NULL;
333 GVariant *out_var = NULL;
334 GVariant *temp = NULL;
338 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
339 &service_function, &request_type,
340 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
342 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
344 if (service_type == BT_CORE_SERVICE) {
345 BT_DBG("No need to check privilege from bt-core");
346 } else if (__bt_service_check_privilege(service_function,
347 service_type, (const char *)sender) == FALSE) {
348 BT_ERR("Client don't have the privilege to excute this function");
349 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
353 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
354 service_type, service_function);
355 switch (service_type) {
356 case BT_BLUEZ_SERVICE:
357 result = __bt_bluez_request(service_function,
358 request_type, request_id,
359 invocation, param1, param2,
360 param3, param4, &out_param1);
362 case BT_OBEX_SERVICE:
363 result = __bt_obexd_request(service_function,
364 request_type, request_id,
367 param4, &out_param1);
369 case BT_AGENT_SERVICE:
370 result = __bt_agent_request(service_function,
371 request_type, request_id,
374 param4, &out_param1);
376 case BT_CORE_SERVICE:
377 result = __bt_core_request(service_function,
378 request_type, request_id,
381 case BT_CHECK_PRIVILEGE:
382 result = BLUETOOTH_ERROR_NONE;
385 BT_ERR("Unknown service type");
386 result = BLUETOOTH_ERROR_INTERNAL;
390 if (result != BLUETOOTH_ERROR_NONE)
393 if (service_type == BT_CHECK_PRIVILEGE)
396 if (service_function == BT_OPP_PUSH_FILES)
399 if (request_type == BT_ASYNC_REQ ||
400 __bt_is_sync_function(service_function)) {
401 /* Do not send reply to bt-api over dbus,
402 Invocation context is already saved in service_function */
407 out_var = g_variant_new_from_data((const GVariantType *)"ay",
408 out_param1->data, out_param1->len,
411 temp = g_variant_new("(iv)", result, out_var);
412 g_dbus_method_invocation_return_value(invocation, temp);
413 g_array_free(out_param1, TRUE);
417 g_variant_unref(param1);
418 g_variant_unref(param2);
419 g_variant_unref(param3);
420 g_variant_unref(param4);
421 g_variant_unref(param5);
425 BT_ERR_C("Request is failed [%s] [0x%x]",
426 _bt_convert_error_to_string(result), result);
428 out_var = g_variant_new_from_data((const GVariantType *)"ay",
429 out_param1->data, out_param1->len,
432 temp = g_variant_new("(iv)", result, out_var);
433 g_dbus_method_invocation_return_value(invocation, temp);
435 g_array_free(out_param1, TRUE);
438 g_variant_unref(param1);
439 g_variant_unref(param2);
440 g_variant_unref(param3);
441 g_variant_unref(param4);
442 g_variant_unref(param5);
444 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
445 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
446 unsigned int mode = 0;
448 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
449 BT_ERR("Fail to get the avc mode");
451 BT_DBG("Absolute Volume Control mode: %d", mode);
453 g_dbus_method_invocation_return_value(invocation,
454 g_variant_new("(u)", mode));
463 static const GDBusInterfaceVTable method_table = {
470 int __bt_bluez_request(int function_name,
473 GDBusMethodInvocation *context,
480 int result = BLUETOOTH_ERROR_NONE;
483 switch (function_name) {
484 case BT_ENABLE_ADAPTER: {
485 result = _bt_enable_adapter();
486 _bt_adapter_start_enable_timer();
489 case BT_DISABLE_ADAPTER: {
490 result = _bt_disable_adapter();
493 case BT_RECOVER_ADAPTER:
494 result = _bt_recover_adapter();
496 case BT_RESET_ADAPTER:
497 result = _bt_reset_adapter();
499 case BT_BATTERY_READ_DATA: {
500 _bt_battery_data_t *data = NULL;
501 data = g_malloc0(sizeof(_bt_battery_data_t));
502 result = __bt_bm_request_data(data);
504 bt_battery_dbus_data_t dbus_data;
505 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
506 dbus_data.session_start_time = data->session_start_time;
507 dbus_data.session_end_time = data->session_end_time;
508 dbus_data.session_scan_time = data->session_scan_time;
509 dbus_data.session_connected_time = data->session_connected_time;
510 dbus_data.tx_time = data->tx_time;
511 dbus_data.rx_time = data->rx_time;
512 dbus_data.idle_time = data->idle_time;
514 /*Populating app data*/
516 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
517 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
518 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
521 dbus_data.num_app = n;
522 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
523 g_slist_free_full(data->atm_list, g_free);
528 case BT_CHECK_ADAPTER: {
529 int enabled = BT_ADAPTER_DISABLED;
530 result = _bt_check_adapter(&enabled);
532 g_array_append_vals(*out_param1, &enabled,
536 case BT_ENABLE_ADAPTER_LE:
537 _bt_set_le_intended_status(TRUE);
538 result = _bt_enable_adapter_le();
540 case BT_DISABLE_ADAPTER_LE:
541 _bt_set_le_intended_status(FALSE);
542 result = _bt_disable_adapter_le();
544 case BT_START_DISCOVERY: {
545 unsigned short max_response;
546 unsigned short discovery_duration;
547 unsigned int classOfDeviceMask;
550 __bt_service_get_parameters(in_param1,
551 &max_response, sizeof(unsigned short));
552 __bt_service_get_parameters(in_param2,
553 &discovery_duration, sizeof(unsigned short));
554 __bt_service_get_parameters(in_param3,
555 &classOfDeviceMask, sizeof(unsigned int));
556 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
558 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
560 if (result == BLUETOOTH_ERROR_NONE) {
563 sender = (char*)g_dbus_method_invocation_get_sender(context);
565 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
566 BT_ERR("Fail to get the sender pid");
568 BT_DBG("Remeber pid / uid for the scan operation");
569 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
574 case BT_START_CUSTOM_DISCOVERY: {
575 bt_discovery_role_type_t role;
577 __bt_service_get_parameters(in_param1,
578 &role, sizeof(bt_discovery_role_type_t));
579 result = _bt_start_custom_discovery(role);
583 case BT_CANCEL_DISCOVERY:
584 result = _bt_cancel_discovery();
586 case BT_IS_DISCOVERYING: {
587 gboolean discovering = FALSE;
588 discovering = _bt_is_discovering();
589 g_array_append_vals(*out_param1,
590 &discovering, sizeof(gboolean));
593 case BT_GET_LOCAL_ADDRESS: {
594 result = _bt_get_local_address();
596 /* Save invocation */
597 if (result == BLUETOOTH_ERROR_NONE) {
598 sender = (char*)g_dbus_method_invocation_get_sender(context);
599 _bt_save_invocation_context(context, result, sender,
600 function_name, NULL);
604 case BT_GET_LOCAL_VERSION: {
605 result = _bt_get_local_version();
607 /* Save invocation */
608 if (result == BLUETOOTH_ERROR_NONE) {
609 sender = (char*)g_dbus_method_invocation_get_sender(context);
610 _bt_save_invocation_context(context, result, sender,
611 function_name, NULL);
615 case BT_GET_LOCAL_NAME: {
616 result = _bt_get_local_name();
618 /* Save invocation */
619 if (result == BLUETOOTH_ERROR_NONE) {
620 sender = (char*)g_dbus_method_invocation_get_sender(context);
621 _bt_save_invocation_context(context, result, sender,
622 function_name, NULL);
626 case BT_SET_LOCAL_NAME: {
627 bluetooth_device_name_t local_name = { {0} };
628 __bt_service_get_parameters(in_param1,
629 &local_name, sizeof(bluetooth_device_name_t));
630 result = _bt_set_local_name(local_name.name);
633 case BT_GET_DISCOVERABLE_MODE: {
634 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
635 result = _bt_get_discoverable_mode(&discoverable_mode);
636 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
639 case BT_GET_DISCOVERABLE_TIME: {
642 result = _bt_get_timeout_value(&timeout);
643 g_array_append_vals(*out_param1, &timeout, sizeof(int));
646 case BT_SET_DISCOVERABLE_MODE: {
647 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
650 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
651 __bt_service_get_parameters(in_param2, &time, sizeof(int));
653 result = _bt_set_discoverable_mode(mode, time);
656 case BT_IS_CONNECTABLE: {
657 gboolean is_connectable = FALSE;
659 is_connectable = _bt_is_connectable();
660 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
663 case BT_GET_CONNECTABLE: {
664 result = _bt_get_connectable();
666 /* Save invocation */
667 if (result == BLUETOOTH_ERROR_NONE) {
668 sender = (char*)g_dbus_method_invocation_get_sender(context);
669 _bt_save_invocation_context(context, result, sender,
670 function_name, NULL);
674 case BT_SET_CONNECTABLE: {
675 gboolean is_connectable;
677 __bt_service_get_parameters(in_param1,
678 &is_connectable, sizeof(gboolean));
679 result = _bt_set_connectable(is_connectable);
682 case BT_IS_SERVICE_USED: {
685 uuid = (char *)g_variant_get_data(in_param1);
686 BT_INFO("UUID to be searched [%s]", uuid);
687 result = _bt_is_service_used();
689 /* Save invocation */
690 if (result == BLUETOOTH_ERROR_NONE) {
691 sender = (char*)g_dbus_method_invocation_get_sender(context);
692 _bt_save_invocation_context(context, result, sender,
693 function_name, g_strdup(uuid));
697 case BT_GET_BONDED_DEVICES: {
698 result = _bt_get_bonded_devices();
699 /* Save invocation */
700 if (result == BLUETOOTH_ERROR_NONE) {
701 sender = (char*)g_dbus_method_invocation_get_sender(context);
702 _bt_save_invocation_context(context, result, sender,
703 function_name, NULL);
707 case BT_GET_BONDED_DEVICE: {
708 bluetooth_device_address_t address = { {0} };
710 __bt_service_get_parameters(in_param1,
711 &address, sizeof(bluetooth_device_address_t));
713 result = _bt_get_bonded_device_info(&address);
714 /* Save invocation */
715 if (result == BLUETOOTH_ERROR_NONE) {
716 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
718 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
722 _bt_convert_addr_type_to_string(addr, address.addr);
723 sender = (char*)g_dbus_method_invocation_get_sender(context);
724 _bt_save_invocation_context(context, result, sender,
725 function_name, addr);
729 case BT_GET_PROFILE_CONNECTED_DEVICES: {
731 uuid = (char *)g_variant_get_data(in_param1);
732 result = _bt_get_profile_connected_devices(uuid);
734 /* Save invocation */
735 if (result == BLUETOOTH_ERROR_NONE) {
736 sender = (char *)g_dbus_method_invocation_get_sender(context);
737 _bt_save_invocation_context(context, result, sender,
738 function_name, NULL);
743 bluetooth_device_address_t address = { {0} };
744 const char *local_name;
746 __bt_service_get_parameters(in_param1,
747 &address, sizeof(bluetooth_device_address_t));
748 local_name = (const char *)g_variant_get_data(in_param2);
750 result = _bt_set_alias(&address, local_name);
753 case BT_BOND_DEVICE: {
754 bluetooth_device_address_t address = { {0} };
756 __bt_service_get_parameters(in_param1,
757 &address, sizeof(bluetooth_device_address_t));
758 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
760 /* Save invocation */
761 if (result == BLUETOOTH_ERROR_NONE) {
762 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
763 _bt_convert_addr_type_to_string(addr, address.addr);
764 sender = (char*)g_dbus_method_invocation_get_sender(context);
765 _bt_save_invocation_context(context, result, sender,
766 function_name, (gpointer)addr);
768 bluetooth_device_info_t dev_info;
770 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
771 memcpy(&dev_info.device_address, &address,
772 sizeof(bluetooth_device_address_t));
773 g_array_append_vals(*out_param1, &dev_info,
774 sizeof(bluetooth_device_info_t));
778 case BT_BOND_DEVICE_BY_TYPE: {
779 bluetooth_device_address_t address = { {0} };
780 unsigned short conn_type = 0;
782 __bt_service_get_parameters(in_param1,
783 &address, sizeof(bluetooth_device_address_t));
784 __bt_service_get_parameters(in_param2,
785 &conn_type, sizeof(unsigned short));
787 result = _bt_bond_device(&address, conn_type, out_param1);
788 /* Save invocation */
789 if (result == BLUETOOTH_ERROR_NONE) {
790 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
791 _bt_convert_addr_type_to_string(addr, address.addr);
792 sender = (char*)g_dbus_method_invocation_get_sender(context);
793 _bt_save_invocation_context(context, result, sender,
794 function_name, (gpointer)addr);
796 bluetooth_device_info_t dev_info;
798 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
799 memcpy(&dev_info.device_address, &address,
800 sizeof(bluetooth_device_address_t));
801 g_array_append_vals(*out_param1, &dev_info,
802 sizeof(bluetooth_device_info_t));
806 case BT_UNBOND_DEVICE: {
807 bluetooth_device_address_t address = { {0} };
809 __bt_service_get_parameters(in_param1,
810 &address, sizeof(bluetooth_device_address_t));
811 result = _bt_unbond_device(&address, out_param1);
813 /* Save invocation */
814 if (result == BLUETOOTH_ERROR_NONE) {
815 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
816 _bt_convert_addr_type_to_string(addr, address.addr);
817 sender = (char*)g_dbus_method_invocation_get_sender(context);
818 _bt_save_invocation_context(context, result, sender,
819 function_name, (gpointer)addr);
821 g_array_append_vals(*out_param1, &address,
822 sizeof(bluetooth_device_address_t));
826 case BT_CANCEL_BONDING:{
827 result = _bt_cancel_bonding();
830 case BT_SEARCH_SERVICE: {
831 bluetooth_device_address_t address = { {0} };
832 __bt_service_get_parameters(in_param1,
833 &address, sizeof(bluetooth_device_address_t));
834 result = _bt_search_device(&address);
835 /* Save invocation */
836 if (result == BLUETOOTH_ERROR_NONE) {
837 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
838 _bt_convert_addr_type_to_string(addr, address.addr);
839 sender = (char*)g_dbus_method_invocation_get_sender(context);
840 _bt_save_invocation_context(context, result, sender,
841 function_name, (gpointer)addr);
843 bt_sdp_info_t sdp_info;
845 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
846 memcpy(&sdp_info.device_addr, &address,
847 sizeof(bluetooth_device_address_t));
848 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
852 case BT_CANCEL_SEARCH_SERVICE: {
853 result = _bt_cancel_search_device();
856 case BT_SET_PASSKEY_NOTIFICATION: {
860 sender = (char *)g_dbus_method_invocation_get_sender(context);
861 __bt_service_get_parameters(in_param1,
862 &enable, sizeof(gboolean));
864 result = _bt_set_passkey_notification(sender, enable);
867 case BT_SET_PIN_CODE: {
868 bluetooth_device_address_t address = { {0} };
869 bluetooth_device_pin_code_t pin_code = { {0} };
871 __bt_service_get_parameters(in_param1,
872 &address, sizeof(bluetooth_device_address_t));
873 __bt_service_get_parameters(in_param2,
874 &pin_code, sizeof(bluetooth_device_pin_code_t));
876 result = _bt_set_pin_code(&address, &pin_code);
879 case BT_UNSET_PIN_CODE: {
880 bluetooth_device_address_t address = { {0} };
882 __bt_service_get_parameters(in_param1,
883 &address, sizeof(bluetooth_device_address_t));
885 result = _bt_unset_pin_code(&address);
888 case BT_PASSKEY_REPLY: {
889 const char *passkey = NULL;
890 gboolean authentication_reply = FALSE;
891 passkey = g_variant_get_data(in_param1);
892 __bt_service_get_parameters(in_param2,
893 &authentication_reply, sizeof(gboolean));
894 result = _bt_passkey_reply(passkey, authentication_reply);
897 case BT_PASSKEY_CONFIRMATION_REPLY: {
898 gboolean confirmation_reply = FALSE;
899 __bt_service_get_parameters(in_param1,
900 &confirmation_reply, sizeof(gboolean));
901 result = _bt_passkey_confirmation_reply(confirmation_reply);
904 case BT_GET_IS_ALIAS_SET: {
905 bluetooth_device_address_t address = { {0} };
907 __bt_service_get_parameters(in_param1,
908 &address, sizeof(bluetooth_device_address_t));
910 result = _bt_is_alias_set(&address);
911 if (result == BLUETOOTH_ERROR_NONE) {
912 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
914 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
918 _bt_convert_addr_type_to_string(addr, address.addr);
919 sender = (char*)g_dbus_method_invocation_get_sender(context);
920 _bt_save_invocation_context(context, result, sender,
921 function_name, addr);
925 case BT_SET_AUTHORIZATION: {
926 bluetooth_device_address_t address = { {0} };
928 __bt_service_get_parameters(in_param1,
929 &address, sizeof(bluetooth_device_address_t));
930 __bt_service_get_parameters(in_param2,
931 &authorize, sizeof(gboolean));
932 result = _bt_set_authorization(&address, authorize);
935 case BT_SET_LE_PRIVACY: {
936 gboolean set_privacy;
937 __bt_service_get_parameters(in_param1, &set_privacy,
939 result = _bt_set_le_privacy(set_privacy);
942 case BT_ADD_WHITE_LIST: {
943 bluetooth_device_address_t address = { {0} };
944 int address_type = 0;
946 __bt_service_get_parameters(in_param1,
947 &address, sizeof(bluetooth_device_address_t));
948 __bt_service_get_parameters(in_param2,
949 &address_type, sizeof(int));
950 result = _bt_set_white_list(&address, address_type, is_add);
953 case BT_REMOVE_WHITE_LIST: {
954 bluetooth_device_address_t address = { {0} };
955 int address_type = 0;
957 __bt_service_get_parameters(in_param1,
958 &address, sizeof(bluetooth_device_address_t));
959 __bt_service_get_parameters(in_param2,
960 &address_type, sizeof(int));
961 result = _bt_set_white_list(&address, address_type, is_add);
964 case BT_UPDATE_LE_CONNECTION_MODE: {
966 bluetooth_device_address_t remote_address = { { 0 } };
967 bluetooth_le_connection_param_t parameters = { 0 };
968 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
970 __bt_service_get_parameters(in_param1, &remote_address,
971 sizeof(bluetooth_device_address_t));
972 __bt_service_get_parameters(in_param2, &mode,
973 sizeof(bluetooth_le_connection_mode_t));
975 result = _bt_get_le_connection_parameter(mode, ¶meters);
976 if (result != BLUETOOTH_ERROR_NONE)
979 sender = (char *)g_dbus_method_invocation_get_sender(context);
981 result = _bt_le_connection_update(sender,
983 parameters.interval_min,
984 parameters.interval_max,
989 case BT_SET_MANUFACTURER_DATA: {
990 bluetooth_manufacturer_data_t m_data = { 0 };
991 __bt_service_get_parameters(in_param1,
992 &m_data, sizeof(bluetooth_manufacturer_data_t));
993 result = _bt_set_manufacturer_data(&m_data);
997 case BT_IS_DEVICE_CONNECTED: {
998 bluetooth_device_address_t address = { {0} };
999 gboolean connected = FALSE;
1002 __bt_service_get_parameters(in_param1,
1003 &address, sizeof(bluetooth_device_address_t));
1004 __bt_service_get_parameters(in_param2,
1005 &service_type, sizeof(int));
1007 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1008 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1009 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1011 connected = _bt_is_device_connected(&address, service_type);
1013 connected = _bt_is_device_connected(&address, service_type);
1015 BT_INFO("is_connected: %d", connected);
1016 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1019 case BT_GET_CONNECTED_LINK_TYPE: {
1020 bluetooth_device_address_t address = { {0} };
1022 __bt_service_get_parameters(in_param1,
1023 &address, sizeof(bluetooth_device_address_t));
1025 result = _bt_get_connected_link(&address);
1026 if (result == BLUETOOTH_ERROR_NONE) {
1027 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1029 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1033 _bt_convert_addr_type_to_string(addr, address.addr);
1034 sender = (char*)g_dbus_method_invocation_get_sender(context);
1035 _bt_save_invocation_context(context, result, sender,
1036 function_name, addr);
1040 case BT_IS_SCAN_FILTER_SUPPORTED:{
1041 int is_supported = 0;
1043 if (_bt_is_scan_filter_supported() == TRUE)
1046 g_array_append_vals(*out_param1,
1047 &is_supported, sizeof(int));
1051 case BT_ENABLE_RSSI: {
1052 bluetooth_device_address_t bd_addr;
1054 bt_rssi_threshold_t rssi_threshold;
1056 int in_range_threshold;
1059 BT_DBG("Enable RSSI");
1061 __bt_service_get_parameters(in_param1,
1062 &bd_addr, sizeof(bluetooth_device_address_t));
1063 __bt_service_get_parameters(in_param2,
1064 &link_type, sizeof(int));
1065 __bt_service_get_parameters(in_param3,
1066 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1068 low_threshold = rssi_threshold.low_threshold;
1069 in_range_threshold = rssi_threshold.in_range_threshold;
1070 high_threshold = rssi_threshold.high_threshold;
1072 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1073 in_range_threshold, high_threshold);
1078 bluetooth_device_address_t bd_addr;
1080 BT_DBG("Get RSSI Strength");
1082 __bt_service_get_parameters(in_param1,
1083 &bd_addr, sizeof(bluetooth_device_address_t));
1084 __bt_service_get_parameters(in_param2,
1085 &link_type, sizeof(int));
1087 result = _bt_get_rssi_strength(&bd_addr, link_type);
1090 case BT_SET_PROFILE_TRUSTED: {
1091 bluetooth_device_address_t bd_addr = { {0} };
1095 __bt_service_get_parameters(in_param1, &bd_addr,
1096 sizeof(bluetooth_device_address_t));
1097 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1098 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1100 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1103 case BT_GET_PROFILE_TRUSTED: {
1104 bluetooth_device_address_t bd_addr = { {0} };
1106 guint trusted_profile = 0;
1108 __bt_service_get_parameters(in_param1, &bd_addr,
1109 sizeof(bluetooth_device_address_t));
1110 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1112 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1113 BT_DBG("TRUST %d", trusted_profile);
1114 if (result == BLUETOOTH_ERROR_NONE) {
1115 g_array_append_vals(*out_param1, &trusted_profile,
1121 case BT_HID_CONNECT: {
1122 bluetooth_device_address_t address = { {0} };
1124 __bt_service_get_parameters(in_param1,
1125 &address, sizeof(bluetooth_device_address_t));
1127 result = _bt_hid_connect(&address);
1128 if (result != BLUETOOTH_ERROR_NONE) {
1129 g_array_append_vals(*out_param1, &address,
1130 sizeof(bluetooth_device_address_t));
1132 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1133 _bt_convert_addr_type_to_string(addr, address.addr);
1134 sender = (char*)g_dbus_method_invocation_get_sender(context);
1135 _bt_save_invocation_context(context, result, sender,
1136 function_name, (gpointer)addr);
1140 case BT_HID_DISCONNECT: {
1141 bluetooth_device_address_t address = { {0} };
1143 __bt_service_get_parameters(in_param1,
1144 &address, sizeof(bluetooth_device_address_t));
1146 result = _bt_hid_disconnect(&address);
1147 if (result != BLUETOOTH_ERROR_NONE) {
1148 g_array_append_vals(*out_param1, &address,
1149 sizeof(bluetooth_device_address_t));
1151 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1152 _bt_convert_addr_type_to_string(addr, address.addr);
1153 sender = (char*)g_dbus_method_invocation_get_sender(context);
1154 _bt_save_invocation_context(context, result, sender,
1155 function_name, (gpointer)addr);
1159 #ifdef TIZEN_FEATURE_BT_DPM
1160 case BT_DPM_SET_ALLOW_BT_MODE: {
1161 dpm_bt_allow_t value = DPM_BT_ERROR;
1163 __bt_service_get_parameters(in_param1, &value,
1166 result = _bt_dpm_set_allow_bluetooth_mode(value);
1169 case BT_DPM_GET_ALLOW_BT_MODE: {
1170 int value = DPM_BT_ERROR;
1172 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1173 g_array_append_vals(*out_param1, &value, sizeof(int));
1176 case BT_DPM_SET_DEVICE_RESTRITION: {
1177 dpm_status_t value = DPM_STATUS_ERROR;
1179 __bt_service_get_parameters(in_param1, &value,
1182 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1185 case BT_DPM_GET_DEVICE_RESTRITION: {
1186 int value = DPM_STATUS_ERROR;
1188 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1189 g_array_append_vals(*out_param1, &value, sizeof(int));
1192 case BT_DPM_SET_UUID_RESTRITION: {
1193 dpm_status_t value = DPM_STATUS_ERROR;
1195 __bt_service_get_parameters(in_param1, &value,
1198 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1201 case BT_DPM_GET_UUID_RESTRITION: {
1202 int value = DPM_STATUS_ERROR;
1204 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1205 g_array_append_vals(*out_param1, &value, sizeof(int));
1208 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1209 bluetooth_device_address_t address = { {0} };
1211 __bt_service_get_parameters(in_param1, &address,
1212 sizeof(bluetooth_device_address_t));
1214 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1217 case BT_DPM_ADD_DEVICES_WHITELIST: {
1218 bluetooth_device_address_t address = { {0} };
1220 __bt_service_get_parameters(in_param1, &address,
1221 sizeof(bluetooth_device_address_t));
1223 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1226 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1227 const char *uuid = NULL;
1229 uuid = g_variant_get_data(in_param1);
1231 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1234 case BT_DPM_ADD_UUIDS_WHITELIST: {
1235 const char *uuid = NULL;
1237 uuid = g_variant_get_data(in_param1);
1239 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1242 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1243 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1246 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1247 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1250 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1251 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1254 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1255 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1258 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1259 bluetooth_device_address_t address = { {0} };
1261 __bt_service_get_parameters(in_param1, &address,
1262 sizeof(bluetooth_device_address_t));
1264 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1267 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1268 bluetooth_device_address_t address = { {0} };
1270 __bt_service_get_parameters(in_param1, &address,
1271 sizeof(bluetooth_device_address_t));
1273 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1276 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1277 const char *uuid = NULL;
1279 uuid = g_variant_get_data(in_param1);
1281 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1284 case BT_DPM_REMOVE_UUID_WHITELIST: {
1285 const char *uuid = NULL;
1287 uuid = g_variant_get_data(in_param1);
1289 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1293 case BT_DPM_GET_DEVICES_BLACKLIST: {
1294 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1297 case BT_DPM_GET_DEVICES_WHITELIST: {
1298 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1301 case BT_DPM_GET_UUIDS_BLACKLIST: {
1302 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1305 case BT_DPM_GET_UUIDS_WHITELIST: {
1306 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1309 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1310 dpm_status_t value = DPM_STATUS_ERROR;
1312 __bt_service_get_parameters(in_param1, &value,
1315 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1319 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1320 int value = DPM_STATUS_ERROR;
1322 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1323 g_array_append_vals(*out_param1, &value, sizeof(int));
1326 case BT_DPM_SET_PAIRING_STATE: {
1327 dpm_status_t value = DPM_STATUS_ERROR;
1329 __bt_service_get_parameters(in_param1, &value,
1332 result = _bt_dpm_set_bluetooth_pairing_state(value);
1336 case BT_DPM_GET_PAIRING_STATE: {
1337 int value = DPM_STATUS_ERROR;
1339 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1340 g_array_append_vals(*out_param1, &value, sizeof(int));
1343 case BT_DPM_SET_PROFILE_STATE: {
1344 int value = DPM_STATUS_ERROR;
1345 int profile = DPM_PROFILE_NONE;
1347 __bt_service_get_parameters(in_param1, &profile,
1349 __bt_service_get_parameters(in_param2, &value,
1352 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1356 case BT_DPM_GET_PROFILE_STATE: {
1357 int value = DPM_STATUS_ERROR;
1358 int profile = DPM_PROFILE_NONE;
1360 __bt_service_get_parameters(in_param1, &profile,
1363 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1364 g_array_append_vals(*out_param1, &value, sizeof(int));
1367 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1368 int value = DPM_BT_ERROR;
1370 __bt_service_get_parameters(in_param1, &value,
1373 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1377 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1378 int value = DPM_STATUS_ERROR;
1380 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1381 g_array_append_vals(*out_param1, &value, sizeof(int));
1384 case BT_DPM_SET_DISCOVERABLE_STATE: {
1385 int value = DPM_STATUS_ERROR;
1387 __bt_service_get_parameters(in_param1, &value,
1390 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1394 case BT_DPM_GET_DISCOVERABLE_STATE: {
1395 int value = DPM_STATUS_ERROR;
1397 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1398 g_array_append_vals(*out_param1, &value, sizeof(int));
1401 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1402 int value = DPM_STATUS_ERROR;
1404 __bt_service_get_parameters(in_param1, &value,
1407 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1411 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1412 int value = DPM_STATUS_ERROR;
1414 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1415 g_array_append_vals(*out_param1, &value, sizeof(int));
1418 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1419 int value = DPM_STATUS_ERROR;
1421 __bt_service_get_parameters(in_param1, &value,
1424 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1428 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1429 int value = DPM_STATUS_ERROR;
1431 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1432 g_array_append_vals(*out_param1, &value, sizeof(int));
1436 case BT_RFCOMM_CLIENT_CONNECT: {
1437 bluetooth_device_address_t address = { {0} };
1441 __bt_service_get_parameters(in_param1,
1442 &address, sizeof(bluetooth_device_address_t));
1443 input_string = (char *)g_variant_get_data(in_param2);
1444 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1446 if (connect_type == BT_RFCOMM_UUID)
1447 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1449 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1451 if (result != BLUETOOTH_ERROR_NONE) {
1452 bluetooth_rfcomm_connection_t conn_info;
1454 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1455 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1456 if (connect_type == BT_RFCOMM_UUID)
1457 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1459 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1461 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1462 conn_info.socket_fd = -1;
1463 g_array_append_vals(*out_param1, &conn_info,
1464 sizeof(bluetooth_rfcomm_connection_t));
1466 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1467 _bt_convert_addr_type_to_string(addr, address.addr);
1468 sender = (char*)g_dbus_method_invocation_get_sender(context);
1469 _bt_save_invocation_context(context, result, sender, function_name, addr);
1473 case BT_RFCOMM_SOCKET_DISCONNECT: {
1475 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1476 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1478 result = BLUETOOTH_ERROR_NONE;
1481 case BT_RFCOMM_SOCKET_WRITE: {
1483 * This call to bt-service is only used for privilege check, so return
1484 * BLUETOOTH_ERROR_NONE from here.
1486 result = BLUETOOTH_ERROR_NONE;
1489 case BT_RFCOMM_CREATE_SOCKET: {
1491 * This call to bt-service is only used for privilege check, so return
1492 * BLUETOOTH_ERROR_NONE from here.
1494 result = BLUETOOTH_ERROR_NONE;
1497 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1501 sender = (char *)g_dbus_method_invocation_get_sender(context);
1502 uuid = (char *)g_variant_get_data(in_param1);
1504 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1506 result = BLUETOOTH_ERROR_NONE;
1507 _bt_save_invocation_context(context,
1508 result, sender, function_name, NULL);
1510 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1514 case BT_RFCOMM_LISTEN: {
1518 sender = (char *)g_dbus_method_invocation_get_sender(context);
1519 uuid = (char *)g_variant_get_data(in_param1);
1521 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1523 result = BLUETOOTH_ERROR_NONE;
1524 _bt_save_invocation_context(context,
1525 result, sender, function_name, NULL);
1527 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1531 case BT_RFCOMM_ACCEPT_CONNECTION: {
1534 address = (char *)g_variant_get_data(in_param1);
1535 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1538 case BT_RFCOMM_REJECT_CONNECTION: {
1541 address = (char *)g_variant_get_data(in_param1);
1542 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1545 case BT_RFCOMM_REMOVE_SOCKET: {
1547 * This call to bt-service is only used for privilege check, so return
1548 * BLUETOOTH_ERROR_NONE from here.
1550 result = BLUETOOTH_ERROR_NONE;
1553 case BT_RFCOMM_SEND_RX_DETAILS: {
1557 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1558 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1559 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1560 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1563 case BT_RFCOMM_SEND_TX_DETAILS: {
1567 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1568 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1569 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1570 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1573 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1574 gboolean connected = FALSE;
1576 int role = RFCOMM_ROLE_SERVER;
1578 sender = (char *)g_dbus_method_invocation_get_sender(context);
1580 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1581 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1582 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1584 if (connected == TRUE)
1585 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1587 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1591 case BT_AUDIO_SELECT_ROLE: {
1592 bluetooth_audio_role_t role;
1594 __bt_service_get_parameters(in_param1,
1595 &role, sizeof(bluetooth_audio_role_t));
1597 result = _bt_audio_select_role(role);
1598 if (result == BLUETOOTH_ERROR_NONE) {
1599 sender = (char*)g_dbus_method_invocation_get_sender(context);
1600 _bt_save_invocation_context(context, result, sender,
1601 function_name, NULL);
1605 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
1606 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1607 unsigned int volume = 0;
1609 __bt_service_get_parameters(in_param1,
1610 &volume, sizeof(unsigned int));
1612 result = _bt_audio_set_absolute_volume(volume);
1615 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1616 unsigned int volume = 0;
1618 result = _bt_audio_get_absolute_volume(&volume);
1619 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1622 case BT_AUDIO_IS_AVC_ACTIVATED: {
1625 result = _bt_audio_is_avc_activated(&activated);
1626 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1630 case BT_AV_CONNECT: {
1631 bluetooth_device_address_t address = { {0} };
1632 __bt_service_get_parameters(in_param1,
1633 &address, sizeof(bluetooth_device_address_t));
1635 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1637 if (result != BLUETOOTH_ERROR_NONE) {
1638 char addr[BT_ADDRESS_STRING_SIZE];
1639 _bt_convert_addr_type_to_string(addr, address.addr);
1640 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1642 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1643 _bt_convert_addr_type_to_string(addr, address.addr);
1644 sender = (char*)g_dbus_method_invocation_get_sender(context);
1645 _bt_save_invocation_context(context, result, sender,
1646 function_name, (gpointer)addr);
1650 case BT_AUDIO_CONNECT: {
1651 bluetooth_device_address_t address = { {0} };
1652 __bt_service_get_parameters(in_param1,
1653 &address, sizeof(bluetooth_device_address_t));
1655 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1657 if (result != BLUETOOTH_ERROR_NONE) {
1658 char addr[BT_ADDRESS_STRING_SIZE];
1659 _bt_convert_addr_type_to_string(addr, address.addr);
1660 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1662 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1663 _bt_convert_addr_type_to_string(addr, address.addr);
1664 sender = (char*)g_dbus_method_invocation_get_sender(context);
1665 _bt_save_invocation_context(context, result, sender,
1666 function_name, (gpointer)addr);
1670 case BT_AUDIO_DISCONNECT: {
1671 bluetooth_device_address_t address = { {0} };
1672 __bt_service_get_parameters(in_param1,
1673 &address, sizeof(bluetooth_device_address_t));
1675 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1677 if (result != BLUETOOTH_ERROR_NONE) {
1678 char addr[BT_ADDRESS_STRING_SIZE];
1679 _bt_convert_addr_type_to_string(addr, address.addr);
1680 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1682 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1683 _bt_convert_addr_type_to_string(addr, address.addr);
1684 sender = (char*)g_dbus_method_invocation_get_sender(context);
1685 _bt_save_invocation_context(context, result, sender,
1686 function_name, (gpointer)addr);
1690 case BT_AV_DISCONNECT: {
1691 bluetooth_device_address_t address = { {0} };
1692 __bt_service_get_parameters(in_param1,
1693 &address, sizeof(bluetooth_device_address_t));
1695 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1697 if (result != BLUETOOTH_ERROR_NONE) {
1698 char addr[BT_ADDRESS_STRING_SIZE];
1699 _bt_convert_addr_type_to_string(addr, address.addr);
1700 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1702 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1703 _bt_convert_addr_type_to_string(addr, address.addr);
1704 sender = (char*)g_dbus_method_invocation_get_sender(context);
1705 _bt_save_invocation_context(context, result, sender,
1706 function_name, (gpointer)addr);
1710 case BT_AG_CONNECT: {
1711 bluetooth_device_address_t address = { {0} };
1712 __bt_service_get_parameters(in_param1,
1713 &address, sizeof(bluetooth_device_address_t));
1715 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1717 if (result != BLUETOOTH_ERROR_NONE) {
1718 char addr[BT_ADDRESS_STRING_SIZE];
1719 _bt_convert_addr_type_to_string(addr, address.addr);
1720 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1722 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1723 _bt_convert_addr_type_to_string(addr, address.addr);
1724 sender = (char*)g_dbus_method_invocation_get_sender(context);
1725 _bt_save_invocation_context(context, result, sender,
1726 function_name, (gpointer)addr);
1730 case BT_AG_DISCONNECT: {
1731 bluetooth_device_address_t address = { {0} };
1733 __bt_service_get_parameters(in_param1,
1734 &address, sizeof(bluetooth_device_address_t));
1736 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1738 if (result != BLUETOOTH_ERROR_NONE) {
1739 char addr[BT_ADDRESS_STRING_SIZE];
1740 _bt_convert_addr_type_to_string(addr, address.addr);
1741 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1743 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1744 _bt_convert_addr_type_to_string(addr, address.addr);
1745 sender = (char*)g_dbus_method_invocation_get_sender(context);
1746 _bt_save_invocation_context(context, result, sender,
1747 function_name, (gpointer)addr);
1751 case BT_AV_SOURCE_CONNECT: {
1752 bluetooth_device_address_t address = { {0} };
1754 __bt_service_get_parameters(in_param1,
1755 &address, sizeof(bluetooth_device_address_t));
1757 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1758 if (result != BLUETOOTH_ERROR_NONE) {
1759 char addr[BT_ADDRESS_STRING_SIZE];
1760 _bt_convert_addr_type_to_string(addr, address.addr);
1761 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1763 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1764 _bt_convert_addr_type_to_string(addr, address.addr);
1765 sender = (char*)g_dbus_method_invocation_get_sender(context);
1766 _bt_save_invocation_context(context, result, sender,
1767 function_name, (gpointer)addr);
1771 case BT_AV_SOURCE_DISCONNECT: {
1772 bluetooth_device_address_t address = { {0} };
1774 __bt_service_get_parameters(in_param1,
1775 &address, sizeof(bluetooth_device_address_t));
1777 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1778 if (result != BLUETOOTH_ERROR_NONE) {
1779 char addr[BT_ADDRESS_STRING_SIZE];
1780 _bt_convert_addr_type_to_string(addr, address.addr);
1781 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1783 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1784 _bt_convert_addr_type_to_string(addr, address.addr);
1785 sender = (char*)g_dbus_method_invocation_get_sender(context);
1786 _bt_save_invocation_context(context, result, sender,
1787 function_name, (gpointer)addr);
1791 case BT_HF_CONNECT: {
1792 bluetooth_device_address_t address = { {0} };
1794 __bt_service_get_parameters(in_param1,
1795 &address, sizeof(bluetooth_device_address_t));
1797 result = _bt_hf_connect(&address);
1798 if (result != BLUETOOTH_ERROR_NONE) {
1799 char addr[BT_ADDRESS_STRING_SIZE];
1800 _bt_convert_addr_type_to_string(addr, address.addr);
1801 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1803 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1804 _bt_convert_addr_type_to_string(addr, address.addr);
1805 sender = (char*)g_dbus_method_invocation_get_sender(context);
1806 _bt_save_invocation_context(context, result, sender,
1807 function_name, (gpointer)addr);
1811 case BT_HF_DISCONNECT: {
1812 bluetooth_device_address_t address = { {0} };
1814 __bt_service_get_parameters(in_param1,
1815 &address, sizeof(bluetooth_device_address_t));
1817 result = _bt_hf_disconnect(&address);
1818 if (result != BLUETOOTH_ERROR_NONE) {
1819 char addr[BT_ADDRESS_STRING_SIZE];
1820 _bt_convert_addr_type_to_string(addr, address.addr);
1821 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1823 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1824 _bt_convert_addr_type_to_string(addr, address.addr);
1825 sender = (char*)g_dbus_method_invocation_get_sender(context);
1826 _bt_save_invocation_context(context, result, sender,
1827 function_name, (gpointer)addr);
1831 case BT_AVRCP_TARGET_CONNECT: {
1832 bluetooth_device_address_t address = { {0} };
1834 __bt_service_get_parameters(in_param1,
1835 &address, sizeof(bluetooth_device_address_t));
1837 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1838 if (result != BLUETOOTH_ERROR_NONE) {
1839 char addr[BT_ADDRESS_STRING_SIZE];
1840 _bt_convert_addr_type_to_string(addr, address.addr);
1841 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1843 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1844 _bt_convert_addr_type_to_string(addr, address.addr);
1845 sender = (char*)g_dbus_method_invocation_get_sender(context);
1846 _bt_save_invocation_context(context, result, sender,
1847 function_name, (gpointer)addr);
1851 case BT_AVRCP_TARGET_DISCONNECT: {
1852 bluetooth_device_address_t address = { {0} };
1854 __bt_service_get_parameters(in_param1,
1855 &address, sizeof(bluetooth_device_address_t));
1857 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1858 if (result != BLUETOOTH_ERROR_NONE) {
1859 char addr[BT_ADDRESS_STRING_SIZE];
1860 _bt_convert_addr_type_to_string(addr, address.addr);
1861 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1863 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1864 _bt_convert_addr_type_to_string(addr, address.addr);
1865 sender = (char*)g_dbus_method_invocation_get_sender(context);
1866 _bt_save_invocation_context(context, result, sender,
1867 function_name, (gpointer)addr);
1871 case BT_AVRCP_CONTROL_CONNECT: {
1872 bluetooth_device_address_t address = { {0} };
1874 __bt_service_get_parameters(in_param1,
1875 &address, sizeof(bluetooth_device_address_t));
1877 result = _bt_audio_connect(BT_AVRCP, &address);
1878 if (result != BLUETOOTH_ERROR_NONE) {
1879 char addr[BT_ADDRESS_STRING_SIZE];
1880 _bt_convert_addr_type_to_string(addr, address.addr);
1881 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1883 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1884 _bt_convert_addr_type_to_string(addr, address.addr);
1885 sender = (char*)g_dbus_method_invocation_get_sender(context);
1886 _bt_save_invocation_context(context, result, sender,
1887 function_name, (gpointer)addr);
1891 case BT_AVRCP_CONTROL_DISCONNECT: {
1892 bluetooth_device_address_t address = { {0} };
1894 __bt_service_get_parameters(in_param1,
1895 &address, sizeof(bluetooth_device_address_t));
1897 result = _bt_audio_disconnect(BT_AVRCP, &address);
1898 if (result != BLUETOOTH_ERROR_NONE) {
1899 char addr[BT_ADDRESS_STRING_SIZE];
1900 _bt_convert_addr_type_to_string(addr, address.addr);
1901 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1903 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1904 _bt_convert_addr_type_to_string(addr, address.addr);
1905 sender = (char*)g_dbus_method_invocation_get_sender(context);
1906 _bt_save_invocation_context(context, result, sender,
1907 function_name, (gpointer)addr);
1911 case BT_AVRCP_HANDLE_CONTROL: {
1913 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1914 result = _bt_avrcp_control_cmd(key_code);
1917 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1919 bluetooth_device_address_t address = { { 0 } };
1921 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1922 __bt_service_get_parameters(in_param2,
1923 &address, sizeof(bluetooth_device_address_t));
1925 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1928 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1932 __bt_service_get_parameters(in_param1,
1933 &type, sizeof(int));
1934 __bt_service_get_parameters(in_param2,
1935 &value, sizeof(unsigned int));
1937 result = _bt_avrcp_control_set_property(type, value);
1940 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1945 __bt_service_get_parameters(in_param1,
1946 &type, sizeof(int));
1947 __bt_service_get_parameters(in_param2,
1948 &value, sizeof(unsigned int));
1950 result = _bt_avrcp_transport_set_property(type, value);
1954 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1957 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1959 result = _bt_avrcp_control_get_property(type);
1960 /* Save invocation */
1961 if (result == BLUETOOTH_ERROR_NONE) {
1962 sender = (char*)g_dbus_method_invocation_get_sender(context);
1963 _bt_save_invocation_context(context, result, sender,
1964 function_name, g_memdup(&type, sizeof(int)));
1968 case BT_AVRCP_GET_TRACK_INFO: {
1969 result = _bt_avrcp_control_get_track_info();
1970 /* Save invocation */
1971 if (result == BLUETOOTH_ERROR_NONE) {
1972 sender = (char*)g_dbus_method_invocation_get_sender(context);
1973 _bt_save_invocation_context(context, result, sender,
1974 function_name, NULL);
1978 case BT_HDP_REGISTER_SINK_APP: {
1979 unsigned short data_type;
1980 bt_hdp_role_type_t role;
1981 bt_hdp_qos_type_t channel_type;
1982 int *app_id = g_new0(int, 1);
1984 __bt_service_get_parameters(in_param1,
1985 &data_type, sizeof(short));
1986 __bt_service_get_parameters(in_param2,
1987 &role, sizeof(bt_hdp_role_type_t));
1988 __bt_service_get_parameters(in_param3,
1989 &channel_type, sizeof(bt_hdp_qos_type_t));
1990 sender = (char*)g_dbus_method_invocation_get_sender(context);
1992 result = _bt_hdp_app_register(role,
1993 channel_type, data_type, sender, app_id);
1994 if (result != BLUETOOTH_ERROR_NONE) {
1995 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1998 _bt_save_invocation_context(context, result, sender,
1999 function_name, (gpointer)app_id);
2003 case BT_HDP_UNREGISTER_SINK_APP: {
2005 int *app_id = g_new0(int, 1);
2007 app_handle = (char *)g_variant_get_data(in_param1);
2008 sscanf(app_handle, "health_app_%d", app_id);
2009 result = _bt_hdp_app_unregister(*app_id);
2010 if (result != BLUETOOTH_ERROR_NONE) {
2013 sender = (char*)g_dbus_method_invocation_get_sender(context);
2014 _bt_save_invocation_context(context, result, sender,
2015 function_name, (gpointer)app_id);
2019 case BT_HDP_CONNECT: {
2023 bt_hdp_connected_t *conn_info = NULL;
2025 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2027 app_handle = (char *)g_variant_get_data(in_param1);
2028 conn_info->app_handle = app_handle;
2029 sscanf(app_handle, "health_app_%d", &app_id);
2031 __bt_service_get_parameters(in_param2,
2032 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2033 __bt_service_get_parameters(in_param3,
2034 &(conn_info->device_address),
2035 sizeof(bluetooth_device_address_t));
2037 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2038 conn_info->type, (int *)(&(conn_info->channel_id)));
2039 if (result != BLUETOOTH_ERROR_NONE) {
2040 g_array_append_vals(*out_param1, conn_info,
2041 sizeof(bt_hdp_connected_t));
2044 sender = (char*)g_dbus_method_invocation_get_sender(context);
2045 _bt_save_invocation_context(context, result, sender,
2046 function_name, (gpointer)conn_info);
2050 case BT_HDP_DISCONNECT: {
2051 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2053 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2055 __bt_service_get_parameters(in_param1,
2056 &(hdp_disconn_info->channel_id), sizeof(int));
2057 __bt_service_get_parameters(in_param2,
2058 &(hdp_disconn_info->device_address),
2059 sizeof(bluetooth_device_address_t));
2061 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2062 if (result != BLUETOOTH_ERROR_NONE) {
2063 g_array_append_vals(*out_param1, hdp_disconn_info,
2064 sizeof(bt_hdp_disconnected_t));
2065 g_free(hdp_disconn_info);
2067 sender = (char*)g_dbus_method_invocation_get_sender(context);
2068 _bt_save_invocation_context(context, result, sender,
2069 function_name, (gpointer)hdp_disconn_info);
2073 case BT_HDP_GET_FD: {
2074 int *channel_id = g_new0(int, 1);
2076 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2078 result = _bt_hdp_get_fd(*channel_id);
2079 if (result != BLUETOOTH_ERROR_NONE) {
2082 sender = (char*)g_dbus_method_invocation_get_sender(context);
2083 _bt_save_invocation_context(context, result, sender,
2084 function_name, (gpointer)channel_id);
2088 case BT_HDP_SEND_DATA: {
2090 * This call to bt-service is only used for privilege check, so return
2091 * BLUETOOTH_ERROR_NONE from here.
2093 result = BLUETOOTH_ERROR_NONE;
2096 case BT_OOB_READ_LOCAL_DATA: { //208
2097 bt_oob_data_t local_oob_data;
2099 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2100 result = _bt_oob_read_local_data(&local_oob_data);
2102 g_array_append_vals(*out_param1, &local_oob_data,
2103 sizeof(bt_oob_data_t));
2107 case BT_OOB_ADD_REMOTE_DATA: { //209
2108 bluetooth_device_address_t address = { {0} };
2109 unsigned short address_type;
2110 bt_oob_data_t remote_oob_data;
2112 __bt_service_get_parameters(in_param1,
2113 &address, sizeof(bluetooth_device_address_t));
2114 __bt_service_get_parameters(in_param2,
2115 &address_type, sizeof(unsigned short));
2116 __bt_service_get_parameters(in_param3,
2117 &remote_oob_data, sizeof(bt_oob_data_t));
2119 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2123 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2124 bluetooth_device_address_t address = { {0} };
2126 __bt_service_get_parameters(in_param1,
2127 &address, sizeof(bluetooth_device_address_t));
2129 result = _bt_oob_remove_remote_data(&address);
2133 case BT_LE_OOB_READ_LOCAL_DATA: {
2134 bt_oob_data_t local_oob_data;
2135 bt_oob_data_t *local_oob_cache_data;
2137 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2138 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2139 g_array_append_vals(*out_param1, local_oob_cache_data,
2140 sizeof(bt_oob_data_t));
2141 return BLUETOOTH_ERROR_NONE;
2144 /* We should modify this logic in later */
2145 if (_bt_is_le_static_random_address_enabled() == false) {
2146 /* Seperate BT & LE address */
2147 _bt_set_le_static_random_address(TRUE);
2150 result = _bt_le_oob_read_local_data(&local_oob_data);
2151 _bt_le_oob_set_local_cache_data(&local_oob_data);
2153 g_array_append_vals(*out_param1, &local_oob_data,
2154 sizeof(bt_oob_data_t));
2158 case BT_LE_OOB_ADD_REMOTE_DATA: {
2159 bluetooth_device_address_t address = { {0} };
2160 unsigned short address_type;
2161 bt_oob_data_t remote_oob_data;
2163 __bt_service_get_parameters(in_param1,
2164 &address, sizeof(bluetooth_device_address_t));
2165 __bt_service_get_parameters(in_param2,
2166 &address_type, sizeof(unsigned short));
2167 __bt_service_get_parameters(in_param3,
2168 &remote_oob_data, sizeof(bt_oob_data_t));
2170 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2174 case BT_AVRCP_SET_TRACK_INFO: {
2175 media_metadata_t data;
2176 media_metadata_attributes_t meta_data;
2178 memset(&data, 0x00, sizeof(media_metadata_t));
2179 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2181 __bt_service_get_parameters(in_param1,
2182 &data, sizeof(media_metadata_t));
2184 meta_data.title = g_strdup(data.title);
2185 meta_data.artist = g_strdup(data.artist);
2186 meta_data.album = g_strdup(data.album);
2187 meta_data.genre = g_strdup(data.genre);
2188 meta_data.total_tracks = data.total_tracks;
2189 meta_data.number = data.number;
2190 meta_data.duration = (int64_t) data.duration;
2192 result = _bt_avrcp_set_track_info(&meta_data);
2194 g_free((gpointer)meta_data.title);
2195 g_free((gpointer)meta_data.artist);
2196 g_free((gpointer)meta_data.album);
2197 g_free((gpointer)meta_data.genre);
2201 case BT_AVRCP_SET_PROPERTY: {
2205 sender = (char *)g_dbus_method_invocation_get_sender(context);
2207 __bt_service_get_parameters(in_param1,
2208 &type, sizeof(int));
2209 __bt_service_get_parameters(in_param2,
2210 &value, sizeof(unsigned int));
2212 if (value == STATUS_PLAYING) {
2213 if (current_sender_playing)
2214 g_free(current_sender_playing);
2215 current_sender_playing = g_strdup(sender);
2217 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2218 current_sender_playing == NULL) {
2219 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2221 BT_INFO("Current Player and this sender (%s) are different", sender);
2222 result = BLUETOOTH_ERROR_NONE;
2225 result = _bt_avrcp_set_property(type, value);
2229 case BT_AVRCP_SET_PROPERTIES: {
2230 media_player_settings_t properties;
2232 memset(&properties, 0x00, sizeof(media_player_settings_t));
2233 __bt_service_get_parameters(in_param1,
2234 &properties, sizeof(media_player_settings_t));
2236 result = _bt_avrcp_set_properties(&properties);
2240 case BT_SET_ADVERTISING_DATA: {
2243 bluetooth_advertising_data_t adv = { {0} };
2245 gboolean use_reserved_slot = FALSE;
2247 app = (char *)g_dbus_method_invocation_get_sender(context);
2248 adv_handle = g_malloc0(sizeof(int));
2250 __bt_service_get_parameters(in_param1,
2251 adv_handle, sizeof(int));
2252 __bt_service_get_parameters(in_param3,
2253 &length, sizeof(int));
2254 __bt_service_get_parameters(in_param2,
2256 __bt_service_get_parameters(in_param4,
2257 &use_reserved_slot, sizeof(gboolean));
2258 result = _bt_set_advertising_data(app, *adv_handle,
2259 &adv, length, use_reserved_slot);
2260 if (result != BLUETOOTH_ERROR_NONE) {
2261 BT_ERR("Set Advertising data failed!!");
2264 _bt_save_invocation_context(context, result, app,
2265 function_name, (gpointer)adv_handle);
2269 case BT_SET_SCAN_RESPONSE_DATA: {
2272 bluetooth_scan_resp_data_t rsp = { {0} };
2274 gboolean use_reserved_slot = FALSE;
2276 app = (char *)g_dbus_method_invocation_get_sender(context);
2277 adv_handle = g_malloc0(sizeof(int));
2279 __bt_service_get_parameters(in_param1,
2280 adv_handle, sizeof(int));
2281 __bt_service_get_parameters(in_param3,
2282 &length, sizeof(int));
2283 __bt_service_get_parameters(in_param2,
2285 __bt_service_get_parameters(in_param4,
2286 &use_reserved_slot, sizeof(gboolean));
2288 result = _bt_set_scan_response_data(app, *adv_handle,
2289 &rsp, length, use_reserved_slot);
2291 if (result != BLUETOOTH_ERROR_NONE) {
2292 BT_ERR("Set Scan Response Data failed!!");
2295 _bt_save_invocation_context(context, result, app,
2296 function_name, (gpointer)adv_handle);
2300 case BT_SET_ADVERTISING: {
2303 gboolean enable = FALSE;
2304 gboolean use_reserved_slot = FALSE;
2306 adv_handle = g_malloc0(sizeof(int));
2307 __bt_service_get_parameters(in_param1,
2308 adv_handle, sizeof(int));
2309 __bt_service_get_parameters(in_param2,
2310 &enable, sizeof(gboolean));
2311 __bt_service_get_parameters(in_param3,
2312 &use_reserved_slot, sizeof(gboolean));
2314 app = (char *)g_dbus_method_invocation_get_sender(context);
2316 result = _bt_set_advertising(app, *adv_handle,
2317 enable, use_reserved_slot);
2318 if (result != BLUETOOTH_ERROR_NONE) {
2319 BT_ERR("Start Advertising failed!!");
2322 _bt_save_invocation_context(context, result, app,
2323 function_name, (gpointer)adv_handle);
2327 case BT_SET_CUSTOM_ADVERTISING: {
2330 gboolean enable = FALSE;
2331 bluetooth_advertising_params_t adv_params;
2332 gboolean use_reserved_slot = FALSE;
2334 app = (char *)g_dbus_method_invocation_get_sender(context);
2335 adv_handle = g_malloc0(sizeof(int));
2337 __bt_service_get_parameters(in_param1, adv_handle,
2339 __bt_service_get_parameters(in_param2, &enable,
2341 __bt_service_get_parameters(in_param3, &adv_params,
2342 sizeof(bluetooth_advertising_params_t));
2343 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2346 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2347 adv_params.interval_min, adv_params.interval_max,
2348 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2349 result = _bt_set_custom_advertising(app, *adv_handle,
2350 enable, &adv_params, use_reserved_slot);
2351 if (result != BLUETOOTH_ERROR_NONE) {
2352 BT_ERR("Start Custom Advertising failed!!");
2355 _bt_save_invocation_context(context, result, app,
2356 function_name, (gpointer)adv_handle);
2360 case BT_GET_SCAN_RESPONSE_DATA: {
2361 bluetooth_scan_resp_data_t rsp = { {0} };
2365 app = (char *)g_dbus_method_invocation_get_sender(context);
2367 __bt_service_get_parameters(in_param1, &adv_handle,
2370 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2371 if (result == BLUETOOTH_ERROR_NONE)
2372 g_array_append_vals(*out_param1, rsp.data, length);
2376 case BT_GET_ADVERTISING_DATA: {
2377 bluetooth_advertising_data_t adv = { {0} };
2381 app = (char *)g_dbus_method_invocation_get_sender(context);
2383 __bt_service_get_parameters(in_param1, &adv_handle,
2386 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2387 if (result == BLUETOOTH_ERROR_NONE)
2388 g_array_append_vals(*out_param1, adv.data, length);
2392 case BT_GATT_REGISTER_APPLICATION: {
2393 BT_DBG("Register GATT application:Unhandled!!");
2396 case BT_GATT_SERVER_REGISTER: {
2397 BT_DBG("GATT Server instance initialization");
2400 app = (char *)g_dbus_method_invocation_get_sender(context);
2401 BT_DBG("GATT Server Unique Name [%s]", app);
2403 /* No ADV handle: Set 0 */
2404 result = _bt_register_server_instance(app, 0);
2406 if (result != BLUETOOTH_ERROR_NONE) {
2407 BT_ERR("GATT Server registration failed. result %d", result);
2409 _bt_save_invocation_context(context, result, app,
2410 function_name, NULL);
2414 case BT_GATT_SERVER_DEREGISTER: {
2416 app = (char*)g_dbus_method_invocation_get_sender(context);
2418 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2421 case BT_GATT_SERVER_ADD_SERVICE: {
2422 BT_DBG("GATT Server Add Service");
2428 int *tmp_inst_id = NULL;
2430 app = (char *)g_dbus_method_invocation_get_sender(context);
2432 __bt_service_get_parameters(in_param1, &service_type,
2434 __bt_service_get_parameters(in_param2, &num_handles,
2436 svc_uuid = (char *)g_variant_get_data(in_param3);
2437 __bt_service_get_parameters(in_param4, &instance_id,
2440 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2441 if (result != BLUETOOTH_ERROR_NONE) {
2442 BT_ERR("GATT Server Add Service failed!!");
2444 tmp_inst_id = g_malloc0(sizeof(int));
2445 *tmp_inst_id = instance_id;
2446 _bt_save_invocation_context(context, result, app,
2447 function_name, (gpointer)tmp_inst_id);
2451 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2452 BT_DBG("GATT Server Add Characteristic");
2455 int *tmp_inst_id = NULL;
2456 bluetooth_gatt_server_attribute_params_t param;
2457 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2459 app = (char*)g_dbus_method_invocation_get_sender(context);
2461 __bt_service_get_parameters(in_param1, ¶m,
2462 sizeof(bluetooth_gatt_server_attribute_params_t));
2463 char_uuid = (char *)g_variant_get_data(in_param2);
2465 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2466 if (result != BLUETOOTH_ERROR_NONE) {
2467 BT_ERR("GATT Server Add Service failed!!");
2469 tmp_inst_id = g_malloc0(sizeof(int));
2470 *tmp_inst_id = param.instance_id;
2472 _bt_save_invocation_context(context, result, app,
2473 function_name, (gpointer)tmp_inst_id);
2477 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2478 BT_DBG("GATT Server Add Descriptor");
2482 bt_gatt_permission_t perm;
2484 int *tmp_inst_id = NULL;
2485 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2487 app = (char *)g_dbus_method_invocation_get_sender(context);
2489 __bt_service_get_parameters(in_param1, &service_handle,
2491 __bt_service_get_parameters(in_param2, &instance_id,
2493 desc_uuid = (char *)g_variant_get_data(in_param4);
2494 __bt_service_get_parameters(in_param3, &perm,
2495 sizeof(bt_gatt_permission_t));
2497 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2498 if (result != BLUETOOTH_ERROR_NONE) {
2499 BT_ERR("GATT Server Add Service failed!!");
2501 tmp_inst_id = g_malloc0(sizeof(int));
2502 *tmp_inst_id = instance_id;
2503 _bt_save_invocation_context(context, result, app,
2504 function_name, (gpointer)tmp_inst_id);
2508 case BT_GATT_SERVER_START_SERVICE: {
2513 int *tmp_inst_id = NULL;
2514 app = (char*)g_dbus_method_invocation_get_sender(context);
2516 __bt_service_get_parameters(in_param1, &service_handle,
2518 __bt_service_get_parameters(in_param2, &instance_id,
2521 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2523 if (BLUETOOTH_ERROR_NONE == result) {
2524 tmp_inst_id = g_malloc0(sizeof(int));
2525 *tmp_inst_id = instance_id;
2526 _bt_save_invocation_context(context, result, app,
2527 function_name, (gpointer)tmp_inst_id);
2531 case BT_GATT_SERVER_STOP_SERVICE: {
2535 int *tmp_inst_id = NULL;
2536 app = (char*)g_dbus_method_invocation_get_sender(context);
2538 __bt_service_get_parameters(in_param1, &service_handle,
2540 __bt_service_get_parameters(in_param2, &instance_id,
2543 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2545 if (BLUETOOTH_ERROR_NONE == result) {
2546 tmp_inst_id = g_malloc0(sizeof(int));
2547 *tmp_inst_id = instance_id;
2548 _bt_save_invocation_context(context, result, app,
2549 function_name, (gpointer)tmp_inst_id);
2553 case BT_GATT_SERVER_DELETE_SERVICE: {
2556 int *tmp_inst_id = NULL;
2558 app = (char*)g_dbus_method_invocation_get_sender(context);
2560 __bt_service_get_parameters(in_param1, &service_handle,
2562 __bt_service_get_parameters(in_param2, &instance_id,
2565 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2567 if (BLUETOOTH_ERROR_NONE == result) {
2568 tmp_inst_id = g_malloc0(sizeof(int));
2569 *tmp_inst_id = instance_id;
2570 _bt_save_invocation_context(context, result, app,
2571 function_name, (gpointer)tmp_inst_id);
2575 case BT_GATT_SERVER_SEND_RESPONSE: {
2576 bluetooth_gatt_server_response_params_t param;
2577 bluetooth_gatt_att_data_t data;
2580 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2581 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2583 app = (char*)g_dbus_method_invocation_get_sender(context);
2585 __bt_service_get_parameters(in_param1, &data,
2586 sizeof(bluetooth_gatt_att_data_t));
2587 __bt_service_get_parameters(in_param2, ¶m,
2588 sizeof(bluetooth_gatt_server_response_params_t));
2590 result = _bt_gatt_server_send_response(app, &data, ¶m);
2594 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2596 bluetooth_gatt_server_acquire_response_params_t param;
2599 msg = g_dbus_method_invocation_get_message(context);
2600 GUnixFDList *fd_list;
2605 fd_list = g_dbus_message_get_unix_fd_list(msg);
2607 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2609 app = (char*)g_dbus_method_invocation_get_sender(context);
2611 __bt_service_get_parameters(in_param1, ¶m,
2612 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2614 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2615 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2616 fd = fd_list_array[0];
2619 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2623 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2625 bluetooth_gatt_server_acquire_response_params_t param;
2628 msg = g_dbus_method_invocation_get_message(context);
2629 GUnixFDList *fd_list;
2634 fd_list = g_dbus_message_get_unix_fd_list(msg);
2636 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2638 app = (char*)g_dbus_method_invocation_get_sender(context);
2640 __bt_service_get_parameters(in_param1, ¶m,
2641 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2643 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2644 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2645 fd = fd_list_array[0];
2648 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2652 case BT_GATT_SERVER_SEND_INDICATION: {
2653 bluetooth_gatt_server_indication_params_t param;
2654 bluetooth_gatt_att_data_t data;
2655 bluetooth_device_address_t address;
2658 app = (char*)g_dbus_method_invocation_get_sender(context);
2660 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2661 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2662 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2664 __bt_service_get_parameters(in_param1, &data,
2665 sizeof(bluetooth_gatt_att_data_t));
2666 __bt_service_get_parameters(in_param2, ¶m,
2667 sizeof(bluetooth_gatt_server_indication_params_t));
2668 __bt_service_get_parameters(in_param3, &address,
2669 sizeof(bluetooth_device_address_t));
2671 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2675 case BT_GATT_SERVER_UPDATE_VALUE: {
2676 bluetooth_gatt_server_update_value_t param;
2680 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2682 app = (char*)g_dbus_method_invocation_get_sender(context);
2684 __bt_service_get_parameters(in_param1, &instance_id,
2686 __bt_service_get_parameters(in_param2, ¶m,
2687 sizeof(bluetooth_gatt_server_update_value_t));
2689 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2692 case BT_GET_ATT_MTU: {
2693 bluetooth_device_address_t address = { {0} };
2694 unsigned int mtu = 0;
2696 __bt_service_get_parameters(in_param1,
2697 &address, sizeof(bluetooth_device_address_t));
2698 result = _bt_get_att_mtu(&address, &mtu);
2699 BT_DBG("MTU: %d", mtu);
2701 if (result == BLUETOOTH_ERROR_NONE) {
2702 g_array_append_vals(*out_param1, &mtu,
2703 sizeof(unsigned int));
2707 case BT_REQ_ATT_MTU: {
2708 bluetooth_device_address_t address = { {0} };
2712 sender = (char*)g_dbus_method_invocation_get_sender(context);
2714 __bt_service_get_parameters(in_param1,
2715 &address, sizeof(bluetooth_device_address_t));
2716 __bt_service_get_parameters(in_param2,
2717 &mtu, sizeof(unsigned int));
2718 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2719 result = _bt_request_att_mtu(&address, mtu);
2720 if (BLUETOOTH_ERROR_NONE == result) {
2721 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2723 _bt_convert_addr_type_to_string(addr, address.addr);
2725 /* Save the informations to invocation */
2726 _bt_save_invocation_context(context, result, sender,
2727 function_name, (gpointer)addr);
2729 g_array_append_vals(*out_param1, &address,
2730 sizeof(bluetooth_device_address_t));
2734 case BT_GET_DEVICE_IDA: {
2735 bluetooth_device_address_t address = { {0} };
2736 bluetooth_device_address_t id_addr = { {0} };
2738 __bt_service_get_parameters(in_param1,
2739 &address, sizeof(bluetooth_device_address_t));
2741 result = _bt_device_get_ida(&address, &id_addr);
2743 if (result == BLUETOOTH_ERROR_NONE) {
2744 g_array_append_vals(*out_param1, &id_addr,
2745 sizeof(bluetooth_device_address_t));
2749 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2752 __bt_service_get_parameters(in_param1, &is_enable,
2755 result = _bt_set_le_static_random_address(is_enable);
2759 #ifdef TIZEN_GATT_CLIENT
2761 case BT_GATT_CLIENT_REGISTER: {
2762 bluetooth_device_address_t address = { {0} };
2765 sender = (char*)g_dbus_method_invocation_get_sender(context);
2767 __bt_service_get_parameters(in_param1,
2768 &address, sizeof(bluetooth_device_address_t));
2770 result = _bt_register_gatt_client_instance(sender, &address);
2771 if (BLUETOOTH_ERROR_NONE == result) {
2772 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2774 _bt_convert_addr_type_to_string(addr, address.addr);
2776 /* Save the informations to invocation */
2777 _bt_save_invocation_context(context, result, sender,
2778 function_name, (gpointer)addr);
2783 case BT_GATT_CLIENT_UNREGISTER: {
2786 sender = (char*)g_dbus_method_invocation_get_sender(context);
2787 __bt_service_get_parameters(in_param1,
2788 &client_id, sizeof(int));
2790 result = _bt_unregister_gatt_client_instance(sender, client_id);
2794 /* Async: Remote Interaction */
2795 case BT_GATT_ACQUIRE_WRITE: {
2799 bluetooth_gatt_client_char_prop_info_t param;
2801 sender = (char*)g_dbus_method_invocation_get_sender(context);
2803 __bt_service_get_parameters(in_param1, ¶m,
2804 sizeof(bluetooth_gatt_client_char_prop_info_t));
2807 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2809 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2811 if (BLUETOOTH_ERROR_NONE == result)
2812 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2814 BT_ERR("GATT Client: gatt acquire write failed");
2818 GUnixFDList *fd_list = NULL;
2819 GError *error = NULL;
2821 /* Add socket fd to unix_fd_list */
2822 fd_list = g_unix_fd_list_new();
2823 g_unix_fd_list_append(fd_list, fd, &error);
2824 g_assert_no_error(error);
2826 _bt_service_method_return_with_unix_fd_list(
2827 context, *out_param1, result, fd_list);
2830 g_object_unref(fd_list);
2834 /* Async: Remote Interaction */
2835 case BT_CONNECT_LE: {
2836 bluetooth_device_address_t address = { {0} };
2837 gboolean auto_connect;
2841 sender = (char*)g_dbus_method_invocation_get_sender(context);
2843 __bt_service_get_parameters(in_param1,
2844 &address, sizeof(bluetooth_device_address_t));
2845 __bt_service_get_parameters(in_param2,
2846 &auto_connect, sizeof(gboolean));
2847 __bt_service_get_parameters(in_param3,
2848 &client_id, sizeof(int));
2850 BT_DBG("GATT Client: client_id[%d]", client_id);
2851 result = _bt_connect_le_device(&address, auto_connect, client_id);
2852 if (BLUETOOTH_ERROR_NONE == result) {
2853 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2854 _bt_convert_addr_type_to_string(addr, address.addr);
2856 /* Save the informations to invocation */
2857 _bt_save_invocation_context(context, result, sender,
2858 function_name, (gpointer)addr);
2861 _bt_handle_invocation_context(function_name, (void *)addr);
2863 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2864 g_array_append_vals(*out_param1, &address,
2865 sizeof(bluetooth_device_address_t));
2869 /* Async: Remote Interaction */
2870 case BT_DISCONNECT_LE: {
2871 bluetooth_device_address_t address = { {0} };
2875 sender = (char*)g_dbus_method_invocation_get_sender(context);
2877 __bt_service_get_parameters(in_param1,
2878 &address, sizeof(bluetooth_device_address_t));
2879 __bt_service_get_parameters(in_param2,
2880 &client_id, sizeof(int));
2882 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2883 result = _bt_disconnect_le_device(&address, client_id);
2884 if (BLUETOOTH_ERROR_NONE == result) {
2885 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2887 _bt_convert_addr_type_to_string(addr, address.addr);
2889 /* Save the informations to invocation */
2890 _bt_save_invocation_context(context, result, sender,
2891 function_name, (gpointer)addr);
2893 g_array_append_vals(*out_param1, &address,
2894 sizeof(bluetooth_device_address_t));
2899 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2900 guint available_packets = 0;
2902 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2903 BT_DBG("LE batching available packets %u", available_packets);
2904 if (result == BLUETOOTH_ERROR_NONE) {
2905 g_array_append_vals(*out_param1, &available_packets,
2912 case BT_ENABLE_GATT_DATA_BATCHING: {
2913 bluetooth_device_address_t address = { {0} };
2914 int packet_threshold;
2917 __bt_service_get_parameters(in_param1,
2918 &address, sizeof(bluetooth_device_address_t));
2919 __bt_service_get_parameters(in_param2,
2920 &packet_threshold, sizeof(int));
2921 __bt_service_get_parameters(in_param3,
2922 &timeout, sizeof(int));
2923 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2928 case BT_DISABLE_GATT_DATA_BATCHING: {
2929 bluetooth_device_address_t address = { {0} };
2931 __bt_service_get_parameters(in_param1,
2932 &address, sizeof(bluetooth_device_address_t));
2933 result = _bt_gatt_disable_data_batching(&address);
2938 case BT_GATT_GET_PRIMARY_SERVICES: {
2941 sender = (char*)g_dbus_method_invocation_get_sender(context);
2942 bluetooth_device_address_t address = { {0} };
2944 __bt_service_get_parameters(in_param1, &address,
2945 sizeof(bluetooth_device_address_t));
2947 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2948 _bt_convert_addr_type_to_string(addr, address.addr);
2950 result = _bt_gatt_get_primary_services(addr);
2951 if (BLUETOOTH_ERROR_NONE == result) {
2952 _bt_save_invocation_context(context, result, sender,
2953 function_name, (gpointer)addr);
2959 case BT_GATT_GET_SERVICE_PROPERTIES: {
2960 bluetooth_gatt_client_svc_prop_info_t param;
2962 sender = (char*)g_dbus_method_invocation_get_sender(context);
2963 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2965 __bt_service_get_parameters(in_param1, ¶m,
2966 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2968 result = _bt_gatt_get_all_characteristic(¶m);
2969 if (BLUETOOTH_ERROR_NONE == result) {
2970 /* Save the informations to invocation */
2971 _bt_save_invocation_context(context, result, sender,
2973 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2977 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2978 bluetooth_gatt_client_char_prop_info_t param;
2980 sender = (char*)g_dbus_method_invocation_get_sender(context);
2981 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2983 __bt_service_get_parameters(in_param1, ¶m,
2984 sizeof(bluetooth_gatt_client_char_prop_info_t));
2986 result = _bt_gatt_get_all_characteristic_properties(¶m);
2987 if (BLUETOOTH_ERROR_NONE == result) {
2988 /* Save the informations to invocation */
2989 _bt_save_invocation_context(context, result, sender,
2991 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2995 /* Async: Remote Interaction */
2996 case BT_GATT_READ_CHARACTERISTIC: {
2997 bluetooth_gatt_client_char_prop_info_t param;
2999 sender = (char*)g_dbus_method_invocation_get_sender(context);
3000 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3002 __bt_service_get_parameters(in_param1, ¶m,
3003 sizeof(bluetooth_gatt_client_char_prop_info_t));
3005 result = _bt_gatt_read_characteristic_value(¶m);
3006 if (BLUETOOTH_ERROR_NONE == result) {
3007 /* Save the informations to invocation */
3008 _bt_save_invocation_context(context, result, sender,
3010 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3014 /* Async: Remote Interaction */
3015 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3016 bluetooth_gatt_client_desc_prop_info_t param;
3018 sender = (char*)g_dbus_method_invocation_get_sender(context);
3019 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3021 __bt_service_get_parameters(in_param1, ¶m,
3022 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3024 result = _bt_gatt_read_descriptor_value(¶m);
3025 if (BLUETOOTH_ERROR_NONE == result) {
3026 /* Save the informations to invocation */
3027 _bt_save_invocation_context(context, result, sender,
3029 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3033 /* Async: Remote Interaction */
3034 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3035 bluetooth_gatt_client_char_prop_info_t param;
3036 bluetooth_gatt_att_data_t data;
3037 bluetooth_gatt_write_type_e write_type;
3039 sender = (char*)g_dbus_method_invocation_get_sender(context);
3041 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3042 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3044 __bt_service_get_parameters(in_param1, ¶m,
3045 sizeof(bluetooth_gatt_client_char_prop_info_t));
3046 __bt_service_get_parameters(in_param2, &data,
3047 sizeof(bluetooth_gatt_att_data_t));
3048 __bt_service_get_parameters(in_param3, &write_type,
3049 sizeof(bluetooth_gatt_write_type_e));
3051 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3052 if (BLUETOOTH_ERROR_NONE == result) {
3053 /* Save the informations to invocation */
3054 _bt_save_invocation_context(context, result, sender,
3056 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3060 /* Async: Remote Interaction */
3061 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3062 bluetooth_gatt_client_desc_prop_info_t param;
3063 bluetooth_gatt_att_data_t data;
3064 bluetooth_gatt_write_type_e write_type;
3066 sender = (char*)g_dbus_method_invocation_get_sender(context);
3067 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3068 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3070 __bt_service_get_parameters(in_param1, ¶m,
3071 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3072 __bt_service_get_parameters(in_param2, &data,
3073 sizeof(bluetooth_gatt_att_data_t));
3074 __bt_service_get_parameters(in_param3, &write_type,
3075 sizeof(bluetooth_gatt_write_type_e));
3077 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3078 if (BLUETOOTH_ERROR_NONE == result) {
3079 /* Save the informations to invocation */
3080 _bt_save_invocation_context(context, result, sender,
3082 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3087 case BT_GATT_WATCH_CHARACTERISTIC: {
3088 bluetooth_gatt_client_char_prop_info_t param;
3093 gboolean is_indicate;
3096 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3098 sender = (char*)g_dbus_method_invocation_get_sender(context);
3100 __bt_service_get_parameters(in_param1, ¶m,
3101 sizeof(bluetooth_gatt_client_char_prop_info_t));
3102 __bt_service_get_parameters(in_param2, &client_id,
3104 __bt_service_get_parameters(in_param3, &is_notify,
3106 __bt_service_get_parameters(in_param4, &is_indicate,
3109 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3113 if (is_indicate == false) {
3114 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3115 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3116 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3118 GUnixFDList *fd_list = NULL;
3119 GError *error = NULL;
3121 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3122 /* Add socket fd to unix_fd_list */
3123 fd_list = g_unix_fd_list_new();
3124 g_unix_fd_list_append(fd_list, fd, &error);
3125 g_assert_no_error(error);
3127 _bt_service_method_return_with_unix_fd_list(
3128 context, *out_param1, result, fd_list);
3130 g_object_unref(fd_list);
3136 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3137 if (BLUETOOTH_ERROR_NONE == result) {
3138 /* Save the informations to invocation */
3139 _bt_save_invocation_context(context, result, sender, function_name,
3140 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3145 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3146 gboolean is_enabled;
3147 bluetooth_device_address_t address;
3149 sender = (char*)g_dbus_method_invocation_get_sender(context);
3151 __bt_service_get_parameters(in_param1,
3152 &address, sizeof(bluetooth_device_address_t));
3153 __bt_service_get_parameters(in_param2, &is_enabled,
3155 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3156 BT_INFO("Service changed indication from app [%s]", sender);
3160 case BT_LE_CONN_UPDATE: {
3161 char *sender = NULL;
3162 bluetooth_device_address_t local_address = { {0} };
3163 bluetooth_le_connection_param_t parameters = {0};
3165 sender = (char *)g_dbus_method_invocation_get_sender(context);
3167 __bt_service_get_parameters(in_param1, &local_address,
3168 sizeof(bluetooth_device_address_t));
3169 __bt_service_get_parameters(in_param2, ¶meters,
3170 sizeof(bluetooth_le_connection_param_t));
3172 result = _bt_le_connection_update(sender,
3174 parameters.interval_min,
3175 parameters.interval_max,
3177 parameters.timeout);
3181 case BT_START_LE_DISCOVERY: {
3185 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3187 sender = (char *)g_dbus_method_invocation_get_sender(context);
3189 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3190 BT_ERR("Fail to get the sender pid");
3192 result = _bt_start_le_scan(sender, uid, pid);
3193 if (result == BLUETOOTH_ERROR_NONE) {
3194 _bt_save_invocation_context(context, result, sender,
3195 function_name, NULL);
3197 BT_DBG("Remeber pid / uid for the scan operation");
3198 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3202 case BT_STOP_LE_DISCOVERY: {
3206 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3208 sender = (char *)g_dbus_method_invocation_get_sender(context);
3210 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3211 BT_ERR("Fail to get the sender pid");
3213 result = _bt_stop_le_scan(sender);
3214 if (result == BLUETOOTH_ERROR_NONE) {
3215 _bt_save_invocation_context(context, result, sender,
3216 function_name, NULL);
3219 BT_DBG("Remove pid / uid for the scan operation");
3220 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3224 case BT_IS_LE_DISCOVERYING: {
3225 gboolean le_discovering = FALSE;
3227 le_discovering = _bt_is_le_scanning();
3228 g_array_append_vals(*out_param1,
3229 &le_discovering, sizeof(gboolean));
3232 case BT_SET_SCAN_PARAMETERS: {
3233 bluetooth_le_scan_params_t scan_params;
3235 __bt_service_get_parameters(in_param1, &scan_params,
3236 sizeof(bluetooth_le_scan_params_t));
3238 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3239 scan_params.interval, scan_params.window,
3242 result = _bt_prepare_scan_parameters(&scan_params, 0);
3245 case BT_SET_SCAN_TYPE: {
3247 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3249 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3250 result = _bt_prepare_scan_parameters(NULL, scan_type);
3253 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3254 case BT_NETWORK_ACTIVATE:
3255 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3256 result = _bt_network_activate();
3258 case BT_NETWORK_DEACTIVATE:
3259 result = _bt_network_deactivate();
3261 case BT_NETWORK_CONNECT: {
3262 bluetooth_device_address_t address = { {0} };
3265 __bt_service_get_parameters(in_param1,
3266 &address, sizeof(bluetooth_device_address_t));
3267 __bt_service_get_parameters(in_param2,
3268 &role, sizeof(int));
3270 result = _bt_network_connect(request_id, role, &address);
3271 if (result != BLUETOOTH_ERROR_NONE) {
3272 g_array_append_vals(*out_param1, &address,
3273 sizeof(bluetooth_device_address_t));
3277 case BT_NETWORK_DISCONNECT: {
3278 bluetooth_device_address_t address = { {0} };
3280 __bt_service_get_parameters(in_param1,
3281 &address, sizeof(bluetooth_device_address_t));
3283 result = _bt_network_disconnect(request_id, &address);
3284 if (result != BLUETOOTH_ERROR_NONE) {
3285 g_array_append_vals(*out_param1, &address,
3286 sizeof(bluetooth_device_address_t));
3290 case BT_NETWORK_SERVER_DISCONNECT: {
3291 bluetooth_device_address_t address = { {0} };
3293 __bt_service_get_parameters(in_param1,
3294 &address, sizeof(bluetooth_device_address_t));
3296 result = _bt_network_server_disconnect(request_id, &address);
3297 if (result != BLUETOOTH_ERROR_NONE) {
3298 g_array_append_vals(*out_param1, &address,
3299 sizeof(bluetooth_device_address_t));
3305 #ifdef TIZEN_FEATURE_BT_IPSP
3306 case BT_LE_IPSP_INIT:
3307 result = _bt_initialize_ipsp();
3309 case BT_LE_IPSP_DEINIT:
3310 result = _bt_deinitialize_ipsp();
3312 case BT_LE_IPSP_CONNECT: {
3313 bluetooth_device_address_t address = { {0} };
3314 __bt_service_get_parameters(in_param1, &address,
3315 sizeof(bluetooth_device_address_t));
3316 result = _bt_connect_le_ipsp_device(&address);
3319 case BT_LE_IPSP_DISCONNECT: {
3320 bluetooth_device_address_t address = { {0} };
3321 __bt_service_get_parameters(in_param1, &address,
3322 sizeof(bluetooth_device_address_t));
3323 result = _bt_disconnect_le_ipsp_device(&address);
3327 case BT_IS_ADVERTISING: {
3328 gboolean advertising = FALSE;
3329 advertising = _bt_is_advertising();
3330 g_array_append_vals(*out_param1, &advertising,
3334 case BT_IS_LE_2M_PHY_SUPPORTED: {
3335 gboolean is_2m_phy_supported = FALSE;
3337 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3338 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3341 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3342 gboolean is_coded_phy_supported = FALSE;
3344 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3345 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3348 case BT_DISCONNECT_DEVICE: {
3349 bluetooth_device_address_t address = { {0} };
3351 __bt_service_get_parameters(in_param1,
3352 &address, sizeof(bluetooth_device_address_t));
3354 result = _bt_disconnect_device(&address);
3357 case BT_REGISTER_SCAN_FILTER: {
3358 bluetooth_le_scan_filter_t scan_filter;
3360 sender = (char*)g_dbus_method_invocation_get_sender(context);
3361 __bt_service_get_parameters(in_param1, &scan_filter,
3362 sizeof(bluetooth_le_scan_filter_t));
3364 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3365 scan_filter.added_features);
3367 result = _bt_register_scan_filter(sender, &scan_filter);
3373 result = _bt_mesh_init();
3376 case BT_MESH_DEINIT:
3377 result = _bt_mesh_deinit();
3380 case BT_MESH_NETWORK_CREATE: {
3381 bluetooth_mesh_node_t node;
3382 GSList *model_list = NULL;
3383 int total_models = 0;
3386 const char *network_name = NULL;
3387 bluetooth_mesh_network_t *network;
3389 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3390 sender = (char*)g_dbus_method_invocation_get_sender(context);
3392 __bt_service_get_parameters(in_param1,
3393 &node, sizeof(bluetooth_mesh_node_t));
3394 network_name = (const char *)g_variant_get_data(in_param2);
3395 BT_INFO("MESH: Network name [%s]", network_name);
3397 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3398 __bt_fill_garray_from_variant(in_param3, param3);
3400 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3401 for (i = 0; i < total_models; i++) {
3402 bluetooth_mesh_model_t *info = NULL;
3403 bluetooth_mesh_model_t *mod = NULL;
3405 info = &g_array_index(param3,
3406 bluetooth_mesh_model_t, i);
3408 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3411 model_list = g_slist_append(model_list,
3414 result = _bt_mesh_network_create(requester_unique_creds,
3415 sender, network_name, &node, model_list);
3417 /* Save invocation */
3418 if (result == BLUETOOTH_ERROR_NONE) {
3419 BT_INFO("Mesh: Save Invoation");
3420 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3422 /* Save Network name & UUID, Token will be received in event */
3423 _bt_mesh_util_convert_hex_to_string(
3424 (uint8_t *) node.uuid, 16,
3426 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3427 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3428 g_strlcpy(network->name.name, network_name,
3429 sizeof(network->name.name));
3430 g_strlcpy(network->app_cred,
3431 requester_unique_creds,
3432 sizeof(network->app_cred));
3433 sender = (char*)g_dbus_method_invocation_get_sender(context);
3434 _bt_save_invocation_context(context,
3436 function_name, (gpointer)network);
3438 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3439 BT_ERR("Mesh: Mesh Network creation schedule failed");
3440 g_slist_free_full(model_list, g_free);
3444 BT_INFO("Mesh: Cleanup");
3445 g_free((gpointer)requester_unique_creds);
3446 g_array_free(param3, TRUE);
3447 BT_INFO("Mesh: Cleanup Done");
3450 case BT_MESH_NETWORK_DESTROY: {
3451 bluetooth_mesh_network_t network;
3452 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3454 __bt_service_get_parameters(in_param1,
3455 &network, sizeof(bluetooth_mesh_network_t));
3457 BT_INFO("Mesh: Destroy Network");
3458 result = _bt_mesh_network_destroy(requester_unique_creds,
3461 if (result != BLUETOOTH_ERROR_NONE) {
3462 g_array_append_vals(*out_param1,
3463 &network, sizeof(bluetooth_mesh_network_t));
3465 BT_INFO("Mesh: Destroy Network scheduled: add invocation");
3466 bluetooth_mesh_network_t *net = \
3467 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3469 sender = (char*)g_dbus_method_invocation_get_sender(context);
3470 _bt_save_invocation_context(context, result, sender,
3471 function_name, (gpointer)net);
3475 case BT_MESH_NETWORK_LOAD: {
3477 bluetooth_mesh_network_t *network;
3478 token = (char *)g_variant_get_data(in_param1);
3479 BT_INFO("MESH: Network Load: Token string [%s]", token);
3480 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3481 /* Save invocation */
3482 if (result == BLUETOOTH_ERROR_NONE) {
3483 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3484 g_strlcpy(network->token.token, token, strlen(token));
3485 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3487 sender = (char*)g_dbus_method_invocation_get_sender(context);
3488 _bt_save_invocation_context(context, result, sender,
3489 function_name, (gpointer)network);
3491 g_free((gpointer)requester_unique_creds);
3494 case BT_MESH_NETWORK_SCAN: {
3495 bluetooth_mesh_network_t network;
3496 bluetooth_mesh_scan_param_t param;
3497 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3498 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3500 __bt_service_get_parameters(in_param1,
3501 &network, sizeof(bluetooth_mesh_network_t));
3503 __bt_service_get_parameters(in_param2,
3504 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3506 result = _bt_mesh_network_scan(requester_unique_creds,
3507 sender, &network, ¶m);
3509 if (result != BLUETOOTH_ERROR_NONE) {
3510 g_array_append_vals(*out_param1,
3511 &network, sizeof(bluetooth_mesh_network_t));
3513 bluetooth_mesh_network_t *net = \
3514 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3516 sender = (char*)g_dbus_method_invocation_get_sender(context);
3517 _bt_save_invocation_context(context, result, sender,
3518 function_name, (gpointer)net);
3522 case BT_MESH_NETWORK_CANCEL_SCAN: {
3523 bluetooth_mesh_network_t network;
3524 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3526 __bt_service_get_parameters(in_param1,
3527 &network, sizeof(bluetooth_mesh_network_t));
3529 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3532 if (result != BLUETOOTH_ERROR_NONE)
3533 g_array_append_vals(*out_param1,
3534 &network, sizeof(bluetooth_mesh_network_t));
3537 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3538 bluetooth_mesh_network_t network;
3539 bluetooth_mesh_provisioner_caps_t caps;
3540 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3541 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3543 __bt_service_get_parameters(in_param1,
3544 &network, sizeof(bluetooth_mesh_network_t));
3546 __bt_service_get_parameters(in_param2,
3547 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3549 result = _bt_mesh_network_set_provisioner_caps(
3550 requester_unique_creds, sender, &network, &caps);
3554 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3555 bluetooth_mesh_provisioning_request_t req;
3556 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3558 __bt_service_get_parameters(in_param1,
3559 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3561 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3562 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3564 result = _bt_mesh_network_provision_device(
3565 requester_unique_creds, sender, &req);
3567 /* Save invocation */
3568 if (result != BLUETOOTH_ERROR_NONE) {
3569 g_array_append_vals(*out_param1, &req,
3570 sizeof(bluetooth_mesh_provisioning_request_t));
3572 bluetooth_mesh_provisioning_request_t *param = \
3573 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3575 sender = (char*)g_dbus_method_invocation_get_sender(context);
3576 _bt_save_invocation_context(context, result, sender,
3577 function_name, (gpointer)param);
3581 case BT_MESH_AUTHENTICATION_REPLY: {
3582 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3583 const char *auth_value = NULL;
3584 gboolean authentication_reply = FALSE;
3586 auth_value = g_variant_get_data(in_param2);
3587 __bt_service_get_parameters(in_param3,
3588 &authentication_reply, sizeof(gboolean));
3589 __bt_service_get_parameters(in_param1,
3590 &auth_type, sizeof(int));
3591 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3592 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3593 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3594 result = _bt_mesh_authentication_reply(auth_type,
3595 auth_value, authentication_reply);
3598 case BT_MESH_NETWORK_SET_NAME: {
3599 bluetooth_mesh_network_t network;
3600 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3602 __bt_service_get_parameters(in_param1,
3603 &network, sizeof(bluetooth_mesh_network_t));
3605 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3609 case BT_MESH_NETWORK_ADD_NETKEY: {
3610 bluetooth_mesh_network_t network;
3611 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3613 __bt_service_get_parameters(in_param1,
3614 &network, sizeof(bluetooth_mesh_network_t));
3616 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3619 if (result != BLUETOOTH_ERROR_NONE) {
3620 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3622 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3624 sender = (char*)g_dbus_method_invocation_get_sender(context);
3625 _bt_save_invocation_context(context, result, sender,
3626 function_name, (gpointer)net);
3630 case BT_MESH_NETWORK_DELETE_NETKEY: {
3631 bluetooth_mesh_network_t network;
3634 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3636 __bt_service_get_parameters(in_param1,
3637 &network, sizeof(bluetooth_mesh_network_t));
3638 __bt_service_get_parameters(in_param2,
3639 &index, sizeof(guint16));
3641 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3642 sender, &network, index);
3644 if (result != BLUETOOTH_ERROR_NONE) {
3645 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3647 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3649 sender = (char*)g_dbus_method_invocation_get_sender(context);
3650 _bt_save_invocation_context(context, result, sender,
3651 function_name, (gpointer)net);
3655 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3656 bluetooth_mesh_network_t network;
3659 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3661 __bt_service_get_parameters(in_param1,
3662 &network, sizeof(bluetooth_mesh_network_t));
3663 __bt_service_get_parameters(in_param2,
3664 &index, sizeof(guint16));
3666 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3667 sender, &network, index);
3669 if (result != BLUETOOTH_ERROR_NONE) {
3670 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3672 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3674 sender = (char*)g_dbus_method_invocation_get_sender(context);
3675 _bt_save_invocation_context(context, result, sender,
3676 function_name, (gpointer)net);
3680 case BT_MESH_NETWORK_ADD_APPKEY: {
3681 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));
3691 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3692 sender, &network, net_idx);
3694 if (result != BLUETOOTH_ERROR_NONE) {
3695 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3697 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3699 sender = (char*)g_dbus_method_invocation_get_sender(context);
3700 _bt_save_invocation_context(context, result, sender,
3701 function_name, (gpointer)net);
3705 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3706 bluetooth_mesh_network_t network;
3710 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3712 __bt_service_get_parameters(in_param1,
3713 &network, sizeof(bluetooth_mesh_network_t));
3714 __bt_service_get_parameters(in_param2,
3715 &net_idx, sizeof(guint16));
3716 __bt_service_get_parameters(in_param3,
3717 &app_idx, sizeof(guint16));
3719 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3720 sender, &network, net_idx, app_idx);
3722 if (result != BLUETOOTH_ERROR_NONE) {
3723 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3725 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3727 sender = (char*)g_dbus_method_invocation_get_sender(context);
3728 _bt_save_invocation_context(context, result, sender,
3729 function_name, (gpointer)net);
3733 case BT_MESH_NETWORK_DELETE_APPKEY: {
3734 bluetooth_mesh_network_t network;
3738 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3740 __bt_service_get_parameters(in_param1,
3741 &network, sizeof(bluetooth_mesh_network_t));
3742 __bt_service_get_parameters(in_param2,
3743 &net_idx, sizeof(guint16));
3744 __bt_service_get_parameters(in_param3,
3745 &app_idx, sizeof(guint16));
3747 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3748 sender, &network, net_idx, app_idx);
3750 if (result != BLUETOOTH_ERROR_NONE) {
3751 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3753 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3755 sender = (char*)g_dbus_method_invocation_get_sender(context);
3756 _bt_save_invocation_context(context, result, sender,
3757 function_name, (gpointer)net);
3761 case BT_MESH_NETWORK_GET_NETKEYS: {
3762 bluetooth_mesh_network_t network;
3763 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3764 __bt_service_get_parameters(in_param1,
3765 &network, sizeof(bluetooth_mesh_network_t));
3766 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3767 sender, &network, out_param1);
3770 case BT_MESH_NETWORK_GET_APPKEYS: {
3771 bluetooth_mesh_network_t network;
3774 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3775 __bt_service_get_parameters(in_param1,
3776 &network, sizeof(bluetooth_mesh_network_t));
3777 __bt_service_get_parameters(in_param2,
3778 &net_idx, sizeof(guint16));
3779 result = _bt_mesh_network_get_appkeys(
3780 requester_unique_creds, sender,
3781 &network, net_idx, out_param1);
3784 case BT_MESH_NETWORK_GET_NODES: {
3785 bluetooth_mesh_network_t network;
3786 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3787 __bt_service_get_parameters(in_param1,
3788 &network, sizeof(bluetooth_mesh_network_t));
3789 result = _bt_mesh_network_get_nodes(
3790 requester_unique_creds, sender,
3791 &network, out_param1);
3794 case BT_MESH_ELEMENT_GET_MODELS: {
3795 bluetooth_mesh_network_t network;
3799 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3800 __bt_service_get_parameters(in_param1,
3801 &network, sizeof(bluetooth_mesh_network_t));
3802 __bt_service_get_parameters(in_param2,
3803 &node_addr, sizeof(guint16));
3804 __bt_service_get_parameters(in_param3,
3805 &elem_idx, sizeof(int));
3806 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3807 &network, node_addr, elem_idx, out_param1);
3810 case BT_MESH_NODE_BROWSE: {
3811 bluetooth_mesh_node_discover_t req;
3812 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3814 __bt_service_get_parameters(in_param1,
3815 &req, sizeof(bluetooth_mesh_node_discover_t));
3817 result = _bt_mesh_browse_remote_node(
3818 requester_unique_creds, sender, &req);
3820 /* Save invocation */
3821 if (result != BLUETOOTH_ERROR_NONE) {
3822 g_array_append_vals(*out_param1, &req,
3823 sizeof(bluetooth_mesh_node_discover_t));
3825 bluetooth_mesh_node_discover_t *param = \
3826 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3828 sender = (char*)g_dbus_method_invocation_get_sender(context);
3829 _bt_save_invocation_context(context, result, sender,
3830 function_name, (gpointer)param);
3834 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3835 bluetooth_mesh_node_features_t req;
3836 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3838 __bt_service_get_parameters(in_param1,
3839 &req, sizeof(bluetooth_mesh_node_features_t));
3841 result = _bt_mesh_node_discover_vendor_features(
3842 requester_unique_creds, sender, &req);
3844 /* Save invocation */
3845 if (result != BLUETOOTH_ERROR_NONE) {
3846 g_array_append_vals(*out_param1,
3847 &req, sizeof(bluetooth_mesh_node_features_t));
3849 bluetooth_mesh_node_features_t *param = \
3850 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3852 sender = (char*)g_dbus_method_invocation_get_sender(context);
3853 _bt_save_invocation_context(context, result, sender,
3854 function_name, (gpointer)param);
3858 case BT_MESH_NODE_CONFIGURE_KEY: {
3859 bluetooth_mesh_key_configure_t req;
3861 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3863 __bt_service_get_parameters(in_param1,
3864 &req, sizeof(bluetooth_mesh_key_configure_t));
3866 result = _bt_mesh_node_configure_key(
3867 requester_unique_creds, sender, &req);
3869 /* Save invocation */
3870 if (result != BLUETOOTH_ERROR_NONE) {
3871 g_array_append_vals(*out_param1,
3872 &req, sizeof(bluetooth_mesh_key_configure_t));
3874 bluetooth_mesh_key_configure_t *param = \
3875 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3877 sender = (char*)g_dbus_method_invocation_get_sender(context);
3878 _bt_save_invocation_context(context, result, sender,
3879 function_name, (gpointer)param);
3883 case BT_MESH_NODE_TTL_EXECUTE: {
3884 bluetooth_mesh_node_ttl_info_t req;
3886 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3888 __bt_service_get_parameters(in_param1,
3889 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3891 result = _bt_mesh_ttl_execute_remote_node(
3892 requester_unique_creds, sender, &req);
3894 /* Save invocation */
3895 if (result != BLUETOOTH_ERROR_NONE) {
3896 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3898 bluetooth_mesh_node_ttl_info_t *param = \
3899 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3901 sender = (char*)g_dbus_method_invocation_get_sender(context);
3902 _bt_save_invocation_context(context, result, sender,
3903 function_name, (gpointer)param);
3907 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3908 bluetooth_mesh_model_configure_t req;
3910 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3912 __bt_service_get_parameters(in_param1,
3913 &req, sizeof(bluetooth_mesh_model_configure_t));
3915 result = _bt_mesh_node_model_appkey_execute(
3916 requester_unique_creds, sender, &req);
3918 /* Save invocation */
3919 if (result != BLUETOOTH_ERROR_NONE) {
3920 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3922 bluetooth_mesh_model_configure_t *param = \
3923 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3925 sender = (char*)g_dbus_method_invocation_get_sender(context);
3926 _bt_save_invocation_context(context, result, sender,
3927 function_name, (gpointer)param);
3931 case BT_MESH_MODEL_EXECUTE_MSG: {
3932 bluetooth_mesh_model_msg_t req;
3934 memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
3936 __bt_service_get_parameters(in_param1,
3937 &req, sizeof(bluetooth_mesh_model_msg_t));
3939 result = _bt_mesh_model_execute_msg(
3940 requester_unique_creds, sender, &req);
3942 /* Save invocation */
3943 if (result != BLUETOOTH_ERROR_NONE) {
3944 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
3946 bluetooth_mesh_model_msg_t *param = \
3947 g_memdup(&req, sizeof(bluetooth_mesh_model_msg_t));
3949 sender = (char*)g_dbus_method_invocation_get_sender(context);
3950 _bt_save_invocation_context(context, result, sender,
3951 function_name, (gpointer)param);
3955 case BT_MESH_NODE_GET_NETKEYS: {
3956 bluetooth_mesh_node_discover_t node;
3957 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3958 __bt_service_get_parameters(in_param1,
3959 &node, sizeof(bluetooth_mesh_node_discover_t));
3960 result = _bt_mesh_network_node_get_netkeys(
3961 requester_unique_creds, &node, out_param1);
3964 case BT_MESH_NODE_GET_APPKEYS: {
3965 bluetooth_mesh_node_discover_t node;
3966 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3967 __bt_service_get_parameters(in_param1,
3968 &node, sizeof(bluetooth_mesh_node_discover_t));
3969 result = _bt_mesh_network_node_get_appkeys(
3970 requester_unique_creds, sender, &node, out_param1);
3973 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3974 bluetooth_mesh_model_configure_t req;
3976 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3978 __bt_service_get_parameters(in_param1,
3979 &req, sizeof(bluetooth_mesh_model_configure_t));
3981 result = _bt_mesh_node_model_get_appkey_list(
3982 requester_unique_creds, sender, &req);
3984 /* Save invocation */
3985 if (result != BLUETOOTH_ERROR_NONE) {
3986 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3988 bluetooth_mesh_model_configure_t *param = \
3989 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3991 sender = (char*)g_dbus_method_invocation_get_sender(context);
3992 _bt_save_invocation_context(context, result, sender,
3993 function_name, (gpointer)param);
3997 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3998 bluetooth_mesh_model_configure_t req;
4000 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4002 __bt_service_get_parameters(in_param1,
4003 &req, sizeof(bluetooth_mesh_model_configure_t));
4005 result = _bt_mesh_node_model_get_subscription_list(
4006 requester_unique_creds, sender, &req);
4008 /* Save invocation */
4009 if (result != BLUETOOTH_ERROR_NONE) {
4010 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4012 bluetooth_mesh_model_configure_t *param = \
4013 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4015 sender = (char*)g_dbus_method_invocation_get_sender(context);
4016 _bt_save_invocation_context(context, result, sender,
4017 function_name, (gpointer)param);
4022 case BT_MESH_NETWORK_CREATE_GROUP: {
4023 bluetooth_mesh_network_t net;
4024 bluetooth_mesh_network_group_info_t res;
4025 gboolean is_virtual;
4028 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4029 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4031 __bt_service_get_parameters(in_param1,
4032 &net, sizeof(bluetooth_mesh_network_t));
4033 __bt_service_get_parameters(in_param2,
4034 &is_virtual, sizeof(gboolean));
4035 __bt_service_get_parameters(in_param3,
4036 &grp_addr, sizeof(guint16));
4038 result = _bt_mesh_network_create_group(
4039 requester_unique_creds, sender, &net,
4040 is_virtual, grp_addr, &res);
4042 if (result == BLUETOOTH_ERROR_NONE)
4043 g_array_append_vals(*out_param1, &res,
4044 sizeof(bluetooth_mesh_network_group_info_t));
4047 case BT_MESH_NETWORK_REMOVE_GROUP: {
4048 bluetooth_mesh_network_t net;
4049 bluetooth_mesh_network_group_info_t req;
4051 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4052 memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4054 __bt_service_get_parameters(in_param1,
4055 &net, sizeof(bluetooth_mesh_network_t));
4056 __bt_service_get_parameters(in_param2,
4057 &req, sizeof(bluetooth_mesh_network_group_info_t));
4059 result = _bt_mesh_network_remove_group(
4060 requester_unique_creds, sender, &net, &req);
4064 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
4065 bluetooth_mesh_model_configure_t req;
4067 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4069 __bt_service_get_parameters(in_param1,
4070 &req, sizeof(bluetooth_mesh_model_configure_t));
4072 result = _bt_mesh_model_configure_group_subscription(
4073 requester_unique_creds, sender, &req);
4075 /* Save invocation */
4076 if (result != BLUETOOTH_ERROR_NONE) {
4077 g_array_append_vals(*out_param1,
4078 &req, sizeof(bluetooth_mesh_model_configure_t));
4080 bluetooth_mesh_model_configure_t *param = \
4081 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4083 sender = (char*)g_dbus_method_invocation_get_sender(context);
4084 _bt_save_invocation_context(context, result, sender,
4085 function_name, (gpointer)param);
4089 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4090 bluetooth_mesh_model_configure_t req;
4092 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4094 __bt_service_get_parameters(in_param1,
4095 &req, sizeof(bluetooth_mesh_model_configure_t));
4097 result = _bt_mesh_model_configure_virtual_group_subscription(
4098 requester_unique_creds, sender, &req);
4100 /* Save invocation */
4101 if (result != BLUETOOTH_ERROR_NONE) {
4102 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4104 bluetooth_mesh_model_configure_t *param = \
4105 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4107 sender = (char*)g_dbus_method_invocation_get_sender(context);
4108 _bt_save_invocation_context(context, result, sender,
4109 function_name, (gpointer)param);
4113 case BT_MESH_MODEL_SET_PUBLICATION: {
4114 bluetooth_mesh_model_configure_t req;
4116 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4118 __bt_service_get_parameters(in_param1,
4119 &req, sizeof(bluetooth_mesh_model_configure_t));
4121 result = _bt_mesh_model_set_publication(
4122 requester_unique_creds, sender, &req);
4124 /* Save invocation */
4125 if (result != BLUETOOTH_ERROR_NONE) {
4126 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4128 bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4130 sender = (char*)g_dbus_method_invocation_get_sender(context);
4131 _bt_save_invocation_context(context, result, sender,
4132 function_name, (gpointer)param);
4136 case BT_MESH_MODEL_GET_PUBLICATION: {
4137 bluetooth_mesh_model_configure_t req;
4139 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4141 __bt_service_get_parameters(in_param1,
4142 &req, sizeof(bluetooth_mesh_model_configure_t));
4144 result = _bt_mesh_model_get_publication(
4145 requester_unique_creds, sender, &req);
4147 /* Save invocation */
4148 if (result != BLUETOOTH_ERROR_NONE) {
4149 g_array_append_vals(*out_param1,
4150 &req, sizeof(bluetooth_mesh_model_configure_t));
4152 bluetooth_mesh_model_configure_t *param = \
4153 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4155 sender = (char*)g_dbus_method_invocation_get_sender(context);
4156 _bt_save_invocation_context(context, result, sender,
4157 function_name, (gpointer)param);
4161 case BT_MESH_NETWORK_GET_GROUPS: {
4162 bluetooth_mesh_network_t network;
4163 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4164 __bt_service_get_parameters(in_param1,
4165 &network, sizeof(bluetooth_mesh_network_t));
4166 BT_INFO("Mesh: Request:: Get Groups");
4167 result = _bt_mesh_network_get_groups(
4168 requester_unique_creds, sender, &network, out_param1);
4172 BT_INFO("UnSupported function [%d]", function_name);
4173 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4179 #ifdef TIZEN_FEATURE_BT_OBEX
4180 /* Function definitions*/
4181 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4186 size = g_variant_get_size(var);
4188 data = (char *)g_variant_get_data(var);
4190 param = g_array_append_vals(param, data, size);
4196 int __bt_obexd_request(int function_name,
4199 GDBusMethodInvocation *context,
4200 GVariant *in_param1,
4201 GVariant *in_param2,
4202 GVariant *in_param3,
4203 GVariant *in_param4,
4204 GArray **out_param1)
4208 int result = BLUETOOTH_ERROR_NONE;
4210 BT_DBG("function_name : %x", function_name);
4212 switch (function_name) {
4213 case BT_OPP_PUSH_FILES: {
4214 BT_DBG("BT_OPP_PUSH_FILES");
4216 bluetooth_device_address_t address = { {0} };
4217 bt_file_path_t *path;
4222 __bt_service_get_parameters(in_param1, &address,
4223 sizeof(bluetooth_device_address_t));
4224 __bt_service_get_parameters(in_param3, &file_count,
4227 file_path = g_new0(char *, file_count + 1);
4229 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4230 __bt_fill_garray_from_variant(in_param2, param2);
4232 for (i = 0; i < file_count; i++) {
4233 path = &g_array_index(param2, bt_file_path_t, i);
4234 file_path[i] = g_strdup(path->path);
4236 BT_DBG("_bt_opp_client_push_files");
4237 result = _bt_opp_client_push_files(request_id, context,
4238 &address, file_path,
4241 for (i = 0; i < file_count; i++)
4242 g_free(file_path[i]);
4245 g_array_free(param2, TRUE);
4249 case BT_OPP_CANCEL_PUSH: {
4250 result = _bt_opp_client_cancel_push();
4254 case BT_OPP_IS_PUSHING_FILES: {
4255 gboolean is_sending = FALSE;
4257 result = _bt_opp_client_is_sending(&is_sending);
4259 g_array_append_vals(*out_param1, &is_sending,
4263 case BT_OPP_GET_TRANSFER_PROGRESS: {
4266 guint8 progress = 0;
4268 __bt_service_get_parameters(in_param1, &direction,
4270 __bt_service_get_parameters(in_param2, &transfer_id,
4273 result = _bt_opp_get_client_progress(&progress);
4275 result = _bt_opp_get_server_progress(transfer_id, &progress);
4277 g_array_append_vals(*out_param1, &progress,
4283 case BT_MAP_CREATE_SESSION: {
4284 BT_DBG("BT_MAP_CREATE_SESSION");
4285 char *address = (char *)g_variant_get_data(in_param1);
4286 char *session_id = NULL;
4287 result = _bt_create_session_sync(address, &session_id);
4288 if (result == BLUETOOTH_ERROR_NONE)
4289 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4293 case BT_MAP_DESTROY_SESSION: {
4294 BT_DBG("BT_MAP_DESTROY_SESSION");
4295 char* session_id = (char *)g_variant_get_data(in_param1);
4296 result = _bt_destroy_session_sync(session_id);
4297 if (result == BLUETOOTH_ERROR_NONE)
4298 BT_DBG("successfully destroyed session");
4302 case BT_MAP_SET_FOLDER: {
4303 BT_DBG("BT_MAP_SET_FOLDER");
4304 char *session_id = (char *)g_variant_get_data(in_param1);
4305 char *name = (char *)g_variant_get_data(in_param2);
4306 result = _bt_map_client_set_folder(session_id, name);
4310 case BT_MAP_LIST_FOLDERS: {
4311 BT_DBG("BT_MAP_LIST_FOLDERS");
4313 char* session_id = (char *)g_variant_get_data(in_param1);
4314 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4316 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4317 if (result == BLUETOOTH_ERROR_NONE)
4318 BT_DBG("_bt_map_client_list_folders succeed");
4323 case BT_MAP_LIST_FILTER_FIELDS: {
4324 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4326 char* session_id = (char *)g_variant_get_data(in_param1);
4328 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4329 if (result == BLUETOOTH_ERROR_NONE)
4330 BT_DBG("_bt_map_client_list_filter_fields succeed");
4335 case BT_MAP_LIST_MESSAGES: {
4336 BT_DBG("BT_MAP_LIST_MESSAGES");
4338 char* session_id = (char*)g_variant_get_data(in_param1);
4339 char* folder = (char*)g_variant_get_data(in_param2);
4340 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4342 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4343 if (result == BLUETOOTH_ERROR_NONE)
4344 BT_DBG("_bt_map_client_list_messages succeed");
4346 BT_DBG("_bt_map_client_list_messages failed");
4351 case BT_MAP_UPDATE_INBOX: {
4352 BT_DBG("BT_MAP_UPDATE_INBOX");
4353 char* session_id = (char *)g_variant_get_data(in_param1);
4354 result = _bt_map_client_update_inbox(session_id);
4358 case BT_MAP_PUSH_MESSAGE: {
4359 BT_DBG("BT_MAP_PUSH_MESSAGE");
4361 char* session_id = (char *)g_variant_get_data(in_param1);
4362 char* source_file = (char *)g_variant_get_data(in_param2);
4363 char* folder = (char *)g_variant_get_data(in_param3);
4364 char* args_serialized = (char *)g_variant_get_data(in_param4);
4366 result = _bt_map_client_push_message(
4367 request_id, context, session_id, source_file, folder, args_serialized);
4368 if (result == BLUETOOTH_ERROR_NONE)
4369 BT_DBG("_bt_map_client_push_message succeed");
4371 BT_ERR("_bt_map_client_push_message failed");
4376 case BT_MAP_GET_MESSAGE: {
4377 BT_DBG("BT_MAP_GET_MESSAGE");
4378 // TODO session currently is not used, but should be valid
4379 //char* session_id = (char *)g_variant_get_data(in_param1);
4380 char* message_object = (char *)g_variant_get_data(in_param2);
4381 char* target_file = (char *)g_variant_get_data(in_param3);
4382 bool attachment = false;
4383 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4385 result = _bt_map_client_get_message(request_id, context, message_object,
4386 target_file, attachment);
4387 if (result == BLUETOOTH_ERROR_NONE)
4388 BT_DBG("_bt_map_client_get_message succeed");
4393 case BT_OBEX_SERVER_ALLOCATE: {
4399 sender = (char *)g_dbus_method_invocation_get_sender(context);
4401 path = (char *)g_variant_get_data(in_param1);
4402 __bt_service_get_parameters(in_param2, &is_native,
4404 __bt_service_get_parameters(in_param3, &app_pid,
4407 result = _bt_obex_server_allocate(sender,
4408 path, app_pid, is_native);
4412 case BT_OBEX_SERVER_DEALLOCATE: {
4416 __bt_service_get_parameters(in_param1, &is_native,
4418 __bt_service_get_parameters(in_param2, &app_pid,
4421 result = _bt_obex_server_deallocate(app_pid, is_native);
4424 case BT_OBEX_SERVER_IS_ACTIVATED: {
4425 gboolean is_activated = FALSE;
4427 result = _bt_obex_server_is_activated(&is_activated);
4429 g_array_append_vals(*out_param1, &is_activated,
4434 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4435 result = _bt_obex_server_accept_connection(request_id);
4439 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4440 result = _bt_obex_server_reject_connection();
4444 case BT_OBEX_SERVER_ACCEPT_FILE: {
4447 file_name = (char *)g_variant_get_data(in_param1);
4449 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4453 case BT_OBEX_SERVER_REJECT_FILE: {
4454 result = _bt_obex_server_reject_authorize();
4458 case BT_OBEX_SERVER_SET_PATH: {
4460 char *destination_path;
4462 destination_path = (char *)g_variant_get_data(in_param1);
4463 __bt_service_get_parameters(in_param2, &is_native,
4466 result = _bt_obex_server_set_destination_path(destination_path,
4471 case BT_OBEX_SERVER_SET_ROOT: {
4474 root = (char *)g_variant_get_data(in_param1);
4476 result = _bt_obex_server_set_root(root);
4480 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4483 __bt_service_get_parameters(in_param1, &transfer_id,
4486 result = _bt_obex_server_cancel_transfer(transfer_id);
4490 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4491 result = _bt_obex_server_cancel_all_transfers();
4495 case BT_OBEX_SERVER_IS_RECEIVING: {
4496 gboolean is_receiving = FALSE;
4498 result = _bt_obex_server_is_receiving(&is_receiving);
4500 g_array_append_vals(*out_param1, &is_receiving,
4504 case BT_PBAP_CONNECT: {
4505 bluetooth_device_address_t address = { {0} };
4507 __bt_service_get_parameters(in_param1, &address,
4508 sizeof(bluetooth_device_address_t));
4510 result = _bt_pbap_connect(&address);
4513 case BT_PBAP_DISCONNECT: {
4514 bluetooth_device_address_t address = { {0} };
4516 __bt_service_get_parameters(in_param1, &address,
4517 sizeof(bluetooth_device_address_t));
4519 result = _bt_pbap_disconnect(&address);
4522 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4523 bluetooth_device_address_t address = { {0} };
4524 bt_pbap_folder_t folder = { 0, };
4526 __bt_service_get_parameters(in_param1, &address,
4527 sizeof(bluetooth_device_address_t));
4528 __bt_service_get_parameters(in_param2, &folder,
4529 sizeof(bt_pbap_folder_t));
4531 result = _bt_pbap_get_phonebook_size(&address,
4532 folder.addressbook, folder.folder_type);
4535 case BT_PBAP_GET_PHONEBOOK: {
4536 bluetooth_device_address_t address = { {0} };
4537 bt_pbap_folder_t folder = { 0, };
4538 bt_pbap_pull_parameters_t app_param = { 0, };
4540 __bt_service_get_parameters(in_param1, &address,
4541 sizeof(bluetooth_device_address_t));
4542 __bt_service_get_parameters(in_param2, &folder,
4543 sizeof(bt_pbap_folder_t));
4544 __bt_service_get_parameters(in_param3, &app_param,
4545 sizeof(bt_pbap_pull_parameters_t));
4547 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4548 folder.folder_type, &app_param);
4551 case BT_PBAP_GET_LIST: {
4552 bluetooth_device_address_t address = { {0} };
4553 bt_pbap_folder_t folder = { 0, };
4554 bt_pbap_list_parameters_t app_param = { 0, };
4556 __bt_service_get_parameters(in_param1, &address,
4557 sizeof(bluetooth_device_address_t));
4558 __bt_service_get_parameters(in_param2, &folder,
4559 sizeof(bt_pbap_folder_t));
4560 __bt_service_get_parameters(in_param3, &app_param,
4561 sizeof(bt_pbap_list_parameters_t));
4563 result = _bt_pbap_get_list(&address, folder.addressbook,
4564 folder.folder_type, &app_param);
4567 case BT_PBAP_PULL_VCARD: {
4568 bluetooth_device_address_t address = { {0} };
4569 bt_pbap_folder_t folder = { 0, };
4570 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4572 __bt_service_get_parameters(in_param1, &address,
4573 sizeof(bluetooth_device_address_t));
4574 __bt_service_get_parameters(in_param2, &folder,
4575 sizeof(bt_pbap_folder_t));
4576 __bt_service_get_parameters(in_param3, &app_param,
4577 sizeof(bt_pbap_pull_vcard_parameters_t));
4579 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4580 folder.folder_type, &app_param);
4583 case BT_PBAP_PHONEBOOK_SEARCH: {
4584 bluetooth_device_address_t address = { {0} };
4585 bt_pbap_folder_t folder = { 0, };
4586 bt_pbap_search_parameters_t app_param = { 0, };
4588 __bt_service_get_parameters(in_param1, &address,
4589 sizeof(bluetooth_device_address_t));
4590 __bt_service_get_parameters(in_param2, &folder,
4591 sizeof(bt_pbap_folder_t));
4592 __bt_service_get_parameters(in_param3, &app_param,
4593 sizeof(bt_pbap_search_parameters_t));
4595 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4596 folder.folder_type, &app_param);
4601 BT_ERR("Unknown function!");
4602 result = BLUETOOTH_ERROR_INTERNAL;
4611 int __bt_agent_request(int function_name,
4614 GDBusMethodInvocation *context,
4615 GVariant *in_param1,
4616 GVariant *in_param2,
4617 GVariant *in_param3,
4618 GVariant *in_param4,
4619 GArray **out_param1)
4622 switch (function_name) {
4623 case BT_SET_AUTHORIZATION: {
4630 sender = (char *)g_dbus_method_invocation_get_sender(context);
4631 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4632 uuid = (char *)g_variant_get_data(in_param2);
4633 path = (char *)g_variant_get_data(in_param3);
4634 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4636 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4639 case BT_UNSET_AUTHORIZATION: {
4643 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4644 uuid = (char *)g_variant_get_data(in_param2);
4646 result = _bt_unregister_osp_server_in_agent(type, uuid);
4650 BT_ERR("Unknown function!");
4651 result = BLUETOOTH_ERROR_INTERNAL;
4658 int __bt_core_request(int function_name,
4661 GDBusMethodInvocation *context,
4662 GVariant *in_param1)
4666 switch (function_name) {
4667 case BT_ENABLE_ADAPTER:
4670 _bt_set_adapter_request_state(TRUE);
4671 status = _bt_adapter_get_status();
4673 if (status == BT_ACTIVATING) {
4674 BT_DBG("Enabling in progress");
4675 result = BLUETOOTH_ERROR_IN_PROGRESS;
4676 } else if (status == BT_ACTIVATED) {
4677 BT_DBG("Already enabled");
4678 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4680 _bt_adapter_set_status(BT_ACTIVATING);
4681 result = BLUETOOTH_ERROR_NONE;
4686 case BT_DISABLE_ADAPTER:
4690 status = _bt_adapter_get_status();
4691 if (status == BT_DEACTIVATING) {
4692 BT_DBG("Disabling in progress");
4693 result = BLUETOOTH_ERROR_IN_PROGRESS;
4694 } else if (status == BT_DEACTIVATED) {
4695 BT_DBG("Already disabled");
4696 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4698 _bt_adapter_set_status(BT_DEACTIVATING);
4699 result = BLUETOOTH_ERROR_NONE;
4704 case BT_ENABLE_ADAPTER_LE:
4706 bt_le_status_t le_status;
4707 _bt_set_le_request_state(TRUE);
4708 le_status = _bt_adapter_get_le_status();
4709 if (le_status == BT_LE_ACTIVATING) {
4710 BT_DBG("Enabling in progress");
4711 result = BLUETOOTH_ERROR_IN_PROGRESS;
4712 } else if (le_status == BT_LE_ACTIVATED) {
4713 BT_DBG("Already enabled");
4714 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4716 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4717 result = BLUETOOTH_ERROR_NONE;
4722 case BT_DISABLE_ADAPTER_LE:
4724 bt_le_status_t le_status;
4726 le_status = _bt_adapter_get_le_status();
4727 if (le_status == BT_LE_DEACTIVATING) {
4728 BT_DBG("Disabling in progress");
4729 result = BLUETOOTH_ERROR_IN_PROGRESS;
4730 } else if (le_status == BT_LE_DEACTIVATED) {
4731 BT_DBG("Already disabled");
4732 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4734 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4735 result = BLUETOOTH_ERROR_NONE;
4741 BT_ERR("Unknown function!");
4742 result = BLUETOOTH_ERROR_INTERNAL;
4749 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
4754 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
4755 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
4757 ret = __bt_service_get_sender_pid(unique_name, &pid);
4758 if (ret != BLUETOOTH_ERROR_NONE) {
4759 BT_ERR("Fail to get the sender pid");
4763 ret = aul_app_get_appid_bypid(pid, app_id, len);
4764 if (ret != AUL_R_OK) {
4765 BT_ERR("app_id not found");
4766 return BLUETOOTH_ERROR_NOT_SUPPORT;
4768 BT_DBG("Sender app_id: %s", app_id);
4770 return BLUETOOTH_ERROR_NONE;
4773 gboolean __bt_service_check_privilege(int function_name,
4775 const char *unique_name)
4778 gboolean result = TRUE;
4779 char *client_creds = NULL;
4780 char *user_creds = NULL;
4781 char *client_session = "";
4782 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4783 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4784 char err_msg[256] = {0, };
4786 retv_if(unique_name == NULL, FALSE);
4787 retv_if(bt_service_conn == NULL, FALSE);
4789 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4790 if (ret_val != CYNARA_API_SUCCESS) {
4791 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4792 BT_ERR("Fail to get default client method: %s", err_msg);
4796 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4797 if (ret_val != CYNARA_API_SUCCESS) {
4798 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4799 BT_ERR("Fail to get default user method: %s", err_msg);
4803 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4804 if (ret_val != CYNARA_API_SUCCESS) {
4805 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4806 BT_ERR("Fail to get client credential: %s", err_msg);
4810 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4811 if (ret_val != CYNARA_API_SUCCESS) {
4812 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4813 BT_ERR("Fail to get user credential: %s", err_msg);
4819 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4821 switch (function_name) {
4822 case BT_SET_LOCAL_NAME:
4823 case BT_START_DISCOVERY:
4824 case BT_START_CUSTOM_DISCOVERY:
4825 case BT_CANCEL_DISCOVERY:
4826 case BT_OOB_ADD_REMOTE_DATA:
4827 case BT_OOB_REMOVE_REMOTE_DATA:
4828 case BT_OOB_READ_LOCAL_DATA:
4829 case BT_SET_ADVERTISING:
4830 case BT_SET_CUSTOM_ADVERTISING:
4831 case BT_SET_ADVERTISING_PARAMETERS:
4832 case BT_START_LE_DISCOVERY:
4833 case BT_STOP_LE_DISCOVERY:
4834 case BT_SET_SCAN_PARAMETERS:
4835 case BT_SET_SCAN_TYPE:
4837 case BT_BOND_DEVICE:
4838 case BT_CANCEL_BONDING:
4839 case BT_UNBOND_DEVICE:
4841 case BT_SET_AUTHORIZATION:
4842 case BT_UNSET_AUTHORIZATION:
4843 case BT_SEARCH_SERVICE:
4845 case BT_RFCOMM_CLIENT_CONNECT:
4846 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4847 BT_PERMANENT_LOG("Connect socket");
4848 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4849 case BT_RFCOMM_SOCKET_DISCONNECT:
4850 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4851 BT_PERMANENT_LOG("Disconnect socket");
4852 case BT_RFCOMM_SOCKET_WRITE:
4853 case BT_RFCOMM_CREATE_SOCKET:
4854 case BT_RFCOMM_REMOVE_SOCKET:
4855 case BT_RFCOMM_SEND_RX_DETAILS:
4856 case BT_RFCOMM_SEND_TX_DETAILS:
4857 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4859 case BT_OPP_PUSH_FILES:
4860 case BT_OPP_CANCEL_PUSH:
4861 /* TODO: MAP? MAP functions, see above */
4863 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4864 case BT_OBEX_SERVER_REJECT_CONNECTION:
4865 case BT_OBEX_SERVER_ACCEPT_FILE:
4866 case BT_OBEX_SERVER_REJECT_FILE:
4867 case BT_OBEX_SERVER_SET_PATH:
4868 case BT_OBEX_SERVER_SET_ROOT:
4869 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4870 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4872 case BT_AUDIO_SELECT_ROLE:
4873 case BT_AUDIO_CONNECT:
4874 case BT_AUDIO_DISCONNECT:
4876 case BT_AG_DISCONNECT:
4878 case BT_AV_DISCONNECT:
4879 case BT_AV_SOURCE_CONNECT:
4880 case BT_AV_SOURCE_DISCONNECT:
4881 case BT_AVRCP_TARGET_CONNECT:
4882 case BT_AVRCP_TARGET_DISCONNECT:
4883 case BT_AVRCP_CONTROL_CONNECT:
4884 case BT_AVRCP_CONTROL_DISCONNECT:
4885 case BT_AVRCP_HANDLE_CONTROL:
4886 case BT_AVRCP_SET_TRACK_INFO:
4887 case BT_AVRCP_SET_PROPERTY:
4888 case BT_AVRCP_SET_PROPERTIES:
4889 case BT_AVRCP_CONTROL_SET_PROPERTY:
4891 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
4892 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4893 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4894 case BT_AUDIO_IS_AVC_ACTIVATED:
4898 case BT_HF_DISCONNECT:
4900 case BT_HID_CONNECT:
4901 case BT_HID_DISCONNECT:
4903 case BT_HID_DEVICE_ACTIVATE:
4904 case BT_HID_DEVICE_DEACTIVATE:
4905 case BT_HID_DEVICE_CONNECT:
4906 case BT_HID_DEVICE_DISCONNECT:
4907 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4908 case BT_HID_DEVICE_SEND_KEY_EVENT:
4909 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4910 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4913 case BT_DISCONNECT_LE:
4915 case BT_SET_ADVERTISING_DATA:
4916 case BT_SET_SCAN_RESPONSE_DATA:
4918 case BT_HDP_CONNECT:
4919 case BT_HDP_DISCONNECT:
4920 case BT_HDP_SEND_DATA:
4921 case BT_HDP_REGISTER_SINK_APP:
4922 case BT_HDP_UNREGISTER_SINK_APP:
4925 case BT_DPM_SET_ALLOW_BT_MODE:
4926 case BT_DPM_GET_ALLOW_BT_MODE:
4927 case BT_DPM_SET_DEVICE_RESTRITION:
4928 case BT_DPM_GET_DEVICE_RESTRITION:
4929 case BT_DPM_SET_UUID_RESTRITION:
4930 case BT_DPM_GET_UUID_RESTRITION:
4931 case BT_DPM_ADD_DEVICES_BLACKLIST:
4932 case BT_DPM_ADD_DEVICES_WHITELIST:
4933 case BT_DPM_ADD_UUIDS_BLACKLIST:
4934 case BT_DPM_ADD_UUIDS_WHITELIST:
4935 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4936 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4937 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4938 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4939 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4940 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4941 case BT_DPM_REMOVE_UUID_BLACKLIST:
4942 case BT_DPM_REMOVE_UUID_WHITELIST:
4943 case BT_DPM_GET_DEVICES_BLACKLIST:
4944 case BT_DPM_GET_DEVICES_WHITELIST:
4945 case BT_DPM_GET_UUIDS_BLACKLIST:
4946 case BT_DPM_GET_UUIDS_WHITELIST:
4947 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4948 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4949 case BT_DPM_SET_PAIRING_STATE:
4950 case BT_DPM_GET_PAIRING_STATE:
4951 case BT_DPM_SET_PROFILE_STATE:
4952 case BT_DPM_GET_PROFILE_STATE:
4953 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4954 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4955 case BT_DPM_SET_DISCOVERABLE_STATE:
4956 case BT_DPM_GET_DISCOVERABLE_STATE:
4957 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4958 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4959 case BT_DPM_SET_DATA_TRANSFER_STATE:
4960 case BT_DPM_GET_DATA_TRANSFER_STATE:
4962 case BT_NETWORK_ACTIVATE:
4963 case BT_NETWORK_DEACTIVATE:
4964 case BT_NETWORK_CONNECT:
4965 case BT_NETWORK_DISCONNECT:
4966 case BT_NETWORK_SERVER_DISCONNECT:
4968 case BT_GATT_GET_PRIMARY_SERVICES:
4969 #ifdef TIZEN_GATT_CLIENT
4970 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4971 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4972 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4974 case BT_GATT_DISCOVER_CHARACTERISTICS:
4975 case BT_GATT_SET_PROPERTY_REQUEST:
4976 case BT_GATT_READ_CHARACTERISTIC:
4977 #ifdef TIZEN_GATT_CLIENT
4978 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4979 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4980 case BT_GATT_ACQUIRE_WRITE:
4981 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4982 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4983 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4984 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4986 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4987 case BT_GATT_REGISTER_APPLICATION:
4988 case BT_GATT_REGISTER_SERVICE:
4989 case BT_GATT_SEND_RESPONSE:
4991 case BT_GATT_SERVER_REGISTER:
4992 case BT_GATT_SERVER_ADD_SERVICE:
4993 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4994 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4995 case BT_GATT_SERVER_START_SERVICE:
4996 case BT_GATT_SERVER_STOP_SERVICE:
4997 case BT_GATT_SERVER_DELETE_SERVICE:
4998 case BT_GATT_SERVER_SEND_RESPONSE:
4999 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
5000 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
5001 case BT_GATT_SERVER_SEND_INDICATION:
5002 case BT_GATT_SERVER_UPDATE_VALUE:
5003 case BT_GATT_SERVER_DEREGISTER:
5005 case BT_REQ_ATT_MTU:
5006 case BT_PBAP_CONNECT:
5007 case BT_PBAP_DISCONNECT:
5008 case BT_PBAP_GET_PHONEBOOK_SIZE:
5009 case BT_PBAP_GET_PHONEBOOK:
5010 case BT_PBAP_GET_LIST:
5011 case BT_PBAP_PULL_VCARD:
5012 case BT_PBAP_PHONEBOOK_SEARCH:
5014 case BT_RFCOMM_LISTEN_AND_ACCEPT:
5016 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5017 BT_PRIVILEGE_PUBLIC);
5019 BT_INFO("Client Credentials [%s]", client_creds);
5020 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5021 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
5025 /* Need to check mediastorage privilege */
5026 if (function_name == BT_PBAP_GET_PHONEBOOK ||
5027 function_name == BT_PBAP_PULL_VCARD) {
5028 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5029 MEDIASTORAGE_PRIVILEGE);
5031 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5032 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
5038 case BT_ENABLE_ADAPTER:
5039 case BT_DISABLE_ADAPTER:
5040 case BT_RESET_ADAPTER:
5041 case BT_RECOVER_ADAPTER:
5042 case BT_BATTERY_READ_DATA:
5043 case BT_ENABLE_ADAPTER_LE:
5044 case BT_DISABLE_ADAPTER_LE:
5045 case BT_SET_CONNECTABLE:
5046 case BT_SET_DISCOVERABLE_MODE:
5047 case BT_ADD_WHITE_LIST:
5048 case BT_REMOVE_WHITE_LIST:
5049 case BT_CLEAR_WHITE_LIST:
5050 case BT_SET_MANUFACTURER_DATA:
5052 case BT_CANCEL_SEARCH_SERVICE:
5053 case BT_ENABLE_RSSI:
5054 case BT_DISCONNECT_DEVICE:
5056 case BT_RFCOMM_ACCEPT_CONNECTION:
5057 case BT_RFCOMM_REJECT_CONNECTION:
5058 case BT_RFCOMM_LISTEN:
5060 case BT_HID_ENABLE_BARCODE_FEATURE:
5062 case BT_AVRCP_CONTROL_GET_PROPERTY:
5063 case BT_AVRCP_GET_TRACK_INFO:
5064 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5065 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5067 case BT_SET_CONTENT_PROTECT:
5068 case BT_BOND_DEVICE_BY_TYPE:
5069 case BT_SET_LE_PRIVACY:
5070 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5071 case BT_LE_CONN_UPDATE:
5072 case BT_UPDATE_LE_CONNECTION_MODE:
5073 case BT_GET_DEVICE_IDA:
5074 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5075 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5076 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5077 case BT_LE_SET_DATA_LENGTH:
5078 case BT_LE_OOB_READ_LOCAL_DATA:
5079 case BT_LE_OOB_ADD_REMOTE_DATA:
5081 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5082 case BT_ENABLE_GATT_DATA_BATCHING:
5083 case BT_DISABLE_GATT_DATA_BATCHING:
5085 case BT_LE_IPSP_INIT:
5086 case BT_LE_IPSP_DEINIT:
5087 case BT_LE_IPSP_CONNECT:
5088 case BT_LE_IPSP_DISCONNECT:
5089 case BT_PXP_MONITOR_SET_PROPERTY:
5090 case BT_PXP_MONITOR_GET_PROPERTY:
5091 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5092 case BT_PXP_REPORTER_REGISTER:
5093 case BT_PXP_REPORTER_UNREGISTER:
5094 case BT_PXP_REPORTER_GET_PROPERTY:
5097 case BT_TDS_PROVIDER_REGISTER:
5098 case BT_TDS_PROVIDER_UNREGISTER:
5099 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5100 case BT_TDS_PROVIDER_CREATE:
5101 case BT_TDS_PROVIDER_DESTROY:
5102 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5103 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5104 case BT_TDS_READ_TRANSPORT_DATA:
5105 case BT_TDS_ENABLE_CONTROL_POINT:
5106 case BT_TDS_ACTIVATE_CONTROL_POINT:
5109 case BT_OTP_SERVER_INIT:
5110 case BT_OTP_SERVER_DEINIT:
5111 case BT_OTP_READ_VALUE:
5112 case BT_OTP_ENABLE_NOTIFICATION:
5113 case BT_OTP_WRITE_VALUE:
5114 case BT_LE_OTC_CONNECT:
5115 case BT_LE_OTC_DISCONNECT:
5117 case BT_MAP_CREATE_SESSION:
5118 case BT_MAP_DESTROY_SESSION:
5119 case BT_MAP_SET_FOLDER:
5120 case BT_MAP_LIST_FOLDERS:
5121 case BT_MAP_LIST_FILTER_FIELDS:
5122 case BT_MAP_LIST_MESSAGES:
5123 case BT_MAP_UPDATE_INBOX:
5124 case BT_MAP_PUSH_MESSAGE:
5125 case BT_MAP_GET_MESSAGE:
5128 case BT_MESH_DEINIT:
5129 case BT_MESH_NETWORK_CREATE:
5130 case BT_MESH_NETWORK_DESTROY:
5131 case BT_MESH_NETWORK_LOAD:
5132 case BT_MESH_NETWORK_SCAN:
5133 case BT_MESH_NETWORK_CANCEL_SCAN:
5134 case BT_MESH_NETWORK_SET_CAPABILITIES:
5135 case BT_MESH_NETWORK_PROVISION_DEVICE:
5136 case BT_MESH_AUTHENTICATION_REPLY:
5137 case BT_MESH_NETWORK_SET_NAME:
5138 case BT_MESH_NETWORK_ADD_NETKEY:
5139 case BT_MESH_NETWORK_DELETE_NETKEY:
5140 case BT_MESH_NETWORK_UPDATE_NETKEY:
5141 case BT_MESH_NETWORK_ADD_APPKEY:
5142 case BT_MESH_NETWORK_DELETE_APPKEY:
5143 case BT_MESH_NETWORK_UPDATE_APPKEY:
5144 case BT_MESH_NETWORK_GET_NETKEYS:
5145 case BT_MESH_NETWORK_GET_APPKEYS:
5146 case BT_MESH_NETWORK_GET_NODES:
5147 case BT_MESH_ELEMENT_GET_MODELS:
5148 case BT_MESH_NODE_BROWSE:
5149 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5150 case BT_MESH_NODE_CONFIGURE_KEY:
5151 case BT_MESH_NODE_TTL_EXECUTE:
5152 case BT_MESH_NODE_GET_NETKEYS:
5153 case BT_MESH_NODE_GET_APPKEYS:
5154 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5155 case BT_MESH_MODEL_GET_APPKEY_LIST:
5156 case BT_MESH_MODEL_EXECUTE_MSG:
5157 case BT_MESH_NETWORK_CREATE_GROUP:
5158 case BT_MESH_NETWORK_REMOVE_GROUP:
5159 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5160 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5161 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST:
5162 case BT_MESH_MODEL_SET_PUBLICATION:
5163 case BT_MESH_MODEL_GET_PUBLICATION:
5164 case BT_MESH_NETWORK_GET_GROUPS:
5166 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5167 BT_PRIVILEGE_PLATFORM);
5169 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5170 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5175 case BT_CHECK_ADAPTER:
5178 case BT_GET_LOCAL_NAME:
5179 case BT_GET_LOCAL_ADDRESS:
5180 case BT_GET_LOCAL_VERSION:
5181 case BT_IS_SERVICE_USED:
5182 case BT_GET_DISCOVERABLE_MODE:
5183 case BT_GET_DISCOVERABLE_TIME:
5184 case BT_IS_DISCOVERYING:
5185 case BT_IS_LE_DISCOVERYING:
5186 case BT_IS_CONNECTABLE:
5187 case BT_GET_CONNECTABLE:
5188 case BT_GET_BONDED_DEVICES:
5189 case BT_GET_PROFILE_CONNECTED_DEVICES:
5190 case BT_GET_BONDED_DEVICE:
5191 case BT_PASSKEY_REPLY:
5192 case BT_PASSKEY_CONFIRMATION_REPLY:
5193 case BT_GET_IS_ALIAS_SET:
5194 case BT_IS_DEVICE_CONNECTED:
5195 case BT_GET_CONNECTED_LINK_TYPE:
5196 case BT_SET_PROFILE_TRUSTED:
5197 case BT_GET_PROFILE_TRUSTED:
5198 case BT_GET_SPEAKER_GAIN:
5199 case BT_SET_SPEAKER_GAIN:
5200 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5201 case BT_RFCOMM_IS_UUID_AVAILABLE:
5202 case BT_GET_ADVERTISING_DATA:
5203 case BT_GET_SCAN_RESPONSE_DATA:
5204 case BT_IS_ADVERTISING:
5205 case BT_IS_LE_2M_PHY_SUPPORTED:
5206 case BT_IS_LE_CODED_PHY_SUPPORTED:
5207 case BT_REGISTER_SCAN_FILTER:
5208 case BT_IS_SCAN_FILTER_SUPPORTED:
5209 case BT_GET_ATT_MTU:
5211 case BT_OBEX_SERVER_ALLOCATE:
5212 case BT_OBEX_SERVER_DEALLOCATE:
5213 case BT_OBEX_SERVER_IS_ACTIVATED:
5214 case BT_OPP_GET_TRANSFER_PROGRESS:
5215 /* Non-privilege control */
5218 BT_ERR("Unknown function!");
5223 if (function_name >= BT_FUNC_MESH_BASE) {
5224 BT_INFO("MESH Function called");
5225 char app_id[256] = { 0, };
5227 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5228 app_id, sizeof(app_id))) {
5229 requester_unique_creds = g_strdup(app_id);
5231 BT_DBG("Requester app_id not found, use client creds");
5232 requester_unique_creds = g_strdup(client_creds);
5234 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5236 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5248 GDBusNodeInfo *__bt_service_create_method_node_info
5249 (const gchar *introspection_data)
5252 GDBusNodeInfo *node_info = NULL;
5254 if (introspection_data == NULL) {
5255 BT_ERR("Introspection XML not present");
5259 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5262 BT_ERR("Unable to create node: %s", err->message);
5263 g_clear_error(&err);
5268 int __bt_service_register_object(GDBusConnection *conn,
5269 GDBusNodeInfo *node_info, gboolean reg)
5271 static guint service_id = 0;
5272 GError *error = NULL;
5275 if (node_info == NULL)
5278 service_id = g_dbus_connection_register_object(conn,
5280 node_info->interfaces[0],
5282 NULL, NULL, &error);
5283 if (service_id == 0)
5286 if (service_id > 0) {
5287 g_dbus_connection_unregister_object(conn,
5296 static void __name_owner_changed(GDBusConnection *connection,
5297 const gchar *sender_name,
5298 const gchar *object_path,
5299 const gchar *interface_name,
5300 const gchar *signal_name,
5301 GVariant *parameters,
5304 const char *name = NULL;
5305 const char *old_owner = NULL;
5306 const char *new_owner = NULL;
5308 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5309 if (*new_owner != '\0')
5312 _bt_check_hdp_app_termination(name);
5314 /* Advertising App Termination */
5315 _bt_check_adv_app_termination(name);
5317 /* Check if le_scanning app is terminated */
5318 _bt_check_le_scanner_app_termination(name);
5320 /* Check if RFCOMM app is terminated */
5321 _bt_rfcomm_check_termination(name);
5324 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5325 const gchar *name, gpointer user_data)
5327 GDBusNodeInfo *node_info = NULL;
5329 BT_INFO("bus acquired");
5331 ret_if(connection == NULL);
5333 node_info = __bt_service_create_method_node_info(
5334 bt_service_introspection_xml);
5335 ret_if(node_info == NULL);
5337 __bt_service_register_object(connection, node_info, TRUE);
5338 g_dbus_node_info_unref(node_info);
5340 bt_service_conn = connection;
5343 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5344 const gchar *name, gpointer user_data)
5346 BT_INFO("name acquired");
5347 name_acquired = TRUE;
5350 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5351 const gchar *name, gpointer user_data)
5353 BT_INFO("name lost");
5354 name_acquired = FALSE;
5357 gboolean _is_name_acquired(void)
5359 return name_acquired;
5362 void _bt_service_unref_connection(void)
5366 if (bt_service_conn) {
5367 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5368 g_object_unref(bt_service_conn);
5369 bt_service_conn = NULL;
5375 int _bt_service_register(void)
5377 GDBusConnection *conn;
5380 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5381 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5382 bt_service_conn = conn;
5384 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5386 G_BUS_NAME_OWNER_FLAGS_NONE,
5387 __bt_service_bus_acquired_handler,
5388 __bt_service_name_acquired_handler,
5389 __bt_service_name_lost_handler,
5391 BT_DBG("owner_id is [%d]", owner_id);
5395 /* Subscribe for name owner changed signal */
5396 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5397 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5398 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5399 __name_owner_changed, NULL, NULL);
5400 BT_INFO("owner_sig_id: %d", owner_sig_id);
5402 return BLUETOOTH_ERROR_NONE;
5405 if (bt_service_conn) {
5406 g_object_unref(bt_service_conn);
5407 bt_service_conn = NULL;
5410 return BLUETOOTH_ERROR_INTERNAL;
5413 void _bt_service_unregister(void)
5415 if (bt_service_conn) {
5416 sd_notify(0, "STOPPING=1");
5418 if (owner_sig_id > 0) {
5419 g_dbus_connection_signal_unsubscribe(
5420 bt_service_conn, owner_sig_id);
5425 g_bus_unown_name(owner_id);
5429 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5433 int _bt_service_cynara_init(void)
5436 char err_msg[256] = {0, };
5438 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5440 result = cynara_initialize(&p_cynara, conf);
5442 if (result != CYNARA_API_SUCCESS) {
5443 cynara_strerror(result, err_msg, sizeof(err_msg));
5444 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5445 return BLUETOOTH_ERROR_INTERNAL;
5448 return BLUETOOTH_ERROR_NONE;
5451 void _bt_service_cynara_deinit(void)
5454 char err_msg[256] = {0, };
5456 ret_if(p_cynara == NULL);
5458 result = cynara_finish(p_cynara);
5460 if (result != CYNARA_API_SUCCESS) {
5461 cynara_strerror(result, err_msg, sizeof(err_msg));
5462 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5470 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5471 GArray *out_param, int result)
5475 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5476 out_param->data, out_param->len, TRUE, NULL, NULL);
5478 g_dbus_method_invocation_return_value(invocation,
5479 g_variant_new("(iv)", result, out_var));
5482 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5483 GArray *out_param, int result, GUnixFDList *fd_list)
5487 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5488 out_param->data, out_param->len, TRUE, NULL, NULL);
5490 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5491 g_variant_new("(iv)", result, out_var), fd_list);